static void __init of_dra7_apll_setup(struct device_node *node) { struct dpll_data *ad = NULL; struct clk_hw_omap *clk_hw = NULL; struct clk_init_data *init = NULL; const char **parent_names = NULL; int i; ad = kzalloc(sizeof(*ad), GFP_KERNEL); clk_hw = kzalloc(sizeof(*clk_hw), GFP_KERNEL); init = kzalloc(sizeof(*init), GFP_KERNEL); if (!ad || !clk_hw || !init) goto cleanup; clk_hw->dpll_data = ad; clk_hw->hw.init = init; clk_hw->flags = MEMMAP_ADDRESSING; init->name = node->name; init->ops = &apll_ck_ops; init->num_parents = of_clk_get_parent_count(node); if (init->num_parents < 1) { pr_err("dra7 apll %s must have parent(s)\n", node->name); goto cleanup; } parent_names = kzalloc(sizeof(char *) * init->num_parents, GFP_KERNEL); if (!parent_names) goto cleanup; for (i = 0; i < init->num_parents; i++) parent_names[i] = of_clk_get_parent_name(node, i); init->parent_names = parent_names; ad->control_reg = ti_clk_get_reg_addr(node, 0); ad->idlest_reg = ti_clk_get_reg_addr(node, 1); if (!ad->control_reg || !ad->idlest_reg) goto cleanup; ad->idlest_mask = 0x1; ad->enable_mask = 0x3; omap_clk_register_apll(&clk_hw->hw, node); return; cleanup: kfree(parent_names); kfree(ad); kfree(clk_hw); kfree(init); }
void __init of_dra7_apll_setup(struct device_node *node) { const struct clk_ops *ops; struct clk *clk; const char *clk_name = node->name; int num_parents; const char **parent_names = NULL; u8 apll_flags = 0; struct dpll_data *ad; u32 idlest_mask = 0x1; u32 autoidle_mask = 0x3; int i; ops = &apll_ck_ops; ad = kzalloc(sizeof(*ad), GFP_KERNEL); if (!ad) { pr_err("%s: could not allocate dpll_data\n", __func__); return; } of_property_read_string(node, "clock-output-names", &clk_name); num_parents = of_clk_get_parent_count(node); if (num_parents < 1) { pr_err("%s: omap dpll %s must have parent(s)\n", __func__, node->name); goto cleanup; } parent_names = kzalloc(sizeof(char *) * num_parents, GFP_KERNEL); for (i = 0; i < num_parents; i++) parent_names[i] = of_clk_get_parent_name(node, i); ad->clk_ref = of_clk_get(node, 0); ad->clk_bypass = of_clk_get(node, 1); if (IS_ERR(ad->clk_ref)) { pr_err("%s: ti,clk-ref for %s not found\n", __func__, clk_name); goto cleanup; } if (IS_ERR(ad->clk_bypass)) { pr_err("%s: ti,clk-bypass for %s not found\n", __func__, clk_name); goto cleanup; } i = of_property_match_string(node, "reg-names", "control"); if (i >= 0) ad->control_reg = of_iomap(node, i); i = of_property_match_string(node, "reg-names", "idlest"); if (i >= 0) ad->idlest_reg = of_iomap(node, i); ad->idlest_mask = idlest_mask; ad->enable_mask = autoidle_mask; clk = omap_clk_register_apll(NULL, clk_name, parent_names, num_parents, apll_flags, ad, NULL, ops); if (!IS_ERR(clk)) of_clk_add_provider(node, of_clk_src_simple_get, clk); return; cleanup: kfree(parent_names); kfree(ad); return; }