diff mbox series

[1/3] adv748x: afe: Select input port when device is reset

Message ID 20201122163637.3590465-2-niklas.soderlund+renesas@ragnatech.se
State Accepted
Commit c30ed81afe890eb021cb4737fa82c127817b5e69
Headers show
Series [1/3] adv748x: afe: Select input port when device is reset | expand

Commit Message

Niklas Söderlund Nov. 22, 2020, 4:36 p.m. UTC
It's not enough to select the AFE input port during probe it also needs
to be set when the device is reset. Move the port selection to
adv748x_reset() that is called during probe and when the device needs to
be reset.

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
---
 drivers/media/i2c/adv748x/adv748x-afe.c  | 6 +-----
 drivers/media/i2c/adv748x/adv748x-core.c | 4 ++++
 drivers/media/i2c/adv748x/adv748x.h      | 1 +
 3 files changed, 6 insertions(+), 5 deletions(-)

Comments

Sergei Shtylyov Nov. 23, 2020, 8 a.m. UTC | #1
Hello!

On 22.11.2020 19:36, Niklas Söderlund wrote:

> It's not enough to select the AFE input port during probe it also needs

                                                            ^ : or --?

> to be set when the device is reset. Move the port selection to

> adv748x_reset() that is called during probe and when the device needs to

> be reset.

> 

> Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>

[...]

MBR, Sergei
Kieran Bingham Nov. 25, 2020, 12:10 p.m. UTC | #2
Hi Niklas,

On 22/11/2020 16:36, Niklas Söderlund wrote:
> It's not enough to select the AFE input port during probe it also needs

> to be set when the device is reset. Move the port selection to

> adv748x_reset() that is called during probe and when the device needs to

> be reset.

> 


Should we instead have an adv748x_afe_reset(), rather than expose the
AFE internals to the top level core?

That said, shouldn't we be able to take advantage of regmap to restore
registers in this instance?

--
Kieran


> Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>

> ---

>  drivers/media/i2c/adv748x/adv748x-afe.c  | 6 +-----

>  drivers/media/i2c/adv748x/adv748x-core.c | 4 ++++

>  drivers/media/i2c/adv748x/adv748x.h      | 1 +

>  3 files changed, 6 insertions(+), 5 deletions(-)

> 

> diff --git a/drivers/media/i2c/adv748x/adv748x-afe.c b/drivers/media/i2c/adv748x/adv748x-afe.c

> index dbbb1e4d63637a33..4052cf67bf16c7fb 100644

> --- a/drivers/media/i2c/adv748x/adv748x-afe.c

> +++ b/drivers/media/i2c/adv748x/adv748x-afe.c

> @@ -154,7 +154,7 @@ static void adv748x_afe_set_video_standard(struct adv748x_state *state,

>  		   (sdpstd & 0xf) << ADV748X_SDP_VID_SEL_SHIFT);

>  }

>  

> -static int adv748x_afe_s_input(struct adv748x_afe *afe, unsigned int input)

> +int adv748x_afe_s_input(struct adv748x_afe *afe, unsigned int input)

>  {

>  	struct adv748x_state *state = adv748x_afe_to_state(afe);

>  

> @@ -520,10 +520,6 @@ int adv748x_afe_init(struct adv748x_afe *afe)

>  		}

>  	}

>  

> -	adv748x_afe_s_input(afe, afe->input);

> -

> -	adv_dbg(state, "AFE Default input set to %d\n", afe->input);

> -

>  	/* Entity pads and sinks are 0-indexed to match the pads */

>  	for (i = ADV748X_AFE_SINK_AIN0; i <= ADV748X_AFE_SINK_AIN7; i++)

>  		afe->pads[i].flags = MEDIA_PAD_FL_SINK;

> diff --git a/drivers/media/i2c/adv748x/adv748x-core.c b/drivers/media/i2c/adv748x/adv748x-core.c

> index 00966fe104881a14..8676ad2428856dd3 100644

> --- a/drivers/media/i2c/adv748x/adv748x-core.c

> +++ b/drivers/media/i2c/adv748x/adv748x-core.c

> @@ -516,6 +516,10 @@ static int adv748x_reset(struct adv748x_state *state)

>  	if (ret)

>  		return ret;

>  

> +	adv748x_afe_s_input(&state->afe, state->afe.input);

> +

> +	adv_dbg(state, "AFE Default input set to %d\n", state->afe.input);

> +

>  	/* Reset TXA and TXB */

