Skip to contentSkip to conversation

pinctrl: aspeed: Fix ast2500 strap register write logic

PATCH In review Yong Li 2 participants 2 messages Aug 17, 2017 – Aug 18, 2017

Subsystems (4)
lore
Share & tools
lore

Yong Li

author
#0 lore raw

PATCH v4 1/1 pinctrl: aspeed: Fix ast2500 strap register write logic

On AST2500, the hardware strap register(SCU70) only accepts write ‘1’, to clear it to ‘0’, must set bits(write ‘1’) to SCU7C

---
 drivers/pinctrl/aspeed/pinctrl-aspeed.c | 21 +++++++++++++++++++++
 drivers/pinctrl/aspeed/pinctrl-aspeed.h |  1 +
 2 files changed, 22 insertions(+)
drivers/pinctrl/aspeed/pinctrl-aspeed.c +21 -0
index a86a4d6..7f13ce8 100644
@@ -213,6 +213,27 @@ static int aspeed_sig_expr_set(const struct aspeed_sig_expr *expr,
 		if (desc->ip == ASPEED_IP_SCU && desc->reg == HW_STRAP2)
 			continue;
 
+		/* On AST2500, Set bits in SCU7C are cleared from SCU70 */
+		if (desc->ip == ASPEED_IP_SCU && desc->reg == HW_STRAP1) {
+			unsigned int rev_id;
+
+			ret = regmap_read(maps[ASPEED_IP_SCU],
+				HW_REVISION_ID, &rev_id);
+			if (ret < 0)
+				return ret;
+
+			if (0x04 == (rev_id >> 24)) {
+				u32 value = ~val & desc->mask;
+
+				if (value) {
+					ret = regmap_write(maps[desc->ip],
+						HW_REVISION_ID, value);
+					if (ret < 0)
+						return ret;
+				}
+			}
+		}
+
 		ret = regmap_update_bits(maps[desc->ip], desc->reg,
 					 desc->mask, val);
 
drivers/pinctrl/aspeed/pinctrl-aspeed.h +1 -0
index fa125db..d4d7f03 100644
@@ -251,6 +251,7 @@
 #define SCU3C           0x3C /* System Reset Control/Status Register */
 #define SCU48           0x48 /* MAC Interface Clock Delay Setting */
 #define HW_STRAP1       0x70 /* AST2400 strapping is 33 bits, is split */
+#define HW_REVISION_ID  0x7C /* Silicon revision ID register */
 #define SCU80           0x80 /* Multi-function Pin Control #1 */
 #define SCU84           0x84 /* Multi-function Pin Control #2 */
 #define SCU88           0x88 /* Multi-function Pin Control #3 */
Signature · 1 line
2.7.4
Reviewed-by Tested-by on v4 1/1
#1 lore raw
Quoted 4 lines · Yong Li

On AST2500, the hardware strap register(SCU70) only accepts write ‘1’, to clear it to ‘0’, must set bits(write  ‘1’) to SCU7C

Take 2 ;)

Cheers,

Andrew

Quoted 49 lines

---
 drivers/pinctrl/aspeed/pinctrl-aspeed.c | 21 +++++++++++++++++++++ drivers/pinctrl/aspeed/pinctrl-aspeed.h |  1 +

 2 files changed, 22 insertions(+)
drivers/pinctrl/aspeed/pinctrl-aspeed.c +0 -0
index a86a4d6..7f13ce8 100644
@@ -213,6 +213,27 @@ static int aspeed_sig_expr_set(const struct aspeed_sig_expr *expr,
 >  		if (desc->ip == ASPEED_IP_SCU && desc->reg == HW_STRAP2)
 >  			continue;

drivers/pinctrl/aspeed/pinctrl-aspeed.c static int aspeed_sig_expr_set(const struct aspeed_sig_expr *expr, · line 218

Quoted 3 lines
drivers/pinctrl/aspeed/pinctrl-aspeed.c +3 -0
+		/* On AST2500, Set bits in SCU7C are cleared from SCU70 */
+		if (desc->ip == ASPEED_IP_SCU && desc->reg == HW_STRAP1) {
+			unsigned int rev_id;

+

drivers/pinctrl/aspeed/pinctrl-aspeed.c static int aspeed_sig_expr_set(const struct aspeed_sig_expr *expr, · line 223

Quoted 4 lines
drivers/pinctrl/aspeed/pinctrl-aspeed.c +4 -0
+			ret = regmap_read(maps[ASPEED_IP_SCU],
+				HW_REVISION_ID, &rev_id);
+			if (ret < 0)
+				return ret;

+

drivers/pinctrl/aspeed/pinctrl-aspeed.c static int aspeed_sig_expr_set(const struct aspeed_sig_expr *expr, · line 226

Quoted 2 lines
drivers/pinctrl/aspeed/pinctrl-aspeed.c +2 -0
+			if (0x04 == (rev_id >> 24)) {
+				u32 value = ~val & desc->mask;

+

drivers/pinctrl/aspeed/pinctrl-aspeed.c static int aspeed_sig_expr_set(const struct aspeed_sig_expr *expr, · line 235

Quoted 8 lines
drivers/pinctrl/aspeed/pinctrl-aspeed.c +8 -0
+				if (value) {
+					ret = regmap_write(maps[desc->ip],
+						HW_REVISION_ID, value);
+					if (ret < 0)
+						return ret;
+				}
+			}
+		}

+

Quoted 2 lines

  ret = regmap_update_bits(maps[desc->ip], desc->reg, desc->mask, val);

drivers/pinctrl/aspeed/pinctrl-aspeed.h +1 -0
index fa125db..d4d7f03 100644
@@ -251,6 +251,7 @@
  #define SCU3C           0x3C /* System Reset Control/Status Register */
  #define SCU48           0x48 /* MAC Interface Clock Delay Setting */
  #define HW_STRAP1       0x70 /* AST2400 strapping is 33 bits, is split */
+#define HW_REVISION_ID  0x7C /* Silicon revision ID register */
  #define SCU80           0x80 /* Multi-function Pin Control #1 */
  #define SCU84           0x84 /* Multi-function Pin Control #2 */
  #define SCU88           0x88 /* Multi-function Pin Control #3 */