linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/5] LogiCVC mfd and GPIO support
@ 2019-09-25  8:45 Paul Kocialkowski
  2019-09-25  8:45 ` [PATCH v2 1/5] dt-bindings: Add Xylon vendor prefix Paul Kocialkowski
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Paul Kocialkowski @ 2019-09-25  8:45 UTC (permalink / raw)
  To: linux-gpio, devicetree, linux-kernel
  Cc: Linus Walleij, Bartosz Golaszewski, Rob Herring, Mark Rutland,
	Lee Jones, Thomas Petazzoni, Paul Kocialkowski

This series introduces support for the LogiCVC GPIO block to the syscon GPIO
driver, with dt bindings documentation also including the top-level mfd
component.

Changes since v1:
- Converted dt bindings documentation to dt schemas;
- Used BIT macro and removed version from structure name;
- Improved documentation example with gpio-line-names;
- Added vendor prefix to dt bindings;
- Added mfd component dt bindings documentation.

Cheers,

Paul

Paul Kocialkowski (5):
  dt-bindings: Add Xylon vendor prefix
  dt-bindings: mfd: Document the Xylon LogiCVC multi-function device
  gpio: syscon: Add support for a custom get operation
  dt-bindings: gpio: Document the Xylon LogiCVC GPIO controller
  gpio: syscon: Add support for the Xylon LogiCVC GPIOs

 .../bindings/gpio/xylon,logicvc-gpio.yaml     | 70 +++++++++++++++++
 .../bindings/mfd/xylon,logicvc.yaml           | 60 +++++++++++++++
 .../devicetree/bindings/vendor-prefixes.yaml  |  2 +
 drivers/gpio/gpio-syscon.c                    | 75 ++++++++++++++++++-
 4 files changed, 204 insertions(+), 3 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/gpio/xylon,logicvc-gpio.yaml
 create mode 100644 Documentation/devicetree/bindings/mfd/xylon,logicvc.yaml

-- 
2.23.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2 1/5] dt-bindings: Add Xylon vendor prefix
  2019-09-25  8:45 [PATCH v2 0/5] LogiCVC mfd and GPIO support Paul Kocialkowski
@ 2019-09-25  8:45 ` Paul Kocialkowski
  2019-09-25  8:45 ` [PATCH v2 2/5] dt-bindings: mfd: Document the Xylon LogiCVC multi-function device Paul Kocialkowski
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Paul Kocialkowski @ 2019-09-25  8:45 UTC (permalink / raw)
  To: linux-gpio, devicetree, linux-kernel
  Cc: Linus Walleij, Bartosz Golaszewski, Rob Herring, Mark Rutland,
	Lee Jones, Thomas Petazzoni, Paul Kocialkowski

Xylon is an electronics company that produces FPGA hardware block designs
optimized for Xilinx FPGAs.

Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
---
 Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/vendor-prefixes.yaml b/Documentation/devicetree/bindings/vendor-prefixes.yaml
index 29dcc6f8a64a..6c9913244e4c 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.yaml
+++ b/Documentation/devicetree/bindings/vendor-prefixes.yaml
@@ -1036,6 +1036,8 @@ patternProperties:
     description: Xilinx
   "^xunlong,.*":
     description: Shenzhen Xunlong Software CO.,Limited
+  "^xylon,.*":
+    description: Xylon
   "^yones-toptech,.*":
     description: Yones Toptech Co., Ltd.
   "^ysoft,.*":
-- 
2.23.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2 2/5] dt-bindings: mfd: Document the Xylon LogiCVC multi-function device
  2019-09-25  8:45 [PATCH v2 0/5] LogiCVC mfd and GPIO support Paul Kocialkowski
  2019-09-25  8:45 ` [PATCH v2 1/5] dt-bindings: Add Xylon vendor prefix Paul Kocialkowski
@ 2019-09-25  8:45 ` Paul Kocialkowski
  2019-09-25  8:45 ` [PATCH v2 3/5] gpio: syscon: Add support for a custom get operation Paul Kocialkowski
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Paul Kocialkowski @ 2019-09-25  8:45 UTC (permalink / raw)
  To: linux-gpio, devicetree, linux-kernel
  Cc: Linus Walleij, Bartosz Golaszewski, Rob Herring, Mark Rutland,
	Lee Jones, Thomas Petazzoni, Paul Kocialkowski

The LogiCVC is a display engine which also exposes GPIO functionality.
For this reason, it is described as a multi-function device that is expected
to provide register access to its children nodes for gpio and display.

Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
---
 .../bindings/mfd/xylon,logicvc.yaml           | 60 +++++++++++++++++++
 1 file changed, 60 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/xylon,logicvc.yaml

diff --git a/Documentation/devicetree/bindings/mfd/xylon,logicvc.yaml b/Documentation/devicetree/bindings/mfd/xylon,logicvc.yaml
new file mode 100644
index 000000000000..f7a2a13d7918
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/xylon,logicvc.yaml
@@ -0,0 +1,60 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+# Copyright 2019 Bootlin
+%YAML 1.2
+---
+$id: "http://devicetree.org/schemas/mfd/xylon,logicvc.yaml#"
+$schema: "http://devicetree.org/meta-schemas/core.yaml#"
+
+title: Xylon LogiCVC multi-function device
+
+maintainers:
+  - Paul Kocialkowski <paul.kocialkowski@bootlin.com>
+
+description: |
+  The LogiCVC is a display controller that also contains a GPIO controller.
+  As a result, a multi-function device is exposed as parent of the display
+  and GPIO blocks.
+
+properties:
+  compatible:
+    items:
+      - enum:
+          - xylon,logicvc-3.02.a
+      - const: syscon
+      - const: simple-mfd
+
+  reg:
+    maxItems: 1
+
+select:
+  properties:
+    compatible:
+      contains:
+        enum:
+          - xylon,logicvc-3.02.a
+
+  required:
+    - compatible
+
+required:
+  - compatible
+  - reg
+
+examples:
+  - |
+    &amba {
+      logicvc: logicvc@43c00000 {
+        compatible = "xylon,logicvc-3.02.a", "syscon", "simple-mfd";
+        reg = <0x43c00000 0x6000>;
+        #address-cells = <1>;
+        #size-cells = <1>;
+
+        logicvc_gpio: gpio@40 {
+          compatible = "xylon,logicvc-3.02.a-gpio";
+          reg = <0x40 0x40>;
+          ...
+        };
+        ...
+      };
+      ...
+    };
-- 
2.23.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2 3/5] gpio: syscon: Add support for a custom get operation
  2019-09-25  8:45 [PATCH v2 0/5] LogiCVC mfd and GPIO support Paul Kocialkowski
  2019-09-25  8:45 ` [PATCH v2 1/5] dt-bindings: Add Xylon vendor prefix Paul Kocialkowski
  2019-09-25  8:45 ` [PATCH v2 2/5] dt-bindings: mfd: Document the Xylon LogiCVC multi-function device Paul Kocialkowski
@ 2019-09-25  8:45 ` Paul Kocialkowski
  2019-09-25  8:45 ` [PATCH v2 4/5] dt-bindings: gpio: Document the Xylon LogiCVC GPIO controller Paul Kocialkowski
  2019-09-25  8:45 ` [PATCH v2 5/5] gpio: syscon: Add support for the Xylon LogiCVC GPIOs Paul Kocialkowski
  4 siblings, 0 replies; 6+ messages in thread
From: Paul Kocialkowski @ 2019-09-25  8:45 UTC (permalink / raw)
  To: linux-gpio, devicetree, linux-kernel
  Cc: Linus Walleij, Bartosz Golaszewski, Rob Herring, Mark Rutland,
	Lee Jones, Thomas Petazzoni, Paul Kocialkowski

Some drivers might need a custom get operation to match custom
behavior implemented in the set operation.

Add plumbing for supporting that.

Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
---
 drivers/gpio/gpio-syscon.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/gpio/gpio-syscon.c b/drivers/gpio/gpio-syscon.c
index 31f332074d7d..05c537ed73f1 100644
--- a/drivers/gpio/gpio-syscon.c
+++ b/drivers/gpio/gpio-syscon.c
@@ -43,8 +43,9 @@ struct syscon_gpio_data {
 	unsigned int	bit_count;
 	unsigned int	dat_bit_offset;
 	unsigned int	dir_bit_offset;
-	void		(*set)(struct gpio_chip *chip,
-			       unsigned offset, int value);
+	int		(*get)(struct gpio_chip *chip, unsigned offset);
+	void		(*set)(struct gpio_chip *chip, unsigned offset,
+			       int value);
 };
 
 struct syscon_gpio_priv {
@@ -252,7 +253,7 @@ static int syscon_gpio_probe(struct platform_device *pdev)
 	priv->chip.label = dev_name(dev);
 	priv->chip.base = -1;
 	priv->chip.ngpio = priv->data->bit_count;
-	priv->chip.get = syscon_gpio_get;
+	priv->chip.get = priv->data->get ? : syscon_gpio_get;
 	if (priv->data->flags & GPIO_SYSCON_FEAT_IN)
 		priv->chip.direction_input = syscon_gpio_dir_in;
 	if (priv->data->flags & GPIO_SYSCON_FEAT_OUT) {
-- 
2.23.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2 4/5] dt-bindings: gpio: Document the Xylon LogiCVC GPIO controller
  2019-09-25  8:45 [PATCH v2 0/5] LogiCVC mfd and GPIO support Paul Kocialkowski
                   ` (2 preceding siblings ...)
  2019-09-25  8:45 ` [PATCH v2 3/5] gpio: syscon: Add support for a custom get operation Paul Kocialkowski
@ 2019-09-25  8:45 ` Paul Kocialkowski
  2019-09-25  8:45 ` [PATCH v2 5/5] gpio: syscon: Add support for the Xylon LogiCVC GPIOs Paul Kocialkowski
  4 siblings, 0 replies; 6+ messages in thread
From: Paul Kocialkowski @ 2019-09-25  8:45 UTC (permalink / raw)
  To: linux-gpio, devicetree, linux-kernel
  Cc: Linus Walleij, Bartosz Golaszewski, Rob Herring, Mark Rutland,
	Lee Jones, Thomas Petazzoni, Paul Kocialkowski

The Xylon LogiCVC display controller exports some GPIOs, which are
exposed as a separate entity.

Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
---
 .../bindings/gpio/xylon,logicvc-gpio.yaml     | 70 +++++++++++++++++++
 1 file changed, 70 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/gpio/xylon,logicvc-gpio.yaml

diff --git a/Documentation/devicetree/bindings/gpio/xylon,logicvc-gpio.yaml b/Documentation/devicetree/bindings/gpio/xylon,logicvc-gpio.yaml
new file mode 100644
index 000000000000..1503c922f845
--- /dev/null
+++ b/Documentation/devicetree/bindings/gpio/xylon,logicvc-gpio.yaml
@@ -0,0 +1,70 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+# Copyright 2019 Bootlin
+%YAML 1.2
+---
+$id: "http://devicetree.org/schemas/gpio/xylon,logicvc-gpio.yaml#"
+$schema: "http://devicetree.org/meta-schemas/core.yaml#"
+
+title: Xylon LogiCVC GPIO controller
+
+maintainers:
+  - Paul Kocialkowski <paul.kocialkowski@bootlin.com>
+
+description: |
+  The LogiCVC GPIO describes the GPIO block included in the LogiCVC display
+  controller. These are meant to be used for controlling display-related
+  signals.
+
+  The controller exposes GPIOs from the display and power control registers,
+  which are mapped by the driver as follows:
+  - GPIO[4:0] (display control) mapped to index 0-4
+  - EN_BLIGHT (power control) mapped to index 5
+  - EN_VDD (power control) mapped to index 6
+  - EN_VEE (power control) mapped to index 7
+  - V_EN (power control) mapped to index 8
+
+properties:
+  $nodename:
+    pattern: "^gpio@[0-9a-f]+$"
+
+  compatible:
+    enum:
+      - xylon,logicvc-3.02.a-gpio
+
+  reg:
+    maxItems: 1
+
+  "#gpio-cells":
+    const: 2
+
+  gpio-controller: true
+
+  gpio-line-names:
+    minItems: 1
+    maxItems: 9
+
+required:
+  - compatible
+  - reg
+  - "#gpio-cells"
+  - gpio-controller
+
+examples:
+  - |
+    &amba {
+      logicvc: logicvc@43c00000 {
+        compatible = "xylon,logicvc-3.02.a", "syscon", "simple-mfd";
+        reg = <0x43c00000 0x6000>;
+        ...
+
+        logicvc_gpio: gpio@40 {
+          compatible = "xylon,logicvc-3.02.a-gpio";
+          reg = <0x40 0x40>;
+          gpio-controller;
+          #gpio-cells = <2>;
+          gpio-lines-names = "GPIO0", "GPIO1", "GPIO2", "GPIO3", "GPIO4",
+                             "EN_BLIGHT", "EN_VDD", "EN_VEE", "V_EN";
+        };
+      };
+      ...
+    };
-- 
2.23.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2 5/5] gpio: syscon: Add support for the Xylon LogiCVC GPIOs
  2019-09-25  8:45 [PATCH v2 0/5] LogiCVC mfd and GPIO support Paul Kocialkowski
                   ` (3 preceding siblings ...)
  2019-09-25  8:45 ` [PATCH v2 4/5] dt-bindings: gpio: Document the Xylon LogiCVC GPIO controller Paul Kocialkowski
@ 2019-09-25  8:45 ` Paul Kocialkowski
  4 siblings, 0 replies; 6+ messages in thread
From: Paul Kocialkowski @ 2019-09-25  8:45 UTC (permalink / raw)
  To: linux-gpio, devicetree, linux-kernel
  Cc: Linus Walleij, Bartosz Golaszewski, Rob Herring, Mark Rutland,
	Lee Jones, Thomas Petazzoni, Paul Kocialkowski

The LogiCVC display hardware block comes with GPIO capabilities
that must be exposed separately from the main driver (as GPIOs) for
use with regulators and panels. A syscon is used to share the same
regmap across the two drivers.

Since the GPIO capabilities are pretty simple, add them to the syscon
GPIO driver.

Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
---
 drivers/gpio/gpio-syscon.c | 68 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 68 insertions(+)

diff --git a/drivers/gpio/gpio-syscon.c b/drivers/gpio/gpio-syscon.c
index 05c537ed73f1..cdcb913b8f0c 100644
--- a/drivers/gpio/gpio-syscon.c
+++ b/drivers/gpio/gpio-syscon.c
@@ -190,6 +190,70 @@ static const struct syscon_gpio_data keystone_dsp_gpio = {
 	.set		= keystone_gpio_set,
 };
 
+#define LOGICVC_CTRL_REG		0x40
+#define LOGICVC_CTRL_GPIO_SHIFT		11
+#define LOGICVC_CTRL_GPIO_BITS		5
+
+#define LOGICVC_POWER_CTRL_REG		0x78
+#define LOGICVC_POWER_CTRL_GPIO_SHIFT	0
+#define LOGICVC_POWER_CTRL_GPIO_BITS	4
+
+static void logicvc_gpio_offset(struct syscon_gpio_priv *priv,
+				unsigned offset, unsigned int *reg,
+				unsigned int *bit)
+{
+	if (offset >= LOGICVC_CTRL_GPIO_BITS) {
+		*reg = LOGICVC_POWER_CTRL_REG;
+
+		/* To the (virtual) power ctrl offset. */
+		offset -= LOGICVC_CTRL_GPIO_BITS;
+		/* To the actual bit offset in reg. */
+		offset += LOGICVC_POWER_CTRL_GPIO_SHIFT;
+	} else {
+		*reg = LOGICVC_CTRL_REG;
+
+		/* To the actual bit offset in reg. */
+		offset += LOGICVC_CTRL_GPIO_SHIFT;
+	}
+
+	*bit = BIT(offset);
+}
+
+static int logicvc_gpio_get(struct gpio_chip *chip, unsigned offset)
+{
+	struct syscon_gpio_priv *priv = gpiochip_get_data(chip);
+	unsigned int reg;
+	unsigned int bit;
+	unsigned int value;
+	int ret;
+
+	logicvc_gpio_offset(priv, offset, &reg, &bit);
+
+	ret = regmap_read(priv->syscon, reg, &value);
+	if (ret)
+		return ret;
+
+	return !!(value & bit);
+}
+
+static void logicvc_gpio_set(struct gpio_chip *chip, unsigned offset, int val)
+{
+	struct syscon_gpio_priv *priv = gpiochip_get_data(chip);
+	unsigned int reg;
+	unsigned int bit;
+
+	logicvc_gpio_offset(priv, offset, &reg, &bit);
+
+	regmap_update_bits(priv->syscon, reg, bit, val ? bit : 0);
+}
+
+static const struct syscon_gpio_data logicvc_gpio = {
+	.flags		= GPIO_SYSCON_FEAT_OUT,
+	.bit_count	= LOGICVC_CTRL_GPIO_BITS + LOGICVC_POWER_CTRL_GPIO_BITS,
+	.get		= logicvc_gpio_get,
+	.set		= logicvc_gpio_set,
+};
+
 static const struct of_device_id syscon_gpio_ids[] = {
 	{
 		.compatible	= "cirrus,ep7209-mctrl-gpio",
@@ -203,6 +267,10 @@ static const struct of_device_id syscon_gpio_ids[] = {
 		.compatible	= "rockchip,rk3328-grf-gpio",
 		.data		= &rockchip_rk3328_gpio_mute,
 	},
+	{
+		.compatible	= "xylon,logicvc-3.02.a-gpio",
+		.data		= &logicvc_gpio,
+	},
 	{ }
 };
 MODULE_DEVICE_TABLE(of, syscon_gpio_ids);
-- 
2.23.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-09-25  8:46 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-25  8:45 [PATCH v2 0/5] LogiCVC mfd and GPIO support Paul Kocialkowski
2019-09-25  8:45 ` [PATCH v2 1/5] dt-bindings: Add Xylon vendor prefix Paul Kocialkowski
2019-09-25  8:45 ` [PATCH v2 2/5] dt-bindings: mfd: Document the Xylon LogiCVC multi-function device Paul Kocialkowski
2019-09-25  8:45 ` [PATCH v2 3/5] gpio: syscon: Add support for a custom get operation Paul Kocialkowski
2019-09-25  8:45 ` [PATCH v2 4/5] dt-bindings: gpio: Document the Xylon LogiCVC GPIO controller Paul Kocialkowski
2019-09-25  8:45 ` [PATCH v2 5/5] gpio: syscon: Add support for the Xylon LogiCVC GPIOs Paul Kocialkowski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).