clock-exynos4210.c 4.7 KB
Newer Older
1
/*
2
 * Copyright (c) 2011-2012 Samsung Electronics Co., Ltd.
3 4 5 6 7 8 9 10 11 12 13 14 15
 *		http://www.samsung.com
 *
 * EXYNOS4210 - Clock support
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
*/

#include <linux/kernel.h>
#include <linux/err.h>
#include <linux/clk.h>
#include <linux/io.h>
16
#include <linux/syscore_ops.h>
17 18 19 20 21 22 23

#include <plat/cpu-freq.h>
#include <plat/clock.h>
#include <plat/cpu.h>
#include <plat/pll.h>
#include <plat/s5p-clock.h>
#include <plat/clock-clksrc.h>
24
#include <plat/pm.h>
25 26 27 28 29

#include <mach/hardware.h>
#include <mach/map.h>
#include <mach/regs-clock.h>

30
#include "common.h"
31
#include "clock-exynos4.h"
32

33
#ifdef CONFIG_PM_SLEEP
34
static struct sleep_save exynos4210_clock_save[] = {
35 36 37 38 39 40 41 42
	SAVE_ITEM(EXYNOS4_CLKSRC_IMAGE),
	SAVE_ITEM(EXYNOS4_CLKDIV_IMAGE),
	SAVE_ITEM(EXYNOS4210_CLKSRC_LCD1),
	SAVE_ITEM(EXYNOS4210_CLKDIV_LCD1),
	SAVE_ITEM(EXYNOS4210_CLKSRC_MASK_LCD1),
	SAVE_ITEM(EXYNOS4210_CLKGATE_IP_IMAGE),
	SAVE_ITEM(EXYNOS4210_CLKGATE_IP_LCD1),
	SAVE_ITEM(EXYNOS4210_CLKGATE_IP_PERIR),
43
};
44
#endif
45

46 47 48 49
static struct clksrc_clk *sysclks[] = {
	/* nothing here yet */
};

50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
static struct clksrc_clk exynos4210_clk_mout_g2d0 = {
	.clk	= {
		.name		= "mout_g2d0",
	},
	.sources = &exynos4_clkset_mout_g2d0,
	.reg_src = { .reg = EXYNOS4_CLKSRC_IMAGE, .shift = 0, .size = 1 },
};

static struct clksrc_clk exynos4210_clk_mout_g2d1 = {
	.clk	= {
		.name		= "mout_g2d1",
	},
	.sources = &exynos4_clkset_mout_g2d1,
	.reg_src = { .reg = EXYNOS4_CLKSRC_IMAGE, .shift = 4, .size = 1 },
};

static struct clk *exynos4210_clkset_mout_g2d_list[] = {
	[0] = &exynos4210_clk_mout_g2d0.clk,
	[1] = &exynos4210_clk_mout_g2d1.clk,
};

static struct clksrc_sources exynos4210_clkset_mout_g2d = {
	.sources	= exynos4210_clkset_mout_g2d_list,
	.nr_sources	= ARRAY_SIZE(exynos4210_clkset_mout_g2d_list),
};

76 77
static int exynos4_clksrc_mask_lcd1_ctrl(struct clk *clk, int enable)
{
78
	return s5p_gatectrl(EXYNOS4210_CLKSRC_MASK_LCD1, clk, enable);
79 80 81 82 83 84 85 86 87 88
}

