Thomas Gleixner | c942fdd | 2019-05-27 08:55:06 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
Emilio López | e277154 | 2014-07-18 15:49:37 -0300 | [diff] [blame] | 2 | /* |
| 3 | * Copyright 2013 Emilio López |
| 4 | * |
| 5 | * Emilio López <emilio@elopez.com.ar> |
Emilio López | e277154 | 2014-07-18 15:49:37 -0300 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | #include <linux/clk-provider.h> |
| 9 | #include <linux/of.h> |
| 10 | #include <linux/of_address.h> |
| 11 | |
| 12 | #define SUN4I_CODEC_GATE 31 |
| 13 | |
| 14 | static void __init sun4i_codec_clk_setup(struct device_node *node) |
| 15 | { |
| 16 | struct clk *clk; |
| 17 | const char *clk_name = node->name, *parent_name; |
| 18 | void __iomem *reg; |
| 19 | |
| 20 | reg = of_io_request_and_map(node, 0, of_node_full_name(node)); |
| 21 | if (IS_ERR(reg)) |
| 22 | return; |
| 23 | |
| 24 | of_property_read_string(node, "clock-output-names", &clk_name); |
| 25 | parent_name = of_clk_get_parent_name(node, 0); |
| 26 | |
| 27 | clk = clk_register_gate(NULL, clk_name, parent_name, |
| 28 | CLK_SET_RATE_PARENT, reg, |
| 29 | SUN4I_CODEC_GATE, 0, NULL); |
| 30 | |
| 31 | if (!IS_ERR(clk)) |
| 32 | of_clk_add_provider(node, of_clk_src_simple_get, clk); |
| 33 | } |
| 34 | CLK_OF_DECLARE(sun4i_codec, "allwinner,sun4i-a10-codec-clk", |
| 35 | sun4i_codec_clk_setup); |