Commit 526ca8dc authored by Antti Palosaari's avatar Antti Palosaari Committed by Mauro Carvalho Chehab

[media] rtl28xxu: use masked reg write where possible

Use masked register write inside rtl2832u_power_ctrl().
Signed-off-by: default avatarAntti Palosaari <crope@iki.fi>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent bc6fc53d
...@@ -1041,67 +1041,34 @@ static int rtl2831u_power_ctrl(struct dvb_usb_device *d, int onoff) ...@@ -1041,67 +1041,34 @@ static int rtl2831u_power_ctrl(struct dvb_usb_device *d, int onoff)
static int rtl2832u_power_ctrl(struct dvb_usb_device *d, int onoff) static int rtl2832u_power_ctrl(struct dvb_usb_device *d, int onoff)
{ {
int ret; int ret;
u8 val;
dev_dbg(&d->udev->dev, "%s: onoff=%d\n", __func__, onoff); dev_dbg(&d->udev->dev, "%s: onoff=%d\n", __func__, onoff);
if (onoff) { if (onoff) {
/* set output values */ /* GPIO3=1, GPIO4=0 */
ret = rtl28xx_rd_reg(d, SYS_GPIO_OUT_VAL, &val); ret = rtl28xx_wr_reg_mask(d, SYS_GPIO_OUT_VAL, 0x08, 0x18);
if (ret)
goto err;
val |= 0x08;
val &= 0xef;
ret = rtl28xx_wr_reg(d, SYS_GPIO_OUT_VAL, val);
if (ret)
goto err;
/* demod_ctl_1 */
ret = rtl28xx_rd_reg(d, SYS_DEMOD_CTL1, &val);
if (ret)
goto err;
val &= 0xef;
ret = rtl28xx_wr_reg(d, SYS_DEMOD_CTL1, val);
if (ret)
goto err;
/* demod control */
/* PLL enable */
ret = rtl28xx_rd_reg(d, SYS_DEMOD_CTL, &val);
if (ret) if (ret)
goto err; goto err;
/* bit 7 to 1 */ /* suspend? */
val |= 0x80; ret = rtl28xx_wr_reg_mask(d, SYS_DEMOD_CTL1, 0x00, 0x10);
ret = rtl28xx_wr_reg(d, SYS_DEMOD_CTL, val);
if (ret) if (ret)
goto err; goto err;
ret = rtl28xx_rd_reg(d, SYS_DEMOD_CTL, &val); /* enable PLL */
ret = rtl28xx_wr_reg_mask(d, SYS_DEMOD_CTL, 0x80, 0x80);
if (ret) if (ret)
goto err; goto err;
val |= 0x20; /* disable reset */
ret = rtl28xx_wr_reg_mask(d, SYS_DEMOD_CTL, 0x20, 0x20);
ret = rtl28xx_wr_reg(d, SYS_DEMOD_CTL, val);
if (ret) if (ret)
goto err; goto err;
mdelay(5); mdelay(5);
/*enable ADC_Q and ADC_I */ /* enable ADC */
ret = rtl28xx_rd_reg(d, SYS_DEMOD_CTL, &val); ret = rtl28xx_wr_reg_mask(d, SYS_DEMOD_CTL, 0x48, 0x48);
if (ret)
goto err;
val |= 0x48;
ret = rtl28xx_wr_reg(d, SYS_DEMOD_CTL, val);
if (ret) if (ret)
goto err; goto err;
...@@ -1114,25 +1081,18 @@ static int rtl2832u_power_ctrl(struct dvb_usb_device *d, int onoff) ...@@ -1114,25 +1081,18 @@ static int rtl2832u_power_ctrl(struct dvb_usb_device *d, int onoff)
if (ret) if (ret)
goto err; goto err;
} else { } else {
/* set output values */ /* GPIO4=1 */
ret = rtl28xx_rd_reg(d, SYS_GPIO_OUT_VAL, &val); ret = rtl28xx_wr_reg_mask(d, SYS_GPIO_OUT_VAL, 0x10, 0x10);
if (ret)
goto err;
val |= 0x10;
ret = rtl28xx_wr_reg(d, SYS_GPIO_OUT_VAL, val);
if (ret) if (ret)
goto err; goto err;
/* demod control */ /* disable ADC */
ret = rtl28xx_rd_reg(d, SYS_DEMOD_CTL, &val); ret = rtl28xx_wr_reg_mask(d, SYS_DEMOD_CTL, 0x00, 0x48);
if (ret) if (ret)
goto err; goto err;
val &= 0x37; /* disable PLL */
ret = rtl28xx_wr_reg_mask(d, SYS_DEMOD_CTL, 0x00, 0x80);
ret = rtl28xx_wr_reg(d, SYS_DEMOD_CTL, val);
if (ret) if (ret)
goto err; goto err;
......
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