static struct clksrc_clk clksrcs[] = {
	{
		.clk		= {
			.name		= "sclk_sata",
			.id		= -1,
			.enable		= exynos4_clksrc_mask_fsys_ctrl,
			.ctrlbit	= (1 << 24),
		},
89 90 91
		.sources = &exynos4_clkset_mout_corebus,
		.reg_src = { .reg = EXYNOS4_CLKSRC_FSYS, .shift = 24, .size = 1 },
		.reg_div = { .reg = EXYNOS4_CLKDIV_FSYS0, .shift = 20, .size = 4 },
92 93 94 95 96 97 98
	}, {
		.clk		= {
			.name		= "sclk_fimd",
			.devname	= "exynos4-fb.1",
			.enable		= exynos4_clksrc_mask_lcd1_ctrl,
			.ctrlbit	= (1 << 0),
		},
99 100 101
		.sources = &exynos4_clkset_group,
		.reg_src = { .reg = EXYNOS4210_CLKSRC_LCD1, .shift = 0, .size = 4 },
		.reg_div = { .reg = EXYNOS4210_CLKDIV_LCD1, .shift = 0, .size = 4 },
102 103 104 105 106 107 108
	}, {
		.clk	= {
			.name		= "sclk_fimg2d",
		},
		.sources = &exynos4210_clkset_mout_g2d,
		.reg_src = { .reg = EXYNOS4_CLKSRC_IMAGE, .shift = 8, .size = 1 },
		.reg_div = { .reg = EXYNOS4_CLKDIV_IMAGE, .shift = 0, .size = 4 },
109 110 111 112 113 114 115
	},
};

static struct clk init_clocks_off[] = {
	{
		.name		= "sataphy",
		.id		= -1,
116
		.parent		= &exynos4_clk_aclk_133.clk,
117 118 119 120 121
		.enable		= exynos4_clk_ip_fsys_ctrl,
		.ctrlbit	= (1 << 3),
	}, {
		.name		= "sata",
		.id		= -1,
122
		.parent		= &exynos4_clk_aclk_133.clk,
123 124 125 126 127 128 129
		.enable		= exynos4_clk_ip_fsys_ctrl,
		.ctrlbit	= (1 << 10),
	}, {
		.name		= "fimd",
		.devname	= "exynos4-fb.1",
		.enable		= exynos4_clk_ip_lcd1_ctrl,
		.ctrlbit	= (1 << 0),
130
	}, {
131 132
		.name		= "sysmmu",
		.devname	= "exynos-sysmmu.9",
133 134 135
		.enable		= exynos4_clk_ip_image_ctrl,
		.ctrlbit	= (1 << 3),
	}, {
136 137
		.name		= "sysmmu",
		.devname	= "exynos-sysmmu.11",
138 139
		.enable		= exynos4_clk_ip_lcd1_ctrl,
		.ctrlbit	= (1 << 4),
140 141 142 143
	}, {
		.name		= "fimg2d",
		.enable		= exynos4_clk_ip_image_ctrl,
		.ctrlbit	= (1 << 0),
144 145 146
	},
};

147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164
#ifdef CONFIG_PM_SLEEP
static int exynos4210_clock_suspend(void)
{
	s3c_pm_do_save(exynos4210_clock_save, ARRAY_SIZE(exynos4210_clock_save));

	return 0;
}

static void exynos4210_clock_resume(void)
{
	s3c_pm_do_restore_core(exynos4210_clock_save, ARRAY_SIZE(exynos4210_clock_save));
}

#else
#define exynos4210_clock_suspend NULL
#define exynos4210_clock_resume NULL
#endif

165
static struct syscore_ops exynos4210_clock_syscore_ops = {
166 167 168 169
	.suspend	= exynos4210_clock_suspend,
	.resume		= exynos4210_clock_resume,
};

170 171 172 173
void __init exynos4210_register_clocks(void)
{
	int ptr;

174 175 176
	exynos4_clk_mout_mpll.reg_src.reg = EXYNOS4_CLKSRC_CPU;
	exynos4_clk_mout_mpll.reg_src.shift = 8;
	exynos4_clk_mout_mpll.reg_src.size = 1;
177 178 179 180 181 182 183 184

	for (ptr = 0; ptr < ARRAY_SIZE(sysclks); ptr++)
		s3c_register_clksrc(sysclks[ptr], 1);

	s3c_register_clksrc(clksrcs, ARRAY_SIZE(clksrcs));

	s3c_register_clocks(init_clocks_off, ARRAY_SIZE(init_clocks_off));
	s3c_disable_clocks(init_clocks_off, ARRAY_SIZE(init_clocks_off));
185 186

	register_syscore_ops(&exynos4210_clock_syscore_ops);
187
}