73 MT_CG_INFRA_PMICSPI_SHARE
,
78 MT_CG_DISP0_SMI_COMMON
,
79 MT_CG_DISP0_SMI_LARB0
,
82 MT_CG_DISP0_DISP_COLOR
,
84 MT_CG_DISP0_DISP_WDMA
,
85 MT_CG_DISP0_DISP_RDMA
,
87 MT_CG_DISP0_MDP_TDSHP
,
93 MT_CG_DISP0_MDP_BLS_26M
,
96 MT_CG_DISP0_MUTEX_32K
,
97 MT_CG_DISP0_DISP_RMDA1
,
98 MT_CG_DISP0_DISP_UFOE
,
100 MT_CG_DISP1_DSI_ENGINE
,
101 MT_CG_DISP1_DSI_DIGITAL
,
102 MT_CG_DISP1_DPI_DIGITAL_LANE
,
103 MT_CG_DISP1_DPI_ENGINE
,
104 MT_CG_DISP1_DPI1_DIGITAL_LANE
,
105 MT_CG_DISP1_DPI1_ENGINE
,
106 MT_CG_DISP1_TVE_OUTPUT_CLOCK
,
107 MT_CG_DISP1_TVE_INPUT_CLOCK
,
108 MT_CG_DISP1_HDMI_PIXEL_CLOCK
,
109 MT_CG_DISP1_HDMI_PLL_CLOCK
,
110 MT_CG_DISP1_HDMI_AUDIO_CLOCK
,
111 MT_CG_DISP1_HDMI_SPDIF_CLOCK
,
112 MT_CG_DISP1_LVDS_PIXEL_CLOCK
,
113 MT_CG_DISP1_LVDS_CTS_CLOCK
,
115 MT_CG_IMAGE_LARB2_SMI
,
120 MT_CG_IMAGE_VENC_JPENC
,
126 MT_CG_AUDIO_APLL_TUNER_CK
,
129 MT_CG_AUDIO_SPDF2_CK
,
214 /* the following definition / declaration are only enabled in Linux kernel */
217 #include <linux/list.h>
218 #include "mach/mt_reg_base.h"
219 #include "mach/mt_typedefs.h"
222 #define CLKMGR_8127 1
224 #define CLKMGR_CLKM0 0
227 #define AP_PLL_CON0 (APMIXEDSYS_BASE + 0x0000)
228 #define AP_PLL_CON1 (APMIXEDSYS_BASE + 0x0004)
229 #define AP_PLL_CON2 (APMIXEDSYS_BASE + 0x0008)
231 #define PLL_HP_CON0 (APMIXEDSYS_BASE + 0x0014)
233 #define ARMPLL_CON0 (APMIXEDSYS_BASE + 0x0200)
234 #define ARMPLL_CON1 (APMIXEDSYS_BASE + 0x0204)
235 #define ARMPLL_PWR_CON0 (APMIXEDSYS_BASE + 0x020C)
237 #define MAINPLL_CON0 (APMIXEDSYS_BASE + 0x0210)
238 #define MAINPLL_CON1 (APMIXEDSYS_BASE + 0x0214)
239 #define MAINPLL_PWR_CON0 (APMIXEDSYS_BASE + 0x021C)
241 #define UNIVPLL_CON0 (APMIXEDSYS_BASE + 0x0220)
242 #define UNIVPLL_CON1 (APMIXEDSYS_BASE + 0x0224)
243 #define UNIVPLL_PWR_CON0 (APMIXEDSYS_BASE + 0x022C)
245 #define MMPLL_CON0 (APMIXEDSYS_BASE + 0x0230)
246 #define MMPLL_CON1 (APMIXEDSYS_BASE + 0x0234)
247 #define MMPLL_PWR_CON0 (APMIXEDSYS_BASE + 0x023C)
249 #define MSDCPLL_CON0 (APMIXEDSYS_BASE + 0x0240)
250 #define MSDCPLL_CON1 (APMIXEDSYS_BASE + 0x0244)
251 #define MSDCPLL_PWR_CON0 (APMIXEDSYS_BASE + 0x024C)
253 #define AUDPLL_CON0 (APMIXEDSYS_BASE + 0x0250)
254 #define AUDPLL_CON1 (APMIXEDSYS_BASE + 0x0254)
255 #define AUDPLL_PWR_CON0 (APMIXEDSYS_BASE + 0x025C)
257 #define VENCPLL_CON0 (DDRPHY_BASE + 0x800)
258 #define VENCPLL_CON1 (DDRPHY_BASE + 0x804)
259 #define VENCPLL_PWR_CON0 (DDRPHY_BASE + 0x80C)
261 #define TVDPLL_CON0 (APMIXEDSYS_BASE + 0x0260)
262 #define TVDPLL_CON1 (APMIXEDSYS_BASE + 0x0264)
263 #define TVDPLL_PWR_CON0 (APMIXEDSYS_BASE + 0x026C)
265 #define LVDSPLL_CON0 (APMIXEDSYS_BASE + 0x0270)
266 #define LVDSPLL_CON1 (APMIXEDSYS_BASE + 0x0274)
267 #define LVDSPLL_PWR_CON0 (APMIXEDSYS_BASE + 0x027C)
269 #define CLK_DSI_PLL_CON0 (MIPI_CONFIG_BASE + 0x50)
271 #define CLK_CFG_0 (INFRA_BASE + 0x0040)
272 #define CLK_CFG_1 (INFRA_BASE + 0x0050)
273 #define CLK_CFG_2 (INFRA_BASE + 0x0060)
274 #define CLK_CFG_3 (INFRA_BASE + 0x0070)
275 #define CLK_CFG_4 (INFRA_BASE + 0x0080)
276 #define CLK_CFG_4_SET (INFRA_BASE + 0x0084)
277 #define CLK_CFG_4_CLR (INFRA_BASE + 0x0088)
278 #define CLK_CFG_5 (INFRA_BASE + 0x0090)
279 #define CLK_CFG_6 (INFRA_BASE + 0x00A0)
280 #define CLK_CFG_8 (INFRA_BASE + 0x0100)
281 #define CLK_CFG_9 (INFRA_BASE + 0x0104)
282 #define CLK_CFG_10 (INFRA_BASE + 0x0108)
283 #define CLK_CFG_11 (INFRA_BASE + 0x010C)
284 #define CLK_SCP_CFG_0 (INFRA_BASE + 0x0200)
285 #define CLK_SCP_CFG_1 (INFRA_BASE + 0x0204)
287 #define INFRA_PDN_SET (INFRACFG_AO_BASE + 0x0040)
288 #define INFRA_PDN_CLR (INFRACFG_AO_BASE + 0x0044)
289 #define INFRA_PDN_STA (INFRACFG_AO_BASE + 0x0048)
291 #define TOPAXI_PROT_EN (INFRACFG_AO_BASE + 0x0220)
292 #define TOPAXI_PROT_STA1 (INFRACFG_AO_BASE + 0x0228)
294 #define PERI_PDN0_SET (PERICFG_BASE + 0x0008)
295 #define PERI_PDN0_CLR (PERICFG_BASE + 0x0010)
296 #define PERI_PDN0_STA (PERICFG_BASE + 0x0018)
298 #define PERI_PDN1_SET (PERICFG_BASE + 0x000C)
299 #define PERI_PDN1_CLR (PERICFG_BASE + 0x0014)
300 #define PERI_PDN1_STA (PERICFG_BASE + 0x001C)
302 #define AUDIO_TOP_CON0 (AUDIO_REG_BASE + 0x0000)
304 #define MFG_CG_CON (G3D_CONFIG_BASE + 0x0000)
305 #define MFG_CG_SET (G3D_CONFIG_BASE + 0x0004)
306 #define MFG_CG_CLR (G3D_CONFIG_BASE + 0x0008)
308 #define DISP_CG_CON0 (DISPSYS_BASE + 0x100)
309 #define DISP_CG_SET0 (DISPSYS_BASE + 0x104)
310 #define DISP_CG_CLR0 (DISPSYS_BASE + 0x108)
311 #define DISP_CG_CON1 (DISPSYS_BASE + 0x110)
312 #define DISP_CG_SET1 (DISPSYS_BASE + 0x114)
313 #define DISP_CG_CLR1 (DISPSYS_BASE + 0x118)
315 #define IMG_CG_CON (IMGSYS_CONFG_BASE + 0x0000)
316 #define IMG_CG_SET (IMGSYS_CONFG_BASE + 0x0004)
317 #define IMG_CG_CLR (IMGSYS_CONFG_BASE + 0x0008)
319 #define VDEC_CKEN_SET (VDEC_GCON_BASE + 0x0000)
320 #define VDEC_CKEN_CLR (VDEC_GCON_BASE + 0x0004)
321 #define LARB_CKEN_SET (VDEC_GCON_BASE + 0x0008)
322 #define LARB_CKEN_CLR (VDEC_GCON_BASE + 0x000C)
332 /* larb monitor mechanism definition */
334 LARB_MONITOR_LEVEL_HIGH
= 10,
335 LARB_MONITOR_LEVEL_MEDIUM
= 20,
336 LARB_MONITOR_LEVEL_LOW
= 30,
339 struct larb_monitor
{
340 struct list_head link
;
342 void (*backup
)(struct larb_monitor
*h
, int larb_idx
); /* called before disable larb clock */
343 void (*restore
)(struct larb_monitor
*h
, int larb_idx
); /* called after enable larb clock */
350 enum monitor_clk_sel_0
{
354 AD_UNIV_249P6M_CK
= 7,
355 AD_UNIV_178P3M_CK_0
= 8,
359 AD_SYS_26M_CK_0
= 21,
363 #endif /* CLKMGR_CLKM0 */
366 enum monitor_clk_sel
{
374 AD_UNIV_178P3M_CK
= 11,
375 AD_MAIN_H156M_CK
= 12,
393 ABIST_AD_MAIN_H546M_CK
= 1,
394 ABIST_AD_MAIN_H364M_CK
= 2,
395 ABIST_AD_MAIN_H218P4M_CK
= 3,
396 ABIST_AD_MAIN_H156M_CK
= 4,
397 ABIST_AD_UNIV_624M_CK
= 5,
398 ABIST_AD_UNIV_416M_CK
= 6,
399 ABIST_AD_UNIV_249P6M_CK
= 7,
400 ABIST_AD_UNIV_178P3M_CK
= 8,
401 ABIST_AD_UNIV_48M_CK
= 9,
402 ABIST_AD_USB_48M_CK
= 10,
403 ABIST_AD_MMPLL_CK
= 11,
404 ABIST_AD_MSDCPLL_CK
= 12,
405 ABIST_AD_DPICLK
= 13,
406 ABIST_CLKPH_MCK_O
= 14,
407 ABIST_AD_MEMPLL2_CKOUT0_PRE_ISO
= 15,
408 ABIST_AD_MCUPLL1_H481M_CK
= 16,
409 ABIST_AD_MDPLL1_416M_CK
= 17,
410 ABIST_AD_WPLL_CK
= 18,
411 ABIST_AD_WHPLL_CK
= 19,
412 ABIST_RTC32K_CK_I
= 20,
413 ABIST_AD_SYS_26M_CK
= 21,
414 ABIST_AD_VENCPLL_CK
= 22,
415 ABIST_AD_MIPI_26M_CK
= 33,
416 ABIST_AD_MEM_26M_CK
= 35,
417 ABIST_AD_PLLGP_TST_CK
= 36,
418 ABIST_AD_DSI0_LNTC_DSICLK
= 37,
419 ABIST_AD_MPPLL_TST_CK
= 38,
420 ABIST_ARMPLL_OCC_MON
= 39,
421 ABIST_AD_MEM2MIPI_26M_CK
= 40,
422 ABIST_AD_MEMPLL_MONCLK
= 41,
423 ABIST_AD_MEMPLL2_MONCLK
= 42,
424 ABIST_AD_MEMPLL3_MONCLK
= 43,
425 ABIST_AD_MEMPLL4_MONCLK
= 44,
426 ABIST_AD_MEMPLL_REFCLK
= 45,
427 ABIST_AD_MEMPLL_FBCLK
= 46,
428 ABIST_AD_MEMPLL2_REFCLK
= 47,
429 ABIST_AD_MEMPLL2_FBCLK
= 48,
430 ABIST_AD_MEMPLL3_REFCLK
= 49,
431 ABIST_AD_MEMPLL3_FBCLK
= 50,
432 ABIST_AD_MEMPLL4_REFCLK
= 51,
433 ABIST_AD_MEMPLL4_FBCLK
= 52,
434 ABIST_AD_MEMPLL_TSTDIV2_CK
= 53,
435 ABIST_AD_LVDSPLL_CK
= 54,
436 ABIST_AD_LVDSTX_MONCLK
= 55,
437 ABIST_AD_HDMITX_MONCLK
= 56,
438 ABIST_AD_USB20_C240M
= 57,
439 ABIST_AD_USB20_C240M_1P
= 58,
440 ABIST_AD_MONREF_CK
= 59,
441 ABIST_AD_MONFBK_CK
= 60,
442 ABIST_AD_TVDPLL_CK
= 61,
443 ABIST_AD_AUDPLL_CK
= 62,
444 ABIST_AD_LVDSPLL_ETH_CK
= 63,
453 CKGEN_HF_FAXI_CK
= 1,
454 CKGEN_HD_FAXI_CK
= 2,
455 CKGEN_HF_FNFI2X_CK
= 3,
456 CKGEN_HF_FDDRPHYCFG_CK
= 4,
459 CKGEN_HF_FVDEC_CK
= 7,
460 CKGEN_HF_FMFG_CK
= 8,
461 CKGEN_HF_FCAMTG_CK
= 9,
462 CKGEN_F_FUART_CK
= 10,
463 CKGEN_HF_FSPI_CK
= 11,
464 CKGEN_F_FUSB20_CK
= 12,
465 CKGEN_HF_FMSDC30_0_CK
= 13,
466 CKGEN_HF_FMSDC30_1_CK
= 14,
467 CKGEN_HF_FMSDC30_2_CK
= 15,
468 CKGEN_HF_FAUDIO_CK
= 16,
469 CKGEN_HF_FAUD_INTBUS_CK
= 17,
470 CKGEN_HF_FPMICSPI_CK
= 18,
471 CKGEN_F_FRTC_CK
= 19,
472 CKGEN_F_F26M_CK
= 20,
473 CKGEN_F_F32K_MD1_CK
= 21,
474 CKGEN_F_FRTC_CONN_CK
= 22,
475 CKGEN_HF_FETH_50M_CK
= 23,
476 CKGEN_HD_HAXI_NLI_CK
= 25,
477 CKGEN_HD_QAXIDCM_CK
= 26,
478 CKGEN_F_FFPC_CK
= 27,
479 CKGEN_HF_FDPI0_CK
= 28,
480 CKGEN_F_FCKBUS_CK_SCAN
= 29,
481 CKGEN_F_FCKRTC_CK_SCAN
= 30,
482 CKGEN_HF_FDPILVDS_CK
= 31,
490 /* Measure clock frequency (in KHz) by frequency meter. */
491 extern uint32_t measure_abist_freq(enum ABIST_CLK clk
);
492 extern uint32_t measure_ckgen_freq(enum CKGEN_CLK clk
);
494 #endif /* CLKMGR_EXT */
497 extern void register_larb_monitor(struct larb_monitor
*handler
);
498 extern void unregister_larb_monitor(struct larb_monitor
*handler
);
501 extern int enable_clock(enum cg_clk_id id
, char *mod_name
);
502 extern int disable_clock(enum cg_clk_id id
, char *mod_name
);
503 extern int mt_enable_clock(enum cg_clk_id id
, char *mod_name
);
504 extern int mt_disable_clock(enum cg_clk_id id
, char *mod_name
);
506 extern int clock_is_on(int id
);
508 extern int clkmux_sel(int id
, unsigned int clksrc
, char *name
);
509 extern void enable_mux(int id
, char *name
);
510 extern void disable_mux(int id
, char *name
);
512 extern void clk_set_force_on(int id
);
513 extern void clk_clr_force_on(int id
);
514 extern int clk_is_force_on(int id
);
517 extern int enable_pll(int id
, char *mod_name
);
518 extern int disable_pll(int id
, char *mod_name
);
520 extern int pll_hp_switch_on(int id
, int hp_on
);
521 extern int pll_hp_switch_off(int id
, int hp_off
);
525 /* set/get PLL frequency in KHz. */
526 extern unsigned int pll_get_freq(int id
);
527 extern unsigned int pll_set_freq(int id
, unsigned int freq_khz
);
529 #endif /* CLKMGR_8127 */
531 extern int pll_fsel(int id
, unsigned int value
);
532 extern int pll_is_on(int id
);
535 extern int enable_subsys(int id
, char *mod_name
);
536 extern int disable_subsys(int id
, char *mod_name
);
537 extern int subsys_is_on(int id
);
539 extern bool isp_vdec_on_off(void);
541 extern int conn_power_on(void);
542 extern int conn_power_off(void);
545 const char *grp_get_name(int id
);
546 int clk_id_to_grp_id(enum cg_clk_id id
);
547 unsigned int clk_id_to_mask(enum cg_clk_id id
);
551 extern void mt_clkmgr_init(void);
553 extern void CLKM_32K(bool flag
);
554 extern int CLK_Monitor(enum ckmon_sel ckmon
, enum monitor_clk_sel sel
, int div
);
557 extern int CLK_Monitor_0(enum ckmon_sel ckmon
, enum monitor_clk_sel_0 sel
, int div
);
558 #endif /* CLKMGR_CLKM0 */
564 /* deprecated or unused in MT8127 */
566 extern int enable_clock_ext_locked(int id
, char *mod_name
);
567 extern int disable_clock_ext_locked(int id
, char *mod_name
);
569 extern int enable_pll_spec(int id
, char *mod_name
);
570 extern int disable_pll_spec(int id
, char *mod_name
);
572 extern int md_power_on(int id
);
573 extern int md_power_off(int id
, unsigned int timeout
);
575 extern void enable_clksq1(void);
576 extern void disable_clksq1(void);
578 extern void clksq1_sw2hw(void);
579 extern void clksq1_hw2sw(void);
581 extern int clkmgr_is_locked(void);
584 #endif /* !CLKMGR_8127 */
587 #ifdef __MT_CLKMGR_C__
589 /* clkmgr internal use only */
591 #ifdef CONFIG_MTK_MMC
592 extern void msdc_clk_status(int *status
);
595 #endif /* __MT_CLKMGR_C__ */
598 #endif /* __KERNEL__ */