• R/O
  • HTTP
  • SSH
  • HTTPS

コミット

タグ
未設定

よく使われているワード(クリックで追加)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

コミットメタ情報

リビジョン773502668478573ab38ad2e84187a6053a6b831a (tree)
日時2016-05-26 23:01:36
作者Yoshinori Sato <ysato@user...>
コミッターYoshinori Sato

ログメッセージ

sh: timer driver

Signed-off-by: Yoshinori Sato <ysato@users.sourceforge.jp>

変更サマリ

差分

--- a/arch/sh/lib/Makefile
+++ b/arch/sh/lib/Makefile
@@ -7,6 +7,7 @@
77
88
99 obj-$(CONFIG_CMD_BOOTM) += bootm.o
10+ifndef CONFIG_DM
1011 ifneq ($(CONFIG_TIMER)$(CONFIG_SPL_BUILD),y)
1112 ifeq ($(CONFIG_CPU_SH2),y)
1213 obj-y += time_sh2.o
@@ -14,6 +15,7 @@ else
1415 obj-y += time.o
1516 endif
1617 endif
18+endif
1719 obj-$(CONFIG_CMD_SH_ZIMAGEBOOT) += zimageboot.o
1820
1921 udivsi3-y := udivsi3_i4i-Os.o
--- a/drivers/timer/Kconfig
+++ b/drivers/timer/Kconfig
@@ -46,6 +46,12 @@ config OMAP_TIMER
4646 help
4747 Select this to enable an timer for Omap devices.
4848
49+config SH3_TIMER
50+ bool "SH3 timer support"
51+ depends on TIMER
52+ help
53+ Select this to enable an timer for SH4 devices.
54+
4955 config SH4_TIMER
5056 bool "SH4 timer support"
5157 depends on TIMER
--- a/drivers/timer/Makefile
+++ b/drivers/timer/Makefile
@@ -9,4 +9,5 @@ obj-$(CONFIG_ALTERA_TIMER) += altera_timer.o
99 obj-$(CONFIG_SANDBOX_TIMER) += sandbox_timer.o
1010 obj-$(CONFIG_X86_TSC_TIMER) += tsc_timer.o
1111 obj-$(CONFIG_OMAP_TIMER) += omap-timer.o
12+obj-$(CONFIG_SH3_TIMER) += sh3_timer.o
1213 obj-$(CONFIG_SH4_TIMER) += sh4_timer.o
--- /dev/null
+++ b/drivers/timer/sh3_timer.c
@@ -0,0 +1,83 @@
1+/*
2+ * (C) Copyright 2016
3+ * Yoshinori Sato <ysato@users.sourceforge.jp>
4+ *
5+ * SPDX-License-Identifier: GPL-2.0+
6+ */
7+
8+#include <common.h>
9+#include <dm.h>
10+#include <timer.h>
11+#include <asm/processor.h>
12+#include <asm/io.h>
13+
14+DECLARE_GLOBAL_DATA_PTR;
15+
16+struct sh3_timer_platdata {
17+ unsigned char *regs;
18+ int ch;
19+};
20+
21+static int timer_read_counter(struct udevice *dev, u64 *count)
22+{
23+ struct sh3_timer_platdata *plat = dev_get_platdata(dev);
24+
25+ *count = timer_conv_64(~readl(plat->regs + 4 + plat->ch * 12 + 4));
26+ return 0;
27+}
28+
29+static void tmu_timer_start(unsigned char *reg, unsigned int timer)
30+{
31+ if (timer > 2)
32+ return;
33+ writeb(readb(reg + 2) | (1 << timer), reg + 2);
34+}
35+
36+static void tmu_timer_stop(unsigned char *reg, unsigned int timer)
37+{
38+ if (timer > 2)
39+ return;
40+ writeb(readb(reg + 2) & ~(1 << timer), reg + 2);
41+}
42+
43+static int sh3_timer_probe(struct udevice *dev)
44+{
45+ struct sh3_timer_platdata *plat = dev_get_platdata(dev);
46+
47+ writew(0, plat->regs + 4 + (plat->ch * 12) + 8);
48+
49+ tmu_timer_stop(plat->regs, plat->ch);
50+ tmu_timer_start(plat->regs, plat->ch);
51+
52+ return 0;
53+}
54+
55+static int sh3_timer_ofdata_to_platdata(struct udevice *dev)
56+{
57+ struct sh3_timer_platdata *plat = dev_get_platdata(dev);
58+
59+ plat->regs = map_physmem(dev_get_addr(dev), 48, MAP_NOCACHE);
60+ plat->ch = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
61+ "renesas,channel", 0);
62+ return 0;
63+}
64+
65+static const struct timer_ops sh3_timer_ops = {
66+ .get_count = timer_read_counter,
67+};
68+
69+static const struct udevice_id sh3_timer_ids[] = {
70+ { .compatible = "renesas,sh3-tmu" },
71+ {}
72+};
73+
74+U_BOOT_DRIVER(sh3_timer) = {
75+ .name = "sh3_timer",
76+ .id = UCLASS_TIMER,
77+ .of_match = of_match_ptr(sh3_timer_ids),
78+ .ofdata_to_platdata = of_match_ptr(sh3_timer_ofdata_to_platdata),
79+ .platdata_auto_alloc_size = sizeof(struct sh3_timer_platdata),
80+ .probe = sh3_timer_probe,
81+ .ops = &sh3_timer_ops,
82+ .flags = DM_FLAG_PRE_RELOC,
83+};
--- a/drivers/timer/sh4_timer.c
+++ b/drivers/timer/sh4_timer.c
@@ -1,12 +1,6 @@
11 /*
2- * (C) Copyright 2009
3- * Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
4- *
5- * (C) Copyright 2007-2012
6- * Nobobuhiro Iwamatsu <iwamatsu@nigauri.org>
7- *
8- * (C) Copyright 2003
9- * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
2+ * (C) Copyright 2016
3+ * Yoshinori Sato <ysato@users.sourceforge.jp>
104 *
115 * SPDX-License-Identifier: GPL-2.0+
126 */