| .. | .. |
|---|
| 3 | 3 | * Copyright (C) 2017, Intel Corporation |
|---|
| 4 | 4 | */ |
|---|
| 5 | 5 | #include <linux/clk-provider.h> |
|---|
| 6 | +#include <linux/io.h> |
|---|
| 6 | 7 | #include <linux/slab.h> |
|---|
| 7 | 8 | #include "stratix10-clk.h" |
|---|
| 8 | 9 | #include "clk.h" |
|---|
| .. | .. |
|---|
| 64 | 65 | .get_parent = socfpga_gate_get_parent, |
|---|
| 65 | 66 | }; |
|---|
| 66 | 67 | |
|---|
| 67 | | -struct clk *s10_register_gate(const char *name, const char *parent_name, |
|---|
| 68 | | - const char * const *parent_names, |
|---|
| 69 | | - u8 num_parents, unsigned long flags, |
|---|
| 70 | | - void __iomem *regbase, unsigned long gate_reg, |
|---|
| 71 | | - unsigned long gate_idx, unsigned long div_reg, |
|---|
| 72 | | - unsigned long div_offset, u8 div_width, |
|---|
| 73 | | - unsigned long bypass_reg, u8 bypass_shift, |
|---|
| 74 | | - u8 fixed_div) |
|---|
| 68 | +struct clk *s10_register_gate(const struct stratix10_gate_clock *clks, void __iomem *regbase) |
|---|
| 75 | 69 | { |
|---|
| 76 | 70 | struct clk *clk; |
|---|
| 77 | 71 | struct socfpga_gate_clk *socfpga_clk; |
|---|
| 78 | | - struct clk_init_data init = {}; |
|---|
| 72 | + struct clk_init_data init; |
|---|
| 73 | + const char *parent_name = clks->parent_name; |
|---|
| 79 | 74 | |
|---|
| 80 | 75 | socfpga_clk = kzalloc(sizeof(*socfpga_clk), GFP_KERNEL); |
|---|
| 81 | 76 | if (!socfpga_clk) |
|---|
| 82 | 77 | return NULL; |
|---|
| 83 | 78 | |
|---|
| 84 | | - socfpga_clk->hw.reg = regbase + gate_reg; |
|---|
| 85 | | - socfpga_clk->hw.bit_idx = gate_idx; |
|---|
| 79 | + socfpga_clk->hw.reg = regbase + clks->gate_reg; |
|---|
| 80 | + socfpga_clk->hw.bit_idx = clks->gate_idx; |
|---|
| 86 | 81 | |
|---|
| 87 | 82 | gateclk_ops.enable = clk_gate_ops.enable; |
|---|
| 88 | 83 | gateclk_ops.disable = clk_gate_ops.disable; |
|---|
| 89 | 84 | |
|---|
| 90 | | - socfpga_clk->fixed_div = fixed_div; |
|---|
| 85 | + socfpga_clk->fixed_div = clks->fixed_div; |
|---|
| 91 | 86 | |
|---|
| 92 | | - if (div_reg) |
|---|
| 93 | | - socfpga_clk->div_reg = regbase + div_reg; |
|---|
| 87 | + if (clks->div_reg) |
|---|
| 88 | + socfpga_clk->div_reg = regbase + clks->div_reg; |
|---|
| 94 | 89 | else |
|---|
| 95 | 90 | socfpga_clk->div_reg = NULL; |
|---|
| 96 | 91 | |
|---|
| 97 | | - socfpga_clk->width = div_width; |
|---|
| 98 | | - socfpga_clk->shift = div_offset; |
|---|
| 92 | + socfpga_clk->width = clks->div_width; |
|---|
| 93 | + socfpga_clk->shift = clks->div_offset; |
|---|
| 99 | 94 | |
|---|
| 100 | | - if (bypass_reg) |
|---|
| 101 | | - socfpga_clk->bypass_reg = regbase + bypass_reg; |
|---|
| 95 | + if (clks->bypass_reg) |
|---|
| 96 | + socfpga_clk->bypass_reg = regbase + clks->bypass_reg; |
|---|
| 102 | 97 | else |
|---|
| 103 | 98 | socfpga_clk->bypass_reg = NULL; |
|---|
| 104 | | - socfpga_clk->bypass_shift = bypass_shift; |
|---|
| 99 | + socfpga_clk->bypass_shift = clks->bypass_shift; |
|---|
| 105 | 100 | |
|---|
| 106 | | - if (streq(name, "cs_pdbg_clk")) |
|---|
| 101 | + if (streq(clks->name, "cs_pdbg_clk")) |
|---|
| 107 | 102 | init.ops = &dbgclk_ops; |
|---|
| 108 | 103 | else |
|---|
| 109 | 104 | init.ops = &gateclk_ops; |
|---|
| 110 | 105 | |
|---|
| 111 | | - init.name = name; |
|---|
| 112 | | - init.flags = flags; |
|---|
| 106 | + init.name = clks->name; |
|---|
| 107 | + init.flags = clks->flags; |
|---|
| 113 | 108 | |
|---|
| 114 | | - init.num_parents = num_parents; |
|---|
| 115 | | - init.parent_names = parent_names ? parent_names : &parent_name; |
|---|
| 109 | + init.num_parents = clks->num_parents; |
|---|
| 110 | + init.parent_names = parent_name ? &parent_name : NULL; |
|---|
| 111 | + if (init.parent_names == NULL) |
|---|
| 112 | + init.parent_data = clks->parent_data; |
|---|
| 116 | 113 | socfpga_clk->hw.hw.init = &init; |
|---|
| 117 | 114 | |
|---|
| 118 | 115 | clk = clk_register(NULL, &socfpga_clk->hw.hw); |
|---|
| .. | .. |
|---|
| 120 | 117 | kfree(socfpga_clk); |
|---|
| 121 | 118 | return NULL; |
|---|
| 122 | 119 | } |
|---|
| 123 | | - |
|---|
| 124 | 120 | return clk; |
|---|
| 125 | 121 | } |
|---|