>  	adv748x_tx_power(&state->txa, 1);

>  	adv748x_tx_power(&state->txa, 0);

> diff --git a/drivers/media/i2c/adv748x/adv748x.h b/drivers/media/i2c/adv748x/adv748x.h

> index 1061f425ece5989e..747947ea3e316451 100644

> --- a/drivers/media/i2c/adv748x/adv748x.h

> +++ b/drivers/media/i2c/adv748x/adv748x.h

> @@ -435,6 +435,7 @@ int adv748x_tx_power(struct adv748x_csi2 *tx, bool on);

>  

>  int adv748x_afe_init(struct adv748x_afe *afe);

>  void adv748x_afe_cleanup(struct adv748x_afe *afe);

> +int adv748x_afe_s_input(struct adv748x_afe *afe, unsigned int input);

>  

>  int adv748x_csi2_init(struct adv748x_state *state, struct adv748x_csi2 *tx);

>  void adv748x_csi2_cleanup(struct adv748x_csi2 *tx);

>
Niklas Söderlund Nov. 25, 2020, 1:16 p.m. UTC | #3
Hi Kieran,

On 2020-11-25 12:10:08 +0000, Kieran Bingham wrote:
> Hi Niklas,

> 

> On 22/11/2020 16:36, Niklas Söderlund wrote:

> > It's not enough to select the AFE input port during probe it also needs

> > to be set when the device is reset. Move the port selection to

> > adv748x_reset() that is called during probe and when the device needs to

> > be reset.

> > 

> 

> Should we instead have an adv748x_afe_reset(), rather than expose the

> AFE internals to the top level core?


We could, I have no real preference. But in this case all 
adv748x_afe_reset() would do is call adv748x_afe_s_input() so unless we 
foresee more work to be done at reset time my preference would be like 
this but it's your call.

> 

> That said, shouldn't we be able to take advantage of regmap to restore

> registers in this instance?


I'm no regmap expert so I don't know. But if so we need to be sure the 
order of registers match what is needed as we need to restore the i2c 
addresses for all none core "pages".

> 

> --

> Kieran

> 

> 

> > Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>

> > ---

> >  drivers/media/i2c/adv748x/adv748x-afe.c  | 6 +-----

> >  drivers/media/i2c/adv748x/adv748x-core.c | 4 ++++

> >  drivers/media/i2c/adv748x/adv748x.h      | 1 +

> >  3 files changed, 6 insertions(+), 5 deletions(-)

> > 

> > diff --git a/drivers/media/i2c/adv748x/adv748x-afe.c b/drivers/media/i2c/adv748x/adv748x-afe.c

> > index dbbb1e4d63637a33..4052cf67bf16c7fb 100644

> > --- a/drivers/media/i2c/adv748x/adv748x-afe.c

> > +++ b/drivers/media/i2c/adv748x/adv748x-afe.c

> > @@ -154,7 +154,7 @@ static void adv748x_afe_set_video_standard(struct adv748x_state *state,

> >  		   (sdpstd & 0xf) << ADV748X_SDP_VID_SEL_SHIFT);

> >  }

> >  

> > -static int adv748x_afe_s_input(struct adv748x_afe *afe, unsigned int input)

> > +int adv748x_afe_s_input(struct adv748x_afe *afe, unsigned int input)

> >  {

> >  	struct adv748x_state *state = adv748x_afe_to_state(afe);

> >  

> > @@ -520,10 +520,6 @@ int adv748x_afe_init(struct adv748x_afe *afe)

> >  		}

> >  	}

> >  

> > -	adv748x_afe_s_input(afe, afe->input);

> > -

> > -	adv_dbg(state, "AFE Default input set to %d\n", afe->input);

> > -

> >  	/* Entity pads and sinks are 0-indexed to match the pads */

> >  	for (i = ADV748X_AFE_SINK_AIN0; i <= ADV748X_AFE_SINK_AIN7; i++)

> >  		afe->pads[i].flags = MEDIA_PAD_FL_SINK;

> > diff --git a/drivers/media/i2c/adv748x/adv748x-core.c b/drivers/media/i2c/adv748x/adv748x-core.c

> > index 00966fe104881a14..8676ad2428856dd3 100644

> > --- a/drivers/media/i2c/adv748x/adv748x-core.c

> > +++ b/drivers/media/i2c/adv748x/adv748x-core.c

> > @@ -516,6 +516,10 @@ static int adv748x_reset(struct adv748x_state *state)

> >  	if (ret)

