• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

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

Commit MetaInfo

Revision277fa69f11b19c0cb07940161a0316c789a49da0 (tree)
Time2020-07-26 18:03:24
AuthorYoshinori Sato <ysato@user...>
CommiterYoshinori Sato

Log Message

update rx-timer

Change Summary

Incremental Difference

--- a/drivers/timer/rx_timer.c
+++ b/drivers/timer/rx_timer.c
@@ -23,22 +23,23 @@
2323 #include <common.h>
2424 #include <dm.h>
2525 #include <timer.h>
26+#include <clk.h>
27+#include <fdtdec.h>
2628 #include <asm/io.h>
2729
2830 DECLARE_GLOBAL_DATA_PTR;
2931
30-struct rx_timer_platdata {
31- unsigned char *regs;
32- int unit;
32+struct rx_timer_priv {
33+ unsigned char *base;
3334 };
3435
3536 static int timer_read_counter(struct udevice *dev, u64 *count)
3637 {
37- struct rx_timer_platdata *plat = dev_get_platdata(dev);
38+ struct rx_timer_priv *priv = dev_get_priv(dev);
3839 u32 tcnt;
3940
40- tcnt = (readw(plat->regs + (plat->unit * 0x0400) + 0x186) << 16) & 0xffff0000;
41- tcnt |= (readw(plat->regs + (plat->unit * 0x0400) + 0x206) & 0xffff);
41+ tcnt = (readw(priv->base + 0x186) << 16) & 0xffff0000;
42+ tcnt |= (readw(priv->base + 0x206) & 0xffff);
4243 *count = timer_conv_64(tcnt);
4344
4445 return 0;
@@ -46,22 +47,30 @@ static int timer_read_counter(struct udevice *dev, u64 *count)
4647
4748 static int rx_timer_probe(struct udevice *dev)
4849 {
49- struct rx_timer_platdata *plat = dev_get_platdata(dev);
50+ struct timer_dev_priv *uc_priv = dev_get_uclass_priv(dev);
51+ struct rx_timer_priv *priv = dev_get_priv(dev);
52+ struct clk clk;
53+ fdt_addr_t addr;
54+ int ret;
55+ u32 rate;
5056
51- writeb(0x07, plat->regs + (plat->unit * 0x0400) + 0x180);
52- writeb(0x07, plat->regs + (plat->unit * 0x0400) + 0x200);
53- writeb(0x06, plat->regs + (plat->unit * 0x0400) + 0x080);
57+ addr = dev_read_addr(dev);
58+ if (addr == FDT_ADDR_T_NONE)
59+ return -EINVAL;
5460
55- return 0;
56-}
61+ priv->base = (unsigned char *)addr;
5762
58-static int rx_timer_ofdata_to_platdata(struct udevice *dev)
59-{
60- struct rx_timer_platdata *plat = dev_get_platdata(dev);
63+ ret = clk_get_by_index(dev, 0, &clk);
64+ if (ret < 0)
65+ return ret;
66+ rate = clk_get_rate(&clk);
67+ rate /= 1024;
68+ uc_priv->clock_rate = rate;
69+
70+ writeb(0x07, addr + 0x180);
71+ writeb(0x07, addr + 0x200);
72+ writeb(0x06, addr + 0x080);
6173
62- plat->regs = map_physmem(dev_read_addr(dev), 0x0700, MAP_NOCACHE);
63- plat->unit = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
64- "renesas,unit", 0);
6574 return 0;
6675 }
6776
@@ -78,9 +87,7 @@ U_BOOT_DRIVER(rx_timer) = {
7887 .name = "rx_timer",
7988 .id = UCLASS_TIMER,
8089 .of_match = rx_timer_ids,
81- .ofdata_to_platdata = rx_timer_ofdata_to_platdata,
82- .platdata_auto_alloc_size = sizeof(struct rx_timer_platdata),
90+ .priv_auto_alloc_size = sizeof(struct rx_timer_priv),
8391 .probe = rx_timer_probe,
8492 .ops = &rx_timer_ops,
85- .flags = DM_FLAG_PRE_RELOC,
8693 };