1 // SPDX-License-Identifier: GPL-2.0-or-later
5 * NetUP Dual DVB-S2 CI driver
7 * Copyright (C) 2009 NetUP Inc.
8 * Copyright (C) 2009 Igor M. Liplianin <liplianin@netup.ru>
9 * Copyright (C) 2009 Abylay Ospan <aospan@netup.ru>
13 #include "netup-init.h"
15 static void i2c_av_write(struct i2c_adapter
*i2c
, u16 reg
, u8 val
)
19 struct i2c_msg msg
= {
30 ret
= i2c_transfer(i2c
, &msg
, 1);
33 pr_err("%s: i2c write error!\n", __func__
);
36 static void i2c_av_write4(struct i2c_adapter
*i2c
, u16 reg
, u32 val
)
40 struct i2c_msg msg
= {
50 buf
[3] = (val
>> 8) & 0xff;
51 buf
[4] = (val
>> 16) & 0xff;
54 ret
= i2c_transfer(i2c
, &msg
, 1);
57 pr_err("%s: i2c write error!\n", __func__
);
60 static u8
i2c_av_read(struct i2c_adapter
*i2c
, u16 reg
)
64 struct i2c_msg msg
= {
74 ret
= i2c_transfer(i2c
, &msg
, 1);
77 pr_err("%s: i2c write error!\n", __func__
);
82 ret
= i2c_transfer(i2c
, &msg
, 1);
85 pr_err("%s: i2c read error!\n", __func__
);
90 static void i2c_av_and_or(struct i2c_adapter
*i2c
, u16 reg
, unsigned and_mask
,
93 i2c_av_write(i2c
, reg
, (i2c_av_read(i2c
, reg
) & and_mask
) | or_value
);
95 /* set 27MHz on AUX_CLK */
96 void netup_initialize(struct cx23885_dev
*dev
)
98 struct cx23885_i2c
*i2c_bus
= &dev
->i2c_bus
[2];
99 struct i2c_adapter
*i2c
= &i2c_bus
->i2c_adap
;
101 /* Stop microcontroller */
102 i2c_av_and_or(i2c
, 0x803, ~0x10, 0x00);
104 /* Aux PLL frac for 27 MHz */
105 i2c_av_write4(i2c
, 0x114, 0xea0eb3);
107 /* Aux PLL int for 27 MHz */
108 i2c_av_write4(i2c
, 0x110, 0x090319);
110 /* start microcontroller */
111 i2c_av_and_or(i2c
, 0x803, ~0x10, 0x10);