diff options
Diffstat (limited to 'drivers/video/sh_mobile_hdmi.c')
-rw-r--r-- | drivers/video/sh_mobile_hdmi.c | 219 |
1 files changed, 210 insertions, 9 deletions
diff --git a/drivers/video/sh_mobile_hdmi.c b/drivers/video/sh_mobile_hdmi.c index eafb19da2c07..930e550e752a 100644 --- a/drivers/video/sh_mobile_hdmi.c +++ b/drivers/video/sh_mobile_hdmi.c | |||
@@ -31,6 +31,7 @@ | |||
31 | 31 | ||
32 | #include "sh_mobile_lcdcfb.h" | 32 | #include "sh_mobile_lcdcfb.h" |
33 | 33 | ||
34 | /* HDMI Core Control Register (HTOP0) */ | ||
34 | #define HDMI_SYSTEM_CTRL 0x00 /* System control */ | 35 | #define HDMI_SYSTEM_CTRL 0x00 /* System control */ |
35 | #define HDMI_L_R_DATA_SWAP_CTRL_RPKT 0x01 /* L/R data swap control, | 36 | #define HDMI_L_R_DATA_SWAP_CTRL_RPKT 0x01 /* L/R data swap control, |
36 | bits 19..16 of 20-bit N for Audio Clock Regeneration packet */ | 37 | bits 19..16 of 20-bit N for Audio Clock Regeneration packet */ |
@@ -201,6 +202,68 @@ | |||
201 | #define HDMI_REVISION_ID 0xF1 /* Revision ID */ | 202 | #define HDMI_REVISION_ID 0xF1 /* Revision ID */ |
202 | #define HDMI_TEST_MODE 0xFE /* Test mode */ | 203 | #define HDMI_TEST_MODE 0xFE /* Test mode */ |
203 | 204 | ||
205 | /* HDMI Control Register (HTOP1) */ | ||
206 | #define HDMI_HTOP1_TEST_MODE 0x0000 /* Test mode */ | ||
207 | #define HDMI_HTOP1_VIDEO_INPUT 0x0008 /* VideoInput */ | ||
208 | #define HDMI_HTOP1_CORE_RSTN 0x000C /* CoreResetn */ | ||
209 | #define HDMI_HTOP1_PLLBW 0x0018 /* PLLBW */ | ||
210 | #define HDMI_HTOP1_CLK_TO_PHY 0x001C /* Clk to Phy */ | ||
211 | #define HDMI_HTOP1_VIDEO_INPUT2 0x0020 /* VideoInput2 */ | ||
212 | #define HDMI_HTOP1_TISEMP0_1 0x0024 /* tisemp0-1 */ | ||
213 | #define HDMI_HTOP1_TISEMP2_C 0x0028 /* tisemp2-c */ | ||
214 | #define HDMI_HTOP1_TISIDRV 0x002C /* tisidrv */ | ||
215 | #define HDMI_HTOP1_TISEN 0x0034 /* tisen */ | ||
216 | #define HDMI_HTOP1_TISDREN 0x0038 /* tisdren */ | ||
217 | #define HDMI_HTOP1_CISRANGE 0x003C /* cisrange */ | ||
218 | #define HDMI_HTOP1_ENABLE_SELECTOR 0x0040 /* Enable Selector */ | ||
219 | #define HDMI_HTOP1_MACRO_RESET 0x0044 /* Macro reset */ | ||
220 | #define HDMI_HTOP1_PLL_CALIBRATION 0x0048 /* PLL calibration */ | ||
221 | #define HDMI_HTOP1_RE_CALIBRATION 0x004C /* Re-calibration */ | ||
222 | #define HDMI_HTOP1_CURRENT 0x0050 /* Current */ | ||
223 | #define HDMI_HTOP1_PLL_LOCK_DETECT 0x0054 /* PLL lock detect */ | ||
224 | #define HDMI_HTOP1_PHY_TEST_MODE 0x0058 /* PHY Test Mode */ | ||
225 | #define HDMI_HTOP1_CLK_SET 0x0080 /* Clock Set */ | ||
226 | #define HDMI_HTOP1_DDC_FAIL_SAFE 0x0084 /* DDC fail safe */ | ||
227 | #define HDMI_HTOP1_PRBS 0x0088 /* PRBS */ | ||
228 | #define HDMI_HTOP1_EDID_AINC_CONTROL 0x008C /* EDID ainc Control */ | ||
229 | #define HDMI_HTOP1_HTOP_DCL_MODE 0x00FC /* Deep Coloer Mode */ | ||
230 | #define HDMI_HTOP1_HTOP_DCL_FRC_COEF0 0x0100 /* Deep Color:FRC COEF0 */ | ||
231 | #define HDMI_HTOP1_HTOP_DCL_FRC_COEF1 0x0104 /* Deep Color:FRC COEF1 */ | ||
232 | #define HDMI_HTOP1_HTOP_DCL_FRC_COEF2 0x0108 /* Deep Color:FRC COEF2 */ | ||
233 | #define HDMI_HTOP1_HTOP_DCL_FRC_COEF3 0x010C /* Deep Color:FRC COEF3 */ | ||
234 | #define HDMI_HTOP1_HTOP_DCL_FRC_COEF0_C 0x0110 /* Deep Color:FRC COEF0C */ | ||
235 | #define HDMI_HTOP1_HTOP_DCL_FRC_COEF1_C 0x0114 /* Deep Color:FRC COEF1C */ | ||
236 | #define HDMI_HTOP1_HTOP_DCL_FRC_COEF2_C 0x0118 /* Deep Color:FRC COEF2C */ | ||
237 | #define HDMI_HTOP1_HTOP_DCL_FRC_COEF3_C 0x011C /* Deep Color:FRC COEF3C */ | ||
238 | #define HDMI_HTOP1_HTOP_DCL_FRC_MODE 0x0120 /* Deep Color:FRC Mode */ | ||
239 | #define HDMI_HTOP1_HTOP_DCL_RECT_START1 0x0124 /* Deep Color:Rect Start1 */ | ||
240 | #define HDMI_HTOP1_HTOP_DCL_RECT_SIZE1 0x0128 /* Deep Color:Rect Size1 */ | ||
241 | #define HDMI_HTOP1_HTOP_DCL_RECT_START2 0x012C /* Deep Color:Rect Start2 */ | ||
242 | #define HDMI_HTOP1_HTOP_DCL_RECT_SIZE2 0x0130 /* Deep Color:Rect Size2 */ | ||
243 | #define HDMI_HTOP1_HTOP_DCL_RECT_START3 0x0134 /* Deep Color:Rect Start3 */ | ||
244 | #define HDMI_HTOP1_HTOP_DCL_RECT_SIZE3 0x0138 /* Deep Color:Rect Size3 */ | ||
245 | #define HDMI_HTOP1_HTOP_DCL_RECT_START4 0x013C /* Deep Color:Rect Start4 */ | ||
246 | #define HDMI_HTOP1_HTOP_DCL_RECT_SIZE4 0x0140 /* Deep Color:Rect Size4 */ | ||
247 | #define HDMI_HTOP1_HTOP_DCL_FIL_PARA_Y1_1 0x0144 /* Deep Color:Fil Para Y1_1 */ | ||
248 | #define HDMI_HTOP1_HTOP_DCL_FIL_PARA_Y1_2 0x0148 /* Deep Color:Fil Para Y1_2 */ | ||
249 | #define HDMI_HTOP1_HTOP_DCL_FIL_PARA_CB1_1 0x014C /* Deep Color:Fil Para CB1_1 */ | ||
250 | #define HDMI_HTOP1_HTOP_DCL_FIL_PARA_CB1_2 0x0150 /* Deep Color:Fil Para CB1_2 */ | ||
251 | #define HDMI_HTOP1_HTOP_DCL_FIL_PARA_CR1_1 0x0154 /* Deep Color:Fil Para CR1_1 */ | ||
252 | #define HDMI_HTOP1_HTOP_DCL_FIL_PARA_CR1_2 0x0158 /* Deep Color:Fil Para CR1_2 */ | ||
253 | #define HDMI_HTOP1_HTOP_DCL_FIL_PARA_Y2_1 0x015C /* Deep Color:Fil Para Y2_1 */ | ||
254 | #define HDMI_HTOP1_HTOP_DCL_FIL_PARA_Y2_2 0x0160 /* Deep Color:Fil Para Y2_2 */ | ||
255 | #define HDMI_HTOP1_HTOP_DCL_FIL_PARA_CB2_1 0x0164 /* Deep Color:Fil Para CB2_1 */ | ||
256 | #define HDMI_HTOP1_HTOP_DCL_FIL_PARA_CB2_2 0x0168 /* Deep Color:Fil Para CB2_2 */ | ||
257 | #define HDMI_HTOP1_HTOP_DCL_FIL_PARA_CR2_1 0x016C /* Deep Color:Fil Para CR2_1 */ | ||
258 | #define HDMI_HTOP1_HTOP_DCL_FIL_PARA_CR2_2 0x0170 /* Deep Color:Fil Para CR2_2 */ | ||
259 | #define HDMI_HTOP1_HTOP_DCL_COR_PARA_Y1 0x0174 /* Deep Color:Cor Para Y1 */ | ||
260 | #define HDMI_HTOP1_HTOP_DCL_COR_PARA_CB1 0x0178 /* Deep Color:Cor Para CB1 */ | ||
261 | #define HDMI_HTOP1_HTOP_DCL_COR_PARA_CR1 0x017C /* Deep Color:Cor Para CR1 */ | ||
262 | #define HDMI_HTOP1_HTOP_DCL_COR_PARA_Y2 0x0180 /* Deep Color:Cor Para Y2 */ | ||
263 | #define HDMI_HTOP1_HTOP_DCL_COR_PARA_CB2 0x0184 /* Deep Color:Cor Para CB2 */ | ||
264 | #define HDMI_HTOP1_HTOP_DCL_COR_PARA_CR2 0x0188 /* Deep Color:Cor Para CR2 */ | ||
265 | #define HDMI_HTOP1_EDID_DATA_READ 0x0200 /* EDID Data Read 128Byte:0x03FC */ | ||
266 | |||
204 | enum hotplug_state { | 267 | enum hotplug_state { |
205 | HDMI_HOTPLUG_DISCONNECTED, | 268 | HDMI_HOTPLUG_DISCONNECTED, |
206 | HDMI_HOTPLUG_CONNECTED, | 269 | HDMI_HOTPLUG_CONNECTED, |
@@ -211,6 +274,7 @@ struct sh_hdmi { | |||
211 | struct sh_mobile_lcdc_entity entity; | 274 | struct sh_mobile_lcdc_entity entity; |
212 | 275 | ||
213 | void __iomem *base; | 276 | void __iomem *base; |
277 | void __iomem *htop1; | ||
214 | enum hotplug_state hp_state; /* hot-plug status */ | 278 | enum hotplug_state hp_state; /* hot-plug status */ |
215 | u8 preprogrammed_vic; /* use a pre-programmed VIC or | 279 | u8 preprogrammed_vic; /* use a pre-programmed VIC or |
216 | the external mode */ | 280 | the external mode */ |
@@ -222,20 +286,66 @@ struct sh_hdmi { | |||
222 | struct delayed_work edid_work; | 286 | struct delayed_work edid_work; |
223 | struct fb_videomode mode; | 287 | struct fb_videomode mode; |
224 | struct fb_monspecs monspec; | 288 | struct fb_monspecs monspec; |
289 | |||
290 | /* register access functions */ | ||
291 | void (*write)(struct sh_hdmi *hdmi, u8 data, u8 reg); | ||
292 | u8 (*read)(struct sh_hdmi *hdmi, u8 reg); | ||
225 | }; | 293 | }; |
226 | 294 | ||
227 | #define entity_to_sh_hdmi(e) container_of(e, struct sh_hdmi, entity) | 295 | #define entity_to_sh_hdmi(e) container_of(e, struct sh_hdmi, entity) |
228 | 296 | ||
229 | static void hdmi_write(struct sh_hdmi *hdmi, u8 data, u8 reg) | 297 | static void __hdmi_write8(struct sh_hdmi *hdmi, u8 data, u8 reg) |
230 | { | 298 | { |
231 | iowrite8(data, hdmi->base + reg); | 299 | iowrite8(data, hdmi->base + reg); |
232 | } | 300 | } |
233 | 301 | ||
234 | static u8 hdmi_read(struct sh_hdmi *hdmi, u8 reg) | 302 | static u8 __hdmi_read8(struct sh_hdmi *hdmi, u8 reg) |
235 | { | 303 | { |
236 | return ioread8(hdmi->base + reg); | 304 | return ioread8(hdmi->base + reg); |
237 | } | 305 | } |
238 | 306 | ||
307 | static void __hdmi_write32(struct sh_hdmi *hdmi, u8 data, u8 reg) | ||
308 | { | ||
309 | iowrite32((u32)data, hdmi->base + (reg * 4)); | ||
310 | udelay(100); | ||
311 | } | ||
312 | |||
313 | static u8 __hdmi_read32(struct sh_hdmi *hdmi, u8 reg) | ||
314 | { | ||
315 | return (u8)ioread32(hdmi->base + (reg * 4)); | ||
316 | } | ||
317 | |||
318 | static void hdmi_write(struct sh_hdmi *hdmi, u8 data, u8 reg) | ||
319 | { | ||
320 | hdmi->write(hdmi, data, reg); | ||
321 | } | ||
322 | |||
323 | static u8 hdmi_read(struct sh_hdmi *hdmi, u8 reg) | ||
324 | { | ||
325 | return hdmi->read(hdmi, reg); | ||
326 | } | ||
327 | |||
328 | static void hdmi_bit_set(struct sh_hdmi *hdmi, u8 mask, u8 data, u8 reg) | ||
329 | { | ||
330 | u8 val = hdmi_read(hdmi, reg); | ||
331 | |||
332 | val &= ~mask; | ||
333 | val |= (data & mask); | ||
334 | |||
335 | hdmi_write(hdmi, val, reg); | ||
336 | } | ||
337 | |||
338 | static void hdmi_htop1_write(struct sh_hdmi *hdmi, u32 data, u32 reg) | ||
339 | { | ||
340 | iowrite32(data, hdmi->htop1 + reg); | ||
341 | udelay(100); | ||
342 | } | ||
343 | |||
344 | static u32 hdmi_htop1_read(struct sh_hdmi *hdmi, u32 reg) | ||
345 | { | ||
346 | return ioread32(hdmi->htop1 + reg); | ||
347 | } | ||
348 | |||
239 | /* | 349 | /* |
240 | * HDMI sound | 350 | * HDMI sound |
241 | */ | 351 | */ |
@@ -693,11 +803,11 @@ static void sh_hdmi_configure(struct sh_hdmi *hdmi) | |||
693 | msleep(10); | 803 | msleep(10); |
694 | 804 | ||
695 | /* PS mode b->d, reset PLLA and PLLB */ | 805 | /* PS mode b->d, reset PLLA and PLLB */ |
696 | hdmi_write(hdmi, 0x4C, HDMI_SYSTEM_CTRL); | 806 | hdmi_bit_set(hdmi, 0xFC, 0x4C, HDMI_SYSTEM_CTRL); |
697 | 807 | ||
698 | udelay(10); | 808 | udelay(10); |
699 | 809 | ||
700 | hdmi_write(hdmi, 0x40, HDMI_SYSTEM_CTRL); | 810 | hdmi_bit_set(hdmi, 0xFC, 0x40, HDMI_SYSTEM_CTRL); |
701 | } | 811 | } |
702 | 812 | ||
703 | static unsigned long sh_hdmi_rate_error(struct sh_hdmi *hdmi, | 813 | static unsigned long sh_hdmi_rate_error(struct sh_hdmi *hdmi, |
@@ -746,7 +856,9 @@ static int sh_hdmi_read_edid(struct sh_hdmi *hdmi, unsigned long *hdmi_rate, | |||
746 | /* Read EDID */ | 856 | /* Read EDID */ |
747 | dev_dbg(hdmi->dev, "Read back EDID code:"); | 857 | dev_dbg(hdmi->dev, "Read back EDID code:"); |
748 | for (i = 0; i < 128; i++) { | 858 | for (i = 0; i < 128; i++) { |
749 | edid[i] = hdmi_read(hdmi, HDMI_EDID_KSV_FIFO_ACCESS_WINDOW); | 859 | edid[i] = (hdmi->htop1) ? |
860 | (u8)hdmi_htop1_read(hdmi, HDMI_HTOP1_EDID_DATA_READ + (i * 4)) : | ||
861 | hdmi_read(hdmi, HDMI_EDID_KSV_FIFO_ACCESS_WINDOW); | ||
750 | #ifdef DEBUG | 862 | #ifdef DEBUG |
751 | if ((i % 16) == 0) { | 863 | if ((i % 16) == 0) { |
752 | printk(KERN_CONT "\n"); | 864 | printk(KERN_CONT "\n"); |
@@ -917,13 +1029,13 @@ static irqreturn_t sh_hdmi_hotplug(int irq, void *dev_id) | |||
917 | u8 status1, status2, mask1, mask2; | 1029 | u8 status1, status2, mask1, mask2; |
918 | 1030 | ||
919 | /* mode_b and PLLA and PLLB reset */ | 1031 | /* mode_b and PLLA and PLLB reset */ |
920 | hdmi_write(hdmi, 0x2C, HDMI_SYSTEM_CTRL); | 1032 | hdmi_bit_set(hdmi, 0xFC, 0x2C, HDMI_SYSTEM_CTRL); |
921 | 1033 | ||
922 | /* How long shall reset be held? */ | 1034 | /* How long shall reset be held? */ |
923 | udelay(10); | 1035 | udelay(10); |
924 | 1036 | ||
925 | /* mode_b and PLLA and PLLB reset release */ | 1037 | /* mode_b and PLLA and PLLB reset release */ |
926 | hdmi_write(hdmi, 0x20, HDMI_SYSTEM_CTRL); | 1038 | hdmi_bit_set(hdmi, 0xFC, 0x20, HDMI_SYSTEM_CTRL); |
927 | 1039 | ||
928 | status1 = hdmi_read(hdmi, HDMI_INTERRUPT_STATUS_1); | 1040 | status1 = hdmi_read(hdmi, HDMI_INTERRUPT_STATUS_1); |
929 | status2 = hdmi_read(hdmi, HDMI_INTERRUPT_STATUS_2); | 1041 | status2 = hdmi_read(hdmi, HDMI_INTERRUPT_STATUS_2); |
@@ -1001,7 +1113,7 @@ static int sh_hdmi_display_on(struct sh_mobile_lcdc_entity *entity) | |||
1001 | */ | 1113 | */ |
1002 | if (hdmi->hp_state == HDMI_HOTPLUG_EDID_DONE) { | 1114 | if (hdmi->hp_state == HDMI_HOTPLUG_EDID_DONE) { |
1003 | /* PS mode d->e. All functions are active */ | 1115 | /* PS mode d->e. All functions are active */ |
1004 | hdmi_write(hdmi, 0x80, HDMI_SYSTEM_CTRL); | 1116 | hdmi_bit_set(hdmi, 0xFC, 0x80, HDMI_SYSTEM_CTRL); |
1005 | dev_dbg(hdmi->dev, "HDMI running\n"); | 1117 | dev_dbg(hdmi->dev, "HDMI running\n"); |
1006 | } | 1118 | } |
1007 | 1119 | ||
@@ -1016,7 +1128,7 @@ static void sh_hdmi_display_off(struct sh_mobile_lcdc_entity *entity) | |||
1016 | 1128 | ||
1017 | dev_dbg(hdmi->dev, "%s(%p)\n", __func__, hdmi); | 1129 | dev_dbg(hdmi->dev, "%s(%p)\n", __func__, hdmi); |
1018 | /* PS mode e->a */ | 1130 | /* PS mode e->a */ |
1019 | hdmi_write(hdmi, 0x10, HDMI_SYSTEM_CTRL); | 1131 | hdmi_bit_set(hdmi, 0xFC, 0x10, HDMI_SYSTEM_CTRL); |
1020 | } | 1132 | } |
1021 | 1133 | ||
1022 | static const struct sh_mobile_lcdc_entity_ops sh_hdmi_ops = { | 1134 | static const struct sh_mobile_lcdc_entity_ops sh_hdmi_ops = { |
@@ -1110,10 +1222,58 @@ out: | |||
1110 | dev_dbg(hdmi->dev, "%s(%p): end\n", __func__, hdmi); | 1222 | dev_dbg(hdmi->dev, "%s(%p): end\n", __func__, hdmi); |
1111 | } | 1223 | } |
1112 | 1224 | ||
1225 | static void sh_hdmi_htop1_init(struct sh_hdmi *hdmi) | ||
1226 | { | ||
1227 | hdmi_htop1_write(hdmi, 0x00000000, HDMI_HTOP1_HTOP_DCL_MODE); | ||
1228 | hdmi_htop1_write(hdmi, 0x0000000b, 0x0010); | ||
1229 | hdmi_htop1_write(hdmi, 0x00006710, HDMI_HTOP1_HTOP_DCL_FRC_MODE); | ||
1230 | hdmi_htop1_write(hdmi, 0x01020406, HDMI_HTOP1_HTOP_DCL_FIL_PARA_Y1_1); | ||
1231 | hdmi_htop1_write(hdmi, 0x07080806, HDMI_HTOP1_HTOP_DCL_FIL_PARA_Y1_2); | ||
1232 | hdmi_htop1_write(hdmi, 0x01020406, HDMI_HTOP1_HTOP_DCL_FIL_PARA_CB1_1); | ||
1233 | hdmi_htop1_write(hdmi, 0x07080806, HDMI_HTOP1_HTOP_DCL_FIL_PARA_CB1_2); | ||
1234 | hdmi_htop1_write(hdmi, 0x01020406, HDMI_HTOP1_HTOP_DCL_FIL_PARA_CR1_1); | ||
1235 | hdmi_htop1_write(hdmi, 0x07080806, HDMI_HTOP1_HTOP_DCL_FIL_PARA_CR1_2); | ||
1236 | hdmi_htop1_write(hdmi, 0x01020406, HDMI_HTOP1_HTOP_DCL_FIL_PARA_Y2_1); | ||
1237 | hdmi_htop1_write(hdmi, 0x07080806, HDMI_HTOP1_HTOP_DCL_FIL_PARA_Y2_2); | ||
1238 | hdmi_htop1_write(hdmi, 0x01020406, HDMI_HTOP1_HTOP_DCL_FIL_PARA_CB2_1); | ||
1239 | hdmi_htop1_write(hdmi, 0x07080806, HDMI_HTOP1_HTOP_DCL_FIL_PARA_CB2_2); | ||
1240 | hdmi_htop1_write(hdmi, 0x01020406, HDMI_HTOP1_HTOP_DCL_FIL_PARA_CR2_1); | ||
1241 | hdmi_htop1_write(hdmi, 0x07080806, HDMI_HTOP1_HTOP_DCL_FIL_PARA_CR2_2); | ||
1242 | hdmi_htop1_write(hdmi, 0x00000000, HDMI_HTOP1_HTOP_DCL_COR_PARA_Y1); | ||
1243 | hdmi_htop1_write(hdmi, 0x00000000, HDMI_HTOP1_HTOP_DCL_COR_PARA_CB1); | ||
1244 | hdmi_htop1_write(hdmi, 0x00000000, HDMI_HTOP1_HTOP_DCL_COR_PARA_CR1); | ||
1245 | hdmi_htop1_write(hdmi, 0x00000000, HDMI_HTOP1_HTOP_DCL_COR_PARA_Y2); | ||
1246 | hdmi_htop1_write(hdmi, 0x00000000, HDMI_HTOP1_HTOP_DCL_COR_PARA_CB2); | ||
1247 | hdmi_htop1_write(hdmi, 0x00000000, HDMI_HTOP1_HTOP_DCL_COR_PARA_CR2); | ||
1248 | hdmi_htop1_write(hdmi, 0x00000008, HDMI_HTOP1_CURRENT); | ||
1249 | hdmi_htop1_write(hdmi, 0x00000000, HDMI_HTOP1_TISEMP0_1); | ||
1250 | hdmi_htop1_write(hdmi, 0x00000000, HDMI_HTOP1_TISEMP2_C); | ||
1251 | hdmi_htop1_write(hdmi, 0x00000000, HDMI_HTOP1_PHY_TEST_MODE); | ||
1252 | hdmi_htop1_write(hdmi, 0x00000081, HDMI_HTOP1_TISIDRV); | ||
1253 | hdmi_htop1_write(hdmi, 0x00000000, HDMI_HTOP1_PLLBW); | ||
1254 | hdmi_htop1_write(hdmi, 0x0000000f, HDMI_HTOP1_TISEN); | ||
1255 | hdmi_htop1_write(hdmi, 0x0000000f, HDMI_HTOP1_TISDREN); | ||
1256 | hdmi_htop1_write(hdmi, 0x00000003, HDMI_HTOP1_ENABLE_SELECTOR); | ||
1257 | hdmi_htop1_write(hdmi, 0x00000001, HDMI_HTOP1_MACRO_RESET); | ||
1258 | hdmi_htop1_write(hdmi, 0x00000016, HDMI_HTOP1_CISRANGE); | ||
1259 | msleep(100); | ||
1260 | hdmi_htop1_write(hdmi, 0x00000001, HDMI_HTOP1_ENABLE_SELECTOR); | ||
1261 | msleep(100); | ||
1262 | hdmi_htop1_write(hdmi, 0x00000003, HDMI_HTOP1_ENABLE_SELECTOR); | ||
1263 | hdmi_htop1_write(hdmi, 0x00000001, HDMI_HTOP1_MACRO_RESET); | ||
1264 | hdmi_htop1_write(hdmi, 0x0000000f, HDMI_HTOP1_TISEN); | ||
1265 | hdmi_htop1_write(hdmi, 0x0000000f, HDMI_HTOP1_TISDREN); | ||
1266 | hdmi_htop1_write(hdmi, 0x00000000, HDMI_HTOP1_VIDEO_INPUT); | ||
1267 | hdmi_htop1_write(hdmi, 0x00000000, HDMI_HTOP1_CLK_TO_PHY); | ||
1268 | hdmi_htop1_write(hdmi, 0x00000000, HDMI_HTOP1_VIDEO_INPUT2); | ||
1269 | hdmi_htop1_write(hdmi, 0x0000000a, HDMI_HTOP1_CLK_SET); | ||
1270 | } | ||
1271 | |||
1113 | static int __init sh_hdmi_probe(struct platform_device *pdev) | 1272 | static int __init sh_hdmi_probe(struct platform_device *pdev) |
1114 | { | 1273 | { |
1115 | struct sh_mobile_hdmi_info *pdata = pdev->dev.platform_data; | 1274 | struct sh_mobile_hdmi_info *pdata = pdev->dev.platform_data; |
1116 | struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 1275 | struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
1276 | struct resource *htop1_res; | ||
1117 | int irq = platform_get_irq(pdev, 0), ret; | 1277 | int irq = platform_get_irq(pdev, 0), ret; |
1118 | struct sh_hdmi *hdmi; | 1278 | struct sh_hdmi *hdmi; |
1119 | long rate; | 1279 | long rate; |
@@ -1121,6 +1281,15 @@ static int __init sh_hdmi_probe(struct platform_device *pdev) | |||
1121 | if (!res || !pdata || irq < 0) | 1281 | if (!res || !pdata || irq < 0) |
1122 | return -ENODEV; | 1282 | return -ENODEV; |
1123 | 1283 | ||
1284 | htop1_res = NULL; | ||
1285 | if (pdata->flags & HDMI_HAS_HTOP1) { | ||
1286 | htop1_res = platform_get_resource(pdev, IORESOURCE_MEM, 1); | ||
1287 | if (!htop1_res) { | ||
1288 | dev_err(&pdev->dev, "htop1 needs register base\n"); | ||
1289 | return -EINVAL; | ||
1290 | } | ||
1291 | } | ||
1292 | |||
1124 | hdmi = kzalloc(sizeof(*hdmi), GFP_KERNEL); | 1293 | hdmi = kzalloc(sizeof(*hdmi), GFP_KERNEL); |
1125 | if (!hdmi) { | 1294 | if (!hdmi) { |
1126 | dev_err(&pdev->dev, "Cannot allocate device data\n"); | 1295 | dev_err(&pdev->dev, "Cannot allocate device data\n"); |
@@ -1138,6 +1307,15 @@ static int __init sh_hdmi_probe(struct platform_device *pdev) | |||
1138 | goto egetclk; | 1307 | goto egetclk; |
1139 | } | 1308 | } |
1140 | 1309 | ||
1310 | /* select register access functions */ | ||
1311 | if (pdata->flags & HDMI_32BIT_REG) { | ||
1312 | hdmi->write = __hdmi_write32; | ||
1313 | hdmi->read = __hdmi_read32; | ||
1314 | } else { | ||
1315 | hdmi->write = __hdmi_write8; | ||
1316 | hdmi->read = __hdmi_read8; | ||
1317 | } | ||
1318 | |||
1141 | /* An arbitrary relaxed pixclock just to get things started: from standard 480p */ | 1319 | /* An arbitrary relaxed pixclock just to get things started: from standard 480p */ |
1142 | rate = clk_round_rate(hdmi->hdmi_clk, PICOS2KHZ(37037)); | 1320 | rate = clk_round_rate(hdmi->hdmi_clk, PICOS2KHZ(37037)); |
1143 | if (rate > 0) | 1321 | if (rate > 0) |
@@ -1176,6 +1354,24 @@ static int __init sh_hdmi_probe(struct platform_device *pdev) | |||
1176 | pm_runtime_enable(&pdev->dev); | 1354 | pm_runtime_enable(&pdev->dev); |
1177 | pm_runtime_get_sync(&pdev->dev); | 1355 | pm_runtime_get_sync(&pdev->dev); |
1178 | 1356 | ||
1357 | /* init interrupt polarity */ | ||
1358 | if (pdata->flags & HDMI_OUTPUT_PUSH_PULL) | ||
1359 | hdmi_bit_set(hdmi, 0x02, 0x02, HDMI_SYSTEM_CTRL); | ||
1360 | |||
1361 | if (pdata->flags & HDMI_OUTPUT_POLARITY_HI) | ||
1362 | hdmi_bit_set(hdmi, 0x01, 0x01, HDMI_SYSTEM_CTRL); | ||
1363 | |||
1364 | /* enable htop1 register if needed */ | ||
1365 | if (htop1_res) { | ||
1366 | hdmi->htop1 = ioremap(htop1_res->start, resource_size(htop1_res)); | ||
1367 | if (!hdmi->htop1) { | ||
1368 | dev_err(&pdev->dev, "control register region already claimed\n"); | ||
1369 | ret = -ENOMEM; | ||
1370 | goto emap_htop1; | ||
1371 | } | ||
1372 | sh_hdmi_htop1_init(hdmi); | ||
1373 | } | ||
1374 | |||
1179 | /* Product and revision IDs are 0 in sh-mobile version */ | 1375 | /* Product and revision IDs are 0 in sh-mobile version */ |
1180 | dev_info(&pdev->dev, "Detected HDMI controller 0x%x:0x%x\n", | 1376 | dev_info(&pdev->dev, "Detected HDMI controller 0x%x:0x%x\n", |
1181 | hdmi_read(hdmi, HDMI_PRODUCT_ID), hdmi_read(hdmi, HDMI_REVISION_ID)); | 1377 | hdmi_read(hdmi, HDMI_PRODUCT_ID), hdmi_read(hdmi, HDMI_REVISION_ID)); |
@@ -1199,6 +1395,9 @@ static int __init sh_hdmi_probe(struct platform_device *pdev) | |||
1199 | ecodec: | 1395 | ecodec: |
1200 | free_irq(irq, hdmi); | 1396 | free_irq(irq, hdmi); |
1201 | ereqirq: | 1397 | ereqirq: |
1398 | if (hdmi->htop1) | ||
1399 | iounmap(hdmi->htop1); | ||
1400 | emap_htop1: | ||
1202 | pm_runtime_put(&pdev->dev); | 1401 | pm_runtime_put(&pdev->dev); |
1203 | pm_runtime_disable(&pdev->dev); | 1402 | pm_runtime_disable(&pdev->dev); |
1204 | iounmap(hdmi->base); | 1403 | iounmap(hdmi->base); |
@@ -1230,6 +1429,8 @@ static int __exit sh_hdmi_remove(struct platform_device *pdev) | |||
1230 | pm_runtime_disable(&pdev->dev); | 1429 | pm_runtime_disable(&pdev->dev); |
1231 | clk_disable(hdmi->hdmi_clk); | 1430 | clk_disable(hdmi->hdmi_clk); |
1232 | clk_put(hdmi->hdmi_clk); | 1431 | clk_put(hdmi->hdmi_clk); |
1432 | if (hdmi->htop1) | ||
1433 | iounmap(hdmi->htop1); | ||
1233 | iounmap(hdmi->base); | 1434 | iounmap(hdmi->base); |
1234 | release_mem_region(res->start, resource_size(res)); | 1435 | release_mem_region(res->start, resource_size(res)); |
1235 | kfree(hdmi); | 1436 | kfree(hdmi); |