int __weak soc_clk_dump(void) { #if defined(CONFIG_DM) && defined(CONFIG_CLK) struct udevice *dev; struct uclass *uc; struct clk clk; int ret; /* Device addresses start at 1 */ ret = uclass_get(UCLASS_CLK, &uc); if (ret) return ret; uclass_foreach_dev(dev, uc) { memset(&clk, 0, sizeof(clk)); ret = device_probe(dev); if (ret) { printf("%-30.30s : ? Hz\n", dev->name); continue; } ret = clk_request(dev, &clk); if (ret) { printf("%-30.30s : ? Hz\n", dev->name); continue; } printf("%-30.30s : %lu Hz\n", dev->name, clk_get_rate(&clk)); clk_free(&clk); }
int timer_init(void) { const u32 emask = SCUTIMER_CONTROL_AUTO_RELOAD_MASK | (TIMER_PRESCALE << SCUTIMER_CONTROL_PRESCALER_SHIFT) | SCUTIMER_CONTROL_ENABLE_MASK; struct udevice *dev; struct clk clk; int ret; ret = uclass_get_device_by_driver(UCLASS_CLK, DM_GET_DRIVER(zynq_clk), &dev); if (ret) return ret; clk.id = cpu_6or4x_clk; ret = clk_request(dev, &clk); if (ret < 0) return ret; gd->cpu_clk = clk_get_rate(&clk); clk_free(&clk); gd->arch.timer_rate_hz = (gd->cpu_clk / 2) / (TIMER_PRESCALE + 1); /* Load the timer counter register */ writel(0xFFFFFFFF, &timer_base->load); /* * Start the A9Timer device * Enable Auto reload mode, Clear prescaler control bits * Set prescaler value, Enable the decrementer */ clrsetbits_le32(&timer_base->control, SCUTIMER_CONTROL_PRESCALER_MASK, emask); /* Reset time */ gd->arch.lastinc = readl(&timer_base->counter) / (gd->arch.timer_rate_hz / CONFIG_SYS_HZ); gd->arch.tbl = 0; return 0; }
static int do_clock(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { static const struct { char *name; int id; } clks[] = { { "osc", CLK_OSC }, { "apll", CLK_ARM }, { "dpll", CLK_DDR }, { "cpll", CLK_CODEC }, { "gpll", CLK_GENERAL }, #ifdef CONFIG_ROCKCHIP_RK3036 { "mpll", CLK_NEW }, #else { "npll", CLK_NEW }, #endif }; int ret, i; struct udevice *dev; ret = rockchip_get_clk(&dev); if (ret) { printf("clk-uclass not found\n"); return 0; } for (i = 0; i < ARRAY_SIZE(clks); i++) { struct clk clk; ulong rate; clk.id = clks[i].id; ret = clk_request(dev, &clk); if (ret < 0) continue; rate = clk_get_rate(&clk); printf("%s: %lu\n", clks[i].name, rate); clk_free(&clk); } return 0; }
int clk_get_by_index(struct udevice *dev, int index, struct clk *clk) { int ret; struct ofnode_phandle_args args; struct udevice *dev_clk; struct clk_ops *ops; debug("%s(dev=%p, index=%d, clk=%p)\n", __func__, dev, index, clk); assert(clk); clk->dev = NULL; ret = dev_read_phandle_with_args(dev, "clocks", "#clock-cells", 0, index, &args); if (ret) { debug("%s: fdtdec_parse_phandle_with_args failed: err=%d\n", __func__, ret); return ret; } ret = uclass_get_device_by_ofnode(UCLASS_CLK, args.node, &dev_clk); if (ret) { debug("%s: uclass_get_device_by_of_offset failed: err=%d\n", __func__, ret); return ret; } clk->dev = dev_clk; ops = clk_dev_ops(dev_clk); if (ops->of_xlate) ret = ops->of_xlate(clk, &args); else ret = clk_of_xlate_default(clk, &args); if (ret) { debug("of_xlate() failed: %d\n", ret); return ret; } return clk_request(dev_clk, clk); }
static int setup_arm_clock(void) { struct udevice *dev; struct clk clk; int ret; ret = rockchip_get_clk(&dev); if (ret) return ret; clk.id = CLK_ARM; ret = clk_request(dev, &clk); if (ret < 0) return ret; ret = clk_set_rate(&clk, 600000000); clk_free(&clk); return ret; }