svn commit: r355812 - stable/12/sys/arm64/rockchip

Emmanuel Vadot manu at FreeBSD.org
Mon Dec 16 18:05:29 UTC 2019


Author: manu
Date: Mon Dec 16 18:05:28 2019
New Revision: 355812
URL: https://svnweb.freebsd.org/changeset/base/355812

Log:
  MFC r355648-r355649
  
  r355648:
  arm64: rockchip: rk_pinctrl: Add bias parsing based on the SoC type
  
  Not all rockchip have the same value for pullup/pulldown so add a function
  per SoC and call the right one to have the proper value.
  
  r355649:
  arm64: rockchip: rk_pinctrl: Fix parse_bias for RK3399
  
  Only bank 0 and bank 2 are different than other rockchip SoC, fix this.
  While here remove some debug printfs that where added in r355648
  
  X-MFC-With:	r355648

Modified:
  stable/12/sys/arm64/rockchip/rk_pinctrl.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/arm64/rockchip/rk_pinctrl.c
==============================================================================
--- stable/12/sys/arm64/rockchip/rk_pinctrl.c	Mon Dec 16 18:04:31 2019	(r355811)
+++ stable/12/sys/arm64/rockchip/rk_pinctrl.c	Mon Dec 16 18:05:28 2019	(r355812)
@@ -101,6 +101,7 @@ struct rk_pinctrl_conf {
 	uint32_t			ngpio_bank;
 	uint32_t	(*get_pd_offset)(struct rk_pinctrl_softc *, uint32_t);
 	struct syscon	*(*get_syscon)(struct rk_pinctrl_softc *, uint32_t);
+	int		(*parse_bias)(phandle_t, int);
 };
 
 struct rk_pinctrl_softc {
@@ -371,6 +372,19 @@ rk3288_get_syscon(struct rk_pinctrl_softc *sc, uint32_
 	return (sc->grf);
 }
 
+static int
+rk3288_parse_bias(phandle_t node, int bank)
+{
+	if (OF_hasprop(node, "bias-disable"))
+		return (0);
+	if (OF_hasprop(node, "bias-pull-up"))
+		return (1);
+	if (OF_hasprop(node, "bias-pull-down"))
+		return (2);
+
+	return (-1);
+}
+
 struct rk_pinctrl_conf rk3288_conf = {
 	.iomux_conf = rk3288_iomux_bank,
 	.iomux_nbanks = nitems(rk3288_iomux_bank),
@@ -382,6 +396,7 @@ struct rk_pinctrl_conf rk3288_conf = {
 	.ngpio_bank = nitems(rk3288_gpio_bank),
 	.get_pd_offset = rk3288_get_pd_offset,
 	.get_syscon = rk3288_get_syscon,
+	.parse_bias = rk3288_parse_bias,
 };
 
 static struct rk_pinctrl_gpio rk3328_gpio_bank[] = {
@@ -525,6 +540,7 @@ struct rk_pinctrl_conf rk3328_conf = {
 	.ngpio_bank = nitems(rk3328_gpio_bank),
 	.get_pd_offset = rk3328_get_pd_offset,
 	.get_syscon = rk3328_get_syscon,
+	.parse_bias = rk3288_parse_bias,
 };
 
 static struct rk_pinctrl_gpio rk3399_gpio_bank[] = {
@@ -618,6 +634,36 @@ rk3399_get_syscon(struct rk_pinctrl_softc *sc, uint32_
 	return (sc->grf);
 }
 
+static int
+rk3399_parse_bias(phandle_t node, int bank)
+{
+	int pullup, pulldown;
+
+	if (OF_hasprop(node, "bias-disable"))
+		return (0);
+
+	switch (bank) {
+	case 0:
+	case 2:
+		pullup = 3;
+		pulldown = 1;
+		break;
+	case 1:
+	case 3:
+	case 4:
+		pullup = 1;
+		pulldown = 2;
+		break;
+	}
+
+	if (OF_hasprop(node, "bias-pull-up"))
+		return (pullup);
+	if (OF_hasprop(node, "bias-pull-down"))
+		return (pulldown);
+
+	return (-1);
+}
+
 struct rk_pinctrl_conf rk3399_conf = {
 	.iomux_conf = rk3399_iomux_bank,
 	.iomux_nbanks = nitems(rk3399_iomux_bank),
@@ -629,6 +675,7 @@ struct rk_pinctrl_conf rk3399_conf = {
 	.ngpio_bank = nitems(rk3399_gpio_bank),
 	.get_pd_offset = rk3399_get_pd_offset,
 	.get_syscon = rk3399_get_syscon,
+	.parse_bias = rk3399_parse_bias,
 };
 
 static struct ofw_compat_data compat_data[] = {
@@ -639,19 +686,6 @@ static struct ofw_compat_data compat_data[] = {
 };
 
 static int
-rk_pinctrl_parse_bias(phandle_t node)
-{
-	if (OF_hasprop(node, "bias-disable"))
-		return (0);
-	if (OF_hasprop(node, "bias-pull-up"))
-		return (1);
-	if (OF_hasprop(node, "bias-pull-down"))
-		return (2);
-
-	return (-1);
-}
-
-static int
 rk_pinctrl_parse_drive(struct rk_pinctrl_softc *sc, phandle_t node,
   uint32_t bank, uint32_t subbank, uint32_t *drive, uint32_t *offset)
 {
@@ -843,7 +877,7 @@ rk_pinctrl_configure_pin(struct rk_pinctrl_softc *sc, 
 	SYSCON_MODIFY_4(syscon, reg, mask, function << bit | (mask << 16));
 
 	/* Pull-Up/Down */
-	bias = rk_pinctrl_parse_bias(pin_conf);
+	bias = sc->conf->parse_bias(pin_conf, bank);
 	if (bias >= 0) {
 		reg = sc->conf->get_pd_offset(sc, bank);
 


More information about the svn-src-all mailing list