Skip to content

Commit 611fbca

Browse files
jbrun3tgregkh
authored andcommitted
nvmem: meson-efuse: add peripheral clock
Get and enable the peripheral clock required by the efuse device. The driver has been handle to work without it so far because the clock was left enabled by default but it won't be the case soon. Signed-off-by: Jerome Brunet <jbrunet@baylibre.com> Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent a91ae34 commit 611fbca

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

drivers/nvmem/meson-efuse.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* more details.
1515
*/
1616

17+
#include <linux/clk.h>
1718
#include <linux/module.h>
1819
#include <linux/nvmem-provider.h>
1920
#include <linux/of.h>
@@ -46,7 +47,31 @@ static int meson_efuse_probe(struct platform_device *pdev)
4647
struct device *dev = &pdev->dev;
4748
struct nvmem_device *nvmem;
4849
struct nvmem_config *econfig;
50+
struct clk *clk;
4951
unsigned int size;
52+
int ret;
53+
54+
clk = devm_clk_get(dev, NULL);
55+
if (IS_ERR(clk)) {
56+
ret = PTR_ERR(clk);
57+
if (ret != -EPROBE_DEFER)
58+
dev_err(dev, "failed to get efuse gate");
59+
return ret;
60+
}
61+
62+
ret = clk_prepare_enable(clk);
63+
if (ret) {
64+
dev_err(dev, "failed to enable gate");
65+
return ret;
66+
}
67+
68+
ret = devm_add_action_or_reset(dev,
69+
(void(*)(void *))clk_disable_unprepare,
70+
clk);
71+
if (ret) {
72+
dev_err(dev, "failed to add disable callback");
73+
return ret;
74+
}
5075

5176
if (meson_sm_call(SM_EFUSE_USER_MAX, &size, 0, 0, 0, 0, 0) < 0) {
5277
dev_err(dev, "failed to get max user");

0 commit comments

Comments
 (0)