summaryrefslogtreecommitdiff
path: root/arch/arm/mach-pxa/clock-pxa2xx.c
blob: 1ce090448493501a23ce9c9da74a4dc81c57182e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*
 * linux/arch/arm/mach-pxa/clock-pxa2xx.c
 *
 * 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/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/sysdev.h>

#include <mach/pxa2xx-regs.h>

#include "clock.h"

void clk_pxa2xx_cken_enable(struct clk *clk)
{
	CKEN |= 1 << clk->cken;
}

void clk_pxa2xx_cken_disable(struct clk *clk)
{
	CKEN &= ~(1 << clk->cken);
}

const struct clkops clk_pxa2xx_cken_ops = {
	.enable		= clk_pxa2xx_cken_enable,
	.disable	= clk_pxa2xx_cken_disable,
};

#ifdef CONFIG_PM
static uint32_t saved_cken;

static int pxa2xx_clock_suspend(struct sys_device *d, pm_message_t state)
{
	saved_cken = CKEN;
	return 0;
}

static int pxa2xx_clock_resume(struct sys_device *d)
{
	CKEN = saved_cken;
	return 0;
}
#else
#define pxa2xx_clock_suspend	NULL
#define pxa2xx_clock_resume	NULL
#endif

struct sysdev_class pxa2xx_clock_sysclass = {
	.name		= "pxa2xx-clock",
	.suspend	= pxa2xx_clock_suspend,
	.resume		= pxa2xx_clock_resume,
};

static int __init pxa2xx_clock_init(void)
{
	if (cpu_is_pxa2xx())
		return sysdev_class_register(&pxa2xx_clock_sysclass);
	return 0;
}
postcore_initcall(pxa2xx_clock_init);