Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
raspberrypi-kernel
提交
a10bd67f
R
raspberrypi-kernel
项目概览
openeuler
/
raspberrypi-kernel
通知
13
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
raspberrypi-kernel
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
a10bd67f
编写于
4月 04, 2012
作者:
S
Shawn Guo
提交者:
Sascha Hauer
5月 02, 2012
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
ARM: imx: add common clock support for pfd
Signed-off-by:
N
Shawn Guo
<
shawn.guo@linaro.org
>
上级
b75c0151
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
152 addition
and
1 deletion
+152
-1
arch/arm/mach-imx/Makefile
arch/arm/mach-imx/Makefile
+2
-1
arch/arm/mach-imx/clk-pfd.c
arch/arm/mach-imx/clk-pfd.c
+147
-0
arch/arm/mach-imx/clk.h
arch/arm/mach-imx/clk.h
+3
-0
未找到文件。
arch/arm/mach-imx/Makefile
浏览文件 @
a10bd67f
...
...
@@ -11,7 +11,8 @@ obj-$(CONFIG_SOC_IMX35) += mm-imx3.o cpu-imx35.o clock-imx35.o ehci-imx35.o pm-i
obj-$(CONFIG_SOC_IMX5)
+=
cpu-imx5.o mm-imx5.o clock-mx51-mx53.o ehci-imx5.o pm-imx5.o cpu_op-mx51.o
obj-$(CONFIG_COMMON_CLK)
+=
clk-pllv1.o clk-pllv2.o clk-pllv3.o clk-gate2.o
obj-$(CONFIG_COMMON_CLK)
+=
clk-pllv1.o clk-pllv2.o clk-pllv3.o clk-gate2.o
\
clk-pfd.o
# Support for CMOS sensor interface
obj-$(CONFIG_MX1_VIDEO)
+=
mx1-camera-fiq.o mx1-camera-fiq-ksym.o
...
...
arch/arm/mach-imx/clk-pfd.c
0 → 100644
浏览文件 @
a10bd67f
/*
* Copyright 2012 Freescale Semiconductor, Inc.
* Copyright 2012 Linaro Ltd.
*
* The code contained herein is licensed under the GNU General Public
* License. You may obtain a copy of the GNU General Public License
* Version 2 or later at the following locations:
*
* http://www.opensource.org/licenses/gpl-license.html
* http://www.gnu.org/copyleft/gpl.html
*/
#include <linux/clk.h>
#include <linux/clk-provider.h>
#include <linux/io.h>
#include <linux/slab.h>
#include <linux/err.h>
#include "clk.h"
/**
* struct clk_pfd - IMX PFD clock
* @clk_hw: clock source
* @reg: PFD register address
* @idx: the index of PFD encoded in the register
*
* PFD clock found on i.MX6 series. Each register for PFD has 4 clk_pfd
* data encoded, and member idx is used to specify the one. And each
* register has SET, CLR and TOG registers at offset 0x4 0x8 and 0xc.
*/
struct
clk_pfd
{
struct
clk_hw
hw
;
void
__iomem
*
reg
;
u8
idx
;
};
#define to_clk_pfd(_hw) container_of(_hw, struct clk_pfd, hw)
#define SET 0x4
#define CLR 0x8
#define OTG 0xc
static
int
clk_pfd_enable
(
struct
clk_hw
*
hw
)
{
struct
clk_pfd
*
pfd
=
to_clk_pfd
(
hw
);
writel_relaxed
(
1
<<
((
pfd
->
idx
+
1
)
*
8
-
1
),
pfd
->
reg
+
CLR
);
return
0
;
}
static
void
clk_pfd_disable
(
struct
clk_hw
*
hw
)
{
struct
clk_pfd
*
pfd
=
to_clk_pfd
(
hw
);
writel_relaxed
(
1
<<
((
pfd
->
idx
+
1
)
*
8
-
1
),
pfd
->
reg
+
SET
);
}
static
unsigned
long
clk_pfd_recalc_rate
(
struct
clk_hw
*
hw
,
unsigned
long
parent_rate
)
{
struct
clk_pfd
*
pfd
=
to_clk_pfd
(
hw
);
u64
tmp
=
parent_rate
;
u8
frac
=
(
readl_relaxed
(
pfd
->
reg
)
>>
(
pfd
->
idx
*
8
))
&
0x3f
;
tmp
*=
18
;
do_div
(
tmp
,
frac
);
return
tmp
;
}
static
long
clk_pfd_round_rate
(
struct
clk_hw
*
hw
,
unsigned
long
rate
,
unsigned
long
*
prate
)
{
u64
tmp
=
*
prate
;
u8
frac
;
tmp
=
tmp
*
18
+
rate
/
2
;
do_div
(
tmp
,
rate
);
frac
=
tmp
;
if
(
frac
<
12
)
frac
=
12
;
else
if
(
frac
>
35
)
frac
=
35
;
tmp
=
*
prate
;
tmp
*=
18
;
do_div
(
tmp
,
frac
);
return
tmp
;
}
static
int
clk_pfd_set_rate
(
struct
clk_hw
*
hw
,
unsigned
long
rate
,
unsigned
long
parent_rate
)
{
struct
clk_pfd
*
pfd
=
to_clk_pfd
(
hw
);
u64
tmp
=
parent_rate
;
u8
frac
;
tmp
=
tmp
*
18
+
rate
/
2
;
do_div
(
tmp
,
rate
);
frac
=
tmp
;
if
(
frac
<
12
)
frac
=
12
;
else
if
(
frac
>
35
)
frac
=
35
;
writel_relaxed
(
0x3f
<<
(
pfd
->
idx
*
8
),
pfd
->
reg
+
CLR
);
writel_relaxed
(
frac
<<
(
pfd
->
idx
*
8
),
pfd
->
reg
+
SET
);
return
0
;
}
static
const
struct
clk_ops
clk_pfd_ops
=
{
.
enable
=
clk_pfd_enable
,
.
disable
=
clk_pfd_disable
,
.
recalc_rate
=
clk_pfd_recalc_rate
,
.
round_rate
=
clk_pfd_round_rate
,
.
set_rate
=
clk_pfd_set_rate
,
};
struct
clk
*
imx_clk_pfd
(
const
char
*
name
,
const
char
*
parent_name
,
void
__iomem
*
reg
,
u8
idx
)
{
struct
clk_pfd
*
pfd
;
struct
clk
*
clk
;
struct
clk_init_data
init
;
pfd
=
kzalloc
(
sizeof
(
*
pfd
),
GFP_KERNEL
);
if
(
!
pfd
)
return
ERR_PTR
(
-
ENOMEM
);
pfd
->
reg
=
reg
;
pfd
->
idx
=
idx
;
init
.
name
=
name
;
init
.
ops
=
&
clk_pfd_ops
;
init
.
flags
=
0
;
init
.
parent_names
=
&
parent_name
;
init
.
num_parents
=
1
;
pfd
->
hw
.
init
=
&
init
;
clk
=
clk_register
(
NULL
,
&
pfd
->
hw
);
if
(
IS_ERR
(
clk
))
kfree
(
pfd
);
return
clk
;
}
arch/arm/mach-imx/clk.h
浏览文件 @
a10bd67f
...
...
@@ -36,6 +36,9 @@ static inline struct clk *imx_clk_gate2(const char *name, const char *parent,
shift
,
0
,
&
imx_ccm_lock
);
}
struct
clk
*
imx_clk_pfd
(
const
char
*
name
,
const
char
*
parent_name
,
void
__iomem
*
reg
,
u8
idx
);
static
inline
struct
clk
*
imx_clk_fixed
(
const
char
*
name
,
int
rate
)
{
return
clk_register_fixed_rate
(
NULL
,
name
,
NULL
,
CLK_IS_ROOT
,
rate
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录