diff options
author | Antti Palosaari <crope@iki.fi> | 2017-06-14 03:58:06 +0200 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@s-opensource.com> | 2017-06-20 15:35:08 +0200 |
commit | cdd19b526f5b806ff0468cec1d429feffaf10c89 (patch) | |
tree | 4204bfbe55fd09fca0266afe63916e68be7ee8c2 /drivers/media/dvb-frontends | |
parent | [media] af9013: refactor firmware download routine (diff) | |
download | linux-cdd19b526f5b806ff0468cec1d429feffaf10c89.tar.xz linux-cdd19b526f5b806ff0468cec1d429feffaf10c89.zip |
[media] af9013: refactor power control
Move power-up and power-down functionality to init/sleep ops and
get rid of old function.
Fixes and simplifies power-up functionality slightly.
Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Diffstat (limited to 'drivers/media/dvb-frontends')
-rw-r--r-- | drivers/media/dvb-frontends/af9013.c | 93 |
1 files changed, 36 insertions, 57 deletions
diff --git a/drivers/media/dvb-frontends/af9013.c b/drivers/media/dvb-frontends/af9013.c index 8408e155b6f5..b8f3ebfc3e27 100644 --- a/drivers/media/dvb-frontends/af9013.c +++ b/drivers/media/dvb-frontends/af9013.c @@ -101,59 +101,6 @@ err: return ret; } -static int af9013_power_ctrl(struct af9013_state *state, u8 onoff) -{ - struct i2c_client *client = state->client; - int ret; - unsigned int utmp; - - dev_dbg(&client->dev, "onoff %d\n", onoff); - - /* enable reset */ - ret = regmap_update_bits(state->regmap, 0xd417, 0x10, 0x10); - if (ret) - goto err; - - /* start reset mechanism */ - ret = regmap_write(state->regmap, 0xaeff, 0x01); - if (ret) - goto err; - - /* wait reset performs */ - ret = regmap_read_poll_timeout(state->regmap, 0xd417, utmp, - (utmp >> 1) & 0x01, 5000, 1000000); - if (ret) - goto err; - - if (!((utmp >> 1) & 0x01)) - return -ETIMEDOUT; - - if (onoff) { - /* clear reset */ - ret = regmap_update_bits(state->regmap, 0xd417, 0x02, 0x00); - if (ret) - goto err; - /* disable reset */ - ret = regmap_update_bits(state->regmap, 0xd417, 0x10, 0x00); - if (ret) - goto err; - /* power on */ - ret = regmap_update_bits(state->regmap, 0xd73a, 0x08, 0x00); - if (ret) - goto err; - } else { - /* power off */ - ret = regmap_update_bits(state->regmap, 0xd73a, 0x08, 0x08); - if (ret) - goto err; - } - - return 0; -err: - dev_dbg(&client->dev, "failed %d\n", ret); - return ret; -} - static int af9013_statistics_ber_unc_start(struct dvb_frontend *fe) { struct af9013_state *state = fe->demodulator_priv; @@ -890,8 +837,18 @@ static int af9013_init(struct dvb_frontend *fe) dev_dbg(&client->dev, "\n"); - /* power on */ - ret = af9013_power_ctrl(state, 1); + /* ADC on */ + ret = regmap_update_bits(state->regmap, 0xd73a, 0x08, 0x00); + if (ret) + goto err; + + /* Clear reset */ + ret = regmap_update_bits(state->regmap, 0xd417, 0x02, 0x00); + if (ret) + goto err; + + /* Disable reset */ + ret = regmap_update_bits(state->regmap, 0xd417, 0x10, 0x00); if (ret) goto err; @@ -1071,6 +1028,7 @@ static int af9013_sleep(struct dvb_frontend *fe) struct af9013_state *state = fe->demodulator_priv; struct i2c_client *client = state->client; int ret; + unsigned int utmp; dev_dbg(&client->dev, "\n"); @@ -1082,8 +1040,29 @@ static int af9013_sleep(struct dvb_frontend *fe) if (ret) goto err; - /* power off */ - ret = af9013_power_ctrl(state, 0); + /* Enable reset */ + ret = regmap_update_bits(state->regmap, 0xd417, 0x10, 0x10); + if (ret) + goto err; + + /* Start reset execution */ + ret = regmap_write(state->regmap, 0xaeff, 0x01); + if (ret) + goto err; + + /* Wait reset performs */ + ret = regmap_read_poll_timeout(state->regmap, 0xd417, utmp, + (utmp >> 1) & 0x01, 5000, 1000000); + if (ret) + goto err; + + if (!((utmp >> 1) & 0x01)) { + ret = -ETIMEDOUT; + goto err; + } + + /* ADC off */ + ret = regmap_update_bits(state->regmap, 0xd73a, 0x08, 0x08); if (ret) goto err; |