> >  		return ret;

> >  

> > +	adv748x_afe_s_input(&state->afe, state->afe.input);

> > +

> > +	adv_dbg(state, "AFE Default input set to %d\n", state->afe.input);

> > +

> >  	/* Reset TXA and TXB */

> >  	adv748x_tx_power(&state->txa, 1);

> >  	adv748x_tx_power(&state->txa, 0);

> > diff --git a/drivers/media/i2c/adv748x/adv748x.h b/drivers/media/i2c/adv748x/adv748x.h

> > index 1061f425ece5989e..747947ea3e316451 100644

> > --- a/drivers/media/i2c/adv748x/adv748x.h

> > +++ b/drivers/media/i2c/adv748x/adv748x.h

> > @@ -435,6 +435,7 @@ int adv748x_tx_power(struct adv748x_csi2 *tx, bool on);

> >  

> >  int adv748x_afe_init(struct adv748x_afe *afe);

> >  void adv748x_afe_cleanup(struct adv748x_afe *afe);

> > +int adv748x_afe_s_input(struct adv748x_afe *afe, unsigned int input);

> >  

> >  int adv748x_csi2_init(struct adv748x_state *state, struct adv748x_csi2 *tx);

> >  void adv748x_csi2_cleanup(struct adv748x_csi2 *tx);

> > 

> 


-- 
Regards,
Niklas Söderlund
diff mbox series

Patch

diff --git a/drivers/media/i2c/adv748x/adv748x-afe.c b/drivers/media/i2c/adv748x/adv748x-afe.c
index dbbb1e4d63637a33..4052cf67bf16c7fb 100644
--- a/drivers/media/i2c/adv748x/adv748x-afe.c
+++ b/drivers/media/i2c/adv748x/adv748x-afe.c
@@ -154,7 +154,7 @@  static void adv748x_afe_set_video_standard(struct adv748x_state *state,
 		   (sdpstd & 0xf) << ADV748X_SDP_VID_SEL_SHIFT);
 }
 
-static int adv748x_afe_s_input(struct adv748x_afe *afe, unsigned int input)
+int adv748x_afe_s_input(struct adv748x_afe *afe, unsigned int input)
 {
 	struct adv748x_state *state = adv748x_afe_to_state(afe);
 
@@ -520,10 +520,6 @@  int adv748x_afe_init(struct adv748x_afe *afe)
 		}
 	}
 
-	adv748x_afe_s_input(afe, afe->input);
-
-	adv_dbg(state, "AFE Default input set to %d\n", afe->input);
-
 	/* Entity pads and sinks are 0-indexed to match the pads */
 	for (i = ADV748X_AFE_SINK_AIN0; i <= ADV748X_AFE_SINK_AIN7; i++)
 		afe->pads[i].flags = MEDIA_PAD_FL_SINK;
diff --git a/drivers/media/i2c/adv748x/adv748x-core.c b/drivers/media/i2c/adv748x/adv748x-core.c
index 00966fe104881a14..8676ad2428856dd3 100644
--- a/drivers/media/i2c/adv748x/adv748x-core.c
+++ b/drivers/media/i2c/adv748x/adv748x-core.c
@@ -516,6 +516,10 @@  static int adv748x_reset(struct adv748x_state *state)
 	if (ret)
 		return ret;
 
+	adv748x_afe_s_input(&state->afe, state->afe.input);
+
+	adv_dbg(state, "AFE Default input set to %d\n", state->afe.input);
+
 	/* Reset TXA and TXB */
 	adv748x_tx_power(&state->txa, 1);
 	adv748x_tx_power(&state->txa, 0);
diff --git a/drivers/media/i2c/adv748x/adv748x.h b/drivers/media/i2c/adv748x/adv748x.h
index 1061f425ece5989e..747947ea3e316451 100644
--- a/drivers/media/i2c/adv748x/adv748x.h
+++ b/drivers/media/i2c/adv748x/adv748x.h
@@ -435,6 +435,7 @@  int adv748x_tx_power(struct adv748x_csi2 *tx, bool on);
 
 int adv748x_afe_init(struct adv748x_afe *afe);
 void adv748x_afe_cleanup(struct adv748x_afe *afe);
+int adv748x_afe_s_input(struct adv748x_afe *afe, unsigned int input);
 
 int adv748x_csi2_init(struct adv748x_state *state, struct adv748x_csi2 *tx);
 void adv748x_csi2_cleanup(struct adv748x_csi2 *tx);