Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2011 Samsung Electronics Co.Ltd |
| 3 | * Authors: |
| 4 | * Seung-Woo Kim <sw0312.kim@samsung.com> |
| 5 | * Inki Dae <inki.dae@samsung.com> |
| 6 | * Joonyoung Shim <jy0922.shim@samsung.com> |
| 7 | * |
| 8 | * Based on drivers/media/video/s5p-tv/hdmi_drv.c |
| 9 | * |
| 10 | * This program is free software; you can redistribute it and/or modify it |
| 11 | * under the terms of the GNU General Public License as published by the |
| 12 | * Free Software Foundation; either version 2 of the License, or (at your |
| 13 | * option) any later version. |
| 14 | * |
| 15 | */ |
| 16 | |
David Howells | 760285e | 2012-10-02 18:01:07 +0100 | [diff] [blame] | 17 | #include <drm/drmP.h> |
| 18 | #include <drm/drm_edid.h> |
| 19 | #include <drm/drm_crtc_helper.h> |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 20 | |
| 21 | #include "regs-hdmi.h" |
| 22 | |
| 23 | #include <linux/kernel.h> |
| 24 | #include <linux/spinlock.h> |
| 25 | #include <linux/wait.h> |
| 26 | #include <linux/i2c.h> |
| 27 | #include <linux/module.h> |
| 28 | #include <linux/platform_device.h> |
| 29 | #include <linux/interrupt.h> |
| 30 | #include <linux/irq.h> |
| 31 | #include <linux/delay.h> |
| 32 | #include <linux/pm_runtime.h> |
| 33 | #include <linux/clk.h> |
| 34 | #include <linux/regulator/consumer.h> |
Rahul Sharma | 22c4f42 | 2012-10-04 20:48:55 +0530 | [diff] [blame] | 35 | #include <linux/io.h> |
| 36 | #include <linux/of_gpio.h> |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 37 | |
| 38 | #include <drm/exynos_drm.h> |
| 39 | |
| 40 | #include "exynos_drm_drv.h" |
| 41 | #include "exynos_drm_hdmi.h" |
| 42 | |
| 43 | #include "exynos_hdmi.h" |
| 44 | |
Tomasz Stanislawski | fca5712 | 2012-10-04 20:48:46 +0530 | [diff] [blame] | 45 | #include <linux/gpio.h> |
| 46 | #include <media/s5p_hdmi.h> |
| 47 | |
Inki Dae | 1de425b | 2012-03-16 18:47:04 +0900 | [diff] [blame] | 48 | #define MAX_WIDTH 1920 |
| 49 | #define MAX_HEIGHT 1080 |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 50 | #define get_hdmi_context(dev) platform_get_drvdata(to_platform_device(dev)) |
| 51 | |
Rahul Sharma | a144c2e | 2012-11-26 10:52:57 +0530 | [diff] [blame] | 52 | /* AVI header and aspect ratio */ |
| 53 | #define HDMI_AVI_VERSION 0x02 |
| 54 | #define HDMI_AVI_LENGTH 0x0D |
| 55 | #define AVI_PIC_ASPECT_RATIO_16_9 (2 << 4) |
| 56 | #define AVI_SAME_AS_PIC_ASPECT_RATIO 8 |
| 57 | |
| 58 | /* AUI header info */ |
| 59 | #define HDMI_AUI_VERSION 0x01 |
| 60 | #define HDMI_AUI_LENGTH 0x0A |
| 61 | |
| 62 | /* HDMI infoframe to configure HDMI out packet header, AUI and AVI */ |
| 63 | enum HDMI_PACKET_TYPE { |
| 64 | /* refer to Table 5-8 Packet Type in HDMI specification v1.4a */ |
| 65 | /* InfoFrame packet type */ |
| 66 | HDMI_PACKET_TYPE_INFOFRAME = 0x80, |
| 67 | /* Vendor-Specific InfoFrame */ |
| 68 | HDMI_PACKET_TYPE_VSI = HDMI_PACKET_TYPE_INFOFRAME + 1, |
| 69 | /* Auxiliary Video information InfoFrame */ |
| 70 | HDMI_PACKET_TYPE_AVI = HDMI_PACKET_TYPE_INFOFRAME + 2, |
| 71 | /* Audio information InfoFrame */ |
| 72 | HDMI_PACKET_TYPE_AUI = HDMI_PACKET_TYPE_INFOFRAME + 4 |
| 73 | }; |
| 74 | |
Rahul Sharma | 5a32507 | 2012-10-04 20:48:54 +0530 | [diff] [blame] | 75 | enum hdmi_type { |
| 76 | HDMI_TYPE13, |
| 77 | HDMI_TYPE14, |
| 78 | }; |
| 79 | |
Joonyoung Shim | 590f418 | 2012-03-16 18:47:14 +0900 | [diff] [blame] | 80 | struct hdmi_resources { |
| 81 | struct clk *hdmi; |
| 82 | struct clk *sclk_hdmi; |
| 83 | struct clk *sclk_pixel; |
| 84 | struct clk *sclk_hdmiphy; |
| 85 | struct clk *hdmiphy; |
| 86 | struct regulator_bulk_data *regul_bulk; |
| 87 | int regul_count; |
| 88 | }; |
| 89 | |
Sean Paul | 2f7e2ed | 2013-01-15 08:11:08 -0500 | [diff] [blame] | 90 | struct hdmi_tg_regs { |
| 91 | u8 cmd[1]; |
| 92 | u8 h_fsz[2]; |
| 93 | u8 hact_st[2]; |
| 94 | u8 hact_sz[2]; |
| 95 | u8 v_fsz[2]; |
| 96 | u8 vsync[2]; |
| 97 | u8 vsync2[2]; |
| 98 | u8 vact_st[2]; |
| 99 | u8 vact_sz[2]; |
| 100 | u8 field_chg[2]; |
| 101 | u8 vact_st2[2]; |
| 102 | u8 vact_st3[2]; |
| 103 | u8 vact_st4[2]; |
| 104 | u8 vsync_top_hdmi[2]; |
| 105 | u8 vsync_bot_hdmi[2]; |
| 106 | u8 field_top_hdmi[2]; |
| 107 | u8 field_bot_hdmi[2]; |
| 108 | u8 tg_3d[1]; |
| 109 | }; |
| 110 | |
Rahul Sharma | 6b986ed | 2013-03-06 17:33:29 +0900 | [diff] [blame] | 111 | struct hdmi_v13_core_regs { |
| 112 | u8 h_blank[2]; |
| 113 | u8 v_blank[3]; |
| 114 | u8 h_v_line[3]; |
| 115 | u8 vsync_pol[1]; |
| 116 | u8 int_pro_mode[1]; |
| 117 | u8 v_blank_f[3]; |
| 118 | u8 h_sync_gen[3]; |
| 119 | u8 v_sync_gen1[3]; |
| 120 | u8 v_sync_gen2[3]; |
| 121 | u8 v_sync_gen3[3]; |
| 122 | }; |
| 123 | |
| 124 | struct hdmi_v14_core_regs { |
Sean Paul | 2f7e2ed | 2013-01-15 08:11:08 -0500 | [diff] [blame] | 125 | u8 h_blank[2]; |
| 126 | u8 v2_blank[2]; |
| 127 | u8 v1_blank[2]; |
| 128 | u8 v_line[2]; |
| 129 | u8 h_line[2]; |
| 130 | u8 hsync_pol[1]; |
| 131 | u8 vsync_pol[1]; |
| 132 | u8 int_pro_mode[1]; |
| 133 | u8 v_blank_f0[2]; |
| 134 | u8 v_blank_f1[2]; |
| 135 | u8 h_sync_start[2]; |
| 136 | u8 h_sync_end[2]; |
| 137 | u8 v_sync_line_bef_2[2]; |
| 138 | u8 v_sync_line_bef_1[2]; |
| 139 | u8 v_sync_line_aft_2[2]; |
| 140 | u8 v_sync_line_aft_1[2]; |
| 141 | u8 v_sync_line_aft_pxl_2[2]; |
| 142 | u8 v_sync_line_aft_pxl_1[2]; |
| 143 | u8 v_blank_f2[2]; /* for 3D mode */ |
| 144 | u8 v_blank_f3[2]; /* for 3D mode */ |
| 145 | u8 v_blank_f4[2]; /* for 3D mode */ |
| 146 | u8 v_blank_f5[2]; /* for 3D mode */ |
| 147 | u8 v_sync_line_aft_3[2]; |
| 148 | u8 v_sync_line_aft_4[2]; |
| 149 | u8 v_sync_line_aft_5[2]; |
| 150 | u8 v_sync_line_aft_6[2]; |
| 151 | u8 v_sync_line_aft_pxl_3[2]; |
| 152 | u8 v_sync_line_aft_pxl_4[2]; |
| 153 | u8 v_sync_line_aft_pxl_5[2]; |
| 154 | u8 v_sync_line_aft_pxl_6[2]; |
| 155 | u8 vact_space_1[2]; |
| 156 | u8 vact_space_2[2]; |
| 157 | u8 vact_space_3[2]; |
| 158 | u8 vact_space_4[2]; |
| 159 | u8 vact_space_5[2]; |
| 160 | u8 vact_space_6[2]; |
| 161 | }; |
| 162 | |
Rahul Sharma | 6b986ed | 2013-03-06 17:33:29 +0900 | [diff] [blame] | 163 | struct hdmi_v13_conf { |
| 164 | struct hdmi_v13_core_regs core; |
Sean Paul | 2f7e2ed | 2013-01-15 08:11:08 -0500 | [diff] [blame] | 165 | struct hdmi_tg_regs tg; |
Rahul Sharma | 6b986ed | 2013-03-06 17:33:29 +0900 | [diff] [blame] | 166 | }; |
| 167 | |
| 168 | struct hdmi_v14_conf { |
| 169 | struct hdmi_v14_core_regs core; |
| 170 | struct hdmi_tg_regs tg; |
| 171 | }; |
| 172 | |
| 173 | struct hdmi_conf_regs { |
| 174 | int pixel_clock; |
Sean Paul | 2f7e2ed | 2013-01-15 08:11:08 -0500 | [diff] [blame] | 175 | int cea_video_id; |
Rahul Sharma | 6b986ed | 2013-03-06 17:33:29 +0900 | [diff] [blame] | 176 | union { |
| 177 | struct hdmi_v13_conf v13_conf; |
| 178 | struct hdmi_v14_conf v14_conf; |
| 179 | } conf; |
Sean Paul | 2f7e2ed | 2013-01-15 08:11:08 -0500 | [diff] [blame] | 180 | }; |
| 181 | |
Joonyoung Shim | 590f418 | 2012-03-16 18:47:14 +0900 | [diff] [blame] | 182 | struct hdmi_context { |
| 183 | struct device *dev; |
| 184 | struct drm_device *drm_dev; |
Joonyoung Shim | cf8fc4f | 2012-04-23 19:35:50 +0900 | [diff] [blame] | 185 | bool hpd; |
| 186 | bool powered; |
Seung-Woo Kim | 872d20d6 | 2012-04-24 17:39:15 +0900 | [diff] [blame] | 187 | bool dvi_mode; |
Joonyoung Shim | cf8fc4f | 2012-04-23 19:35:50 +0900 | [diff] [blame] | 188 | struct mutex hdmi_mutex; |
Joonyoung Shim | 590f418 | 2012-03-16 18:47:14 +0900 | [diff] [blame] | 189 | |
Joonyoung Shim | 590f418 | 2012-03-16 18:47:14 +0900 | [diff] [blame] | 190 | void __iomem *regs; |
Inki Dae | 1055b39 | 2012-10-19 17:37:35 +0900 | [diff] [blame] | 191 | void *parent_ctx; |
Sean Paul | 77006a7 | 2013-01-16 10:17:20 -0500 | [diff] [blame] | 192 | int irq; |
Joonyoung Shim | 590f418 | 2012-03-16 18:47:14 +0900 | [diff] [blame] | 193 | |
| 194 | struct i2c_client *ddc_port; |
| 195 | struct i2c_client *hdmiphy_port; |
| 196 | |
Rahul Sharma | 6b986ed | 2013-03-06 17:33:29 +0900 | [diff] [blame] | 197 | /* current hdmiphy conf regs */ |
| 198 | struct hdmi_conf_regs mode_conf; |
Joonyoung Shim | 590f418 | 2012-03-16 18:47:14 +0900 | [diff] [blame] | 199 | |
| 200 | struct hdmi_resources res; |
Joonyoung Shim | 7ecd34e | 2012-04-23 19:35:47 +0900 | [diff] [blame] | 201 | |
Tomasz Stanislawski | fca5712 | 2012-10-04 20:48:46 +0530 | [diff] [blame] | 202 | int hpd_gpio; |
Rahul Sharma | 5a32507 | 2012-10-04 20:48:54 +0530 | [diff] [blame] | 203 | |
| 204 | enum hdmi_type type; |
Joonyoung Shim | 590f418 | 2012-03-16 18:47:14 +0900 | [diff] [blame] | 205 | }; |
| 206 | |
Sean Paul | 2f7e2ed | 2013-01-15 08:11:08 -0500 | [diff] [blame] | 207 | struct hdmiphy_config { |
| 208 | int pixel_clock; |
| 209 | u8 conf[32]; |
Joonyoung Shim | 3ecd70b | 2012-03-16 18:47:03 +0900 | [diff] [blame] | 210 | }; |
| 211 | |
Rahul Sharma | 6b986ed | 2013-03-06 17:33:29 +0900 | [diff] [blame] | 212 | /* list of phy config settings */ |
| 213 | static const struct hdmiphy_config hdmiphy_v13_configs[] = { |
| 214 | { |
| 215 | .pixel_clock = 27000000, |
| 216 | .conf = { |
| 217 | 0x01, 0x05, 0x00, 0xD8, 0x10, 0x1C, 0x30, 0x40, |
| 218 | 0x6B, 0x10, 0x02, 0x51, 0xDF, 0xF2, 0x54, 0x87, |
| 219 | 0x84, 0x00, 0x30, 0x38, 0x00, 0x08, 0x10, 0xE0, |
| 220 | 0x22, 0x40, 0xE3, 0x26, 0x00, 0x00, 0x00, 0x00, |
| 221 | }, |
| 222 | }, |
| 223 | { |
| 224 | .pixel_clock = 27027000, |
| 225 | .conf = { |
| 226 | 0x01, 0x05, 0x00, 0xD4, 0x10, 0x9C, 0x09, 0x64, |
| 227 | 0x6B, 0x10, 0x02, 0x51, 0xDF, 0xF2, 0x54, 0x87, |
| 228 | 0x84, 0x00, 0x30, 0x38, 0x00, 0x08, 0x10, 0xE0, |
| 229 | 0x22, 0x40, 0xE3, 0x26, 0x00, 0x00, 0x00, 0x00, |
| 230 | }, |
| 231 | }, |
| 232 | { |
| 233 | .pixel_clock = 74176000, |
| 234 | .conf = { |
| 235 | 0x01, 0x05, 0x00, 0xD8, 0x10, 0x9C, 0xef, 0x5B, |
| 236 | 0x6D, 0x10, 0x01, 0x51, 0xef, 0xF3, 0x54, 0xb9, |
| 237 | 0x84, 0x00, 0x30, 0x38, 0x00, 0x08, 0x10, 0xE0, |
| 238 | 0x22, 0x40, 0xa5, 0x26, 0x01, 0x00, 0x00, 0x00, |
| 239 | }, |
| 240 | }, |
| 241 | { |
| 242 | .pixel_clock = 74250000, |
| 243 | .conf = { |
| 244 | 0x01, 0x05, 0x00, 0xd8, 0x10, 0x9c, 0xf8, 0x40, |
| 245 | 0x6a, 0x10, 0x01, 0x51, 0xff, 0xf1, 0x54, 0xba, |
| 246 | 0x84, 0x00, 0x10, 0x38, 0x00, 0x08, 0x10, 0xe0, |
| 247 | 0x22, 0x40, 0xa4, 0x26, 0x01, 0x00, 0x00, 0x00, |
| 248 | }, |
| 249 | }, |
| 250 | { |
| 251 | .pixel_clock = 148500000, |
| 252 | .conf = { |
| 253 | 0x01, 0x05, 0x00, 0xD8, 0x10, 0x9C, 0xf8, 0x40, |
| 254 | 0x6A, 0x18, 0x00, 0x51, 0xff, 0xF1, 0x54, 0xba, |
| 255 | 0x84, 0x00, 0x10, 0x38, 0x00, 0x08, 0x10, 0xE0, |
| 256 | 0x22, 0x40, 0xa4, 0x26, 0x02, 0x00, 0x00, 0x00, |
| 257 | }, |
| 258 | }, |
| 259 | }; |
| 260 | |
Sean Paul | 2f7e2ed | 2013-01-15 08:11:08 -0500 | [diff] [blame] | 261 | static const struct hdmiphy_config hdmiphy_v14_configs[] = { |
| 262 | { |
| 263 | .pixel_clock = 25200000, |
| 264 | .conf = { |
| 265 | 0x01, 0x51, 0x2A, 0x75, 0x40, 0x01, 0x00, 0x08, |
| 266 | 0x82, 0x80, 0xfc, 0xd8, 0x45, 0xa0, 0xac, 0x80, |
| 267 | 0x08, 0x80, 0x11, 0x04, 0x02, 0x22, 0x44, 0x86, |
| 268 | 0x54, 0xf4, 0x24, 0x00, 0x00, 0x00, 0x01, 0x80, |
| 269 | }, |
Joonyoung Shim | 3ecd70b | 2012-03-16 18:47:03 +0900 | [diff] [blame] | 270 | }, |
Sean Paul | 2f7e2ed | 2013-01-15 08:11:08 -0500 | [diff] [blame] | 271 | { |
| 272 | .pixel_clock = 27000000, |
| 273 | .conf = { |
| 274 | 0x01, 0xd1, 0x22, 0x51, 0x40, 0x08, 0xfc, 0x20, |
| 275 | 0x98, 0xa0, 0xcb, 0xd8, 0x45, 0xa0, 0xac, 0x80, |
| 276 | 0x06, 0x80, 0x11, 0x04, 0x02, 0x22, 0x44, 0x86, |
| 277 | 0x54, 0xe4, 0x24, 0x00, 0x00, 0x00, 0x01, 0x80, |
| 278 | }, |
Joonyoung Shim | 3ecd70b | 2012-03-16 18:47:03 +0900 | [diff] [blame] | 279 | }, |
Sean Paul | 2f7e2ed | 2013-01-15 08:11:08 -0500 | [diff] [blame] | 280 | { |
| 281 | .pixel_clock = 27027000, |
| 282 | .conf = { |
| 283 | 0x01, 0xd1, 0x2d, 0x72, 0x40, 0x64, 0x12, 0x08, |
| 284 | 0x43, 0xa0, 0x0e, 0xd9, 0x45, 0xa0, 0xac, 0x80, |
| 285 | 0x08, 0x80, 0x11, 0x04, 0x02, 0x22, 0x44, 0x86, |
| 286 | 0x54, 0xe3, 0x24, 0x00, 0x00, 0x00, 0x01, 0x00, |
| 287 | }, |
Joonyoung Shim | 3ecd70b | 2012-03-16 18:47:03 +0900 | [diff] [blame] | 288 | }, |
Sean Paul | 2f7e2ed | 2013-01-15 08:11:08 -0500 | [diff] [blame] | 289 | { |
| 290 | .pixel_clock = 36000000, |
| 291 | .conf = { |
| 292 | 0x01, 0x51, 0x2d, 0x55, 0x40, 0x01, 0x00, 0x08, |
| 293 | 0x82, 0x80, 0x0e, 0xd9, 0x45, 0xa0, 0xac, 0x80, |
| 294 | 0x08, 0x80, 0x11, 0x04, 0x02, 0x22, 0x44, 0x86, |
| 295 | 0x54, 0xab, 0x24, 0x00, 0x00, 0x00, 0x01, 0x80, |
| 296 | }, |
Joonyoung Shim | 3ecd70b | 2012-03-16 18:47:03 +0900 | [diff] [blame] | 297 | }, |
Sean Paul | 2f7e2ed | 2013-01-15 08:11:08 -0500 | [diff] [blame] | 298 | { |
| 299 | .pixel_clock = 40000000, |
| 300 | .conf = { |
| 301 | 0x01, 0x51, 0x32, 0x55, 0x40, 0x01, 0x00, 0x08, |
| 302 | 0x82, 0x80, 0x2c, 0xd9, 0x45, 0xa0, 0xac, 0x80, |
| 303 | 0x08, 0x80, 0x11, 0x04, 0x02, 0x22, 0x44, 0x86, |
| 304 | 0x54, 0x9a, 0x24, 0x00, 0x00, 0x00, 0x01, 0x80, |
| 305 | }, |
Joonyoung Shim | 3ecd70b | 2012-03-16 18:47:03 +0900 | [diff] [blame] | 306 | }, |
Sean Paul | 2f7e2ed | 2013-01-15 08:11:08 -0500 | [diff] [blame] | 307 | { |
| 308 | .pixel_clock = 65000000, |
| 309 | .conf = { |
| 310 | 0x01, 0xd1, 0x36, 0x34, 0x40, 0x1e, 0x0a, 0x08, |
| 311 | 0x82, 0xa0, 0x45, 0xd9, 0x45, 0xa0, 0xac, 0x80, |
| 312 | 0x08, 0x80, 0x11, 0x04, 0x02, 0x22, 0x44, 0x86, |
| 313 | 0x54, 0xbd, 0x24, 0x01, 0x00, 0x00, 0x01, 0x80, |
| 314 | }, |
Joonyoung Shim | 3ecd70b | 2012-03-16 18:47:03 +0900 | [diff] [blame] | 315 | }, |
Sean Paul | 2f7e2ed | 2013-01-15 08:11:08 -0500 | [diff] [blame] | 316 | { |
| 317 | .pixel_clock = 74176000, |
| 318 | .conf = { |
| 319 | 0x01, 0xd1, 0x3e, 0x35, 0x40, 0x5b, 0xde, 0x08, |
| 320 | 0x82, 0xa0, 0x73, 0xd9, 0x45, 0xa0, 0xac, 0x80, |
| 321 | 0x56, 0x80, 0x11, 0x04, 0x02, 0x22, 0x44, 0x86, |
| 322 | 0x54, 0xa6, 0x24, 0x01, 0x00, 0x00, 0x01, 0x80, |
| 323 | }, |
Joonyoung Shim | 3ecd70b | 2012-03-16 18:47:03 +0900 | [diff] [blame] | 324 | }, |
Sean Paul | 2f7e2ed | 2013-01-15 08:11:08 -0500 | [diff] [blame] | 325 | { |
| 326 | .pixel_clock = 74250000, |
| 327 | .conf = { |
| 328 | 0x01, 0xd1, 0x1f, 0x10, 0x40, 0x40, 0xf8, 0x08, |
| 329 | 0x81, 0xa0, 0xba, 0xd8, 0x45, 0xa0, 0xac, 0x80, |
| 330 | 0x3c, 0x80, 0x11, 0x04, 0x02, 0x22, 0x44, 0x86, |
| 331 | 0x54, 0xa5, 0x24, 0x01, 0x00, 0x00, 0x01, 0x00, |
| 332 | }, |
Joonyoung Shim | 3ecd70b | 2012-03-16 18:47:03 +0900 | [diff] [blame] | 333 | }, |
Sean Paul | 2f7e2ed | 2013-01-15 08:11:08 -0500 | [diff] [blame] | 334 | { |
| 335 | .pixel_clock = 83500000, |
| 336 | .conf = { |
| 337 | 0x01, 0xd1, 0x23, 0x11, 0x40, 0x0c, 0xfb, 0x08, |
| 338 | 0x85, 0xa0, 0xd1, 0xd8, 0x45, 0xa0, 0xac, 0x80, |
| 339 | 0x08, 0x80, 0x11, 0x04, 0x02, 0x22, 0x44, 0x86, |
| 340 | 0x54, 0x93, 0x24, 0x01, 0x00, 0x00, 0x01, 0x80, |
| 341 | }, |
Joonyoung Shim | 3ecd70b | 2012-03-16 18:47:03 +0900 | [diff] [blame] | 342 | }, |
Sean Paul | 2f7e2ed | 2013-01-15 08:11:08 -0500 | [diff] [blame] | 343 | { |
| 344 | .pixel_clock = 106500000, |
| 345 | .conf = { |
| 346 | 0x01, 0xd1, 0x2c, 0x12, 0x40, 0x0c, 0x09, 0x08, |
| 347 | 0x84, 0xa0, 0x0a, 0xd9, 0x45, 0xa0, 0xac, 0x80, |
| 348 | 0x08, 0x80, 0x11, 0x04, 0x02, 0x22, 0x44, 0x86, |
| 349 | 0x54, 0x73, 0x24, 0x01, 0x00, 0x00, 0x01, 0x80, |
| 350 | }, |
Joonyoung Shim | 3ecd70b | 2012-03-16 18:47:03 +0900 | [diff] [blame] | 351 | }, |
Sean Paul | 2f7e2ed | 2013-01-15 08:11:08 -0500 | [diff] [blame] | 352 | { |
| 353 | .pixel_clock = 108000000, |
| 354 | .conf = { |
| 355 | 0x01, 0x51, 0x2d, 0x15, 0x40, 0x01, 0x00, 0x08, |
| 356 | 0x82, 0x80, 0x0e, 0xd9, 0x45, 0xa0, 0xac, 0x80, |
| 357 | 0x08, 0x80, 0x11, 0x04, 0x02, 0x22, 0x44, 0x86, |
| 358 | 0x54, 0xc7, 0x25, 0x03, 0x00, 0x00, 0x01, 0x80, |
| 359 | }, |
Seung-Woo Kim | e540adf | 2012-04-24 17:55:06 +0900 | [diff] [blame] | 360 | }, |
Sean Paul | 2f7e2ed | 2013-01-15 08:11:08 -0500 | [diff] [blame] | 361 | { |
| 362 | .pixel_clock = 146250000, |
| 363 | .conf = { |
| 364 | 0x01, 0xd1, 0x3d, 0x15, 0x40, 0x18, 0xfd, 0x08, |
| 365 | 0x83, 0xa0, 0x6e, 0xd9, 0x45, 0xa0, 0xac, 0x80, |
| 366 | 0x08, 0x80, 0x11, 0x04, 0x02, 0x22, 0x44, 0x86, |
| 367 | 0x54, 0x50, 0x25, 0x03, 0x00, 0x00, 0x01, 0x80, |
| 368 | }, |
Seung-Woo Kim | e540adf | 2012-04-24 17:55:06 +0900 | [diff] [blame] | 369 | }, |
Sean Paul | 2f7e2ed | 2013-01-15 08:11:08 -0500 | [diff] [blame] | 370 | { |
| 371 | .pixel_clock = 148500000, |
| 372 | .conf = { |
| 373 | 0x01, 0xd1, 0x1f, 0x00, 0x40, 0x40, 0xf8, 0x08, |
| 374 | 0x81, 0xa0, 0xba, 0xd8, 0x45, 0xa0, 0xac, 0x80, |
| 375 | 0x3c, 0x80, 0x11, 0x04, 0x02, 0x22, 0x44, 0x86, |
| 376 | 0x54, 0x4b, 0x25, 0x03, 0x00, 0x00, 0x01, 0x00, |
| 377 | }, |
Joonyoung Shim | 3ecd70b | 2012-03-16 18:47:03 +0900 | [diff] [blame] | 378 | }, |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 379 | }; |
| 380 | |
Rahul Sharma | a144c2e | 2012-11-26 10:52:57 +0530 | [diff] [blame] | 381 | struct hdmi_infoframe { |
| 382 | enum HDMI_PACKET_TYPE type; |
| 383 | u8 ver; |
| 384 | u8 len; |
| 385 | }; |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 386 | |
| 387 | static inline u32 hdmi_reg_read(struct hdmi_context *hdata, u32 reg_id) |
| 388 | { |
| 389 | return readl(hdata->regs + reg_id); |
| 390 | } |
| 391 | |
| 392 | static inline void hdmi_reg_writeb(struct hdmi_context *hdata, |
| 393 | u32 reg_id, u8 value) |
| 394 | { |
| 395 | writeb(value, hdata->regs + reg_id); |
| 396 | } |
| 397 | |
| 398 | static inline void hdmi_reg_writemask(struct hdmi_context *hdata, |
| 399 | u32 reg_id, u32 value, u32 mask) |
| 400 | { |
| 401 | u32 old = readl(hdata->regs + reg_id); |
| 402 | value = (value & mask) | (old & ~mask); |
| 403 | writel(value, hdata->regs + reg_id); |
| 404 | } |
| 405 | |
Joonyoung Shim | 3ecd70b | 2012-03-16 18:47:03 +0900 | [diff] [blame] | 406 | static void hdmi_v13_regs_dump(struct hdmi_context *hdata, char *prefix) |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 407 | { |
| 408 | #define DUMPREG(reg_id) \ |
| 409 | DRM_DEBUG_KMS("%s:" #reg_id " = %08x\n", prefix, \ |
| 410 | readl(hdata->regs + reg_id)) |
| 411 | DRM_DEBUG_KMS("%s: ---- CONTROL REGISTERS ----\n", prefix); |
| 412 | DUMPREG(HDMI_INTC_FLAG); |
| 413 | DUMPREG(HDMI_INTC_CON); |
| 414 | DUMPREG(HDMI_HPD_STATUS); |
Joonyoung Shim | 3ecd70b | 2012-03-16 18:47:03 +0900 | [diff] [blame] | 415 | DUMPREG(HDMI_V13_PHY_RSTOUT); |
| 416 | DUMPREG(HDMI_V13_PHY_VPLL); |
| 417 | DUMPREG(HDMI_V13_PHY_CMU); |
| 418 | DUMPREG(HDMI_V13_CORE_RSTOUT); |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 419 | |
| 420 | DRM_DEBUG_KMS("%s: ---- CORE REGISTERS ----\n", prefix); |
| 421 | DUMPREG(HDMI_CON_0); |
| 422 | DUMPREG(HDMI_CON_1); |
| 423 | DUMPREG(HDMI_CON_2); |
| 424 | DUMPREG(HDMI_SYS_STATUS); |
Joonyoung Shim | 3ecd70b | 2012-03-16 18:47:03 +0900 | [diff] [blame] | 425 | DUMPREG(HDMI_V13_PHY_STATUS); |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 426 | DUMPREG(HDMI_STATUS_EN); |
| 427 | DUMPREG(HDMI_HPD); |
| 428 | DUMPREG(HDMI_MODE_SEL); |
Joonyoung Shim | 3ecd70b | 2012-03-16 18:47:03 +0900 | [diff] [blame] | 429 | DUMPREG(HDMI_V13_HPD_GEN); |
| 430 | DUMPREG(HDMI_V13_DC_CONTROL); |
| 431 | DUMPREG(HDMI_V13_VIDEO_PATTERN_GEN); |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 432 | |
| 433 | DRM_DEBUG_KMS("%s: ---- CORE SYNC REGISTERS ----\n", prefix); |
| 434 | DUMPREG(HDMI_H_BLANK_0); |
| 435 | DUMPREG(HDMI_H_BLANK_1); |
Joonyoung Shim | 3ecd70b | 2012-03-16 18:47:03 +0900 | [diff] [blame] | 436 | DUMPREG(HDMI_V13_V_BLANK_0); |
| 437 | DUMPREG(HDMI_V13_V_BLANK_1); |
| 438 | DUMPREG(HDMI_V13_V_BLANK_2); |
| 439 | DUMPREG(HDMI_V13_H_V_LINE_0); |
| 440 | DUMPREG(HDMI_V13_H_V_LINE_1); |
| 441 | DUMPREG(HDMI_V13_H_V_LINE_2); |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 442 | DUMPREG(HDMI_VSYNC_POL); |
| 443 | DUMPREG(HDMI_INT_PRO_MODE); |
Joonyoung Shim | 3ecd70b | 2012-03-16 18:47:03 +0900 | [diff] [blame] | 444 | DUMPREG(HDMI_V13_V_BLANK_F_0); |
| 445 | DUMPREG(HDMI_V13_V_BLANK_F_1); |
| 446 | DUMPREG(HDMI_V13_V_BLANK_F_2); |
| 447 | DUMPREG(HDMI_V13_H_SYNC_GEN_0); |
| 448 | DUMPREG(HDMI_V13_H_SYNC_GEN_1); |
| 449 | DUMPREG(HDMI_V13_H_SYNC_GEN_2); |
| 450 | DUMPREG(HDMI_V13_V_SYNC_GEN_1_0); |
| 451 | DUMPREG(HDMI_V13_V_SYNC_GEN_1_1); |
| 452 | DUMPREG(HDMI_V13_V_SYNC_GEN_1_2); |
| 453 | DUMPREG(HDMI_V13_V_SYNC_GEN_2_0); |
| 454 | DUMPREG(HDMI_V13_V_SYNC_GEN_2_1); |
| 455 | DUMPREG(HDMI_V13_V_SYNC_GEN_2_2); |
| 456 | DUMPREG(HDMI_V13_V_SYNC_GEN_3_0); |
| 457 | DUMPREG(HDMI_V13_V_SYNC_GEN_3_1); |
| 458 | DUMPREG(HDMI_V13_V_SYNC_GEN_3_2); |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 459 | |
| 460 | DRM_DEBUG_KMS("%s: ---- TG REGISTERS ----\n", prefix); |
| 461 | DUMPREG(HDMI_TG_CMD); |
| 462 | DUMPREG(HDMI_TG_H_FSZ_L); |
| 463 | DUMPREG(HDMI_TG_H_FSZ_H); |
| 464 | DUMPREG(HDMI_TG_HACT_ST_L); |
| 465 | DUMPREG(HDMI_TG_HACT_ST_H); |
| 466 | DUMPREG(HDMI_TG_HACT_SZ_L); |
| 467 | DUMPREG(HDMI_TG_HACT_SZ_H); |
| 468 | DUMPREG(HDMI_TG_V_FSZ_L); |
| 469 | DUMPREG(HDMI_TG_V_FSZ_H); |
| 470 | DUMPREG(HDMI_TG_VSYNC_L); |
| 471 | DUMPREG(HDMI_TG_VSYNC_H); |
| 472 | DUMPREG(HDMI_TG_VSYNC2_L); |
| 473 | DUMPREG(HDMI_TG_VSYNC2_H); |
| 474 | DUMPREG(HDMI_TG_VACT_ST_L); |
| 475 | DUMPREG(HDMI_TG_VACT_ST_H); |
| 476 | DUMPREG(HDMI_TG_VACT_SZ_L); |
| 477 | DUMPREG(HDMI_TG_VACT_SZ_H); |
| 478 | DUMPREG(HDMI_TG_FIELD_CHG_L); |
| 479 | DUMPREG(HDMI_TG_FIELD_CHG_H); |
| 480 | DUMPREG(HDMI_TG_VACT_ST2_L); |
| 481 | DUMPREG(HDMI_TG_VACT_ST2_H); |
| 482 | DUMPREG(HDMI_TG_VSYNC_TOP_HDMI_L); |
| 483 | DUMPREG(HDMI_TG_VSYNC_TOP_HDMI_H); |
| 484 | DUMPREG(HDMI_TG_VSYNC_BOT_HDMI_L); |
| 485 | DUMPREG(HDMI_TG_VSYNC_BOT_HDMI_H); |
| 486 | DUMPREG(HDMI_TG_FIELD_TOP_HDMI_L); |
| 487 | DUMPREG(HDMI_TG_FIELD_TOP_HDMI_H); |
| 488 | DUMPREG(HDMI_TG_FIELD_BOT_HDMI_L); |
| 489 | DUMPREG(HDMI_TG_FIELD_BOT_HDMI_H); |
| 490 | #undef DUMPREG |
| 491 | } |
| 492 | |
Joonyoung Shim | 3ecd70b | 2012-03-16 18:47:03 +0900 | [diff] [blame] | 493 | static void hdmi_v14_regs_dump(struct hdmi_context *hdata, char *prefix) |
| 494 | { |
| 495 | int i; |
| 496 | |
| 497 | #define DUMPREG(reg_id) \ |
| 498 | DRM_DEBUG_KMS("%s:" #reg_id " = %08x\n", prefix, \ |
| 499 | readl(hdata->regs + reg_id)) |
| 500 | |
| 501 | DRM_DEBUG_KMS("%s: ---- CONTROL REGISTERS ----\n", prefix); |
| 502 | DUMPREG(HDMI_INTC_CON); |
| 503 | DUMPREG(HDMI_INTC_FLAG); |
| 504 | DUMPREG(HDMI_HPD_STATUS); |
| 505 | DUMPREG(HDMI_INTC_CON_1); |
| 506 | DUMPREG(HDMI_INTC_FLAG_1); |
| 507 | DUMPREG(HDMI_PHY_STATUS_0); |
| 508 | DUMPREG(HDMI_PHY_STATUS_PLL); |
| 509 | DUMPREG(HDMI_PHY_CON_0); |
| 510 | DUMPREG(HDMI_PHY_RSTOUT); |
| 511 | DUMPREG(HDMI_PHY_VPLL); |
| 512 | DUMPREG(HDMI_PHY_CMU); |
| 513 | DUMPREG(HDMI_CORE_RSTOUT); |
| 514 | |
| 515 | DRM_DEBUG_KMS("%s: ---- CORE REGISTERS ----\n", prefix); |
| 516 | DUMPREG(HDMI_CON_0); |
| 517 | DUMPREG(HDMI_CON_1); |
| 518 | DUMPREG(HDMI_CON_2); |
| 519 | DUMPREG(HDMI_SYS_STATUS); |
| 520 | DUMPREG(HDMI_PHY_STATUS_0); |
| 521 | DUMPREG(HDMI_STATUS_EN); |
| 522 | DUMPREG(HDMI_HPD); |
| 523 | DUMPREG(HDMI_MODE_SEL); |
| 524 | DUMPREG(HDMI_ENC_EN); |
| 525 | DUMPREG(HDMI_DC_CONTROL); |
| 526 | DUMPREG(HDMI_VIDEO_PATTERN_GEN); |
| 527 | |
| 528 | DRM_DEBUG_KMS("%s: ---- CORE SYNC REGISTERS ----\n", prefix); |
| 529 | DUMPREG(HDMI_H_BLANK_0); |
| 530 | DUMPREG(HDMI_H_BLANK_1); |
| 531 | DUMPREG(HDMI_V2_BLANK_0); |
| 532 | DUMPREG(HDMI_V2_BLANK_1); |
| 533 | DUMPREG(HDMI_V1_BLANK_0); |
| 534 | DUMPREG(HDMI_V1_BLANK_1); |
| 535 | DUMPREG(HDMI_V_LINE_0); |
| 536 | DUMPREG(HDMI_V_LINE_1); |
| 537 | DUMPREG(HDMI_H_LINE_0); |
| 538 | DUMPREG(HDMI_H_LINE_1); |
| 539 | DUMPREG(HDMI_HSYNC_POL); |
| 540 | |
| 541 | DUMPREG(HDMI_VSYNC_POL); |
| 542 | DUMPREG(HDMI_INT_PRO_MODE); |
| 543 | DUMPREG(HDMI_V_BLANK_F0_0); |
| 544 | DUMPREG(HDMI_V_BLANK_F0_1); |
| 545 | DUMPREG(HDMI_V_BLANK_F1_0); |
| 546 | DUMPREG(HDMI_V_BLANK_F1_1); |
| 547 | |
| 548 | DUMPREG(HDMI_H_SYNC_START_0); |
| 549 | DUMPREG(HDMI_H_SYNC_START_1); |
| 550 | DUMPREG(HDMI_H_SYNC_END_0); |
| 551 | DUMPREG(HDMI_H_SYNC_END_1); |
| 552 | |
| 553 | DUMPREG(HDMI_V_SYNC_LINE_BEF_2_0); |
| 554 | DUMPREG(HDMI_V_SYNC_LINE_BEF_2_1); |
| 555 | DUMPREG(HDMI_V_SYNC_LINE_BEF_1_0); |
| 556 | DUMPREG(HDMI_V_SYNC_LINE_BEF_1_1); |
| 557 | |
| 558 | DUMPREG(HDMI_V_SYNC_LINE_AFT_2_0); |
| 559 | DUMPREG(HDMI_V_SYNC_LINE_AFT_2_1); |
| 560 | DUMPREG(HDMI_V_SYNC_LINE_AFT_1_0); |
| 561 | DUMPREG(HDMI_V_SYNC_LINE_AFT_1_1); |
| 562 | |
| 563 | DUMPREG(HDMI_V_SYNC_LINE_AFT_PXL_2_0); |
| 564 | DUMPREG(HDMI_V_SYNC_LINE_AFT_PXL_2_1); |
| 565 | DUMPREG(HDMI_V_SYNC_LINE_AFT_PXL_1_0); |
| 566 | DUMPREG(HDMI_V_SYNC_LINE_AFT_PXL_1_1); |
| 567 | |
| 568 | DUMPREG(HDMI_V_BLANK_F2_0); |
| 569 | DUMPREG(HDMI_V_BLANK_F2_1); |
| 570 | DUMPREG(HDMI_V_BLANK_F3_0); |
| 571 | DUMPREG(HDMI_V_BLANK_F3_1); |
| 572 | DUMPREG(HDMI_V_BLANK_F4_0); |
| 573 | DUMPREG(HDMI_V_BLANK_F4_1); |
| 574 | DUMPREG(HDMI_V_BLANK_F5_0); |
| 575 | DUMPREG(HDMI_V_BLANK_F5_1); |
| 576 | |
| 577 | DUMPREG(HDMI_V_SYNC_LINE_AFT_3_0); |
| 578 | DUMPREG(HDMI_V_SYNC_LINE_AFT_3_1); |
| 579 | DUMPREG(HDMI_V_SYNC_LINE_AFT_4_0); |
| 580 | DUMPREG(HDMI_V_SYNC_LINE_AFT_4_1); |
| 581 | DUMPREG(HDMI_V_SYNC_LINE_AFT_5_0); |
| 582 | DUMPREG(HDMI_V_SYNC_LINE_AFT_5_1); |
| 583 | DUMPREG(HDMI_V_SYNC_LINE_AFT_6_0); |
| 584 | DUMPREG(HDMI_V_SYNC_LINE_AFT_6_1); |
| 585 | |
| 586 | DUMPREG(HDMI_V_SYNC_LINE_AFT_PXL_3_0); |
| 587 | DUMPREG(HDMI_V_SYNC_LINE_AFT_PXL_3_1); |
| 588 | DUMPREG(HDMI_V_SYNC_LINE_AFT_PXL_4_0); |
| 589 | DUMPREG(HDMI_V_SYNC_LINE_AFT_PXL_4_1); |
| 590 | DUMPREG(HDMI_V_SYNC_LINE_AFT_PXL_5_0); |
| 591 | DUMPREG(HDMI_V_SYNC_LINE_AFT_PXL_5_1); |
| 592 | DUMPREG(HDMI_V_SYNC_LINE_AFT_PXL_6_0); |
| 593 | DUMPREG(HDMI_V_SYNC_LINE_AFT_PXL_6_1); |
| 594 | |
| 595 | DUMPREG(HDMI_VACT_SPACE_1_0); |
| 596 | DUMPREG(HDMI_VACT_SPACE_1_1); |
| 597 | DUMPREG(HDMI_VACT_SPACE_2_0); |
| 598 | DUMPREG(HDMI_VACT_SPACE_2_1); |
| 599 | DUMPREG(HDMI_VACT_SPACE_3_0); |
| 600 | DUMPREG(HDMI_VACT_SPACE_3_1); |
| 601 | DUMPREG(HDMI_VACT_SPACE_4_0); |
| 602 | DUMPREG(HDMI_VACT_SPACE_4_1); |
| 603 | DUMPREG(HDMI_VACT_SPACE_5_0); |
| 604 | DUMPREG(HDMI_VACT_SPACE_5_1); |
| 605 | DUMPREG(HDMI_VACT_SPACE_6_0); |
| 606 | DUMPREG(HDMI_VACT_SPACE_6_1); |
| 607 | |
| 608 | DRM_DEBUG_KMS("%s: ---- TG REGISTERS ----\n", prefix); |
| 609 | DUMPREG(HDMI_TG_CMD); |
| 610 | DUMPREG(HDMI_TG_H_FSZ_L); |
| 611 | DUMPREG(HDMI_TG_H_FSZ_H); |
| 612 | DUMPREG(HDMI_TG_HACT_ST_L); |
| 613 | DUMPREG(HDMI_TG_HACT_ST_H); |
| 614 | DUMPREG(HDMI_TG_HACT_SZ_L); |
| 615 | DUMPREG(HDMI_TG_HACT_SZ_H); |
| 616 | DUMPREG(HDMI_TG_V_FSZ_L); |
| 617 | DUMPREG(HDMI_TG_V_FSZ_H); |
| 618 | DUMPREG(HDMI_TG_VSYNC_L); |
| 619 | DUMPREG(HDMI_TG_VSYNC_H); |
| 620 | DUMPREG(HDMI_TG_VSYNC2_L); |
| 621 | DUMPREG(HDMI_TG_VSYNC2_H); |
| 622 | DUMPREG(HDMI_TG_VACT_ST_L); |
| 623 | DUMPREG(HDMI_TG_VACT_ST_H); |
| 624 | DUMPREG(HDMI_TG_VACT_SZ_L); |
| 625 | DUMPREG(HDMI_TG_VACT_SZ_H); |
| 626 | DUMPREG(HDMI_TG_FIELD_CHG_L); |
| 627 | DUMPREG(HDMI_TG_FIELD_CHG_H); |
| 628 | DUMPREG(HDMI_TG_VACT_ST2_L); |
| 629 | DUMPREG(HDMI_TG_VACT_ST2_H); |
| 630 | DUMPREG(HDMI_TG_VACT_ST3_L); |
| 631 | DUMPREG(HDMI_TG_VACT_ST3_H); |
| 632 | DUMPREG(HDMI_TG_VACT_ST4_L); |
| 633 | DUMPREG(HDMI_TG_VACT_ST4_H); |
| 634 | DUMPREG(HDMI_TG_VSYNC_TOP_HDMI_L); |
| 635 | DUMPREG(HDMI_TG_VSYNC_TOP_HDMI_H); |
| 636 | DUMPREG(HDMI_TG_VSYNC_BOT_HDMI_L); |
| 637 | DUMPREG(HDMI_TG_VSYNC_BOT_HDMI_H); |
| 638 | DUMPREG(HDMI_TG_FIELD_TOP_HDMI_L); |
| 639 | DUMPREG(HDMI_TG_FIELD_TOP_HDMI_H); |
| 640 | DUMPREG(HDMI_TG_FIELD_BOT_HDMI_L); |
| 641 | DUMPREG(HDMI_TG_FIELD_BOT_HDMI_H); |
| 642 | DUMPREG(HDMI_TG_3D); |
| 643 | |
| 644 | DRM_DEBUG_KMS("%s: ---- PACKET REGISTERS ----\n", prefix); |
| 645 | DUMPREG(HDMI_AVI_CON); |
| 646 | DUMPREG(HDMI_AVI_HEADER0); |
| 647 | DUMPREG(HDMI_AVI_HEADER1); |
| 648 | DUMPREG(HDMI_AVI_HEADER2); |
| 649 | DUMPREG(HDMI_AVI_CHECK_SUM); |
| 650 | DUMPREG(HDMI_VSI_CON); |
| 651 | DUMPREG(HDMI_VSI_HEADER0); |
| 652 | DUMPREG(HDMI_VSI_HEADER1); |
| 653 | DUMPREG(HDMI_VSI_HEADER2); |
| 654 | for (i = 0; i < 7; ++i) |
| 655 | DUMPREG(HDMI_VSI_DATA(i)); |
| 656 | |
| 657 | #undef DUMPREG |
| 658 | } |
| 659 | |
| 660 | static void hdmi_regs_dump(struct hdmi_context *hdata, char *prefix) |
| 661 | { |
Rahul Sharma | 5a32507 | 2012-10-04 20:48:54 +0530 | [diff] [blame] | 662 | if (hdata->type == HDMI_TYPE13) |
Joonyoung Shim | 3ecd70b | 2012-03-16 18:47:03 +0900 | [diff] [blame] | 663 | hdmi_v13_regs_dump(hdata, prefix); |
| 664 | else |
| 665 | hdmi_v14_regs_dump(hdata, prefix); |
| 666 | } |
| 667 | |
Rahul Sharma | a144c2e | 2012-11-26 10:52:57 +0530 | [diff] [blame] | 668 | static u8 hdmi_chksum(struct hdmi_context *hdata, |
| 669 | u32 start, u8 len, u32 hdr_sum) |
| 670 | { |
| 671 | int i; |
| 672 | |
| 673 | /* hdr_sum : header0 + header1 + header2 |
| 674 | * start : start address of packet byte1 |
| 675 | * len : packet bytes - 1 */ |
| 676 | for (i = 0; i < len; ++i) |
| 677 | hdr_sum += 0xff & hdmi_reg_read(hdata, start + i * 4); |
| 678 | |
| 679 | /* return 2's complement of 8 bit hdr_sum */ |
| 680 | return (u8)(~(hdr_sum & 0xff) + 1); |
| 681 | } |
| 682 | |
| 683 | static void hdmi_reg_infoframe(struct hdmi_context *hdata, |
| 684 | struct hdmi_infoframe *infoframe) |
| 685 | { |
| 686 | u32 hdr_sum; |
| 687 | u8 chksum; |
| 688 | u32 aspect_ratio; |
| 689 | u32 mod; |
| 690 | u32 vic; |
| 691 | |
| 692 | DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__); |
| 693 | |
| 694 | mod = hdmi_reg_read(hdata, HDMI_MODE_SEL); |
| 695 | if (hdata->dvi_mode) { |
| 696 | hdmi_reg_writeb(hdata, HDMI_VSI_CON, |
| 697 | HDMI_VSI_CON_DO_NOT_TRANSMIT); |
| 698 | hdmi_reg_writeb(hdata, HDMI_AVI_CON, |
| 699 | HDMI_AVI_CON_DO_NOT_TRANSMIT); |
| 700 | hdmi_reg_writeb(hdata, HDMI_AUI_CON, HDMI_AUI_CON_NO_TRAN); |
| 701 | return; |
| 702 | } |
| 703 | |
| 704 | switch (infoframe->type) { |
| 705 | case HDMI_PACKET_TYPE_AVI: |
| 706 | hdmi_reg_writeb(hdata, HDMI_AVI_CON, HDMI_AVI_CON_EVERY_VSYNC); |
| 707 | hdmi_reg_writeb(hdata, HDMI_AVI_HEADER0, infoframe->type); |
| 708 | hdmi_reg_writeb(hdata, HDMI_AVI_HEADER1, infoframe->ver); |
| 709 | hdmi_reg_writeb(hdata, HDMI_AVI_HEADER2, infoframe->len); |
| 710 | hdr_sum = infoframe->type + infoframe->ver + infoframe->len; |
| 711 | |
| 712 | /* Output format zero hardcoded ,RGB YBCR selection */ |
| 713 | hdmi_reg_writeb(hdata, HDMI_AVI_BYTE(1), 0 << 5 | |
| 714 | AVI_ACTIVE_FORMAT_VALID | |
| 715 | AVI_UNDERSCANNED_DISPLAY_VALID); |
| 716 | |
| 717 | aspect_ratio = AVI_PIC_ASPECT_RATIO_16_9; |
| 718 | |
| 719 | hdmi_reg_writeb(hdata, HDMI_AVI_BYTE(2), aspect_ratio | |
| 720 | AVI_SAME_AS_PIC_ASPECT_RATIO); |
| 721 | |
Rahul Sharma | 6b986ed | 2013-03-06 17:33:29 +0900 | [diff] [blame] | 722 | vic = hdata->mode_conf.cea_video_id; |
Rahul Sharma | a144c2e | 2012-11-26 10:52:57 +0530 | [diff] [blame] | 723 | hdmi_reg_writeb(hdata, HDMI_AVI_BYTE(4), vic); |
| 724 | |
| 725 | chksum = hdmi_chksum(hdata, HDMI_AVI_BYTE(1), |
| 726 | infoframe->len, hdr_sum); |
| 727 | DRM_DEBUG_KMS("AVI checksum = 0x%x\n", chksum); |
| 728 | hdmi_reg_writeb(hdata, HDMI_AVI_CHECK_SUM, chksum); |
| 729 | break; |
| 730 | case HDMI_PACKET_TYPE_AUI: |
| 731 | hdmi_reg_writeb(hdata, HDMI_AUI_CON, 0x02); |
| 732 | hdmi_reg_writeb(hdata, HDMI_AUI_HEADER0, infoframe->type); |
| 733 | hdmi_reg_writeb(hdata, HDMI_AUI_HEADER1, infoframe->ver); |
| 734 | hdmi_reg_writeb(hdata, HDMI_AUI_HEADER2, infoframe->len); |
| 735 | hdr_sum = infoframe->type + infoframe->ver + infoframe->len; |
| 736 | chksum = hdmi_chksum(hdata, HDMI_AUI_BYTE(1), |
| 737 | infoframe->len, hdr_sum); |
| 738 | DRM_DEBUG_KMS("AUI checksum = 0x%x\n", chksum); |
| 739 | hdmi_reg_writeb(hdata, HDMI_AUI_CHECK_SUM, chksum); |
| 740 | break; |
| 741 | default: |
| 742 | break; |
| 743 | } |
| 744 | } |
| 745 | |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 746 | static bool hdmi_is_connected(void *ctx) |
| 747 | { |
Joonyoung Shim | f9309d1 | 2012-04-05 20:49:22 +0900 | [diff] [blame] | 748 | struct hdmi_context *hdata = ctx; |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 749 | |
Joonyoung Shim | cf8fc4f | 2012-04-23 19:35:50 +0900 | [diff] [blame] | 750 | return hdata->hpd; |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 751 | } |
| 752 | |
Rahul Sharma | 9c08e4b | 2013-01-04 07:59:11 -0500 | [diff] [blame] | 753 | static struct edid *hdmi_get_edid(void *ctx, struct drm_connector *connector) |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 754 | { |
| 755 | struct edid *raw_edid; |
Joonyoung Shim | f9309d1 | 2012-04-05 20:49:22 +0900 | [diff] [blame] | 756 | struct hdmi_context *hdata = ctx; |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 757 | |
| 758 | DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__); |
| 759 | |
| 760 | if (!hdata->ddc_port) |
Rahul Sharma | 9c08e4b | 2013-01-04 07:59:11 -0500 | [diff] [blame] | 761 | return ERR_PTR(-ENODEV); |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 762 | |
| 763 | raw_edid = drm_get_edid(connector, hdata->ddc_port->adapter); |
Rahul Sharma | 9c08e4b | 2013-01-04 07:59:11 -0500 | [diff] [blame] | 764 | if (!raw_edid) |
| 765 | return ERR_PTR(-ENODEV); |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 766 | |
Rahul Sharma | 9c08e4b | 2013-01-04 07:59:11 -0500 | [diff] [blame] | 767 | hdata->dvi_mode = !drm_detect_hdmi_monitor(raw_edid); |
| 768 | DRM_DEBUG_KMS("%s : width[%d] x height[%d]\n", |
| 769 | (hdata->dvi_mode ? "dvi monitor" : "hdmi monitor"), |
| 770 | raw_edid->width_cm, raw_edid->height_cm); |
| 771 | |
| 772 | return raw_edid; |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 773 | } |
| 774 | |
Rahul Sharma | 6b986ed | 2013-03-06 17:33:29 +0900 | [diff] [blame] | 775 | static int hdmi_find_phy_conf(struct hdmi_context *hdata, u32 pixel_clock) |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 776 | { |
Rahul Sharma | 6b986ed | 2013-03-06 17:33:29 +0900 | [diff] [blame] | 777 | const struct hdmiphy_config *confs; |
| 778 | int count, i; |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 779 | |
Rahul Sharma | 6b986ed | 2013-03-06 17:33:29 +0900 | [diff] [blame] | 780 | DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__); |
Inki Dae | 1de425b | 2012-03-16 18:47:04 +0900 | [diff] [blame] | 781 | |
Rahul Sharma | 6b986ed | 2013-03-06 17:33:29 +0900 | [diff] [blame] | 782 | if (hdata->type == HDMI_TYPE13) { |
| 783 | confs = hdmiphy_v13_configs; |
| 784 | count = ARRAY_SIZE(hdmiphy_v13_configs); |
| 785 | } else if (hdata->type == HDMI_TYPE14) { |
| 786 | confs = hdmiphy_v14_configs; |
| 787 | count = ARRAY_SIZE(hdmiphy_v14_configs); |
| 788 | } else |
| 789 | return -EINVAL; |
Inki Dae | 1de425b | 2012-03-16 18:47:04 +0900 | [diff] [blame] | 790 | |
Rahul Sharma | 6b986ed | 2013-03-06 17:33:29 +0900 | [diff] [blame] | 791 | for (i = 0; i < count; i++) |
| 792 | if (confs[i].pixel_clock == pixel_clock) |
Sean Paul | 2f7e2ed | 2013-01-15 08:11:08 -0500 | [diff] [blame] | 793 | return i; |
Sean Paul | 2f7e2ed | 2013-01-15 08:11:08 -0500 | [diff] [blame] | 794 | |
| 795 | DRM_DEBUG_KMS("Could not find phy config for %d\n", pixel_clock); |
| 796 | return -EINVAL; |
| 797 | } |
| 798 | |
Rahul Sharma | 438c0f8 | 2013-01-15 08:11:05 -0500 | [diff] [blame] | 799 | static int hdmi_check_timing(void *ctx, struct fb_videomode *timing) |
Joonyoung Shim | 3ecd70b | 2012-03-16 18:47:03 +0900 | [diff] [blame] | 800 | { |
Joonyoung Shim | f9309d1 | 2012-04-05 20:49:22 +0900 | [diff] [blame] | 801 | struct hdmi_context *hdata = ctx; |
Rahul Sharma | 6b986ed | 2013-03-06 17:33:29 +0900 | [diff] [blame] | 802 | int ret; |
Joonyoung Shim | 3ecd70b | 2012-03-16 18:47:03 +0900 | [diff] [blame] | 803 | |
| 804 | DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__); |
| 805 | |
Rahul Sharma | 438c0f8 | 2013-01-15 08:11:05 -0500 | [diff] [blame] | 806 | DRM_DEBUG_KMS("[%d]x[%d] [%d]Hz [%x]\n", timing->xres, |
| 807 | timing->yres, timing->refresh, |
| 808 | timing->vmode); |
Joonyoung Shim | 3ecd70b | 2012-03-16 18:47:03 +0900 | [diff] [blame] | 809 | |
Rahul Sharma | 6b986ed | 2013-03-06 17:33:29 +0900 | [diff] [blame] | 810 | ret = hdmi_find_phy_conf(hdata, timing->pixclock); |
| 811 | if (ret < 0) |
| 812 | return ret; |
| 813 | return 0; |
Joonyoung Shim | 3ecd70b | 2012-03-16 18:47:03 +0900 | [diff] [blame] | 814 | } |
| 815 | |
Seung-Woo Kim | 3e148ba | 2012-03-16 18:47:16 +0900 | [diff] [blame] | 816 | static void hdmi_set_acr(u32 freq, u8 *acr) |
| 817 | { |
| 818 | u32 n, cts; |
| 819 | |
| 820 | switch (freq) { |
| 821 | case 32000: |
| 822 | n = 4096; |
| 823 | cts = 27000; |
| 824 | break; |
| 825 | case 44100: |
| 826 | n = 6272; |
| 827 | cts = 30000; |
| 828 | break; |
| 829 | case 88200: |
| 830 | n = 12544; |
| 831 | cts = 30000; |
| 832 | break; |
| 833 | case 176400: |
| 834 | n = 25088; |
| 835 | cts = 30000; |
| 836 | break; |
| 837 | case 48000: |
| 838 | n = 6144; |
| 839 | cts = 27000; |
| 840 | break; |
| 841 | case 96000: |
| 842 | n = 12288; |
| 843 | cts = 27000; |
| 844 | break; |
| 845 | case 192000: |
| 846 | n = 24576; |
| 847 | cts = 27000; |
| 848 | break; |
| 849 | default: |
| 850 | n = 0; |
| 851 | cts = 0; |
| 852 | break; |
| 853 | } |
| 854 | |
| 855 | acr[1] = cts >> 16; |
| 856 | acr[2] = cts >> 8 & 0xff; |
| 857 | acr[3] = cts & 0xff; |
| 858 | |
| 859 | acr[4] = n >> 16; |
| 860 | acr[5] = n >> 8 & 0xff; |
| 861 | acr[6] = n & 0xff; |
| 862 | } |
| 863 | |
| 864 | static void hdmi_reg_acr(struct hdmi_context *hdata, u8 *acr) |
| 865 | { |
| 866 | hdmi_reg_writeb(hdata, HDMI_ACR_N0, acr[6]); |
| 867 | hdmi_reg_writeb(hdata, HDMI_ACR_N1, acr[5]); |
| 868 | hdmi_reg_writeb(hdata, HDMI_ACR_N2, acr[4]); |
| 869 | hdmi_reg_writeb(hdata, HDMI_ACR_MCTS0, acr[3]); |
| 870 | hdmi_reg_writeb(hdata, HDMI_ACR_MCTS1, acr[2]); |
| 871 | hdmi_reg_writeb(hdata, HDMI_ACR_MCTS2, acr[1]); |
| 872 | hdmi_reg_writeb(hdata, HDMI_ACR_CTS0, acr[3]); |
| 873 | hdmi_reg_writeb(hdata, HDMI_ACR_CTS1, acr[2]); |
| 874 | hdmi_reg_writeb(hdata, HDMI_ACR_CTS2, acr[1]); |
| 875 | |
Rahul Sharma | 5a32507 | 2012-10-04 20:48:54 +0530 | [diff] [blame] | 876 | if (hdata->type == HDMI_TYPE13) |
Seung-Woo Kim | 3e148ba | 2012-03-16 18:47:16 +0900 | [diff] [blame] | 877 | hdmi_reg_writeb(hdata, HDMI_V13_ACR_CON, 4); |
| 878 | else |
| 879 | hdmi_reg_writeb(hdata, HDMI_ACR_CON, 4); |
| 880 | } |
| 881 | |
| 882 | static void hdmi_audio_init(struct hdmi_context *hdata) |
| 883 | { |
| 884 | u32 sample_rate, bits_per_sample, frame_size_code; |
| 885 | u32 data_num, bit_ch, sample_frq; |
| 886 | u32 val; |
| 887 | u8 acr[7]; |
| 888 | |
| 889 | sample_rate = 44100; |
| 890 | bits_per_sample = 16; |
| 891 | frame_size_code = 0; |
| 892 | |
| 893 | switch (bits_per_sample) { |
| 894 | case 20: |
| 895 | data_num = 2; |
| 896 | bit_ch = 1; |
| 897 | break; |
| 898 | case 24: |
| 899 | data_num = 3; |
| 900 | bit_ch = 1; |
| 901 | break; |
| 902 | default: |
| 903 | data_num = 1; |
| 904 | bit_ch = 0; |
| 905 | break; |
| 906 | } |
| 907 | |
| 908 | hdmi_set_acr(sample_rate, acr); |
| 909 | hdmi_reg_acr(hdata, acr); |
| 910 | |
| 911 | hdmi_reg_writeb(hdata, HDMI_I2S_MUX_CON, HDMI_I2S_IN_DISABLE |
| 912 | | HDMI_I2S_AUD_I2S | HDMI_I2S_CUV_I2S_ENABLE |
| 913 | | HDMI_I2S_MUX_ENABLE); |
| 914 | |
| 915 | hdmi_reg_writeb(hdata, HDMI_I2S_MUX_CH, HDMI_I2S_CH0_EN |
| 916 | | HDMI_I2S_CH1_EN | HDMI_I2S_CH2_EN); |
| 917 | |
| 918 | hdmi_reg_writeb(hdata, HDMI_I2S_MUX_CUV, HDMI_I2S_CUV_RL_EN); |
| 919 | |
| 920 | sample_frq = (sample_rate == 44100) ? 0 : |
| 921 | (sample_rate == 48000) ? 2 : |
| 922 | (sample_rate == 32000) ? 3 : |
| 923 | (sample_rate == 96000) ? 0xa : 0x0; |
| 924 | |
| 925 | hdmi_reg_writeb(hdata, HDMI_I2S_CLK_CON, HDMI_I2S_CLK_DIS); |
| 926 | hdmi_reg_writeb(hdata, HDMI_I2S_CLK_CON, HDMI_I2S_CLK_EN); |
| 927 | |
| 928 | val = hdmi_reg_read(hdata, HDMI_I2S_DSD_CON) | 0x01; |
| 929 | hdmi_reg_writeb(hdata, HDMI_I2S_DSD_CON, val); |
| 930 | |
| 931 | /* Configuration I2S input ports. Configure I2S_PIN_SEL_0~4 */ |
| 932 | hdmi_reg_writeb(hdata, HDMI_I2S_PIN_SEL_0, HDMI_I2S_SEL_SCLK(5) |
| 933 | | HDMI_I2S_SEL_LRCK(6)); |
| 934 | hdmi_reg_writeb(hdata, HDMI_I2S_PIN_SEL_1, HDMI_I2S_SEL_SDATA1(1) |
| 935 | | HDMI_I2S_SEL_SDATA2(4)); |
| 936 | hdmi_reg_writeb(hdata, HDMI_I2S_PIN_SEL_2, HDMI_I2S_SEL_SDATA3(1) |
| 937 | | HDMI_I2S_SEL_SDATA2(2)); |
| 938 | hdmi_reg_writeb(hdata, HDMI_I2S_PIN_SEL_3, HDMI_I2S_SEL_DSD(0)); |
| 939 | |
| 940 | /* I2S_CON_1 & 2 */ |
| 941 | hdmi_reg_writeb(hdata, HDMI_I2S_CON_1, HDMI_I2S_SCLK_FALLING_EDGE |
| 942 | | HDMI_I2S_L_CH_LOW_POL); |
| 943 | hdmi_reg_writeb(hdata, HDMI_I2S_CON_2, HDMI_I2S_MSB_FIRST_MODE |
| 944 | | HDMI_I2S_SET_BIT_CH(bit_ch) |
| 945 | | HDMI_I2S_SET_SDATA_BIT(data_num) |
| 946 | | HDMI_I2S_BASIC_FORMAT); |
| 947 | |
| 948 | /* Configure register related to CUV information */ |
| 949 | hdmi_reg_writeb(hdata, HDMI_I2S_CH_ST_0, HDMI_I2S_CH_STATUS_MODE_0 |
| 950 | | HDMI_I2S_2AUD_CH_WITHOUT_PREEMPH |
| 951 | | HDMI_I2S_COPYRIGHT |
| 952 | | HDMI_I2S_LINEAR_PCM |
| 953 | | HDMI_I2S_CONSUMER_FORMAT); |
| 954 | hdmi_reg_writeb(hdata, HDMI_I2S_CH_ST_1, HDMI_I2S_CD_PLAYER); |
| 955 | hdmi_reg_writeb(hdata, HDMI_I2S_CH_ST_2, HDMI_I2S_SET_SOURCE_NUM(0)); |
| 956 | hdmi_reg_writeb(hdata, HDMI_I2S_CH_ST_3, HDMI_I2S_CLK_ACCUR_LEVEL_2 |
| 957 | | HDMI_I2S_SET_SMP_FREQ(sample_frq)); |
| 958 | hdmi_reg_writeb(hdata, HDMI_I2S_CH_ST_4, |
| 959 | HDMI_I2S_ORG_SMP_FREQ_44_1 |
| 960 | | HDMI_I2S_WORD_LEN_MAX24_24BITS |
| 961 | | HDMI_I2S_WORD_LEN_MAX_24BITS); |
| 962 | |
| 963 | hdmi_reg_writeb(hdata, HDMI_I2S_CH_ST_CON, HDMI_I2S_CH_STATUS_RELOAD); |
| 964 | } |
| 965 | |
| 966 | static void hdmi_audio_control(struct hdmi_context *hdata, bool onoff) |
| 967 | { |
Seung-Woo Kim | 872d20d6 | 2012-04-24 17:39:15 +0900 | [diff] [blame] | 968 | if (hdata->dvi_mode) |
Seung-Woo Kim | 3e148ba | 2012-03-16 18:47:16 +0900 | [diff] [blame] | 969 | return; |
| 970 | |
| 971 | hdmi_reg_writeb(hdata, HDMI_AUI_CON, onoff ? 2 : 0); |
| 972 | hdmi_reg_writemask(hdata, HDMI_CON_0, onoff ? |
| 973 | HDMI_ASP_EN : HDMI_ASP_DIS, HDMI_ASP_MASK); |
| 974 | } |
| 975 | |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 976 | static void hdmi_conf_reset(struct hdmi_context *hdata) |
| 977 | { |
Joonyoung Shim | 3ecd70b | 2012-03-16 18:47:03 +0900 | [diff] [blame] | 978 | u32 reg; |
| 979 | |
Rahul Sharma | 5a32507 | 2012-10-04 20:48:54 +0530 | [diff] [blame] | 980 | if (hdata->type == HDMI_TYPE13) |
Joonyoung Shim | 3ecd70b | 2012-03-16 18:47:03 +0900 | [diff] [blame] | 981 | reg = HDMI_V13_CORE_RSTOUT; |
| 982 | else |
| 983 | reg = HDMI_CORE_RSTOUT; |
| 984 | |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 985 | /* resetting HDMI core */ |
Joonyoung Shim | 3ecd70b | 2012-03-16 18:47:03 +0900 | [diff] [blame] | 986 | hdmi_reg_writemask(hdata, reg, 0, HDMI_CORE_SW_RSTOUT); |
Sean Paul | 09760ea | 2013-01-14 17:03:20 -0500 | [diff] [blame] | 987 | usleep_range(10000, 12000); |
Joonyoung Shim | 3ecd70b | 2012-03-16 18:47:03 +0900 | [diff] [blame] | 988 | hdmi_reg_writemask(hdata, reg, ~0, HDMI_CORE_SW_RSTOUT); |
Sean Paul | 09760ea | 2013-01-14 17:03:20 -0500 | [diff] [blame] | 989 | usleep_range(10000, 12000); |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 990 | } |
| 991 | |
| 992 | static void hdmi_conf_init(struct hdmi_context *hdata) |
| 993 | { |
Rahul Sharma | a144c2e | 2012-11-26 10:52:57 +0530 | [diff] [blame] | 994 | struct hdmi_infoframe infoframe; |
| 995 | |
Sean Paul | 77006a7 | 2013-01-16 10:17:20 -0500 | [diff] [blame] | 996 | /* disable HPD interrupts from HDMI IP block, use GPIO instead */ |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 997 | hdmi_reg_writemask(hdata, HDMI_INTC_CON, 0, HDMI_INTC_EN_GLOBAL | |
| 998 | HDMI_INTC_EN_HPD_PLUG | HDMI_INTC_EN_HPD_UNPLUG); |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 999 | |
| 1000 | /* choose HDMI mode */ |
| 1001 | hdmi_reg_writemask(hdata, HDMI_MODE_SEL, |
| 1002 | HDMI_MODE_HDMI_EN, HDMI_MODE_MASK); |
| 1003 | /* disable bluescreen */ |
| 1004 | hdmi_reg_writemask(hdata, HDMI_CON_0, 0, HDMI_BLUE_SCR_EN); |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 1005 | |
Seung-Woo Kim | 872d20d6 | 2012-04-24 17:39:15 +0900 | [diff] [blame] | 1006 | if (hdata->dvi_mode) { |
| 1007 | /* choose DVI mode */ |
| 1008 | hdmi_reg_writemask(hdata, HDMI_MODE_SEL, |
| 1009 | HDMI_MODE_DVI_EN, HDMI_MODE_MASK); |
| 1010 | hdmi_reg_writeb(hdata, HDMI_CON_2, |
| 1011 | HDMI_VID_PREAMBLE_DIS | HDMI_GUARD_BAND_DIS); |
| 1012 | } |
| 1013 | |
Rahul Sharma | 5a32507 | 2012-10-04 20:48:54 +0530 | [diff] [blame] | 1014 | if (hdata->type == HDMI_TYPE13) { |
Joonyoung Shim | 3ecd70b | 2012-03-16 18:47:03 +0900 | [diff] [blame] | 1015 | /* choose bluescreen (fecal) color */ |
| 1016 | hdmi_reg_writeb(hdata, HDMI_V13_BLUE_SCREEN_0, 0x12); |
| 1017 | hdmi_reg_writeb(hdata, HDMI_V13_BLUE_SCREEN_1, 0x34); |
| 1018 | hdmi_reg_writeb(hdata, HDMI_V13_BLUE_SCREEN_2, 0x56); |
| 1019 | |
| 1020 | /* enable AVI packet every vsync, fixes purple line problem */ |
| 1021 | hdmi_reg_writeb(hdata, HDMI_V13_AVI_CON, 0x02); |
| 1022 | /* force RGB, look to CEA-861-D, table 7 for more detail */ |
| 1023 | hdmi_reg_writeb(hdata, HDMI_V13_AVI_BYTE(0), 0 << 5); |
| 1024 | hdmi_reg_writemask(hdata, HDMI_CON_1, 0x10 << 5, 0x11 << 5); |
| 1025 | |
| 1026 | hdmi_reg_writeb(hdata, HDMI_V13_SPD_CON, 0x02); |
| 1027 | hdmi_reg_writeb(hdata, HDMI_V13_AUI_CON, 0x02); |
| 1028 | hdmi_reg_writeb(hdata, HDMI_V13_ACR_CON, 0x04); |
| 1029 | } else { |
Rahul Sharma | a144c2e | 2012-11-26 10:52:57 +0530 | [diff] [blame] | 1030 | infoframe.type = HDMI_PACKET_TYPE_AVI; |
| 1031 | infoframe.ver = HDMI_AVI_VERSION; |
| 1032 | infoframe.len = HDMI_AVI_LENGTH; |
| 1033 | hdmi_reg_infoframe(hdata, &infoframe); |
| 1034 | |
| 1035 | infoframe.type = HDMI_PACKET_TYPE_AUI; |
| 1036 | infoframe.ver = HDMI_AUI_VERSION; |
| 1037 | infoframe.len = HDMI_AUI_LENGTH; |
| 1038 | hdmi_reg_infoframe(hdata, &infoframe); |
| 1039 | |
Joonyoung Shim | 3ecd70b | 2012-03-16 18:47:03 +0900 | [diff] [blame] | 1040 | /* enable AVI packet every vsync, fixes purple line problem */ |
Joonyoung Shim | 3ecd70b | 2012-03-16 18:47:03 +0900 | [diff] [blame] | 1041 | hdmi_reg_writemask(hdata, HDMI_CON_1, 2, 3 << 5); |
| 1042 | } |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 1043 | } |
| 1044 | |
Joonyoung Shim | 3ecd70b | 2012-03-16 18:47:03 +0900 | [diff] [blame] | 1045 | static void hdmi_v13_timing_apply(struct hdmi_context *hdata) |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 1046 | { |
Rahul Sharma | 6b986ed | 2013-03-06 17:33:29 +0900 | [diff] [blame] | 1047 | const struct hdmi_tg_regs *tg = &hdata->mode_conf.conf.v13_conf.tg; |
| 1048 | const struct hdmi_v13_core_regs *core = |
| 1049 | &hdata->mode_conf.conf.v13_conf.core; |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 1050 | int tries; |
| 1051 | |
| 1052 | /* setting core registers */ |
| 1053 | hdmi_reg_writeb(hdata, HDMI_H_BLANK_0, core->h_blank[0]); |
| 1054 | hdmi_reg_writeb(hdata, HDMI_H_BLANK_1, core->h_blank[1]); |
Joonyoung Shim | 3ecd70b | 2012-03-16 18:47:03 +0900 | [diff] [blame] | 1055 | hdmi_reg_writeb(hdata, HDMI_V13_V_BLANK_0, core->v_blank[0]); |
| 1056 | hdmi_reg_writeb(hdata, HDMI_V13_V_BLANK_1, core->v_blank[1]); |
| 1057 | hdmi_reg_writeb(hdata, HDMI_V13_V_BLANK_2, core->v_blank[2]); |
| 1058 | hdmi_reg_writeb(hdata, HDMI_V13_H_V_LINE_0, core->h_v_line[0]); |
| 1059 | hdmi_reg_writeb(hdata, HDMI_V13_H_V_LINE_1, core->h_v_line[1]); |
| 1060 | hdmi_reg_writeb(hdata, HDMI_V13_H_V_LINE_2, core->h_v_line[2]); |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 1061 | hdmi_reg_writeb(hdata, HDMI_VSYNC_POL, core->vsync_pol[0]); |
| 1062 | hdmi_reg_writeb(hdata, HDMI_INT_PRO_MODE, core->int_pro_mode[0]); |
Joonyoung Shim | 3ecd70b | 2012-03-16 18:47:03 +0900 | [diff] [blame] | 1063 | hdmi_reg_writeb(hdata, HDMI_V13_V_BLANK_F_0, core->v_blank_f[0]); |
| 1064 | hdmi_reg_writeb(hdata, HDMI_V13_V_BLANK_F_1, core->v_blank_f[1]); |
| 1065 | hdmi_reg_writeb(hdata, HDMI_V13_V_BLANK_F_2, core->v_blank_f[2]); |
| 1066 | hdmi_reg_writeb(hdata, HDMI_V13_H_SYNC_GEN_0, core->h_sync_gen[0]); |
| 1067 | hdmi_reg_writeb(hdata, HDMI_V13_H_SYNC_GEN_1, core->h_sync_gen[1]); |
| 1068 | hdmi_reg_writeb(hdata, HDMI_V13_H_SYNC_GEN_2, core->h_sync_gen[2]); |
| 1069 | hdmi_reg_writeb(hdata, HDMI_V13_V_SYNC_GEN_1_0, core->v_sync_gen1[0]); |
| 1070 | hdmi_reg_writeb(hdata, HDMI_V13_V_SYNC_GEN_1_1, core->v_sync_gen1[1]); |
| 1071 | hdmi_reg_writeb(hdata, HDMI_V13_V_SYNC_GEN_1_2, core->v_sync_gen1[2]); |
| 1072 | hdmi_reg_writeb(hdata, HDMI_V13_V_SYNC_GEN_2_0, core->v_sync_gen2[0]); |
| 1073 | hdmi_reg_writeb(hdata, HDMI_V13_V_SYNC_GEN_2_1, core->v_sync_gen2[1]); |
| 1074 | hdmi_reg_writeb(hdata, HDMI_V13_V_SYNC_GEN_2_2, core->v_sync_gen2[2]); |
| 1075 | hdmi_reg_writeb(hdata, HDMI_V13_V_SYNC_GEN_3_0, core->v_sync_gen3[0]); |
| 1076 | hdmi_reg_writeb(hdata, HDMI_V13_V_SYNC_GEN_3_1, core->v_sync_gen3[1]); |
| 1077 | hdmi_reg_writeb(hdata, HDMI_V13_V_SYNC_GEN_3_2, core->v_sync_gen3[2]); |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 1078 | /* Timing generator registers */ |
Rahul Sharma | 6b986ed | 2013-03-06 17:33:29 +0900 | [diff] [blame] | 1079 | hdmi_reg_writeb(hdata, HDMI_TG_H_FSZ_L, tg->h_fsz[0]); |
| 1080 | hdmi_reg_writeb(hdata, HDMI_TG_H_FSZ_H, tg->h_fsz[1]); |
| 1081 | hdmi_reg_writeb(hdata, HDMI_TG_HACT_ST_L, tg->hact_st[0]); |
| 1082 | hdmi_reg_writeb(hdata, HDMI_TG_HACT_ST_H, tg->hact_st[1]); |
| 1083 | hdmi_reg_writeb(hdata, HDMI_TG_HACT_SZ_L, tg->hact_sz[0]); |
| 1084 | hdmi_reg_writeb(hdata, HDMI_TG_HACT_SZ_H, tg->hact_sz[1]); |
| 1085 | hdmi_reg_writeb(hdata, HDMI_TG_V_FSZ_L, tg->v_fsz[0]); |
| 1086 | hdmi_reg_writeb(hdata, HDMI_TG_V_FSZ_H, tg->v_fsz[1]); |
| 1087 | hdmi_reg_writeb(hdata, HDMI_TG_VSYNC_L, tg->vsync[0]); |
| 1088 | hdmi_reg_writeb(hdata, HDMI_TG_VSYNC_H, tg->vsync[1]); |
| 1089 | hdmi_reg_writeb(hdata, HDMI_TG_VSYNC2_L, tg->vsync2[0]); |
| 1090 | hdmi_reg_writeb(hdata, HDMI_TG_VSYNC2_H, tg->vsync2[1]); |
| 1091 | hdmi_reg_writeb(hdata, HDMI_TG_VACT_ST_L, tg->vact_st[0]); |
| 1092 | hdmi_reg_writeb(hdata, HDMI_TG_VACT_ST_H, tg->vact_st[1]); |
| 1093 | hdmi_reg_writeb(hdata, HDMI_TG_VACT_SZ_L, tg->vact_sz[0]); |
| 1094 | hdmi_reg_writeb(hdata, HDMI_TG_VACT_SZ_H, tg->vact_sz[1]); |
| 1095 | hdmi_reg_writeb(hdata, HDMI_TG_FIELD_CHG_L, tg->field_chg[0]); |
| 1096 | hdmi_reg_writeb(hdata, HDMI_TG_FIELD_CHG_H, tg->field_chg[1]); |
| 1097 | hdmi_reg_writeb(hdata, HDMI_TG_VACT_ST2_L, tg->vact_st2[0]); |
| 1098 | hdmi_reg_writeb(hdata, HDMI_TG_VACT_ST2_H, tg->vact_st2[1]); |
| 1099 | hdmi_reg_writeb(hdata, HDMI_TG_VSYNC_TOP_HDMI_L, tg->vsync_top_hdmi[0]); |
| 1100 | hdmi_reg_writeb(hdata, HDMI_TG_VSYNC_TOP_HDMI_H, tg->vsync_top_hdmi[1]); |
| 1101 | hdmi_reg_writeb(hdata, HDMI_TG_VSYNC_BOT_HDMI_L, tg->vsync_bot_hdmi[0]); |
| 1102 | hdmi_reg_writeb(hdata, HDMI_TG_VSYNC_BOT_HDMI_H, tg->vsync_bot_hdmi[1]); |
| 1103 | hdmi_reg_writeb(hdata, HDMI_TG_FIELD_TOP_HDMI_L, tg->field_top_hdmi[0]); |
| 1104 | hdmi_reg_writeb(hdata, HDMI_TG_FIELD_TOP_HDMI_H, tg->field_top_hdmi[1]); |
| 1105 | hdmi_reg_writeb(hdata, HDMI_TG_FIELD_BOT_HDMI_L, tg->field_bot_hdmi[0]); |
| 1106 | hdmi_reg_writeb(hdata, HDMI_TG_FIELD_BOT_HDMI_H, tg->field_bot_hdmi[1]); |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 1107 | |
| 1108 | /* waiting for HDMIPHY's PLL to get to steady state */ |
| 1109 | for (tries = 100; tries; --tries) { |
Joonyoung Shim | 3ecd70b | 2012-03-16 18:47:03 +0900 | [diff] [blame] | 1110 | u32 val = hdmi_reg_read(hdata, HDMI_V13_PHY_STATUS); |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 1111 | if (val & HDMI_PHY_STATUS_READY) |
| 1112 | break; |
Sean Paul | 09760ea | 2013-01-14 17:03:20 -0500 | [diff] [blame] | 1113 | usleep_range(1000, 2000); |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 1114 | } |
| 1115 | /* steady state not achieved */ |
| 1116 | if (tries == 0) { |
| 1117 | DRM_ERROR("hdmiphy's pll could not reach steady state.\n"); |
| 1118 | hdmi_regs_dump(hdata, "timing apply"); |
| 1119 | } |
| 1120 | |
| 1121 | clk_disable(hdata->res.sclk_hdmi); |
| 1122 | clk_set_parent(hdata->res.sclk_hdmi, hdata->res.sclk_hdmiphy); |
| 1123 | clk_enable(hdata->res.sclk_hdmi); |
| 1124 | |
| 1125 | /* enable HDMI and timing generator */ |
| 1126 | hdmi_reg_writemask(hdata, HDMI_CON_0, ~0, HDMI_EN); |
| 1127 | if (core->int_pro_mode[0]) |
| 1128 | hdmi_reg_writemask(hdata, HDMI_TG_CMD, ~0, HDMI_TG_EN | |
| 1129 | HDMI_FIELD_EN); |
| 1130 | else |
| 1131 | hdmi_reg_writemask(hdata, HDMI_TG_CMD, ~0, HDMI_TG_EN); |
| 1132 | } |
| 1133 | |
Joonyoung Shim | 3ecd70b | 2012-03-16 18:47:03 +0900 | [diff] [blame] | 1134 | static void hdmi_v14_timing_apply(struct hdmi_context *hdata) |
| 1135 | { |
Rahul Sharma | 6b986ed | 2013-03-06 17:33:29 +0900 | [diff] [blame] | 1136 | const struct hdmi_tg_regs *tg = &hdata->mode_conf.conf.v14_conf.tg; |
| 1137 | const struct hdmi_v14_core_regs *core = |
| 1138 | &hdata->mode_conf.conf.v14_conf.core; |
Joonyoung Shim | 3ecd70b | 2012-03-16 18:47:03 +0900 | [diff] [blame] | 1139 | int tries; |
| 1140 | |
| 1141 | /* setting core registers */ |
| 1142 | hdmi_reg_writeb(hdata, HDMI_H_BLANK_0, core->h_blank[0]); |
| 1143 | hdmi_reg_writeb(hdata, HDMI_H_BLANK_1, core->h_blank[1]); |
| 1144 | hdmi_reg_writeb(hdata, HDMI_V2_BLANK_0, core->v2_blank[0]); |
| 1145 | hdmi_reg_writeb(hdata, HDMI_V2_BLANK_1, core->v2_blank[1]); |
| 1146 | hdmi_reg_writeb(hdata, HDMI_V1_BLANK_0, core->v1_blank[0]); |
| 1147 | hdmi_reg_writeb(hdata, HDMI_V1_BLANK_1, core->v1_blank[1]); |
| 1148 | hdmi_reg_writeb(hdata, HDMI_V_LINE_0, core->v_line[0]); |
| 1149 | hdmi_reg_writeb(hdata, HDMI_V_LINE_1, core->v_line[1]); |
| 1150 | hdmi_reg_writeb(hdata, HDMI_H_LINE_0, core->h_line[0]); |
| 1151 | hdmi_reg_writeb(hdata, HDMI_H_LINE_1, core->h_line[1]); |
| 1152 | hdmi_reg_writeb(hdata, HDMI_HSYNC_POL, core->hsync_pol[0]); |
| 1153 | hdmi_reg_writeb(hdata, HDMI_VSYNC_POL, core->vsync_pol[0]); |
| 1154 | hdmi_reg_writeb(hdata, HDMI_INT_PRO_MODE, core->int_pro_mode[0]); |
| 1155 | hdmi_reg_writeb(hdata, HDMI_V_BLANK_F0_0, core->v_blank_f0[0]); |
| 1156 | hdmi_reg_writeb(hdata, HDMI_V_BLANK_F0_1, core->v_blank_f0[1]); |
| 1157 | hdmi_reg_writeb(hdata, HDMI_V_BLANK_F1_0, core->v_blank_f1[0]); |
| 1158 | hdmi_reg_writeb(hdata, HDMI_V_BLANK_F1_1, core->v_blank_f1[1]); |
| 1159 | hdmi_reg_writeb(hdata, HDMI_H_SYNC_START_0, core->h_sync_start[0]); |
| 1160 | hdmi_reg_writeb(hdata, HDMI_H_SYNC_START_1, core->h_sync_start[1]); |
| 1161 | hdmi_reg_writeb(hdata, HDMI_H_SYNC_END_0, core->h_sync_end[0]); |
| 1162 | hdmi_reg_writeb(hdata, HDMI_H_SYNC_END_1, core->h_sync_end[1]); |
| 1163 | hdmi_reg_writeb(hdata, HDMI_V_SYNC_LINE_BEF_2_0, |
| 1164 | core->v_sync_line_bef_2[0]); |
| 1165 | hdmi_reg_writeb(hdata, HDMI_V_SYNC_LINE_BEF_2_1, |
| 1166 | core->v_sync_line_bef_2[1]); |
| 1167 | hdmi_reg_writeb(hdata, HDMI_V_SYNC_LINE_BEF_1_0, |
| 1168 | core->v_sync_line_bef_1[0]); |
| 1169 | hdmi_reg_writeb(hdata, HDMI_V_SYNC_LINE_BEF_1_1, |
| 1170 | core->v_sync_line_bef_1[1]); |
| 1171 | hdmi_reg_writeb(hdata, HDMI_V_SYNC_LINE_AFT_2_0, |
| 1172 | core->v_sync_line_aft_2[0]); |
| 1173 | hdmi_reg_writeb(hdata, HDMI_V_SYNC_LINE_AFT_2_1, |
| 1174 | core->v_sync_line_aft_2[1]); |
| 1175 | hdmi_reg_writeb(hdata, HDMI_V_SYNC_LINE_AFT_1_0, |
| 1176 | core->v_sync_line_aft_1[0]); |
| 1177 | hdmi_reg_writeb(hdata, HDMI_V_SYNC_LINE_AFT_1_1, |
| 1178 | core->v_sync_line_aft_1[1]); |
| 1179 | hdmi_reg_writeb(hdata, HDMI_V_SYNC_LINE_AFT_PXL_2_0, |
| 1180 | core->v_sync_line_aft_pxl_2[0]); |
| 1181 | hdmi_reg_writeb(hdata, HDMI_V_SYNC_LINE_AFT_PXL_2_1, |
| 1182 | core->v_sync_line_aft_pxl_2[1]); |
| 1183 | hdmi_reg_writeb(hdata, HDMI_V_SYNC_LINE_AFT_PXL_1_0, |
| 1184 | core->v_sync_line_aft_pxl_1[0]); |
| 1185 | hdmi_reg_writeb(hdata, HDMI_V_SYNC_LINE_AFT_PXL_1_1, |
| 1186 | core->v_sync_line_aft_pxl_1[1]); |
| 1187 | hdmi_reg_writeb(hdata, HDMI_V_BLANK_F2_0, core->v_blank_f2[0]); |
| 1188 | hdmi_reg_writeb(hdata, HDMI_V_BLANK_F2_1, core->v_blank_f2[1]); |
| 1189 | hdmi_reg_writeb(hdata, HDMI_V_BLANK_F3_0, core->v_blank_f3[0]); |
| 1190 | hdmi_reg_writeb(hdata, HDMI_V_BLANK_F3_1, core->v_blank_f3[1]); |
| 1191 | hdmi_reg_writeb(hdata, HDMI_V_BLANK_F4_0, core->v_blank_f4[0]); |
| 1192 | hdmi_reg_writeb(hdata, HDMI_V_BLANK_F4_1, core->v_blank_f4[1]); |
| 1193 | hdmi_reg_writeb(hdata, HDMI_V_BLANK_F5_0, core->v_blank_f5[0]); |
| 1194 | hdmi_reg_writeb(hdata, HDMI_V_BLANK_F5_1, core->v_blank_f5[1]); |
| 1195 | hdmi_reg_writeb(hdata, HDMI_V_SYNC_LINE_AFT_3_0, |
| 1196 | core->v_sync_line_aft_3[0]); |
| 1197 | hdmi_reg_writeb(hdata, HDMI_V_SYNC_LINE_AFT_3_1, |
| 1198 | core->v_sync_line_aft_3[1]); |
| 1199 | hdmi_reg_writeb(hdata, HDMI_V_SYNC_LINE_AFT_4_0, |
| 1200 | core->v_sync_line_aft_4[0]); |
| 1201 | hdmi_reg_writeb(hdata, HDMI_V_SYNC_LINE_AFT_4_1, |
| 1202 | core->v_sync_line_aft_4[1]); |
| 1203 | hdmi_reg_writeb(hdata, HDMI_V_SYNC_LINE_AFT_5_0, |
| 1204 | core->v_sync_line_aft_5[0]); |
| 1205 | hdmi_reg_writeb(hdata, HDMI_V_SYNC_LINE_AFT_5_1, |
| 1206 | core->v_sync_line_aft_5[1]); |
| 1207 | hdmi_reg_writeb(hdata, HDMI_V_SYNC_LINE_AFT_6_0, |
| 1208 | core->v_sync_line_aft_6[0]); |
| 1209 | hdmi_reg_writeb(hdata, HDMI_V_SYNC_LINE_AFT_6_1, |
| 1210 | core->v_sync_line_aft_6[1]); |
| 1211 | hdmi_reg_writeb(hdata, HDMI_V_SYNC_LINE_AFT_PXL_3_0, |
| 1212 | core->v_sync_line_aft_pxl_3[0]); |
| 1213 | hdmi_reg_writeb(hdata, HDMI_V_SYNC_LINE_AFT_PXL_3_1, |
| 1214 | core->v_sync_line_aft_pxl_3[1]); |
| 1215 | hdmi_reg_writeb(hdata, HDMI_V_SYNC_LINE_AFT_PXL_4_0, |
| 1216 | core->v_sync_line_aft_pxl_4[0]); |
| 1217 | hdmi_reg_writeb(hdata, HDMI_V_SYNC_LINE_AFT_PXL_4_1, |
| 1218 | core->v_sync_line_aft_pxl_4[1]); |
| 1219 | hdmi_reg_writeb(hdata, HDMI_V_SYNC_LINE_AFT_PXL_5_0, |
| 1220 | core->v_sync_line_aft_pxl_5[0]); |
| 1221 | hdmi_reg_writeb(hdata, HDMI_V_SYNC_LINE_AFT_PXL_5_1, |
| 1222 | core->v_sync_line_aft_pxl_5[1]); |
| 1223 | hdmi_reg_writeb(hdata, HDMI_V_SYNC_LINE_AFT_PXL_6_0, |
| 1224 | core->v_sync_line_aft_pxl_6[0]); |
| 1225 | hdmi_reg_writeb(hdata, HDMI_V_SYNC_LINE_AFT_PXL_6_1, |
| 1226 | core->v_sync_line_aft_pxl_6[1]); |
| 1227 | hdmi_reg_writeb(hdata, HDMI_VACT_SPACE_1_0, core->vact_space_1[0]); |
| 1228 | hdmi_reg_writeb(hdata, HDMI_VACT_SPACE_1_1, core->vact_space_1[1]); |
| 1229 | hdmi_reg_writeb(hdata, HDMI_VACT_SPACE_2_0, core->vact_space_2[0]); |
| 1230 | hdmi_reg_writeb(hdata, HDMI_VACT_SPACE_2_1, core->vact_space_2[1]); |
| 1231 | hdmi_reg_writeb(hdata, HDMI_VACT_SPACE_3_0, core->vact_space_3[0]); |
| 1232 | hdmi_reg_writeb(hdata, HDMI_VACT_SPACE_3_1, core->vact_space_3[1]); |
| 1233 | hdmi_reg_writeb(hdata, HDMI_VACT_SPACE_4_0, core->vact_space_4[0]); |
| 1234 | hdmi_reg_writeb(hdata, HDMI_VACT_SPACE_4_1, core->vact_space_4[1]); |
| 1235 | hdmi_reg_writeb(hdata, HDMI_VACT_SPACE_5_0, core->vact_space_5[0]); |
| 1236 | hdmi_reg_writeb(hdata, HDMI_VACT_SPACE_5_1, core->vact_space_5[1]); |
| 1237 | hdmi_reg_writeb(hdata, HDMI_VACT_SPACE_6_0, core->vact_space_6[0]); |
| 1238 | hdmi_reg_writeb(hdata, HDMI_VACT_SPACE_6_1, core->vact_space_6[1]); |
| 1239 | |
| 1240 | /* Timing generator registers */ |
Sean Paul | 2f7e2ed | 2013-01-15 08:11:08 -0500 | [diff] [blame] | 1241 | hdmi_reg_writeb(hdata, HDMI_TG_H_FSZ_L, tg->h_fsz[0]); |
| 1242 | hdmi_reg_writeb(hdata, HDMI_TG_H_FSZ_H, tg->h_fsz[1]); |
| 1243 | hdmi_reg_writeb(hdata, HDMI_TG_HACT_ST_L, tg->hact_st[0]); |
| 1244 | hdmi_reg_writeb(hdata, HDMI_TG_HACT_ST_H, tg->hact_st[1]); |
| 1245 | hdmi_reg_writeb(hdata, HDMI_TG_HACT_SZ_L, tg->hact_sz[0]); |
| 1246 | hdmi_reg_writeb(hdata, HDMI_TG_HACT_SZ_H, tg->hact_sz[1]); |
| 1247 | hdmi_reg_writeb(hdata, HDMI_TG_V_FSZ_L, tg->v_fsz[0]); |
| 1248 | hdmi_reg_writeb(hdata, HDMI_TG_V_FSZ_H, tg->v_fsz[1]); |
| 1249 | hdmi_reg_writeb(hdata, HDMI_TG_VSYNC_L, tg->vsync[0]); |
| 1250 | hdmi_reg_writeb(hdata, HDMI_TG_VSYNC_H, tg->vsync[1]); |
| 1251 | hdmi_reg_writeb(hdata, HDMI_TG_VSYNC2_L, tg->vsync2[0]); |
| 1252 | hdmi_reg_writeb(hdata, HDMI_TG_VSYNC2_H, tg->vsync2[1]); |
| 1253 | hdmi_reg_writeb(hdata, HDMI_TG_VACT_ST_L, tg->vact_st[0]); |
| 1254 | hdmi_reg_writeb(hdata, HDMI_TG_VACT_ST_H, tg->vact_st[1]); |
| 1255 | hdmi_reg_writeb(hdata, HDMI_TG_VACT_SZ_L, tg->vact_sz[0]); |
| 1256 | hdmi_reg_writeb(hdata, HDMI_TG_VACT_SZ_H, tg->vact_sz[1]); |
| 1257 | hdmi_reg_writeb(hdata, HDMI_TG_FIELD_CHG_L, tg->field_chg[0]); |
| 1258 | hdmi_reg_writeb(hdata, HDMI_TG_FIELD_CHG_H, tg->field_chg[1]); |
| 1259 | hdmi_reg_writeb(hdata, HDMI_TG_VACT_ST2_L, tg->vact_st2[0]); |
| 1260 | hdmi_reg_writeb(hdata, HDMI_TG_VACT_ST2_H, tg->vact_st2[1]); |
| 1261 | hdmi_reg_writeb(hdata, HDMI_TG_VACT_ST3_L, tg->vact_st3[0]); |
| 1262 | hdmi_reg_writeb(hdata, HDMI_TG_VACT_ST3_H, tg->vact_st3[1]); |
| 1263 | hdmi_reg_writeb(hdata, HDMI_TG_VACT_ST4_L, tg->vact_st4[0]); |
| 1264 | hdmi_reg_writeb(hdata, HDMI_TG_VACT_ST4_H, tg->vact_st4[1]); |
| 1265 | hdmi_reg_writeb(hdata, HDMI_TG_VSYNC_TOP_HDMI_L, tg->vsync_top_hdmi[0]); |
| 1266 | hdmi_reg_writeb(hdata, HDMI_TG_VSYNC_TOP_HDMI_H, tg->vsync_top_hdmi[1]); |
| 1267 | hdmi_reg_writeb(hdata, HDMI_TG_VSYNC_BOT_HDMI_L, tg->vsync_bot_hdmi[0]); |
| 1268 | hdmi_reg_writeb(hdata, HDMI_TG_VSYNC_BOT_HDMI_H, tg->vsync_bot_hdmi[1]); |
| 1269 | hdmi_reg_writeb(hdata, HDMI_TG_FIELD_TOP_HDMI_L, tg->field_top_hdmi[0]); |
| 1270 | hdmi_reg_writeb(hdata, HDMI_TG_FIELD_TOP_HDMI_H, tg->field_top_hdmi[1]); |
| 1271 | hdmi_reg_writeb(hdata, HDMI_TG_FIELD_BOT_HDMI_L, tg->field_bot_hdmi[0]); |
| 1272 | hdmi_reg_writeb(hdata, HDMI_TG_FIELD_BOT_HDMI_H, tg->field_bot_hdmi[1]); |
| 1273 | hdmi_reg_writeb(hdata, HDMI_TG_3D, tg->tg_3d[0]); |
Joonyoung Shim | 3ecd70b | 2012-03-16 18:47:03 +0900 | [diff] [blame] | 1274 | |
| 1275 | /* waiting for HDMIPHY's PLL to get to steady state */ |
| 1276 | for (tries = 100; tries; --tries) { |
| 1277 | u32 val = hdmi_reg_read(hdata, HDMI_PHY_STATUS_0); |
| 1278 | if (val & HDMI_PHY_STATUS_READY) |
| 1279 | break; |
Sean Paul | 09760ea | 2013-01-14 17:03:20 -0500 | [diff] [blame] | 1280 | usleep_range(1000, 2000); |
Joonyoung Shim | 3ecd70b | 2012-03-16 18:47:03 +0900 | [diff] [blame] | 1281 | } |
| 1282 | /* steady state not achieved */ |
| 1283 | if (tries == 0) { |
| 1284 | DRM_ERROR("hdmiphy's pll could not reach steady state.\n"); |
| 1285 | hdmi_regs_dump(hdata, "timing apply"); |
| 1286 | } |
| 1287 | |
| 1288 | clk_disable(hdata->res.sclk_hdmi); |
| 1289 | clk_set_parent(hdata->res.sclk_hdmi, hdata->res.sclk_hdmiphy); |
| 1290 | clk_enable(hdata->res.sclk_hdmi); |
| 1291 | |
| 1292 | /* enable HDMI and timing generator */ |
| 1293 | hdmi_reg_writemask(hdata, HDMI_CON_0, ~0, HDMI_EN); |
| 1294 | if (core->int_pro_mode[0]) |
| 1295 | hdmi_reg_writemask(hdata, HDMI_TG_CMD, ~0, HDMI_TG_EN | |
| 1296 | HDMI_FIELD_EN); |
| 1297 | else |
| 1298 | hdmi_reg_writemask(hdata, HDMI_TG_CMD, ~0, HDMI_TG_EN); |
| 1299 | } |
| 1300 | |
| 1301 | static void hdmi_timing_apply(struct hdmi_context *hdata) |
| 1302 | { |
Rahul Sharma | 5a32507 | 2012-10-04 20:48:54 +0530 | [diff] [blame] | 1303 | if (hdata->type == HDMI_TYPE13) |
Joonyoung Shim | 3ecd70b | 2012-03-16 18:47:03 +0900 | [diff] [blame] | 1304 | hdmi_v13_timing_apply(hdata); |
| 1305 | else |
| 1306 | hdmi_v14_timing_apply(hdata); |
| 1307 | } |
| 1308 | |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 1309 | static void hdmiphy_conf_reset(struct hdmi_context *hdata) |
| 1310 | { |
| 1311 | u8 buffer[2]; |
Joonyoung Shim | 3ecd70b | 2012-03-16 18:47:03 +0900 | [diff] [blame] | 1312 | u32 reg; |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 1313 | |
| 1314 | clk_disable(hdata->res.sclk_hdmi); |
| 1315 | clk_set_parent(hdata->res.sclk_hdmi, hdata->res.sclk_pixel); |
| 1316 | clk_enable(hdata->res.sclk_hdmi); |
| 1317 | |
| 1318 | /* operation mode */ |
| 1319 | buffer[0] = 0x1f; |
| 1320 | buffer[1] = 0x00; |
| 1321 | |
| 1322 | if (hdata->hdmiphy_port) |
| 1323 | i2c_master_send(hdata->hdmiphy_port, buffer, 2); |
| 1324 | |
Rahul Sharma | 5a32507 | 2012-10-04 20:48:54 +0530 | [diff] [blame] | 1325 | if (hdata->type == HDMI_TYPE13) |
Joonyoung Shim | 3ecd70b | 2012-03-16 18:47:03 +0900 | [diff] [blame] | 1326 | reg = HDMI_V13_PHY_RSTOUT; |
| 1327 | else |
| 1328 | reg = HDMI_PHY_RSTOUT; |
| 1329 | |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 1330 | /* reset hdmiphy */ |
Joonyoung Shim | 3ecd70b | 2012-03-16 18:47:03 +0900 | [diff] [blame] | 1331 | hdmi_reg_writemask(hdata, reg, ~0, HDMI_PHY_SW_RSTOUT); |
Sean Paul | 09760ea | 2013-01-14 17:03:20 -0500 | [diff] [blame] | 1332 | usleep_range(10000, 12000); |
Joonyoung Shim | 3ecd70b | 2012-03-16 18:47:03 +0900 | [diff] [blame] | 1333 | hdmi_reg_writemask(hdata, reg, 0, HDMI_PHY_SW_RSTOUT); |
Sean Paul | 09760ea | 2013-01-14 17:03:20 -0500 | [diff] [blame] | 1334 | usleep_range(10000, 12000); |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 1335 | } |
| 1336 | |
Rahul Sharma | a556225 | 2012-11-28 11:30:25 +0530 | [diff] [blame] | 1337 | static void hdmiphy_poweron(struct hdmi_context *hdata) |
| 1338 | { |
| 1339 | DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__); |
| 1340 | |
| 1341 | if (hdata->type == HDMI_TYPE14) |
| 1342 | hdmi_reg_writemask(hdata, HDMI_PHY_CON_0, 0, |
| 1343 | HDMI_PHY_POWER_OFF_EN); |
| 1344 | } |
| 1345 | |
| 1346 | static void hdmiphy_poweroff(struct hdmi_context *hdata) |
| 1347 | { |
| 1348 | DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__); |
| 1349 | |
| 1350 | if (hdata->type == HDMI_TYPE14) |
| 1351 | hdmi_reg_writemask(hdata, HDMI_PHY_CON_0, ~0, |
| 1352 | HDMI_PHY_POWER_OFF_EN); |
| 1353 | } |
| 1354 | |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 1355 | static void hdmiphy_conf_apply(struct hdmi_context *hdata) |
| 1356 | { |
Joonyoung Shim | 3ecd70b | 2012-03-16 18:47:03 +0900 | [diff] [blame] | 1357 | const u8 *hdmiphy_data; |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 1358 | u8 buffer[32]; |
| 1359 | u8 operation[2]; |
| 1360 | u8 read_buffer[32] = {0, }; |
| 1361 | int ret; |
| 1362 | int i; |
| 1363 | |
| 1364 | if (!hdata->hdmiphy_port) { |
| 1365 | DRM_ERROR("hdmiphy is not attached\n"); |
| 1366 | return; |
| 1367 | } |
| 1368 | |
| 1369 | /* pixel clock */ |
Rahul Sharma | 6b986ed | 2013-03-06 17:33:29 +0900 | [diff] [blame] | 1370 | i = hdmi_find_phy_conf(hdata, hdata->mode_conf.pixel_clock); |
| 1371 | if (i < 0) { |
| 1372 | DRM_ERROR("failed to find hdmiphy conf\n"); |
| 1373 | return; |
| 1374 | } |
Sean Paul | 2f7e2ed | 2013-01-15 08:11:08 -0500 | [diff] [blame] | 1375 | |
Sachin Kamat | 5f46c33 | 2013-04-26 11:29:00 +0530 | [diff] [blame] | 1376 | if (hdata->type == HDMI_TYPE13) |
Rahul Sharma | 6b986ed | 2013-03-06 17:33:29 +0900 | [diff] [blame] | 1377 | hdmiphy_data = hdmiphy_v13_configs[i].conf; |
Sachin Kamat | 5f46c33 | 2013-04-26 11:29:00 +0530 | [diff] [blame] | 1378 | else |
Sean Paul | 2f7e2ed | 2013-01-15 08:11:08 -0500 | [diff] [blame] | 1379 | hdmiphy_data = hdmiphy_v14_configs[i].conf; |
Joonyoung Shim | 3ecd70b | 2012-03-16 18:47:03 +0900 | [diff] [blame] | 1380 | |
| 1381 | memcpy(buffer, hdmiphy_data, 32); |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 1382 | ret = i2c_master_send(hdata->hdmiphy_port, buffer, 32); |
| 1383 | if (ret != 32) { |
| 1384 | DRM_ERROR("failed to configure HDMIPHY via I2C\n"); |
| 1385 | return; |
| 1386 | } |
| 1387 | |
Sean Paul | 09760ea | 2013-01-14 17:03:20 -0500 | [diff] [blame] | 1388 | usleep_range(10000, 12000); |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 1389 | |
| 1390 | /* operation mode */ |
| 1391 | operation[0] = 0x1f; |
| 1392 | operation[1] = 0x80; |
| 1393 | |
| 1394 | ret = i2c_master_send(hdata->hdmiphy_port, operation, 2); |
| 1395 | if (ret != 2) { |
| 1396 | DRM_ERROR("failed to enable hdmiphy\n"); |
| 1397 | return; |
| 1398 | } |
| 1399 | |
| 1400 | ret = i2c_master_recv(hdata->hdmiphy_port, read_buffer, 32); |
| 1401 | if (ret < 0) { |
| 1402 | DRM_ERROR("failed to read hdmiphy config\n"); |
| 1403 | return; |
| 1404 | } |
| 1405 | |
| 1406 | for (i = 0; i < ret; i++) |
| 1407 | DRM_DEBUG_KMS("hdmiphy[0x%02x] write[0x%02x] - " |
| 1408 | "recv [0x%02x]\n", i, buffer[i], read_buffer[i]); |
| 1409 | } |
| 1410 | |
| 1411 | static void hdmi_conf_apply(struct hdmi_context *hdata) |
| 1412 | { |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 1413 | DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__); |
| 1414 | |
| 1415 | hdmiphy_conf_reset(hdata); |
| 1416 | hdmiphy_conf_apply(hdata); |
| 1417 | |
Joonyoung Shim | cf8fc4f | 2012-04-23 19:35:50 +0900 | [diff] [blame] | 1418 | mutex_lock(&hdata->hdmi_mutex); |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 1419 | hdmi_conf_reset(hdata); |
| 1420 | hdmi_conf_init(hdata); |
Joonyoung Shim | cf8fc4f | 2012-04-23 19:35:50 +0900 | [diff] [blame] | 1421 | mutex_unlock(&hdata->hdmi_mutex); |
| 1422 | |
Seung-Woo Kim | 3e148ba | 2012-03-16 18:47:16 +0900 | [diff] [blame] | 1423 | hdmi_audio_init(hdata); |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 1424 | |
| 1425 | /* setting core registers */ |
Joonyoung Shim | 3ecd70b | 2012-03-16 18:47:03 +0900 | [diff] [blame] | 1426 | hdmi_timing_apply(hdata); |
Seung-Woo Kim | 3e148ba | 2012-03-16 18:47:16 +0900 | [diff] [blame] | 1427 | hdmi_audio_control(hdata, true); |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 1428 | |
| 1429 | hdmi_regs_dump(hdata, "start"); |
| 1430 | } |
| 1431 | |
Sean Paul | 2f7e2ed | 2013-01-15 08:11:08 -0500 | [diff] [blame] | 1432 | static void hdmi_set_reg(u8 *reg_pair, int num_bytes, u32 value) |
| 1433 | { |
| 1434 | int i; |
| 1435 | BUG_ON(num_bytes > 4); |
| 1436 | for (i = 0; i < num_bytes; i++) |
| 1437 | reg_pair[i] = (value >> (8 * i)) & 0xff; |
| 1438 | } |
| 1439 | |
Rahul Sharma | 6b986ed | 2013-03-06 17:33:29 +0900 | [diff] [blame] | 1440 | static void hdmi_v13_mode_set(struct hdmi_context *hdata, |
| 1441 | struct drm_display_mode *m) |
| 1442 | { |
| 1443 | struct hdmi_v13_core_regs *core = &hdata->mode_conf.conf.v13_conf.core; |
| 1444 | struct hdmi_tg_regs *tg = &hdata->mode_conf.conf.v13_conf.tg; |
| 1445 | unsigned int val; |
| 1446 | |
| 1447 | hdata->mode_conf.cea_video_id = |
| 1448 | drm_match_cea_mode((struct drm_display_mode *)m); |
| 1449 | hdata->mode_conf.pixel_clock = m->clock * 1000; |
| 1450 | |
| 1451 | hdmi_set_reg(core->h_blank, 2, m->htotal - m->hdisplay); |
| 1452 | hdmi_set_reg(core->h_v_line, 3, (m->htotal << 12) | m->vtotal); |
| 1453 | |
| 1454 | val = (m->flags & DRM_MODE_FLAG_NVSYNC) ? 1 : 0; |
| 1455 | hdmi_set_reg(core->vsync_pol, 1, val); |
| 1456 | |
| 1457 | val = (m->flags & DRM_MODE_FLAG_INTERLACE) ? 1 : 0; |
| 1458 | hdmi_set_reg(core->int_pro_mode, 1, val); |
| 1459 | |
| 1460 | val = (m->hsync_start - m->hdisplay - 2); |
| 1461 | val |= ((m->hsync_end - m->hdisplay - 2) << 10); |
| 1462 | val |= ((m->flags & DRM_MODE_FLAG_NHSYNC) ? 1 : 0)<<20; |
| 1463 | hdmi_set_reg(core->h_sync_gen, 3, val); |
| 1464 | |
| 1465 | /* |
| 1466 | * Quirk requirement for exynos HDMI IP design, |
| 1467 | * 2 pixels less than the actual calculation for hsync_start |
| 1468 | * and end. |
| 1469 | */ |
| 1470 | |
| 1471 | /* Following values & calculations differ for different type of modes */ |
| 1472 | if (m->flags & DRM_MODE_FLAG_INTERLACE) { |
| 1473 | /* Interlaced Mode */ |
| 1474 | val = ((m->vsync_end - m->vdisplay) / 2); |
| 1475 | val |= ((m->vsync_start - m->vdisplay) / 2) << 12; |
| 1476 | hdmi_set_reg(core->v_sync_gen1, 3, val); |
| 1477 | |
| 1478 | val = m->vtotal / 2; |
| 1479 | val |= ((m->vtotal - m->vdisplay) / 2) << 11; |
| 1480 | hdmi_set_reg(core->v_blank, 3, val); |
| 1481 | |
| 1482 | val = (m->vtotal + |
| 1483 | ((m->vsync_end - m->vsync_start) * 4) + 5) / 2; |
| 1484 | val |= m->vtotal << 11; |
| 1485 | hdmi_set_reg(core->v_blank_f, 3, val); |
| 1486 | |
| 1487 | val = ((m->vtotal / 2) + 7); |
| 1488 | val |= ((m->vtotal / 2) + 2) << 12; |
| 1489 | hdmi_set_reg(core->v_sync_gen2, 3, val); |
| 1490 | |
| 1491 | val = ((m->htotal / 2) + (m->hsync_start - m->hdisplay)); |
| 1492 | val |= ((m->htotal / 2) + |
| 1493 | (m->hsync_start - m->hdisplay)) << 12; |
| 1494 | hdmi_set_reg(core->v_sync_gen3, 3, val); |
| 1495 | |
| 1496 | hdmi_set_reg(tg->vact_st, 2, (m->vtotal - m->vdisplay) / 2); |
| 1497 | hdmi_set_reg(tg->vact_sz, 2, m->vdisplay / 2); |
| 1498 | |
| 1499 | hdmi_set_reg(tg->vact_st2, 2, 0x249);/* Reset value + 1*/ |
| 1500 | } else { |
| 1501 | /* Progressive Mode */ |
| 1502 | |
| 1503 | val = m->vtotal; |
| 1504 | val |= (m->vtotal - m->vdisplay) << 11; |
| 1505 | hdmi_set_reg(core->v_blank, 3, val); |
| 1506 | |
| 1507 | hdmi_set_reg(core->v_blank_f, 3, 0); |
| 1508 | |
| 1509 | val = (m->vsync_end - m->vdisplay); |
| 1510 | val |= ((m->vsync_start - m->vdisplay) << 12); |
| 1511 | hdmi_set_reg(core->v_sync_gen1, 3, val); |
| 1512 | |
| 1513 | hdmi_set_reg(core->v_sync_gen2, 3, 0x1001);/* Reset value */ |
| 1514 | hdmi_set_reg(core->v_sync_gen3, 3, 0x1001);/* Reset value */ |
| 1515 | hdmi_set_reg(tg->vact_st, 2, m->vtotal - m->vdisplay); |
| 1516 | hdmi_set_reg(tg->vact_sz, 2, m->vdisplay); |
| 1517 | hdmi_set_reg(tg->vact_st2, 2, 0x248); /* Reset value */ |
| 1518 | } |
| 1519 | |
| 1520 | /* Timing generator registers */ |
| 1521 | hdmi_set_reg(tg->cmd, 1, 0x0); |
| 1522 | hdmi_set_reg(tg->h_fsz, 2, m->htotal); |
| 1523 | hdmi_set_reg(tg->hact_st, 2, m->htotal - m->hdisplay); |
| 1524 | hdmi_set_reg(tg->hact_sz, 2, m->hdisplay); |
| 1525 | hdmi_set_reg(tg->v_fsz, 2, m->vtotal); |
| 1526 | hdmi_set_reg(tg->vsync, 2, 0x1); |
| 1527 | hdmi_set_reg(tg->vsync2, 2, 0x233); /* Reset value */ |
| 1528 | hdmi_set_reg(tg->field_chg, 2, 0x233); /* Reset value */ |
| 1529 | hdmi_set_reg(tg->vsync_top_hdmi, 2, 0x1); /* Reset value */ |
| 1530 | hdmi_set_reg(tg->vsync_bot_hdmi, 2, 0x233); /* Reset value */ |
| 1531 | hdmi_set_reg(tg->field_top_hdmi, 2, 0x1); /* Reset value */ |
| 1532 | hdmi_set_reg(tg->field_bot_hdmi, 2, 0x233); /* Reset value */ |
| 1533 | hdmi_set_reg(tg->tg_3d, 1, 0x0); /* Not used */ |
| 1534 | } |
| 1535 | |
Sean Paul | 2f7e2ed | 2013-01-15 08:11:08 -0500 | [diff] [blame] | 1536 | static void hdmi_v14_mode_set(struct hdmi_context *hdata, |
| 1537 | struct drm_display_mode *m) |
| 1538 | { |
Rahul Sharma | 6b986ed | 2013-03-06 17:33:29 +0900 | [diff] [blame] | 1539 | struct hdmi_tg_regs *tg = &hdata->mode_conf.conf.v14_conf.tg; |
| 1540 | struct hdmi_v14_core_regs *core = |
| 1541 | &hdata->mode_conf.conf.v14_conf.core; |
Sean Paul | 2f7e2ed | 2013-01-15 08:11:08 -0500 | [diff] [blame] | 1542 | |
Rahul Sharma | 6b986ed | 2013-03-06 17:33:29 +0900 | [diff] [blame] | 1543 | hdata->mode_conf.cea_video_id = |
| 1544 | drm_match_cea_mode((struct drm_display_mode *)m); |
Sean Paul | 2f7e2ed | 2013-01-15 08:11:08 -0500 | [diff] [blame] | 1545 | hdata->mode_conf.pixel_clock = m->clock * 1000; |
Rahul Sharma | 6b986ed | 2013-03-06 17:33:29 +0900 | [diff] [blame] | 1546 | |
Sean Paul | 2f7e2ed | 2013-01-15 08:11:08 -0500 | [diff] [blame] | 1547 | hdmi_set_reg(core->h_blank, 2, m->htotal - m->hdisplay); |
| 1548 | hdmi_set_reg(core->v_line, 2, m->vtotal); |
| 1549 | hdmi_set_reg(core->h_line, 2, m->htotal); |
| 1550 | hdmi_set_reg(core->hsync_pol, 1, |
| 1551 | (m->flags & DRM_MODE_FLAG_NHSYNC) ? 1 : 0); |
| 1552 | hdmi_set_reg(core->vsync_pol, 1, |
| 1553 | (m->flags & DRM_MODE_FLAG_NVSYNC) ? 1 : 0); |
| 1554 | hdmi_set_reg(core->int_pro_mode, 1, |
| 1555 | (m->flags & DRM_MODE_FLAG_INTERLACE) ? 1 : 0); |
| 1556 | |
| 1557 | /* |
| 1558 | * Quirk requirement for exynos 5 HDMI IP design, |
| 1559 | * 2 pixels less than the actual calculation for hsync_start |
| 1560 | * and end. |
| 1561 | */ |
| 1562 | |
| 1563 | /* Following values & calculations differ for different type of modes */ |
| 1564 | if (m->flags & DRM_MODE_FLAG_INTERLACE) { |
| 1565 | /* Interlaced Mode */ |
| 1566 | hdmi_set_reg(core->v_sync_line_bef_2, 2, |
| 1567 | (m->vsync_end - m->vdisplay) / 2); |
| 1568 | hdmi_set_reg(core->v_sync_line_bef_1, 2, |
| 1569 | (m->vsync_start - m->vdisplay) / 2); |
| 1570 | hdmi_set_reg(core->v2_blank, 2, m->vtotal / 2); |
| 1571 | hdmi_set_reg(core->v1_blank, 2, (m->vtotal - m->vdisplay) / 2); |
| 1572 | hdmi_set_reg(core->v_blank_f0, 2, (m->vtotal + |
| 1573 | ((m->vsync_end - m->vsync_start) * 4) + 5) / 2); |
| 1574 | hdmi_set_reg(core->v_blank_f1, 2, m->vtotal); |
| 1575 | hdmi_set_reg(core->v_sync_line_aft_2, 2, (m->vtotal / 2) + 7); |
| 1576 | hdmi_set_reg(core->v_sync_line_aft_1, 2, (m->vtotal / 2) + 2); |
| 1577 | hdmi_set_reg(core->v_sync_line_aft_pxl_2, 2, |
| 1578 | (m->htotal / 2) + (m->hsync_start - m->hdisplay)); |
| 1579 | hdmi_set_reg(core->v_sync_line_aft_pxl_1, 2, |
| 1580 | (m->htotal / 2) + (m->hsync_start - m->hdisplay)); |
| 1581 | hdmi_set_reg(tg->vact_st, 2, (m->vtotal - m->vdisplay) / 2); |
| 1582 | hdmi_set_reg(tg->vact_sz, 2, m->vdisplay / 2); |
| 1583 | hdmi_set_reg(tg->vact_st2, 2, 0x249);/* Reset value + 1*/ |
| 1584 | hdmi_set_reg(tg->vact_st3, 2, 0x0); |
| 1585 | hdmi_set_reg(tg->vact_st4, 2, 0x0); |
| 1586 | } else { |
| 1587 | /* Progressive Mode */ |
| 1588 | hdmi_set_reg(core->v_sync_line_bef_2, 2, |
| 1589 | m->vsync_end - m->vdisplay); |
| 1590 | hdmi_set_reg(core->v_sync_line_bef_1, 2, |
| 1591 | m->vsync_start - m->vdisplay); |
| 1592 | hdmi_set_reg(core->v2_blank, 2, m->vtotal); |
| 1593 | hdmi_set_reg(core->v1_blank, 2, m->vtotal - m->vdisplay); |
| 1594 | hdmi_set_reg(core->v_blank_f0, 2, 0xffff); |
| 1595 | hdmi_set_reg(core->v_blank_f1, 2, 0xffff); |
| 1596 | hdmi_set_reg(core->v_sync_line_aft_2, 2, 0xffff); |
| 1597 | hdmi_set_reg(core->v_sync_line_aft_1, 2, 0xffff); |
| 1598 | hdmi_set_reg(core->v_sync_line_aft_pxl_2, 2, 0xffff); |
| 1599 | hdmi_set_reg(core->v_sync_line_aft_pxl_1, 2, 0xffff); |
| 1600 | hdmi_set_reg(tg->vact_st, 2, m->vtotal - m->vdisplay); |
| 1601 | hdmi_set_reg(tg->vact_sz, 2, m->vdisplay); |
| 1602 | hdmi_set_reg(tg->vact_st2, 2, 0x248); /* Reset value */ |
| 1603 | hdmi_set_reg(tg->vact_st3, 2, 0x47b); /* Reset value */ |
| 1604 | hdmi_set_reg(tg->vact_st4, 2, 0x6ae); /* Reset value */ |
| 1605 | } |
| 1606 | |
| 1607 | /* Following values & calculations are same irrespective of mode type */ |
| 1608 | hdmi_set_reg(core->h_sync_start, 2, m->hsync_start - m->hdisplay - 2); |
| 1609 | hdmi_set_reg(core->h_sync_end, 2, m->hsync_end - m->hdisplay - 2); |
| 1610 | hdmi_set_reg(core->vact_space_1, 2, 0xffff); |
| 1611 | hdmi_set_reg(core->vact_space_2, 2, 0xffff); |
| 1612 | hdmi_set_reg(core->vact_space_3, 2, 0xffff); |
| 1613 | hdmi_set_reg(core->vact_space_4, 2, 0xffff); |
| 1614 | hdmi_set_reg(core->vact_space_5, 2, 0xffff); |
| 1615 | hdmi_set_reg(core->vact_space_6, 2, 0xffff); |
| 1616 | hdmi_set_reg(core->v_blank_f2, 2, 0xffff); |
| 1617 | hdmi_set_reg(core->v_blank_f3, 2, 0xffff); |
| 1618 | hdmi_set_reg(core->v_blank_f4, 2, 0xffff); |
| 1619 | hdmi_set_reg(core->v_blank_f5, 2, 0xffff); |
| 1620 | hdmi_set_reg(core->v_sync_line_aft_3, 2, 0xffff); |
| 1621 | hdmi_set_reg(core->v_sync_line_aft_4, 2, 0xffff); |
| 1622 | hdmi_set_reg(core->v_sync_line_aft_5, 2, 0xffff); |
| 1623 | hdmi_set_reg(core->v_sync_line_aft_6, 2, 0xffff); |
| 1624 | hdmi_set_reg(core->v_sync_line_aft_pxl_3, 2, 0xffff); |
| 1625 | hdmi_set_reg(core->v_sync_line_aft_pxl_4, 2, 0xffff); |
| 1626 | hdmi_set_reg(core->v_sync_line_aft_pxl_5, 2, 0xffff); |
| 1627 | hdmi_set_reg(core->v_sync_line_aft_pxl_6, 2, 0xffff); |
| 1628 | |
| 1629 | /* Timing generator registers */ |
| 1630 | hdmi_set_reg(tg->cmd, 1, 0x0); |
| 1631 | hdmi_set_reg(tg->h_fsz, 2, m->htotal); |
| 1632 | hdmi_set_reg(tg->hact_st, 2, m->htotal - m->hdisplay); |
| 1633 | hdmi_set_reg(tg->hact_sz, 2, m->hdisplay); |
| 1634 | hdmi_set_reg(tg->v_fsz, 2, m->vtotal); |
| 1635 | hdmi_set_reg(tg->vsync, 2, 0x1); |
| 1636 | hdmi_set_reg(tg->vsync2, 2, 0x233); /* Reset value */ |
| 1637 | hdmi_set_reg(tg->field_chg, 2, 0x233); /* Reset value */ |
| 1638 | hdmi_set_reg(tg->vsync_top_hdmi, 2, 0x1); /* Reset value */ |
| 1639 | hdmi_set_reg(tg->vsync_bot_hdmi, 2, 0x233); /* Reset value */ |
| 1640 | hdmi_set_reg(tg->field_top_hdmi, 2, 0x1); /* Reset value */ |
| 1641 | hdmi_set_reg(tg->field_bot_hdmi, 2, 0x233); /* Reset value */ |
| 1642 | hdmi_set_reg(tg->tg_3d, 1, 0x0); |
Sean Paul | 2f7e2ed | 2013-01-15 08:11:08 -0500 | [diff] [blame] | 1643 | } |
| 1644 | |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 1645 | static void hdmi_mode_set(void *ctx, void *mode) |
| 1646 | { |
Joonyoung Shim | f9309d1 | 2012-04-05 20:49:22 +0900 | [diff] [blame] | 1647 | struct hdmi_context *hdata = ctx; |
Rahul Sharma | 6b986ed | 2013-03-06 17:33:29 +0900 | [diff] [blame] | 1648 | struct drm_display_mode *m = mode; |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 1649 | |
Rahul Sharma | 6b986ed | 2013-03-06 17:33:29 +0900 | [diff] [blame] | 1650 | DRM_DEBUG_KMS("[%s]: xres=%d, yres=%d, refresh=%d, intl=%s\n", |
| 1651 | __func__, m->hdisplay, m->vdisplay, |
| 1652 | m->vrefresh, (m->flags & DRM_MODE_FLAG_INTERLACE) ? |
| 1653 | "INTERLACED" : "PROGERESSIVE"); |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 1654 | |
Sachin Kamat | 5f46c33 | 2013-04-26 11:29:00 +0530 | [diff] [blame] | 1655 | if (hdata->type == HDMI_TYPE13) |
Rahul Sharma | 6b986ed | 2013-03-06 17:33:29 +0900 | [diff] [blame] | 1656 | hdmi_v13_mode_set(hdata, mode); |
Sachin Kamat | 5f46c33 | 2013-04-26 11:29:00 +0530 | [diff] [blame] | 1657 | else |
Sean Paul | 2f7e2ed | 2013-01-15 08:11:08 -0500 | [diff] [blame] | 1658 | hdmi_v14_mode_set(hdata, mode); |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 1659 | } |
| 1660 | |
Inki Dae | 1de425b | 2012-03-16 18:47:04 +0900 | [diff] [blame] | 1661 | static void hdmi_get_max_resol(void *ctx, unsigned int *width, |
| 1662 | unsigned int *height) |
| 1663 | { |
| 1664 | DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__); |
| 1665 | |
| 1666 | *width = MAX_WIDTH; |
| 1667 | *height = MAX_HEIGHT; |
| 1668 | } |
| 1669 | |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 1670 | static void hdmi_commit(void *ctx) |
| 1671 | { |
Joonyoung Shim | f9309d1 | 2012-04-05 20:49:22 +0900 | [diff] [blame] | 1672 | struct hdmi_context *hdata = ctx; |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 1673 | |
| 1674 | DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__); |
| 1675 | |
Shirish S | dda9012 | 2013-01-23 22:03:18 -0500 | [diff] [blame] | 1676 | mutex_lock(&hdata->hdmi_mutex); |
| 1677 | if (!hdata->powered) { |
| 1678 | mutex_unlock(&hdata->hdmi_mutex); |
| 1679 | return; |
| 1680 | } |
| 1681 | mutex_unlock(&hdata->hdmi_mutex); |
| 1682 | |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 1683 | hdmi_conf_apply(hdata); |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 1684 | } |
| 1685 | |
Joonyoung Shim | cf8fc4f | 2012-04-23 19:35:50 +0900 | [diff] [blame] | 1686 | static void hdmi_poweron(struct hdmi_context *hdata) |
| 1687 | { |
| 1688 | struct hdmi_resources *res = &hdata->res; |
| 1689 | |
| 1690 | DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__); |
| 1691 | |
| 1692 | mutex_lock(&hdata->hdmi_mutex); |
| 1693 | if (hdata->powered) { |
| 1694 | mutex_unlock(&hdata->hdmi_mutex); |
| 1695 | return; |
| 1696 | } |
| 1697 | |
| 1698 | hdata->powered = true; |
| 1699 | |
Joonyoung Shim | cf8fc4f | 2012-04-23 19:35:50 +0900 | [diff] [blame] | 1700 | mutex_unlock(&hdata->hdmi_mutex); |
| 1701 | |
Seung-Woo Kim | ad07945 | 2013-06-05 14:34:38 +0900 | [diff] [blame^] | 1702 | if (regulator_bulk_enable(res->regul_count, res->regul_bulk)) |
| 1703 | DRM_DEBUG_KMS("failed to enable regulator bulk\n"); |
| 1704 | |
Joonyoung Shim | cf8fc4f | 2012-04-23 19:35:50 +0900 | [diff] [blame] | 1705 | clk_enable(res->hdmiphy); |
| 1706 | clk_enable(res->hdmi); |
| 1707 | clk_enable(res->sclk_hdmi); |
Rahul Sharma | a556225 | 2012-11-28 11:30:25 +0530 | [diff] [blame] | 1708 | |
| 1709 | hdmiphy_poweron(hdata); |
Joonyoung Shim | cf8fc4f | 2012-04-23 19:35:50 +0900 | [diff] [blame] | 1710 | } |
| 1711 | |
| 1712 | static void hdmi_poweroff(struct hdmi_context *hdata) |
| 1713 | { |
| 1714 | struct hdmi_resources *res = &hdata->res; |
| 1715 | |
| 1716 | DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__); |
| 1717 | |
| 1718 | mutex_lock(&hdata->hdmi_mutex); |
| 1719 | if (!hdata->powered) |
| 1720 | goto out; |
| 1721 | mutex_unlock(&hdata->hdmi_mutex); |
| 1722 | |
| 1723 | /* |
| 1724 | * The TV power domain needs any condition of hdmiphy to turn off and |
| 1725 | * its reset state seems to meet the condition. |
| 1726 | */ |
| 1727 | hdmiphy_conf_reset(hdata); |
Rahul Sharma | a556225 | 2012-11-28 11:30:25 +0530 | [diff] [blame] | 1728 | hdmiphy_poweroff(hdata); |
Joonyoung Shim | cf8fc4f | 2012-04-23 19:35:50 +0900 | [diff] [blame] | 1729 | |
| 1730 | clk_disable(res->sclk_hdmi); |
| 1731 | clk_disable(res->hdmi); |
| 1732 | clk_disable(res->hdmiphy); |
| 1733 | regulator_bulk_disable(res->regul_count, res->regul_bulk); |
| 1734 | |
Joonyoung Shim | cf8fc4f | 2012-04-23 19:35:50 +0900 | [diff] [blame] | 1735 | mutex_lock(&hdata->hdmi_mutex); |
Joonyoung Shim | cf8fc4f | 2012-04-23 19:35:50 +0900 | [diff] [blame] | 1736 | |
| 1737 | hdata->powered = false; |
| 1738 | |
| 1739 | out: |
| 1740 | mutex_unlock(&hdata->hdmi_mutex); |
| 1741 | } |
| 1742 | |
| 1743 | static void hdmi_dpms(void *ctx, int mode) |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 1744 | { |
Joonyoung Shim | f9309d1 | 2012-04-05 20:49:22 +0900 | [diff] [blame] | 1745 | struct hdmi_context *hdata = ctx; |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 1746 | |
Rahul Sharma | 64327cb | 2012-11-28 11:30:23 +0530 | [diff] [blame] | 1747 | DRM_DEBUG_KMS("[%d] %s mode %d\n", __LINE__, __func__, mode); |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 1748 | |
Joonyoung Shim | cf8fc4f | 2012-04-23 19:35:50 +0900 | [diff] [blame] | 1749 | switch (mode) { |
| 1750 | case DRM_MODE_DPMS_ON: |
Rahul Sharma | 64327cb | 2012-11-28 11:30:23 +0530 | [diff] [blame] | 1751 | if (pm_runtime_suspended(hdata->dev)) |
| 1752 | pm_runtime_get_sync(hdata->dev); |
Joonyoung Shim | cf8fc4f | 2012-04-23 19:35:50 +0900 | [diff] [blame] | 1753 | break; |
| 1754 | case DRM_MODE_DPMS_STANDBY: |
| 1755 | case DRM_MODE_DPMS_SUSPEND: |
| 1756 | case DRM_MODE_DPMS_OFF: |
Rahul Sharma | 64327cb | 2012-11-28 11:30:23 +0530 | [diff] [blame] | 1757 | if (!pm_runtime_suspended(hdata->dev)) |
| 1758 | pm_runtime_put_sync(hdata->dev); |
Joonyoung Shim | cf8fc4f | 2012-04-23 19:35:50 +0900 | [diff] [blame] | 1759 | break; |
| 1760 | default: |
| 1761 | DRM_DEBUG_KMS("unknown dpms mode: %d\n", mode); |
| 1762 | break; |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 1763 | } |
| 1764 | } |
| 1765 | |
Joonyoung Shim | 578b606 | 2012-04-05 20:49:26 +0900 | [diff] [blame] | 1766 | static struct exynos_hdmi_ops hdmi_ops = { |
| 1767 | /* display */ |
| 1768 | .is_connected = hdmi_is_connected, |
| 1769 | .get_edid = hdmi_get_edid, |
| 1770 | .check_timing = hdmi_check_timing, |
Joonyoung Shim | 578b606 | 2012-04-05 20:49:26 +0900 | [diff] [blame] | 1771 | |
| 1772 | /* manager */ |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 1773 | .mode_set = hdmi_mode_set, |
Inki Dae | 1de425b | 2012-03-16 18:47:04 +0900 | [diff] [blame] | 1774 | .get_max_resol = hdmi_get_max_resol, |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 1775 | .commit = hdmi_commit, |
Joonyoung Shim | cf8fc4f | 2012-04-23 19:35:50 +0900 | [diff] [blame] | 1776 | .dpms = hdmi_dpms, |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 1777 | }; |
| 1778 | |
Sean Paul | 77006a7 | 2013-01-16 10:17:20 -0500 | [diff] [blame] | 1779 | static irqreturn_t hdmi_irq_thread(int irq, void *arg) |
Joonyoung Shim | cf8fc4f | 2012-04-23 19:35:50 +0900 | [diff] [blame] | 1780 | { |
| 1781 | struct exynos_drm_hdmi_context *ctx = arg; |
| 1782 | struct hdmi_context *hdata = ctx->ctx; |
| 1783 | |
Joonyoung Shim | cf8fc4f | 2012-04-23 19:35:50 +0900 | [diff] [blame] | 1784 | mutex_lock(&hdata->hdmi_mutex); |
Tomasz Stanislawski | fca5712 | 2012-10-04 20:48:46 +0530 | [diff] [blame] | 1785 | hdata->hpd = gpio_get_value(hdata->hpd_gpio); |
Joonyoung Shim | cf8fc4f | 2012-04-23 19:35:50 +0900 | [diff] [blame] | 1786 | mutex_unlock(&hdata->hdmi_mutex); |
| 1787 | |
| 1788 | if (ctx->drm_dev) |
| 1789 | drm_helper_hpd_irq_event(ctx->drm_dev); |
| 1790 | |
Joonyoung Shim | cf8fc4f | 2012-04-23 19:35:50 +0900 | [diff] [blame] | 1791 | return IRQ_HANDLED; |
| 1792 | } |
| 1793 | |
Greg Kroah-Hartman | 56550d9 | 2012-12-21 15:09:25 -0800 | [diff] [blame] | 1794 | static int hdmi_resources_init(struct hdmi_context *hdata) |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 1795 | { |
| 1796 | struct device *dev = hdata->dev; |
| 1797 | struct hdmi_resources *res = &hdata->res; |
| 1798 | static char *supply[] = { |
| 1799 | "hdmi-en", |
| 1800 | "vdd", |
| 1801 | "vdd_osc", |
| 1802 | "vdd_pll", |
| 1803 | }; |
| 1804 | int i, ret; |
| 1805 | |
| 1806 | DRM_DEBUG_KMS("HDMI resource init\n"); |
| 1807 | |
Sachin Kamat | adc837a | 2012-08-31 15:50:47 +0530 | [diff] [blame] | 1808 | memset(res, 0, sizeof(*res)); |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 1809 | |
| 1810 | /* get clocks, power */ |
Sachin Kamat | 9f49d9f | 2012-11-23 14:13:27 +0530 | [diff] [blame] | 1811 | res->hdmi = devm_clk_get(dev, "hdmi"); |
Sachin Kamat | ee7cbaf | 2013-03-21 15:33:57 +0530 | [diff] [blame] | 1812 | if (IS_ERR(res->hdmi)) { |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 1813 | DRM_ERROR("failed to get clock 'hdmi'\n"); |
| 1814 | goto fail; |
| 1815 | } |
Sachin Kamat | 9f49d9f | 2012-11-23 14:13:27 +0530 | [diff] [blame] | 1816 | res->sclk_hdmi = devm_clk_get(dev, "sclk_hdmi"); |
Sachin Kamat | ee7cbaf | 2013-03-21 15:33:57 +0530 | [diff] [blame] | 1817 | if (IS_ERR(res->sclk_hdmi)) { |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 1818 | DRM_ERROR("failed to get clock 'sclk_hdmi'\n"); |
| 1819 | goto fail; |
| 1820 | } |
Sachin Kamat | 9f49d9f | 2012-11-23 14:13:27 +0530 | [diff] [blame] | 1821 | res->sclk_pixel = devm_clk_get(dev, "sclk_pixel"); |
Sachin Kamat | ee7cbaf | 2013-03-21 15:33:57 +0530 | [diff] [blame] | 1822 | if (IS_ERR(res->sclk_pixel)) { |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 1823 | DRM_ERROR("failed to get clock 'sclk_pixel'\n"); |
| 1824 | goto fail; |
| 1825 | } |
Sachin Kamat | 9f49d9f | 2012-11-23 14:13:27 +0530 | [diff] [blame] | 1826 | res->sclk_hdmiphy = devm_clk_get(dev, "sclk_hdmiphy"); |
Sachin Kamat | ee7cbaf | 2013-03-21 15:33:57 +0530 | [diff] [blame] | 1827 | if (IS_ERR(res->sclk_hdmiphy)) { |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 1828 | DRM_ERROR("failed to get clock 'sclk_hdmiphy'\n"); |
| 1829 | goto fail; |
| 1830 | } |
Sachin Kamat | 9f49d9f | 2012-11-23 14:13:27 +0530 | [diff] [blame] | 1831 | res->hdmiphy = devm_clk_get(dev, "hdmiphy"); |
Sachin Kamat | ee7cbaf | 2013-03-21 15:33:57 +0530 | [diff] [blame] | 1832 | if (IS_ERR(res->hdmiphy)) { |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 1833 | DRM_ERROR("failed to get clock 'hdmiphy'\n"); |
| 1834 | goto fail; |
| 1835 | } |
| 1836 | |
| 1837 | clk_set_parent(res->sclk_hdmi, res->sclk_pixel); |
| 1838 | |
Sachin Kamat | 9f49d9f | 2012-11-23 14:13:27 +0530 | [diff] [blame] | 1839 | res->regul_bulk = devm_kzalloc(dev, ARRAY_SIZE(supply) * |
Sachin Kamat | adc837a | 2012-08-31 15:50:47 +0530 | [diff] [blame] | 1840 | sizeof(res->regul_bulk[0]), GFP_KERNEL); |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 1841 | if (!res->regul_bulk) { |
| 1842 | DRM_ERROR("failed to get memory for regulators\n"); |
| 1843 | goto fail; |
| 1844 | } |
| 1845 | for (i = 0; i < ARRAY_SIZE(supply); ++i) { |
| 1846 | res->regul_bulk[i].supply = supply[i]; |
| 1847 | res->regul_bulk[i].consumer = NULL; |
| 1848 | } |
Sachin Kamat | 9f49d9f | 2012-11-23 14:13:27 +0530 | [diff] [blame] | 1849 | ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(supply), res->regul_bulk); |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 1850 | if (ret) { |
| 1851 | DRM_ERROR("failed to get regulators\n"); |
| 1852 | goto fail; |
| 1853 | } |
| 1854 | res->regul_count = ARRAY_SIZE(supply); |
| 1855 | |
| 1856 | return 0; |
| 1857 | fail: |
| 1858 | DRM_ERROR("HDMI resource init - failed\n"); |
| 1859 | return -ENODEV; |
| 1860 | } |
| 1861 | |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 1862 | static struct i2c_client *hdmi_ddc, *hdmi_hdmiphy; |
| 1863 | |
| 1864 | void hdmi_attach_ddc_client(struct i2c_client *ddc) |
| 1865 | { |
| 1866 | if (ddc) |
| 1867 | hdmi_ddc = ddc; |
| 1868 | } |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 1869 | |
| 1870 | void hdmi_attach_hdmiphy_client(struct i2c_client *hdmiphy) |
| 1871 | { |
| 1872 | if (hdmiphy) |
| 1873 | hdmi_hdmiphy = hdmiphy; |
| 1874 | } |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 1875 | |
Rahul Sharma | 22c4f42 | 2012-10-04 20:48:55 +0530 | [diff] [blame] | 1876 | #ifdef CONFIG_OF |
| 1877 | static struct s5p_hdmi_platform_data *drm_hdmi_dt_parse_pdata |
| 1878 | (struct device *dev) |
| 1879 | { |
| 1880 | struct device_node *np = dev->of_node; |
| 1881 | struct s5p_hdmi_platform_data *pd; |
| 1882 | enum of_gpio_flags flags; |
| 1883 | u32 value; |
| 1884 | |
| 1885 | pd = devm_kzalloc(dev, sizeof(*pd), GFP_KERNEL); |
| 1886 | if (!pd) { |
| 1887 | DRM_ERROR("memory allocation for pdata failed\n"); |
| 1888 | goto err_data; |
| 1889 | } |
| 1890 | |
| 1891 | if (!of_find_property(np, "hpd-gpio", &value)) { |
| 1892 | DRM_ERROR("no hpd gpio property found\n"); |
| 1893 | goto err_data; |
| 1894 | } |
| 1895 | |
| 1896 | pd->hpd_gpio = of_get_named_gpio_flags(np, "hpd-gpio", 0, &flags); |
| 1897 | |
| 1898 | return pd; |
| 1899 | |
| 1900 | err_data: |
| 1901 | return NULL; |
| 1902 | } |
| 1903 | #else |
| 1904 | static struct s5p_hdmi_platform_data *drm_hdmi_dt_parse_pdata |
| 1905 | (struct device *dev) |
| 1906 | { |
| 1907 | return NULL; |
| 1908 | } |
| 1909 | #endif |
| 1910 | |
Tomasz Stanislawski | c119ed0 | 2012-10-04 20:48:44 +0530 | [diff] [blame] | 1911 | static struct platform_device_id hdmi_driver_types[] = { |
| 1912 | { |
| 1913 | .name = "s5pv210-hdmi", |
| 1914 | .driver_data = HDMI_TYPE13, |
| 1915 | }, { |
| 1916 | .name = "exynos4-hdmi", |
| 1917 | .driver_data = HDMI_TYPE13, |
| 1918 | }, { |
| 1919 | .name = "exynos4-hdmi14", |
Rahul Sharma | 22c4f42 | 2012-10-04 20:48:55 +0530 | [diff] [blame] | 1920 | .driver_data = HDMI_TYPE14, |
| 1921 | }, { |
| 1922 | .name = "exynos5-hdmi", |
| 1923 | .driver_data = HDMI_TYPE14, |
| 1924 | }, { |
| 1925 | /* end node */ |
| 1926 | } |
| 1927 | }; |
| 1928 | |
Sachin Kamat | 65da035 | 2012-12-12 14:24:07 +0530 | [diff] [blame] | 1929 | #ifdef CONFIG_OF |
Rahul Sharma | 22c4f42 | 2012-10-04 20:48:55 +0530 | [diff] [blame] | 1930 | static struct of_device_id hdmi_match_types[] = { |
| 1931 | { |
| 1932 | .compatible = "samsung,exynos5-hdmi", |
| 1933 | .data = (void *)HDMI_TYPE14, |
Tomasz Stanislawski | c119ed0 | 2012-10-04 20:48:44 +0530 | [diff] [blame] | 1934 | }, { |
| 1935 | /* end node */ |
| 1936 | } |
| 1937 | }; |
Sachin Kamat | 65da035 | 2012-12-12 14:24:07 +0530 | [diff] [blame] | 1938 | #endif |
Tomasz Stanislawski | c119ed0 | 2012-10-04 20:48:44 +0530 | [diff] [blame] | 1939 | |
Greg Kroah-Hartman | 56550d9 | 2012-12-21 15:09:25 -0800 | [diff] [blame] | 1940 | static int hdmi_probe(struct platform_device *pdev) |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 1941 | { |
| 1942 | struct device *dev = &pdev->dev; |
| 1943 | struct exynos_drm_hdmi_context *drm_hdmi_ctx; |
| 1944 | struct hdmi_context *hdata; |
Tomasz Stanislawski | fca5712 | 2012-10-04 20:48:46 +0530 | [diff] [blame] | 1945 | struct s5p_hdmi_platform_data *pdata; |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 1946 | struct resource *res; |
| 1947 | int ret; |
| 1948 | |
| 1949 | DRM_DEBUG_KMS("[%d]\n", __LINE__); |
| 1950 | |
Seung-Woo Kim | d873ab9 | 2013-05-22 21:14:14 +0900 | [diff] [blame] | 1951 | if (dev->of_node) { |
Rahul Sharma | 22c4f42 | 2012-10-04 20:48:55 +0530 | [diff] [blame] | 1952 | pdata = drm_hdmi_dt_parse_pdata(dev); |
| 1953 | if (IS_ERR(pdata)) { |
| 1954 | DRM_ERROR("failed to parse dt\n"); |
| 1955 | return PTR_ERR(pdata); |
| 1956 | } |
| 1957 | } else { |
Seung-Woo Kim | d873ab9 | 2013-05-22 21:14:14 +0900 | [diff] [blame] | 1958 | pdata = dev->platform_data; |
Rahul Sharma | 22c4f42 | 2012-10-04 20:48:55 +0530 | [diff] [blame] | 1959 | } |
| 1960 | |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 1961 | if (!pdata) { |
| 1962 | DRM_ERROR("no platform data specified\n"); |
| 1963 | return -EINVAL; |
| 1964 | } |
| 1965 | |
Seung-Woo Kim | d873ab9 | 2013-05-22 21:14:14 +0900 | [diff] [blame] | 1966 | drm_hdmi_ctx = devm_kzalloc(dev, sizeof(*drm_hdmi_ctx), |
Sachin Kamat | a6e6507 | 2012-06-19 11:47:40 +0530 | [diff] [blame] | 1967 | GFP_KERNEL); |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 1968 | if (!drm_hdmi_ctx) { |
| 1969 | DRM_ERROR("failed to allocate common hdmi context.\n"); |
| 1970 | return -ENOMEM; |
| 1971 | } |
| 1972 | |
Seung-Woo Kim | d873ab9 | 2013-05-22 21:14:14 +0900 | [diff] [blame] | 1973 | hdata = devm_kzalloc(dev, sizeof(struct hdmi_context), |
Sachin Kamat | a6e6507 | 2012-06-19 11:47:40 +0530 | [diff] [blame] | 1974 | GFP_KERNEL); |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 1975 | if (!hdata) { |
| 1976 | DRM_ERROR("out of memory\n"); |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 1977 | return -ENOMEM; |
| 1978 | } |
| 1979 | |
Joonyoung Shim | cf8fc4f | 2012-04-23 19:35:50 +0900 | [diff] [blame] | 1980 | mutex_init(&hdata->hdmi_mutex); |
| 1981 | |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 1982 | drm_hdmi_ctx->ctx = (void *)hdata; |
| 1983 | hdata->parent_ctx = (void *)drm_hdmi_ctx; |
| 1984 | |
| 1985 | platform_set_drvdata(pdev, drm_hdmi_ctx); |
| 1986 | |
Rahul Sharma | 22c4f42 | 2012-10-04 20:48:55 +0530 | [diff] [blame] | 1987 | if (dev->of_node) { |
| 1988 | const struct of_device_id *match; |
| 1989 | match = of_match_node(of_match_ptr(hdmi_match_types), |
Seung-Woo Kim | d873ab9 | 2013-05-22 21:14:14 +0900 | [diff] [blame] | 1990 | dev->of_node); |
Sachin Kamat | 1a4513b | 2012-12-12 14:24:08 +0530 | [diff] [blame] | 1991 | if (match == NULL) |
| 1992 | return -ENODEV; |
Rahul Sharma | 22c4f42 | 2012-10-04 20:48:55 +0530 | [diff] [blame] | 1993 | hdata->type = (enum hdmi_type)match->data; |
| 1994 | } else { |
| 1995 | hdata->type = (enum hdmi_type)platform_get_device_id |
Rahul Sharma | 5a32507 | 2012-10-04 20:48:54 +0530 | [diff] [blame] | 1996 | (pdev)->driver_data; |
Rahul Sharma | 22c4f42 | 2012-10-04 20:48:55 +0530 | [diff] [blame] | 1997 | } |
| 1998 | |
Tomasz Stanislawski | fca5712 | 2012-10-04 20:48:46 +0530 | [diff] [blame] | 1999 | hdata->hpd_gpio = pdata->hpd_gpio; |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 2000 | hdata->dev = dev; |
| 2001 | |
| 2002 | ret = hdmi_resources_init(hdata); |
Rahul Sharma | 22c4f42 | 2012-10-04 20:48:55 +0530 | [diff] [blame] | 2003 | |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 2004 | if (ret) { |
Rahul Sharma | 22c4f42 | 2012-10-04 20:48:55 +0530 | [diff] [blame] | 2005 | DRM_ERROR("hdmi_resources_init failed\n"); |
Sachin Kamat | 9f49d9f | 2012-11-23 14:13:27 +0530 | [diff] [blame] | 2006 | return -EINVAL; |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 2007 | } |
| 2008 | |
| 2009 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
Seung-Woo Kim | d873ab9 | 2013-05-22 21:14:14 +0900 | [diff] [blame] | 2010 | hdata->regs = devm_ioremap_resource(dev, res); |
Thierry Reding | d4ed602 | 2013-01-21 11:09:02 +0100 | [diff] [blame] | 2011 | if (IS_ERR(hdata->regs)) |
| 2012 | return PTR_ERR(hdata->regs); |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 2013 | |
Seung-Woo Kim | d873ab9 | 2013-05-22 21:14:14 +0900 | [diff] [blame] | 2014 | ret = devm_gpio_request(dev, hdata->hpd_gpio, "HPD"); |
Tomasz Stanislawski | fca5712 | 2012-10-04 20:48:46 +0530 | [diff] [blame] | 2015 | if (ret) { |
| 2016 | DRM_ERROR("failed to request HPD gpio\n"); |
Sachin Kamat | 9f49d9f | 2012-11-23 14:13:27 +0530 | [diff] [blame] | 2017 | return ret; |
Tomasz Stanislawski | fca5712 | 2012-10-04 20:48:46 +0530 | [diff] [blame] | 2018 | } |
| 2019 | |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 2020 | /* DDC i2c driver */ |
| 2021 | if (i2c_add_driver(&ddc_driver)) { |
| 2022 | DRM_ERROR("failed to register ddc i2c driver\n"); |
Sachin Kamat | 9f49d9f | 2012-11-23 14:13:27 +0530 | [diff] [blame] | 2023 | return -ENOENT; |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 2024 | } |
| 2025 | |
| 2026 | hdata->ddc_port = hdmi_ddc; |
| 2027 | |
| 2028 | /* hdmiphy i2c driver */ |
| 2029 | if (i2c_add_driver(&hdmiphy_driver)) { |
| 2030 | DRM_ERROR("failed to register hdmiphy i2c driver\n"); |
| 2031 | ret = -ENOENT; |
| 2032 | goto err_ddc; |
| 2033 | } |
| 2034 | |
| 2035 | hdata->hdmiphy_port = hdmi_hdmiphy; |
| 2036 | |
Sean Paul | 77006a7 | 2013-01-16 10:17:20 -0500 | [diff] [blame] | 2037 | hdata->irq = gpio_to_irq(hdata->hpd_gpio); |
| 2038 | if (hdata->irq < 0) { |
| 2039 | DRM_ERROR("failed to get GPIO irq\n"); |
| 2040 | ret = hdata->irq; |
Joonyoung Shim | 66265a2 | 2012-04-23 19:35:49 +0900 | [diff] [blame] | 2041 | goto err_hdmiphy; |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 2042 | } |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 2043 | |
Tomasz Stanislawski | fca5712 | 2012-10-04 20:48:46 +0530 | [diff] [blame] | 2044 | hdata->hpd = gpio_get_value(hdata->hpd_gpio); |
| 2045 | |
Seung-Woo Kim | dcb9a7c | 2013-05-22 21:14:17 +0900 | [diff] [blame] | 2046 | ret = devm_request_threaded_irq(dev, hdata->irq, NULL, |
Sean Paul | 77006a7 | 2013-01-16 10:17:20 -0500 | [diff] [blame] | 2047 | hdmi_irq_thread, IRQF_TRIGGER_RISING | |
Joonyoung Shim | cf8fc4f | 2012-04-23 19:35:50 +0900 | [diff] [blame] | 2048 | IRQF_TRIGGER_FALLING | IRQF_ONESHOT, |
Sean Paul | 77006a7 | 2013-01-16 10:17:20 -0500 | [diff] [blame] | 2049 | "hdmi", drm_hdmi_ctx); |
Joonyoung Shim | cf8fc4f | 2012-04-23 19:35:50 +0900 | [diff] [blame] | 2050 | if (ret) { |
Sean Paul | 77006a7 | 2013-01-16 10:17:20 -0500 | [diff] [blame] | 2051 | DRM_ERROR("failed to register hdmi interrupt\n"); |
Joonyoung Shim | cf8fc4f | 2012-04-23 19:35:50 +0900 | [diff] [blame] | 2052 | goto err_hdmiphy; |
| 2053 | } |
| 2054 | |
Rahul Sharma | 768c305 | 2012-10-04 20:48:56 +0530 | [diff] [blame] | 2055 | /* Attach HDMI Driver to common hdmi. */ |
| 2056 | exynos_hdmi_drv_attach(drm_hdmi_ctx); |
| 2057 | |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 2058 | /* register specific callbacks to common hdmi. */ |
Joonyoung Shim | 578b606 | 2012-04-05 20:49:26 +0900 | [diff] [blame] | 2059 | exynos_hdmi_ops_register(&hdmi_ops); |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 2060 | |
Joonyoung Shim | cf8fc4f | 2012-04-23 19:35:50 +0900 | [diff] [blame] | 2061 | pm_runtime_enable(dev); |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 2062 | |
| 2063 | return 0; |
| 2064 | |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 2065 | err_hdmiphy: |
| 2066 | i2c_del_driver(&hdmiphy_driver); |
| 2067 | err_ddc: |
| 2068 | i2c_del_driver(&ddc_driver); |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 2069 | return ret; |
| 2070 | } |
| 2071 | |
Greg Kroah-Hartman | 56550d9 | 2012-12-21 15:09:25 -0800 | [diff] [blame] | 2072 | static int hdmi_remove(struct platform_device *pdev) |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 2073 | { |
Joonyoung Shim | cf8fc4f | 2012-04-23 19:35:50 +0900 | [diff] [blame] | 2074 | struct device *dev = &pdev->dev; |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 2075 | |
| 2076 | DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__); |
| 2077 | |
Joonyoung Shim | cf8fc4f | 2012-04-23 19:35:50 +0900 | [diff] [blame] | 2078 | pm_runtime_disable(dev); |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 2079 | |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 2080 | /* hdmiphy i2c driver */ |
| 2081 | i2c_del_driver(&hdmiphy_driver); |
| 2082 | /* DDC i2c driver */ |
| 2083 | i2c_del_driver(&ddc_driver); |
| 2084 | |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 2085 | return 0; |
| 2086 | } |
| 2087 | |
Joonyoung Shim | ab27af8 | 2012-04-23 19:35:51 +0900 | [diff] [blame] | 2088 | #ifdef CONFIG_PM_SLEEP |
| 2089 | static int hdmi_suspend(struct device *dev) |
| 2090 | { |
| 2091 | struct exynos_drm_hdmi_context *ctx = get_hdmi_context(dev); |
| 2092 | struct hdmi_context *hdata = ctx->ctx; |
| 2093 | |
Rahul Sharma | 64327cb | 2012-11-28 11:30:23 +0530 | [diff] [blame] | 2094 | DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__); |
| 2095 | |
Sean Paul | 77006a7 | 2013-01-16 10:17:20 -0500 | [diff] [blame] | 2096 | disable_irq(hdata->irq); |
Joonyoung Shim | ab27af8 | 2012-04-23 19:35:51 +0900 | [diff] [blame] | 2097 | |
| 2098 | hdata->hpd = false; |
| 2099 | if (ctx->drm_dev) |
| 2100 | drm_helper_hpd_irq_event(ctx->drm_dev); |
| 2101 | |
Rahul Sharma | 64327cb | 2012-11-28 11:30:23 +0530 | [diff] [blame] | 2102 | if (pm_runtime_suspended(dev)) { |
| 2103 | DRM_DEBUG_KMS("%s : Already suspended\n", __func__); |
| 2104 | return 0; |
| 2105 | } |
| 2106 | |
Joonyoung Shim | ab27af8 | 2012-04-23 19:35:51 +0900 | [diff] [blame] | 2107 | hdmi_poweroff(hdata); |
| 2108 | |
| 2109 | return 0; |
| 2110 | } |
| 2111 | |
| 2112 | static int hdmi_resume(struct device *dev) |
| 2113 | { |
| 2114 | struct exynos_drm_hdmi_context *ctx = get_hdmi_context(dev); |
| 2115 | struct hdmi_context *hdata = ctx->ctx; |
| 2116 | |
Rahul Sharma | 64327cb | 2012-11-28 11:30:23 +0530 | [diff] [blame] | 2117 | DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__); |
| 2118 | |
| 2119 | hdata->hpd = gpio_get_value(hdata->hpd_gpio); |
| 2120 | |
Sean Paul | 77006a7 | 2013-01-16 10:17:20 -0500 | [diff] [blame] | 2121 | enable_irq(hdata->irq); |
Rahul Sharma | 64327cb | 2012-11-28 11:30:23 +0530 | [diff] [blame] | 2122 | |
| 2123 | if (!pm_runtime_suspended(dev)) { |
| 2124 | DRM_DEBUG_KMS("%s : Already resumed\n", __func__); |
| 2125 | return 0; |
| 2126 | } |
| 2127 | |
| 2128 | hdmi_poweron(hdata); |
| 2129 | |
Joonyoung Shim | ab27af8 | 2012-04-23 19:35:51 +0900 | [diff] [blame] | 2130 | return 0; |
| 2131 | } |
| 2132 | #endif |
| 2133 | |
Rahul Sharma | 64327cb | 2012-11-28 11:30:23 +0530 | [diff] [blame] | 2134 | #ifdef CONFIG_PM_RUNTIME |
| 2135 | static int hdmi_runtime_suspend(struct device *dev) |
| 2136 | { |
| 2137 | struct exynos_drm_hdmi_context *ctx = get_hdmi_context(dev); |
| 2138 | struct hdmi_context *hdata = ctx->ctx; |
| 2139 | DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__); |
| 2140 | |
| 2141 | hdmi_poweroff(hdata); |
| 2142 | |
| 2143 | return 0; |
| 2144 | } |
| 2145 | |
| 2146 | static int hdmi_runtime_resume(struct device *dev) |
| 2147 | { |
| 2148 | struct exynos_drm_hdmi_context *ctx = get_hdmi_context(dev); |
| 2149 | struct hdmi_context *hdata = ctx->ctx; |
| 2150 | DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__); |
| 2151 | |
| 2152 | hdmi_poweron(hdata); |
| 2153 | |
| 2154 | return 0; |
| 2155 | } |
| 2156 | #endif |
| 2157 | |
| 2158 | static const struct dev_pm_ops hdmi_pm_ops = { |
| 2159 | SET_SYSTEM_SLEEP_PM_OPS(hdmi_suspend, hdmi_resume) |
| 2160 | SET_RUNTIME_PM_OPS(hdmi_runtime_suspend, hdmi_runtime_resume, NULL) |
| 2161 | }; |
Joonyoung Shim | ab27af8 | 2012-04-23 19:35:51 +0900 | [diff] [blame] | 2162 | |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 2163 | struct platform_driver hdmi_driver = { |
| 2164 | .probe = hdmi_probe, |
Greg Kroah-Hartman | 56550d9 | 2012-12-21 15:09:25 -0800 | [diff] [blame] | 2165 | .remove = hdmi_remove, |
Tomasz Stanislawski | c119ed0 | 2012-10-04 20:48:44 +0530 | [diff] [blame] | 2166 | .id_table = hdmi_driver_types, |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 2167 | .driver = { |
Rahul Sharma | 22c4f42 | 2012-10-04 20:48:55 +0530 | [diff] [blame] | 2168 | .name = "exynos-hdmi", |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 2169 | .owner = THIS_MODULE, |
Joonyoung Shim | ab27af8 | 2012-04-23 19:35:51 +0900 | [diff] [blame] | 2170 | .pm = &hdmi_pm_ops, |
Sachin Kamat | 65da035 | 2012-12-12 14:24:07 +0530 | [diff] [blame] | 2171 | .of_match_table = of_match_ptr(hdmi_match_types), |
Seung-Woo Kim | d840832 | 2011-12-21 17:39:39 +0900 | [diff] [blame] | 2172 | }, |
| 2173 | }; |