Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 12 Dec 2019 13:02:22 +0000 (UTC)
From:      Emmanuel Vadot <manu@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r355648 - head/sys/arm64/rockchip
Message-ID:  <201912121302.xBCD2MVA062285@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: manu
Date: Thu Dec 12 13:02:22 2019
New Revision: 355648
URL: https://svnweb.freebsd.org/changeset/base/355648

Log:
  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.
  
  MFC after:	3 days

Modified:
  head/sys/arm64/rockchip/rk_pinctrl.c

Modified: head/sys/arm64/rockchip/rk_pinctrl.c
==============================================================================
--- head/sys/arm64/rockchip/rk_pinctrl.c	Thu Dec 12 05:11:53 2019	(r355647)
+++ head/sys/arm64/rockchip/rk_pinctrl.c	Thu Dec 12 13:02:22 2019	(r355648)
@@ -100,6 +100,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 node);
 };
 
 struct rk_pinctrl_softc {
@@ -370,6 +371,19 @@ rk3288_get_syscon(struct rk_pinctrl_softc *sc, uint32_
 	return (sc->grf);
 }
 
+static int
+rk3288_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);
+}
+
 struct rk_pinctrl_conf rk3288_conf = {
 	.iomux_conf = rk3288_iomux_bank,
 	.iomux_nbanks = nitems(rk3288_iomux_bank),
@@ -381,6 +395,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[] = {
@@ -524,6 +539,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[] = {
@@ -611,12 +627,28 @@ rk3399_get_pd_offset(struct rk_pinctrl_softc *sc, uint
 static struct syscon *
 rk3399_get_syscon(struct rk_pinctrl_softc *sc, uint32_t bank)
 {
-	if (bank < 2)
+	if (bank < 2) {
+		device_printf(sc->dev, "%s: Using PMU GRF\n", __func__);
 		return (sc->pmu);
+	}
 
+	device_printf(sc->dev, "%s: Using GRF\n", __func__);
 	return (sc->grf);
 }
 
+static int
+rk3399_parse_bias(phandle_t node)
+{
+	if (OF_hasprop(node, "bias-disable"))
+		return (0);
+	if (OF_hasprop(node, "bias-pull-up"))
+		return (3);
+	if (OF_hasprop(node, "bias-pull-down"))
+		return (1);
+
+	return (-1);
+}
+
 struct rk_pinctrl_conf rk3399_conf = {
 	.iomux_conf = rk3399_iomux_bank,
 	.iomux_nbanks = nitems(rk3399_iomux_bank),
@@ -628,6 +660,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[] = {
@@ -638,19 +671,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)
 {
@@ -842,7 +862,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);
 	if (bias >= 0) {
 		reg = sc->conf->get_pd_offset(sc, bank);
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201912121302.xBCD2MVA062285>