diff mbox

[RFT,2/2] pinctrl: dove: Checking valid config in dove_audio1_ctrl_set

Message ID 1352641569.3113.2.camel@phoenix (mailing list archive)
State New, archived
Headers show

Commit Message

Axel Lin Nov. 11, 2012, 1:46 p.m. UTC
Move the code checking valid config to dove_audio1_ctrl_set(), this ensures we
always set valid config. And then dove_audio1_ctrl_get() always returns correct
config.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
 drivers/pinctrl/mvebu/pinctrl-dove.c |   13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

Comments

Sebastian Hesselbarth Nov. 12, 2012, 9:43 a.m. UTC | #1
On 11/11/2012 02:46 PM, Axel Lin wrote:
> Move the code checking valid config to dove_audio1_ctrl_set(), this ensures we
> always set valid config. And then dove_audio1_ctrl_get() always returns correct
> config.
>
> Signed-off-by: Axel Lin<axel.lin@ingics.com>

Axel,

although correct in a software point-of-view, I don't think we should move this
from _get to _set because the hardware allows to set these bits without changing
the actual function. There are some dominant bits in this settings so the masking
is done to not have ~5 different values for the same function here.

The pinctrl driver will set one of the (software) supported values anyway but on
reset there could be one of the values mentioned above written into the registers.

Sebastian
diff mbox

Patch

diff --git a/drivers/pinctrl/mvebu/pinctrl-dove.c b/drivers/pinctrl/mvebu/pinctrl-dove.c
index e5cc694..a393790 100644
--- a/drivers/pinctrl/mvebu/pinctrl-dove.c
+++ b/drivers/pinctrl/mvebu/pinctrl-dove.c
@@ -217,12 +217,6 @@  static int dove_audio1_ctrl_get(struct mvebu_mpp_ctrl *ctrl,
 	if (gcfg2 & DOVE_TWSI_OPTION3_GPIO)
 		*config |= BIT(0);
 
-	/* SSP/TWSI only if I2S1 not set*/
-	if ((*config & BIT(3)) == 0)
-		*config &= ~(BIT(2) | BIT(0));
-	/* TWSI only if SPDIFO not set*/
-	if ((*config & BIT(1)) == 0)
-		*config &= ~BIT(0);
 	return 0;
 }
 
@@ -234,6 +228,13 @@  static int dove_audio1_ctrl_set(struct mvebu_mpp_ctrl *ctrl,
 	unsigned long gmpp = readl(DOVE_MPP_GENERAL_VIRT_BASE);
 	unsigned long gcfg2 = readl(DOVE_GLOBAL_CONFIG_2);
 
+	/* SSP/TWSI only if I2S1 not set*/
+	if ((config & BIT(3)) == 0)
+		config &= ~(BIT(2) | BIT(0));
+	/* TWSI only if SPDIFO not set*/
+	if ((config & BIT(1)) == 0)
+		config &= ~BIT(0);
+
 	if (config & BIT(0))
 		gcfg2 |= DOVE_TWSI_OPTION3_GPIO;
 	else