• Home
  • Raw
  • Download

Lines Matching refs:hdmi

291 	void (*write)(struct sh_hdmi *hdmi, u8 data, u8 reg);
292 u8 (*read)(struct sh_hdmi *hdmi, u8 reg);
297 static void __hdmi_write8(struct sh_hdmi *hdmi, u8 data, u8 reg) in __hdmi_write8() argument
299 iowrite8(data, hdmi->base + reg); in __hdmi_write8()
302 static u8 __hdmi_read8(struct sh_hdmi *hdmi, u8 reg) in __hdmi_read8() argument
304 return ioread8(hdmi->base + reg); in __hdmi_read8()
307 static void __hdmi_write32(struct sh_hdmi *hdmi, u8 data, u8 reg) in __hdmi_write32() argument
309 iowrite32((u32)data, hdmi->base + (reg * 4)); in __hdmi_write32()
313 static u8 __hdmi_read32(struct sh_hdmi *hdmi, u8 reg) in __hdmi_read32() argument
315 return (u8)ioread32(hdmi->base + (reg * 4)); in __hdmi_read32()
318 static void hdmi_write(struct sh_hdmi *hdmi, u8 data, u8 reg) in hdmi_write() argument
320 hdmi->write(hdmi, data, reg); in hdmi_write()
323 static u8 hdmi_read(struct sh_hdmi *hdmi, u8 reg) in hdmi_read() argument
325 return hdmi->read(hdmi, reg); in hdmi_read()
328 static void hdmi_bit_set(struct sh_hdmi *hdmi, u8 mask, u8 data, u8 reg) in hdmi_bit_set() argument
330 u8 val = hdmi_read(hdmi, reg); in hdmi_bit_set()
335 hdmi_write(hdmi, val, reg); in hdmi_bit_set()
338 static void hdmi_htop1_write(struct sh_hdmi *hdmi, u32 data, u32 reg) in hdmi_htop1_write() argument
340 iowrite32(data, hdmi->htop1 + reg); in hdmi_htop1_write()
344 static u32 hdmi_htop1_read(struct sh_hdmi *hdmi, u32 reg) in hdmi_htop1_read() argument
346 return ioread32(hdmi->htop1 + reg); in hdmi_htop1_read()
355 struct sh_hdmi *hdmi = snd_soc_codec_get_drvdata(codec); in sh_hdmi_snd_read() local
357 return hdmi_read(hdmi, reg); in sh_hdmi_snd_read()
364 struct sh_hdmi *hdmi = snd_soc_codec_get_drvdata(codec); in sh_hdmi_snd_write() local
366 hdmi_write(hdmi, value, reg); in sh_hdmi_snd_write()
402 static void sh_hdmi_external_video_param(struct sh_hdmi *hdmi) in sh_hdmi_external_video_param() argument
404 struct fb_videomode *mode = &hdmi->mode; in sh_hdmi_external_video_param()
434 dev_dbg(hdmi->dev, "H: %u, %u, %u, %u; V: %u, %u, %u, %u; sync 0x%x\n", in sh_hdmi_external_video_param()
438 hdmi_write(hdmi, sync | (voffset << 4), HDMI_EXTERNAL_VIDEO_PARAM_SETTINGS); in sh_hdmi_external_video_param()
440 hdmi_write(hdmi, htotal, HDMI_EXTERNAL_H_TOTAL_7_0); in sh_hdmi_external_video_param()
441 hdmi_write(hdmi, htotal >> 8, HDMI_EXTERNAL_H_TOTAL_11_8); in sh_hdmi_external_video_param()
443 hdmi_write(hdmi, hblank, HDMI_EXTERNAL_H_BLANK_7_0); in sh_hdmi_external_video_param()
444 hdmi_write(hdmi, hblank >> 8, HDMI_EXTERNAL_H_BLANK_9_8); in sh_hdmi_external_video_param()
446 hdmi_write(hdmi, hdelay, HDMI_EXTERNAL_H_DELAY_7_0); in sh_hdmi_external_video_param()
447 hdmi_write(hdmi, hdelay >> 8, HDMI_EXTERNAL_H_DELAY_9_8); in sh_hdmi_external_video_param()
449 hdmi_write(hdmi, mode->hsync_len, HDMI_EXTERNAL_H_DURATION_7_0); in sh_hdmi_external_video_param()
450 hdmi_write(hdmi, mode->hsync_len >> 8, HDMI_EXTERNAL_H_DURATION_9_8); in sh_hdmi_external_video_param()
452 hdmi_write(hdmi, vtotal, HDMI_EXTERNAL_V_TOTAL_7_0); in sh_hdmi_external_video_param()
453 hdmi_write(hdmi, vtotal >> 8, HDMI_EXTERNAL_V_TOTAL_9_8); in sh_hdmi_external_video_param()
455 hdmi_write(hdmi, vblank, HDMI_EXTERNAL_V_BLANK); in sh_hdmi_external_video_param()
457 hdmi_write(hdmi, vdelay, HDMI_EXTERNAL_V_DELAY); in sh_hdmi_external_video_param()
459 hdmi_write(hdmi, mode->vsync_len, HDMI_EXTERNAL_V_DURATION); in sh_hdmi_external_video_param()
462 if (!hdmi->preprogrammed_vic) in sh_hdmi_external_video_param()
463 hdmi_write(hdmi, sync | 1 | (voffset << 4), in sh_hdmi_external_video_param()
470 static void sh_hdmi_video_config(struct sh_hdmi *hdmi) in sh_hdmi_video_config() argument
477 hdmi_write(hdmi, 0x20, HDMI_AUDIO_VIDEO_SETTING_1); in sh_hdmi_video_config()
485 hdmi_write(hdmi, 0x34, HDMI_VIDEO_SETTING_1); in sh_hdmi_video_config()
492 hdmi_write(hdmi, 0x20, HDMI_DEEP_COLOR_MODES); in sh_hdmi_video_config()
498 static void sh_hdmi_audio_config(struct sh_hdmi *hdmi) in sh_hdmi_audio_config() argument
501 struct sh_mobile_hdmi_info *pdata = hdmi->dev->platform_data; in sh_hdmi_audio_config()
507 hdmi_write(hdmi, 0x00, HDMI_L_R_DATA_SWAP_CTRL_RPKT); in sh_hdmi_audio_config()
509 hdmi_write(hdmi, 0x18, HDMI_20_BIT_N_FOR_AUDIO_RPKT_15_8); in sh_hdmi_audio_config()
511 hdmi_write(hdmi, 0x00, HDMI_20_BIT_N_FOR_AUDIO_RPKT_7_0); in sh_hdmi_audio_config()
514 hdmi_write(hdmi, 0x20, HDMI_SPDIF_AUDIO_SAMP_FREQ_CTS); in sh_hdmi_audio_config()
536 hdmi_write(hdmi, data, HDMI_AUDIO_SETTING_1); in sh_hdmi_audio_config()
539 hdmi_write(hdmi, 0x40, HDMI_AUDIO_SETTING_2); in sh_hdmi_audio_config()
545 hdmi_write(hdmi, 0x04, HDMI_I2S_AUDIO_SET); in sh_hdmi_audio_config()
548 hdmi_write(hdmi, 0x00, HDMI_DSD_AUDIO_SET); in sh_hdmi_audio_config()
551 hdmi_write(hdmi, 0x00, HDMI_I2S_INPUT_PIN_SWAP); in sh_hdmi_audio_config()
557 hdmi_write(hdmi, 0x00, HDMI_AUDIO_STATUS_BITS_SETTING_1); in sh_hdmi_audio_config()
566 hdmi_write(hdmi, 0x00, HDMI_AUDIO_STATUS_BITS_SETTING_2); in sh_hdmi_audio_config()
569 hdmi_write(hdmi, 0x00, HDMI_CATEGORY_CODE); in sh_hdmi_audio_config()
575 hdmi_write(hdmi, 0x00, HDMI_SOURCE_NUM_AUDIO_WORD_LEN); in sh_hdmi_audio_config()
578 hdmi_write(hdmi, 0x20, HDMI_AUDIO_VIDEO_SETTING_1); in sh_hdmi_audio_config()
584 static void sh_hdmi_phy_config(struct sh_hdmi *hdmi) in sh_hdmi_phy_config() argument
586 if (hdmi->mode.pixclock < 10000) { in sh_hdmi_phy_config()
588 hdmi_write(hdmi, 0x1d, HDMI_SLIPHDMIT_PARAM_SETTINGS_1); in sh_hdmi_phy_config()
589 hdmi_write(hdmi, 0x00, HDMI_SLIPHDMIT_PARAM_SETTINGS_2); in sh_hdmi_phy_config()
590 hdmi_write(hdmi, 0x00, HDMI_SLIPHDMIT_PARAM_SETTINGS_3); in sh_hdmi_phy_config()
591 hdmi_write(hdmi, 0x4c, HDMI_SLIPHDMIT_PARAM_SETTINGS_5); in sh_hdmi_phy_config()
592 hdmi_write(hdmi, 0x1e, HDMI_SLIPHDMIT_PARAM_SETTINGS_6); in sh_hdmi_phy_config()
593 hdmi_write(hdmi, 0x48, HDMI_SLIPHDMIT_PARAM_SETTINGS_7); in sh_hdmi_phy_config()
594 hdmi_write(hdmi, 0x0e, HDMI_SLIPHDMIT_PARAM_SETTINGS_8); in sh_hdmi_phy_config()
595 hdmi_write(hdmi, 0x25, HDMI_SLIPHDMIT_PARAM_SETTINGS_9); in sh_hdmi_phy_config()
596 hdmi_write(hdmi, 0x04, HDMI_SLIPHDMIT_PARAM_SETTINGS_10); in sh_hdmi_phy_config()
597 } else if (hdmi->mode.pixclock < 30000) { in sh_hdmi_phy_config()
606 hdmi_write(hdmi, 0x0f, HDMI_SLIPHDMIT_PARAM_SETTINGS_1); in sh_hdmi_phy_config()
608 hdmi_write(hdmi, 0x00, HDMI_SLIPHDMIT_PARAM_SETTINGS_2); in sh_hdmi_phy_config()
613 hdmi_write(hdmi, 0x00, HDMI_SLIPHDMIT_PARAM_SETTINGS_3); in sh_hdmi_phy_config()
615 hdmi_write(hdmi, 0x44, HDMI_SLIPHDMIT_PARAM_SETTINGS_5); in sh_hdmi_phy_config()
620 hdmi_write(hdmi, 0x32, HDMI_SLIPHDMIT_PARAM_SETTINGS_6); in sh_hdmi_phy_config()
622 hdmi_write(hdmi, 0x4A, HDMI_SLIPHDMIT_PARAM_SETTINGS_7); in sh_hdmi_phy_config()
627 hdmi_write(hdmi, 0x00, HDMI_SLIPHDMIT_PARAM_SETTINGS_8); in sh_hdmi_phy_config()
629 hdmi_write(hdmi, 0x25, HDMI_SLIPHDMIT_PARAM_SETTINGS_9); in sh_hdmi_phy_config()
635 hdmi_write(hdmi, 0x04, HDMI_SLIPHDMIT_PARAM_SETTINGS_10); in sh_hdmi_phy_config()
638 hdmi_write(hdmi, 0x19, HDMI_SLIPHDMIT_PARAM_SETTINGS_1); in sh_hdmi_phy_config()
639 hdmi_write(hdmi, 0x00, HDMI_SLIPHDMIT_PARAM_SETTINGS_2); in sh_hdmi_phy_config()
640 hdmi_write(hdmi, 0x00, HDMI_SLIPHDMIT_PARAM_SETTINGS_3); in sh_hdmi_phy_config()
641 hdmi_write(hdmi, 0x44, HDMI_SLIPHDMIT_PARAM_SETTINGS_5); in sh_hdmi_phy_config()
642 hdmi_write(hdmi, 0x32, HDMI_SLIPHDMIT_PARAM_SETTINGS_6); in sh_hdmi_phy_config()
643 hdmi_write(hdmi, 0x48, HDMI_SLIPHDMIT_PARAM_SETTINGS_7); in sh_hdmi_phy_config()
644 hdmi_write(hdmi, 0x0F, HDMI_SLIPHDMIT_PARAM_SETTINGS_8); in sh_hdmi_phy_config()
645 hdmi_write(hdmi, 0x20, HDMI_SLIPHDMIT_PARAM_SETTINGS_9); in sh_hdmi_phy_config()
646 hdmi_write(hdmi, 0x04, HDMI_SLIPHDMIT_PARAM_SETTINGS_10); in sh_hdmi_phy_config()
653 static void sh_hdmi_avi_infoframe_setup(struct sh_hdmi *hdmi) in sh_hdmi_avi_infoframe_setup() argument
658 hdmi_write(hdmi, 0x06, HDMI_CTRL_PKT_BUF_INDEX); in sh_hdmi_avi_infoframe_setup()
661 hdmi_write(hdmi, 0x82, HDMI_CTRL_PKT_BUF_ACCESS_HB0); in sh_hdmi_avi_infoframe_setup()
664 hdmi_write(hdmi, 0x02, HDMI_CTRL_PKT_BUF_ACCESS_HB1); in sh_hdmi_avi_infoframe_setup()
667 hdmi_write(hdmi, 0x0D, HDMI_CTRL_PKT_BUF_ACCESS_HB2); in sh_hdmi_avi_infoframe_setup()
670 hdmi_write(hdmi, 0x00, HDMI_CTRL_PKT_BUF_ACCESS_PB0); in sh_hdmi_avi_infoframe_setup()
678 hdmi_write(hdmi, 0x00, HDMI_CTRL_PKT_BUF_ACCESS_PB1); in sh_hdmi_avi_infoframe_setup()
685 hdmi_write(hdmi, 0x28, HDMI_CTRL_PKT_BUF_ACCESS_PB2); in sh_hdmi_avi_infoframe_setup()
693 hdmi_write(hdmi, 0x00, HDMI_CTRL_PKT_BUF_ACCESS_PB3); in sh_hdmi_avi_infoframe_setup()
699 if (hdmi->preprogrammed_vic) in sh_hdmi_avi_infoframe_setup()
700 vic = hdmi->preprogrammed_vic; in sh_hdmi_avi_infoframe_setup()
703 hdmi_write(hdmi, vic, HDMI_CTRL_PKT_BUF_ACCESS_PB4); in sh_hdmi_avi_infoframe_setup()
706 hdmi_write(hdmi, 0x00, HDMI_CTRL_PKT_BUF_ACCESS_PB5); in sh_hdmi_avi_infoframe_setup()
709 hdmi_write(hdmi, 0x00, HDMI_CTRL_PKT_BUF_ACCESS_PB6); in sh_hdmi_avi_infoframe_setup()
712 hdmi_write(hdmi, 0x00, HDMI_CTRL_PKT_BUF_ACCESS_PB7); in sh_hdmi_avi_infoframe_setup()
715 hdmi_write(hdmi, 0x00, HDMI_CTRL_PKT_BUF_ACCESS_PB8); in sh_hdmi_avi_infoframe_setup()
718 hdmi_write(hdmi, 0x00, HDMI_CTRL_PKT_BUF_ACCESS_PB9); in sh_hdmi_avi_infoframe_setup()
721 hdmi_write(hdmi, 0x00, HDMI_CTRL_PKT_BUF_ACCESS_PB10); in sh_hdmi_avi_infoframe_setup()
724 hdmi_write(hdmi, 0x00, HDMI_CTRL_PKT_BUF_ACCESS_PB11); in sh_hdmi_avi_infoframe_setup()
727 hdmi_write(hdmi, 0x00, HDMI_CTRL_PKT_BUF_ACCESS_PB12); in sh_hdmi_avi_infoframe_setup()
730 hdmi_write(hdmi, 0x00, HDMI_CTRL_PKT_BUF_ACCESS_PB13); in sh_hdmi_avi_infoframe_setup()
736 static void sh_hdmi_audio_infoframe_setup(struct sh_hdmi *hdmi) in sh_hdmi_audio_infoframe_setup() argument
739 hdmi_write(hdmi, 0x08, HDMI_CTRL_PKT_BUF_INDEX); in sh_hdmi_audio_infoframe_setup()
742 hdmi_write(hdmi, 0x84, HDMI_CTRL_PKT_BUF_ACCESS_HB0); in sh_hdmi_audio_infoframe_setup()
745 hdmi_write(hdmi, 0x01, HDMI_CTRL_PKT_BUF_ACCESS_HB1); in sh_hdmi_audio_infoframe_setup()
748 hdmi_write(hdmi, 0x0A, HDMI_CTRL_PKT_BUF_ACCESS_HB2); in sh_hdmi_audio_infoframe_setup()
751 hdmi_write(hdmi, 0x00, HDMI_CTRL_PKT_BUF_ACCESS_PB0); in sh_hdmi_audio_infoframe_setup()
754 hdmi_write(hdmi, 0x00, HDMI_CTRL_PKT_BUF_ACCESS_PB1); in sh_hdmi_audio_infoframe_setup()
757 hdmi_write(hdmi, 0x00, HDMI_CTRL_PKT_BUF_ACCESS_PB2); in sh_hdmi_audio_infoframe_setup()
760 hdmi_write(hdmi, 0x00, HDMI_CTRL_PKT_BUF_ACCESS_PB3); in sh_hdmi_audio_infoframe_setup()
763 hdmi_write(hdmi, 0x00, HDMI_CTRL_PKT_BUF_ACCESS_PB4); in sh_hdmi_audio_infoframe_setup()
766 hdmi_write(hdmi, 0x00, HDMI_CTRL_PKT_BUF_ACCESS_PB5); in sh_hdmi_audio_infoframe_setup()
769 hdmi_write(hdmi, 0x00, HDMI_CTRL_PKT_BUF_ACCESS_PB6); in sh_hdmi_audio_infoframe_setup()
770 hdmi_write(hdmi, 0x00, HDMI_CTRL_PKT_BUF_ACCESS_PB7); in sh_hdmi_audio_infoframe_setup()
771 hdmi_write(hdmi, 0x00, HDMI_CTRL_PKT_BUF_ACCESS_PB8); in sh_hdmi_audio_infoframe_setup()
772 hdmi_write(hdmi, 0x00, HDMI_CTRL_PKT_BUF_ACCESS_PB9); in sh_hdmi_audio_infoframe_setup()
773 hdmi_write(hdmi, 0x00, HDMI_CTRL_PKT_BUF_ACCESS_PB10); in sh_hdmi_audio_infoframe_setup()
779 static void sh_hdmi_configure(struct sh_hdmi *hdmi) in sh_hdmi_configure() argument
782 sh_hdmi_video_config(hdmi); in sh_hdmi_configure()
785 sh_hdmi_audio_config(hdmi); in sh_hdmi_configure()
788 sh_hdmi_phy_config(hdmi); in sh_hdmi_configure()
791 sh_hdmi_avi_infoframe_setup(hdmi); in sh_hdmi_configure()
794 sh_hdmi_audio_infoframe_setup(hdmi); in sh_hdmi_configure()
800 hdmi_write(hdmi, 0x8E, HDMI_CTRL_PKT_AUTO_SEND); in sh_hdmi_configure()
806 hdmi_bit_set(hdmi, 0xFC, 0x4C, HDMI_SYSTEM_CTRL); in sh_hdmi_configure()
810 hdmi_bit_set(hdmi, 0xFC, 0x40, HDMI_SYSTEM_CTRL); in sh_hdmi_configure()
813 static unsigned long sh_hdmi_rate_error(struct sh_hdmi *hdmi, in sh_hdmi_rate_error() argument
818 struct sh_mobile_hdmi_info *pdata = hdmi->dev->platform_data; in sh_hdmi_rate_error()
820 *hdmi_rate = clk_round_rate(hdmi->hdmi_clk, target); in sh_hdmi_rate_error()
822 *hdmi_rate = clk_get_rate(hdmi->hdmi_clk); in sh_hdmi_rate_error()
827 else if (clk_get_parent(hdmi->hdmi_clk)) in sh_hdmi_rate_error()
828 *parent_rate = clk_get_rate(clk_get_parent(hdmi->hdmi_clk)); in sh_hdmi_rate_error()
830 dev_dbg(hdmi->dev, "%u-%u-%u-%u x %u-%u-%u-%u\n", in sh_hdmi_rate_error()
836 dev_dbg(hdmi->dev, "\t@%lu(+/-%lu)Hz, e=%lu / 1000, r=%uHz, p=%luHz\n", target, in sh_hdmi_rate_error()
843 static int sh_hdmi_read_edid(struct sh_hdmi *hdmi, unsigned long *hdmi_rate, in sh_hdmi_read_edid() argument
846 struct sh_mobile_lcdc_chan *ch = hdmi->entity.lcdc; in sh_hdmi_read_edid()
857 dev_dbg(hdmi->dev, "Read back EDID code:"); in sh_hdmi_read_edid()
859 edid[i] = (hdmi->htop1) ? in sh_hdmi_read_edid()
860 (u8)hdmi_htop1_read(hdmi, HDMI_HTOP1_EDID_DATA_READ + (i * 4)) : in sh_hdmi_read_edid()
861 hdmi_read(hdmi, HDMI_EDID_KSV_FIFO_ACCESS_WINDOW); in sh_hdmi_read_edid()
875 if (!hdmi->edid_blocks) { in sh_hdmi_read_edid()
876 fb_edid_to_monspecs(edid, &hdmi->monspec); in sh_hdmi_read_edid()
877 hdmi->edid_blocks = edid[126] + 1; in sh_hdmi_read_edid()
879 dev_dbg(hdmi->dev, "%d main modes, %d extension blocks\n", in sh_hdmi_read_edid()
880 hdmi->monspec.modedb_len, hdmi->edid_blocks - 1); in sh_hdmi_read_edid()
882 dev_dbg(hdmi->dev, "Extension %u detected, DTD start %u\n", in sh_hdmi_read_edid()
884 fb_edid_add_monspecs(edid, &hdmi->monspec); in sh_hdmi_read_edid()
887 if (hdmi->edid_blocks > hdmi->edid_segment_nr * 2 + in sh_hdmi_read_edid()
888 (hdmi->edid_block_addr >> 7) + 1) { in sh_hdmi_read_edid()
890 if (hdmi->edid_block_addr) { in sh_hdmi_read_edid()
891 hdmi->edid_block_addr = 0; in sh_hdmi_read_edid()
892 hdmi->edid_segment_nr++; in sh_hdmi_read_edid()
894 hdmi->edid_block_addr = 0x80; in sh_hdmi_read_edid()
897 hdmi_write(hdmi, hdmi->edid_block_addr, HDMI_EDID_WORD_ADDRESS); in sh_hdmi_read_edid()
899 hdmi_write(hdmi, 0xC6, HDMI_INTERRUPT_MASK_1); in sh_hdmi_read_edid()
901 hdmi_write(hdmi, hdmi->edid_segment_nr, HDMI_EDID_SEGMENT_POINTER); in sh_hdmi_read_edid()
906 dev_dbg(hdmi->dev, "%d main and extended modes\n", hdmi->monspec.modedb_len); in sh_hdmi_read_edid()
920 dev_dbg(hdmi->dev, "Forced mode %ux%u@%uHz\n", in sh_hdmi_read_edid()
925 for (i = 0, mode = hdmi->monspec.modedb; in sh_hdmi_read_edid()
926 i < hdmi->monspec.modedb_len && scanning; in sh_hdmi_read_edid()
946 rate_error = sh_hdmi_rate_error(hdmi, mode, hdmi_rate, parent_rate); in sh_hdmi_read_edid()
987 if (!found && hdmi->entity.def_mode.xres != 0) { in sh_hdmi_read_edid()
988 found = &hdmi->entity.def_mode; in sh_hdmi_read_edid()
989 found_rate_error = sh_hdmi_rate_error(hdmi, found, hdmi_rate, in sh_hdmi_read_edid()
998 hdmi->preprogrammed_vic = 1; in sh_hdmi_read_edid()
1000 hdmi->preprogrammed_vic = 2; in sh_hdmi_read_edid()
1002 hdmi->preprogrammed_vic = 17; in sh_hdmi_read_edid()
1004 hdmi->preprogrammed_vic = 4; in sh_hdmi_read_edid()
1006 hdmi->preprogrammed_vic = 32; in sh_hdmi_read_edid()
1008 hdmi->preprogrammed_vic = 31; in sh_hdmi_read_edid()
1010 hdmi->preprogrammed_vic = 16; in sh_hdmi_read_edid()
1012 hdmi->preprogrammed_vic = 0; in sh_hdmi_read_edid()
1014 dev_dbg(hdmi->dev, "Using %s %s mode %ux%u@%uHz (%luHz), " in sh_hdmi_read_edid()
1016 hdmi->preprogrammed_vic ? "VIC" : "external", found->xres, in sh_hdmi_read_edid()
1020 hdmi->mode = *found; in sh_hdmi_read_edid()
1021 sh_hdmi_external_video_param(hdmi); in sh_hdmi_read_edid()
1028 struct sh_hdmi *hdmi = dev_id; in sh_hdmi_hotplug() local
1032 hdmi_bit_set(hdmi, 0xFC, 0x2C, HDMI_SYSTEM_CTRL); in sh_hdmi_hotplug()
1038 hdmi_bit_set(hdmi, 0xFC, 0x20, HDMI_SYSTEM_CTRL); in sh_hdmi_hotplug()
1040 status1 = hdmi_read(hdmi, HDMI_INTERRUPT_STATUS_1); in sh_hdmi_hotplug()
1041 status2 = hdmi_read(hdmi, HDMI_INTERRUPT_STATUS_2); in sh_hdmi_hotplug()
1043 mask1 = hdmi_read(hdmi, HDMI_INTERRUPT_MASK_1); in sh_hdmi_hotplug()
1044 mask2 = hdmi_read(hdmi, HDMI_INTERRUPT_MASK_2); in sh_hdmi_hotplug()
1047 hdmi_write(hdmi, 0xFF, HDMI_INTERRUPT_STATUS_1); in sh_hdmi_hotplug()
1048 hdmi_write(hdmi, 0xFF, HDMI_INTERRUPT_STATUS_2); in sh_hdmi_hotplug()
1051 dev_dbg(hdmi->dev, "IRQ #%d: Status #1: 0x%x & 0x%x, #2: 0x%x & 0x%x\n", in sh_hdmi_hotplug()
1062 msens = hdmi_read(hdmi, HDMI_HOT_PLUG_MSENS_STATUS); in sh_hdmi_hotplug()
1063 dev_dbg(hdmi->dev, "MSENS 0x%x\n", msens); in sh_hdmi_hotplug()
1067 hdmi->edid_segment_nr = 0; in sh_hdmi_hotplug()
1068 hdmi->edid_block_addr = 0; in sh_hdmi_hotplug()
1069 hdmi->edid_blocks = 0; in sh_hdmi_hotplug()
1070 hdmi->hp_state = HDMI_HOTPLUG_CONNECTED; in sh_hdmi_hotplug()
1073 hdmi_write(hdmi, 0x00, HDMI_EDID_WORD_ADDRESS); in sh_hdmi_hotplug()
1075 hdmi_write(hdmi, 0xC6, HDMI_INTERRUPT_MASK_1); in sh_hdmi_hotplug()
1077 hdmi_write(hdmi, 0x00, HDMI_EDID_SEGMENT_POINTER); in sh_hdmi_hotplug()
1080 if (hdmi->hp_state != HDMI_HOTPLUG_DISCONNECTED) { in sh_hdmi_hotplug()
1081 hdmi->hp_state = HDMI_HOTPLUG_DISCONNECTED; in sh_hdmi_hotplug()
1082 schedule_delayed_work(&hdmi->edid_work, 0); in sh_hdmi_hotplug()
1089 hdmi_write(hdmi, hdmi->edid_block_addr, HDMI_EDID_WORD_ADDRESS); in sh_hdmi_hotplug()
1091 hdmi_write(hdmi, hdmi->edid_segment_nr, HDMI_EDID_SEGMENT_POINTER); in sh_hdmi_hotplug()
1094 hdmi_write(hdmi, 0xC0, HDMI_INTERRUPT_MASK_1); in sh_hdmi_hotplug()
1095 schedule_delayed_work(&hdmi->edid_work, msecs_to_jiffies(10)); in sh_hdmi_hotplug()
1103 struct sh_hdmi *hdmi = entity_to_sh_hdmi(entity); in sh_hdmi_display_on() local
1105 dev_dbg(hdmi->dev, "%s(%p): state %x\n", __func__, hdmi, in sh_hdmi_display_on()
1106 hdmi->hp_state); in sh_hdmi_display_on()
1114 if (hdmi->hp_state == HDMI_HOTPLUG_EDID_DONE) { in sh_hdmi_display_on()
1116 hdmi_bit_set(hdmi, 0xFC, 0x80, HDMI_SYSTEM_CTRL); in sh_hdmi_display_on()
1117 dev_dbg(hdmi->dev, "HDMI running\n"); in sh_hdmi_display_on()
1120 return hdmi->hp_state == HDMI_HOTPLUG_DISCONNECTED in sh_hdmi_display_on()
1127 struct sh_hdmi *hdmi = entity_to_sh_hdmi(entity); in sh_hdmi_display_off() local
1129 dev_dbg(hdmi->dev, "%s(%p)\n", __func__, hdmi); in sh_hdmi_display_off()
1131 hdmi_bit_set(hdmi, 0xFC, 0x10, HDMI_SYSTEM_CTRL); in sh_hdmi_display_off()
1148 static long sh_hdmi_clk_configure(struct sh_hdmi *hdmi, unsigned long hdmi_rate, in sh_hdmi_clk_configure() argument
1153 if (parent_rate && clk_get_parent(hdmi->hdmi_clk)) { in sh_hdmi_clk_configure()
1154 ret = clk_set_rate(clk_get_parent(hdmi->hdmi_clk), parent_rate); in sh_hdmi_clk_configure()
1156 dev_warn(hdmi->dev, "Cannot set parent rate %ld: %d\n", parent_rate, ret); in sh_hdmi_clk_configure()
1157 hdmi_rate = clk_round_rate(hdmi->hdmi_clk, hdmi_rate); in sh_hdmi_clk_configure()
1159 dev_dbg(hdmi->dev, "HDMI set parent frequency %lu\n", parent_rate); in sh_hdmi_clk_configure()
1163 ret = clk_set_rate(hdmi->hdmi_clk, hdmi_rate); in sh_hdmi_clk_configure()
1165 dev_warn(hdmi->dev, "Cannot set rate %ld: %d\n", hdmi_rate, ret); in sh_hdmi_clk_configure()
1168 dev_dbg(hdmi->dev, "HDMI set frequency %lu\n", hdmi_rate); in sh_hdmi_clk_configure()
1177 struct sh_hdmi *hdmi = container_of(work, struct sh_hdmi, edid_work.work); in sh_hdmi_edid_work_fn() local
1178 struct sh_mobile_lcdc_chan *ch = hdmi->entity.lcdc; in sh_hdmi_edid_work_fn()
1181 dev_dbg(hdmi->dev, "%s(%p): begin, hotplug status %d\n", __func__, hdmi, in sh_hdmi_edid_work_fn()
1182 hdmi->hp_state); in sh_hdmi_edid_work_fn()
1184 if (hdmi->hp_state == HDMI_HOTPLUG_CONNECTED) { in sh_hdmi_edid_work_fn()
1187 ret = sh_hdmi_read_edid(hdmi, &hdmi_rate, &parent_rate); in sh_hdmi_edid_work_fn()
1191 hdmi->hp_state = HDMI_HOTPLUG_EDID_DONE; in sh_hdmi_edid_work_fn()
1194 ret = sh_hdmi_clk_configure(hdmi, hdmi_rate, parent_rate); in sh_hdmi_edid_work_fn()
1199 sh_hdmi_configure(hdmi); in sh_hdmi_edid_work_fn()
1205 &hdmi->mode, &hdmi->monspec); in sh_hdmi_edid_work_fn()
1207 hdmi->monspec.modedb_len = 0; in sh_hdmi_edid_work_fn()
1208 fb_destroy_modedb(hdmi->monspec.modedb); in sh_hdmi_edid_work_fn()
1209 hdmi->monspec.modedb = NULL; in sh_hdmi_edid_work_fn()
1220 hdmi->hp_state = HDMI_HOTPLUG_DISCONNECTED; in sh_hdmi_edid_work_fn()
1222 dev_dbg(hdmi->dev, "%s(%p): end\n", __func__, hdmi); in sh_hdmi_edid_work_fn()
1225 static void sh_hdmi_htop1_init(struct sh_hdmi *hdmi) in sh_hdmi_htop1_init() argument
1227 hdmi_htop1_write(hdmi, 0x00000000, HDMI_HTOP1_HTOP_DCL_MODE); in sh_hdmi_htop1_init()
1228 hdmi_htop1_write(hdmi, 0x0000000b, 0x0010); in sh_hdmi_htop1_init()
1229 hdmi_htop1_write(hdmi, 0x00006710, HDMI_HTOP1_HTOP_DCL_FRC_MODE); in sh_hdmi_htop1_init()
1230 hdmi_htop1_write(hdmi, 0x01020406, HDMI_HTOP1_HTOP_DCL_FIL_PARA_Y1_1); in sh_hdmi_htop1_init()
1231 hdmi_htop1_write(hdmi, 0x07080806, HDMI_HTOP1_HTOP_DCL_FIL_PARA_Y1_2); in sh_hdmi_htop1_init()
1232 hdmi_htop1_write(hdmi, 0x01020406, HDMI_HTOP1_HTOP_DCL_FIL_PARA_CB1_1); in sh_hdmi_htop1_init()
1233 hdmi_htop1_write(hdmi, 0x07080806, HDMI_HTOP1_HTOP_DCL_FIL_PARA_CB1_2); in sh_hdmi_htop1_init()
1234 hdmi_htop1_write(hdmi, 0x01020406, HDMI_HTOP1_HTOP_DCL_FIL_PARA_CR1_1); in sh_hdmi_htop1_init()
1235 hdmi_htop1_write(hdmi, 0x07080806, HDMI_HTOP1_HTOP_DCL_FIL_PARA_CR1_2); in sh_hdmi_htop1_init()
1236 hdmi_htop1_write(hdmi, 0x01020406, HDMI_HTOP1_HTOP_DCL_FIL_PARA_Y2_1); in sh_hdmi_htop1_init()
1237 hdmi_htop1_write(hdmi, 0x07080806, HDMI_HTOP1_HTOP_DCL_FIL_PARA_Y2_2); in sh_hdmi_htop1_init()
1238 hdmi_htop1_write(hdmi, 0x01020406, HDMI_HTOP1_HTOP_DCL_FIL_PARA_CB2_1); in sh_hdmi_htop1_init()
1239 hdmi_htop1_write(hdmi, 0x07080806, HDMI_HTOP1_HTOP_DCL_FIL_PARA_CB2_2); in sh_hdmi_htop1_init()
1240 hdmi_htop1_write(hdmi, 0x01020406, HDMI_HTOP1_HTOP_DCL_FIL_PARA_CR2_1); in sh_hdmi_htop1_init()
1241 hdmi_htop1_write(hdmi, 0x07080806, HDMI_HTOP1_HTOP_DCL_FIL_PARA_CR2_2); in sh_hdmi_htop1_init()
1242 hdmi_htop1_write(hdmi, 0x00000000, HDMI_HTOP1_HTOP_DCL_COR_PARA_Y1); in sh_hdmi_htop1_init()
1243 hdmi_htop1_write(hdmi, 0x00000000, HDMI_HTOP1_HTOP_DCL_COR_PARA_CB1); in sh_hdmi_htop1_init()
1244 hdmi_htop1_write(hdmi, 0x00000000, HDMI_HTOP1_HTOP_DCL_COR_PARA_CR1); in sh_hdmi_htop1_init()
1245 hdmi_htop1_write(hdmi, 0x00000000, HDMI_HTOP1_HTOP_DCL_COR_PARA_Y2); in sh_hdmi_htop1_init()
1246 hdmi_htop1_write(hdmi, 0x00000000, HDMI_HTOP1_HTOP_DCL_COR_PARA_CB2); in sh_hdmi_htop1_init()
1247 hdmi_htop1_write(hdmi, 0x00000000, HDMI_HTOP1_HTOP_DCL_COR_PARA_CR2); in sh_hdmi_htop1_init()
1248 hdmi_htop1_write(hdmi, 0x00000008, HDMI_HTOP1_CURRENT); in sh_hdmi_htop1_init()
1249 hdmi_htop1_write(hdmi, 0x00000000, HDMI_HTOP1_TISEMP0_1); in sh_hdmi_htop1_init()
1250 hdmi_htop1_write(hdmi, 0x00000000, HDMI_HTOP1_TISEMP2_C); in sh_hdmi_htop1_init()
1251 hdmi_htop1_write(hdmi, 0x00000000, HDMI_HTOP1_PHY_TEST_MODE); in sh_hdmi_htop1_init()
1252 hdmi_htop1_write(hdmi, 0x00000081, HDMI_HTOP1_TISIDRV); in sh_hdmi_htop1_init()
1253 hdmi_htop1_write(hdmi, 0x00000000, HDMI_HTOP1_PLLBW); in sh_hdmi_htop1_init()
1254 hdmi_htop1_write(hdmi, 0x0000000f, HDMI_HTOP1_TISEN); in sh_hdmi_htop1_init()
1255 hdmi_htop1_write(hdmi, 0x0000000f, HDMI_HTOP1_TISDREN); in sh_hdmi_htop1_init()
1256 hdmi_htop1_write(hdmi, 0x00000003, HDMI_HTOP1_ENABLE_SELECTOR); in sh_hdmi_htop1_init()
1257 hdmi_htop1_write(hdmi, 0x00000001, HDMI_HTOP1_MACRO_RESET); in sh_hdmi_htop1_init()
1258 hdmi_htop1_write(hdmi, 0x00000016, HDMI_HTOP1_CISRANGE); in sh_hdmi_htop1_init()
1260 hdmi_htop1_write(hdmi, 0x00000001, HDMI_HTOP1_ENABLE_SELECTOR); in sh_hdmi_htop1_init()
1262 hdmi_htop1_write(hdmi, 0x00000003, HDMI_HTOP1_ENABLE_SELECTOR); in sh_hdmi_htop1_init()
1263 hdmi_htop1_write(hdmi, 0x00000001, HDMI_HTOP1_MACRO_RESET); in sh_hdmi_htop1_init()
1264 hdmi_htop1_write(hdmi, 0x0000000f, HDMI_HTOP1_TISEN); in sh_hdmi_htop1_init()
1265 hdmi_htop1_write(hdmi, 0x0000000f, HDMI_HTOP1_TISDREN); in sh_hdmi_htop1_init()
1266 hdmi_htop1_write(hdmi, 0x00000000, HDMI_HTOP1_VIDEO_INPUT); in sh_hdmi_htop1_init()
1267 hdmi_htop1_write(hdmi, 0x00000000, HDMI_HTOP1_CLK_TO_PHY); in sh_hdmi_htop1_init()
1268 hdmi_htop1_write(hdmi, 0x00000000, HDMI_HTOP1_VIDEO_INPUT2); in sh_hdmi_htop1_init()
1269 hdmi_htop1_write(hdmi, 0x0000000a, HDMI_HTOP1_CLK_SET); in sh_hdmi_htop1_init()
1278 struct sh_hdmi *hdmi; in sh_hdmi_probe() local
1293 hdmi = kzalloc(sizeof(*hdmi), GFP_KERNEL); in sh_hdmi_probe()
1294 if (!hdmi) { in sh_hdmi_probe()
1299 hdmi->dev = &pdev->dev; in sh_hdmi_probe()
1300 hdmi->entity.owner = THIS_MODULE; in sh_hdmi_probe()
1301 hdmi->entity.ops = &sh_hdmi_ops; in sh_hdmi_probe()
1303 hdmi->hdmi_clk = clk_get(&pdev->dev, "ick"); in sh_hdmi_probe()
1304 if (IS_ERR(hdmi->hdmi_clk)) { in sh_hdmi_probe()
1305 ret = PTR_ERR(hdmi->hdmi_clk); in sh_hdmi_probe()
1312 hdmi->write = __hdmi_write32; in sh_hdmi_probe()
1313 hdmi->read = __hdmi_read32; in sh_hdmi_probe()
1315 hdmi->write = __hdmi_write8; in sh_hdmi_probe()
1316 hdmi->read = __hdmi_read8; in sh_hdmi_probe()
1320 rate = clk_round_rate(hdmi->hdmi_clk, PICOS2KHZ(37037)); in sh_hdmi_probe()
1322 rate = sh_hdmi_clk_configure(hdmi, rate, 0); in sh_hdmi_probe()
1329 ret = clk_enable(hdmi->hdmi_clk); in sh_hdmi_probe()
1331 dev_err(hdmi->dev, "Cannot enable clock: %d\n", ret); in sh_hdmi_probe()
1343 hdmi->base = ioremap(res->start, resource_size(res)); in sh_hdmi_probe()
1344 if (!hdmi->base) { in sh_hdmi_probe()
1350 platform_set_drvdata(pdev, &hdmi->entity); in sh_hdmi_probe()
1352 INIT_DELAYED_WORK(&hdmi->edid_work, sh_hdmi_edid_work_fn); in sh_hdmi_probe()
1359 hdmi_bit_set(hdmi, 0x02, 0x02, HDMI_SYSTEM_CTRL); in sh_hdmi_probe()
1362 hdmi_bit_set(hdmi, 0x01, 0x01, HDMI_SYSTEM_CTRL); in sh_hdmi_probe()
1366 hdmi->htop1 = ioremap(htop1_res->start, resource_size(htop1_res)); in sh_hdmi_probe()
1367 if (!hdmi->htop1) { in sh_hdmi_probe()
1372 sh_hdmi_htop1_init(hdmi); in sh_hdmi_probe()
1377 hdmi_read(hdmi, HDMI_PRODUCT_ID), hdmi_read(hdmi, HDMI_REVISION_ID)); in sh_hdmi_probe()
1380 dev_name(&pdev->dev), hdmi); in sh_hdmi_probe()
1396 free_irq(irq, hdmi); in sh_hdmi_probe()
1398 if (hdmi->htop1) in sh_hdmi_probe()
1399 iounmap(hdmi->htop1); in sh_hdmi_probe()
1403 iounmap(hdmi->base); in sh_hdmi_probe()
1407 clk_disable(hdmi->hdmi_clk); in sh_hdmi_probe()
1409 clk_put(hdmi->hdmi_clk); in sh_hdmi_probe()
1411 kfree(hdmi); in sh_hdmi_probe()
1418 struct sh_hdmi *hdmi = entity_to_sh_hdmi(platform_get_drvdata(pdev)); in sh_hdmi_remove() local
1425 free_irq(irq, hdmi); in sh_hdmi_remove()
1427 cancel_delayed_work_sync(&hdmi->edid_work); in sh_hdmi_remove()
1430 clk_disable(hdmi->hdmi_clk); in sh_hdmi_remove()
1431 clk_put(hdmi->hdmi_clk); in sh_hdmi_remove()
1432 if (hdmi->htop1) in sh_hdmi_remove()
1433 iounmap(hdmi->htop1); in sh_hdmi_remove()
1434 iounmap(hdmi->base); in sh_hdmi_remove()
1436 kfree(hdmi); in sh_hdmi_remove()