Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

clk: max77686: Register OF clock provider

If max77686 chip is instantiated from device tree, it is desirable to
have an OF clock provider to allow device tree based look-up of clocks.
This patch adds OF clock provider registration to the clk-max77686
driver.

Signed-off-by: Tomasz Figa <t.figa@samsung.com>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Mike Turquette <mturquette@linaro.org>

authored by

Tomasz Figa and committed by
Mike Turquette
b06c6987 3966c947

+65
+38
Documentation/devicetree/bindings/clock/maxim,max77686.txt
··· 1 + Binding for Maxim MAX77686 32k clock generator block 2 + 3 + This is a part of device tree bindings of MAX77686 multi-function device. 4 + More information can be found in bindings/mfd/max77686.txt file. 5 + 6 + The MAX77686 contains three 32.768khz clock outputs that can be controlled 7 + (gated/ungated) over I2C. 8 + 9 + Following properties should be presend in main device node of the MFD chip. 10 + 11 + Required properties: 12 + - #clock-cells: simple one-cell clock specifier format is used, where the 13 + only cell is used as an index of the clock inside the provider. Following 14 + indices are allowed: 15 + - 0: 32khz_ap clock, 16 + - 1: 32khz_cp clock, 17 + - 2: 32khz_pmic clock. 18 + 19 + Example: Node of the MFD chip 20 + 21 + max77686: max77686@09 { 22 + compatible = "maxim,max77686"; 23 + interrupt-parent = <&wakeup_eint>; 24 + interrupts = <26 0>; 25 + reg = <0x09>; 26 + #clock-cells = <1>; 27 + 28 + /* ... */ 29 + }; 30 + 31 + Example: Clock consumer node 32 + 33 + foo@0 { 34 + compatible = "bar,foo"; 35 + /* ... */ 36 + clock-names = "my-clock"; 37 + clocks = <&max77686 2>; 38 + };
+3
Documentation/devicetree/bindings/mfd/max77686.txt
··· 7 7 client while probing.This document describes the binding for mfd device and 8 8 PMIC submodule. 9 9 10 + Binding for the built-in 32k clock generator block is defined separately 11 + in bindings/clk/maxim,max77686.txt file. 12 + 10 13 Required properties: 11 14 - compatible : Must be "maxim,max77686"; 12 15 - reg : Specifies the i2c slave address of PMIC block.
+24
drivers/clk/clk-max77686.c
··· 169 169 170 170 platform_set_drvdata(pdev, clocks); 171 171 172 + if (iodev->dev->of_node) { 173 + struct clk_onecell_data *of_data; 174 + 175 + of_data = devm_kzalloc(&pdev->dev, 176 + sizeof(*of_data), GFP_KERNEL); 177 + if (!of_data) { 178 + ret = -ENOMEM; 179 + goto err_clocks; 180 + } 181 + 182 + of_data->clks = clocks; 183 + of_data->clk_num = MAX77686_CLKS_NUM; 184 + ret = of_clk_add_provider(iodev->dev->of_node, 185 + of_clk_src_onecell_get, of_data); 186 + if (ret) { 187 + dev_err(&pdev->dev, "failed to register OF clock provider\n"); 188 + goto err_clocks; 189 + } 190 + } 191 + 172 192 return 0; 173 193 174 194 err_clocks: ··· 202 182 203 183 static int max77686_clk_remove(struct platform_device *pdev) 204 184 { 185 + struct max77686_dev *iodev = dev_get_drvdata(pdev->dev.parent); 205 186 struct clk **clocks = platform_get_drvdata(pdev); 206 187 int i; 188 + 189 + if (iodev->dev->of_node) 190 + of_clk_del_provider(iodev->dev->of_node); 207 191 208 192 for (i = 0; i < MAX77686_CLKS_NUM; i++) { 209 193 struct clk_hw *hw = __clk_get_hw(clocks[i]);