Commit c567fb37 authored by Khiem Nguyen's avatar Khiem Nguyen Committed by Stephen Boyd

clk: cs2000: add Suspend/Resume feature

CS2000 needs re-setup when redume, otherwise, it can't
handle correct clock rate.
Signed-off-by: default avatarKhiem Nguyen <khiem.nguyen.xt@rvc.renesas.com>
[Kuninori: cleanup original patch]
Signed-off-by: default avatarKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: default avatarStephen Boyd <sboyd@codeaurora.org>
parent 3e1aec4e
...@@ -59,6 +59,10 @@ struct cs2000_priv { ...@@ -59,6 +59,10 @@ struct cs2000_priv {
struct i2c_client *client; struct i2c_client *client;
struct clk *clk_in; struct clk *clk_in;
struct clk *ref_clk; struct clk *ref_clk;
/* suspend/resume */
unsigned long saved_rate;
unsigned long saved_parent_rate;
}; };
static const struct of_device_id cs2000_of_match[] = { static const struct of_device_id cs2000_of_match[] = {
...@@ -286,6 +290,9 @@ static int __cs2000_set_rate(struct cs2000_priv *priv, int ch, ...@@ -286,6 +290,9 @@ static int __cs2000_set_rate(struct cs2000_priv *priv, int ch,
if (ret < 0) if (ret < 0)
return ret; return ret;
priv->saved_rate = rate;
priv->saved_parent_rate = parent_rate;
return 0; return 0;
} }
...@@ -489,9 +496,24 @@ static int cs2000_probe(struct i2c_client *client, ...@@ -489,9 +496,24 @@ static int cs2000_probe(struct i2c_client *client,
return ret; return ret;
} }
static int cs2000_resume(struct device *dev)
{
struct cs2000_priv *priv = dev_get_drvdata(dev);
int ch = 0; /* it uses ch0 only at this point */
return __cs2000_set_rate(priv, ch,
priv->saved_rate,
priv->saved_parent_rate);
}
static const struct dev_pm_ops cs2000_pm_ops = {
.resume_early = cs2000_resume,
};
static struct i2c_driver cs2000_driver = { static struct i2c_driver cs2000_driver = {
.driver = { .driver = {
.name = "cs2000-cp", .name = "cs2000-cp",
.pm = &cs2000_pm_ops,
.of_match_table = cs2000_of_match, .of_match_table = cs2000_of_match,
}, },
.probe = cs2000_probe, .probe = cs2000_probe,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment