Skip to contentSkip to conversation

Adding support for NI Ettus Research USRP E3XX pinconf

RFC In review Moritz Fischer 4 participants 14 messages Nov 5, 2015 – Nov 17, 2015

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover Adding support for NI Ettus Research USRP E3XX pinconf

Hi all,

I've been hacking on this pinctrl driver to control pins on our FPGA idle image to use different daughterboards using different pin configurations.

I send this as an RFC because it's still pretty early stage, and while it seems to work fine I'm unsure about some of the semantics (as always, there will probably other changes required).

I'm planning to use this pinctrl driver to set pins to either input (do nothing, default), or output with a value of (1 or 0).

Can I use the 'output-low', 'output-high' bindings to achieve this, or am I supposed to implement a gpio controller to do this kind of stuff?

I'm not sure if I'm using the pinctrl framework correctly to achieve this, any suggestions on how to change a pin from output to input, as the bindings documentation explicitly states 'input-enable' does *not* affect output.

Thanks for your help & feedback,

Moritz

Moritz Fischer (3):
Documentation: dt: Add devicetree bindings for NI USRP E3xx pinconf
pinctrl: e3xx: Adding support for NI Ettus Research USRP E3xx pinconf
ARM: e3xx: Add header file for pinctrl constants

 .../devicetree/bindings/pinctrl/pinctrl-e3xx.txt   |  27 ++
 drivers/pinctrl/Kconfig                            |  11 +
 drivers/pinctrl/Makefile                           |   1 +
 drivers/pinctrl/pinctrl-e3xx.c                     | 403 +++++++++++++++++++++
 include/dt-bindings/pinctrl/pinctrl-e3xx.h         | 142 ++++++++
 5 files changed, 584 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pinctrl/pinctrl-e3xx.txt
 create mode 100644 drivers/pinctrl/pinctrl-e3xx.c
 create mode 100644 include/dt-bindings/pinctrl/pinctrl-e3xx.h
Signature · 1 line
2.4.3
#1 lore raw

RFC 1/3 Documentation: dt: Add devicetree bindings for NI USRP E3xx pinconf

---
 .../devicetree/bindings/pinctrl/pinctrl-e3xx.txt   | 27 ++++++++++++++++++++++
 1 file changed, 27 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pinctrl/pinctrl-e3xx.txt
Documentation/devicetree/bindings/pinctrl/pinctrl-e3xx.txt new file +27 -0
new file mode 100644
index 0000000..2bfbd21
@@ -0,0 +1,27 @@
+USRP E3xx Pincontrol bindings
+
+The pins of the NI Ettus Research USRP E3xx idle image can be configured for different
+daughterboard configurations. This pinmux is implemented in an FPGA as soft core.
+
+Required properties:
+- compatible: Must be one of the following:
+  - "ettus,pinctrl-e3xx-1.0"
+- clocks: The clock driving the pinmux
+
+Example:
+
+	e3xx_pinctrl: e3xx-pinctrl@40200a00 {
+		compatible = "ettus,e3xx-pinctrl-1.0";
+		reg = <0x40200a00 0x1000>;
+		clocks = <&clkc 15>;
+
+		foo_state: pinconf {
+			conf {
+				pins = E31X_LED_RX1_RX;
+				output-low;
+			};
+		};
+	};
+
+Note: Constants that facilitate creation of devicetree files are available in
+      include/dt-bindings/pinctrl/pinctrl-e3xx.h
Signature · 1 line
2.4.3
#2 lore raw

Re: [RFC 1/3] Documentation: dt: Add devicetree bindings for NI USRP E3xx pinconf

Quoted 1 line · On Thursday 05 November 2015 15:41:21 Moritz Fischer wrote:

+ e3xx_pinctrl: e3xx-pinctrl@40200a00 {

Just "pinctrl@40200a00"

Quoted 1 line

+ compatible = "ettus,e3xx-pinctrl-1.0";

no wildcards in the name, use exact chip revisions here. If two chips use the same one, add a fallback to the older version in the dts file of the newer one.

Arnd

#3 lore raw

RFC 2/3 pinctrl: e3xx: Adding support for NI Ettus Research USRP E3xx pinconf

In reply to Moritz Fischer

The USRP E3XX series requires pinctrl to configure the idle state FPGA image for minimizing power consumption.
This is required since different daughtercards have different uses for pins on a common connector.

---
 drivers/pinctrl/Kconfig        |  11 ++
 drivers/pinctrl/Makefile       |   1 +
 drivers/pinctrl/pinctrl-e3xx.c | 403 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 415 insertions(+)
 create mode 100644 drivers/pinctrl/pinctrl-e3xx.c
drivers/pinctrl/Kconfig +11 -0
index b422e4e..fb2e195 100644
@@ -101,6 +101,17 @@ config PINCTRL_DIGICOLOR
 	select PINMUX
 	select GENERIC_PINCONF
 
+config PINCTRL_E3XX
+	bool "NI Ettus Research USRP E3xx pinctrl driver"
+	depends on OF
+	select PINCONF
+	select GENERIC_PINCONF
+	help
+	  Say Y here to support Ettus Research E3xx pinctrl driver, which is used for
+	  the NI Ettus Research USRP E3xx family of embedded SDRs, including E310
+	  and E330.
+	  This driver requires the pinctrl framework.
+
 config PINCTRL_LANTIQ
 	bool
 	depends on LANTIQ
drivers/pinctrl/Makefile +1 -0
index 738cb49..799f3ac 100644
@@ -15,6 +15,7 @@ obj-$(CONFIG_PINCTRL_AT91)	+= pinctrl-at91.o
 obj-$(CONFIG_PINCTRL_AT91PIO4)	+= pinctrl-at91-pio4.o
 obj-$(CONFIG_PINCTRL_AMD)	+= pinctrl-amd.o
 obj-$(CONFIG_PINCTRL_DIGICOLOR)	+= pinctrl-digicolor.o
+obj-$(CONFIG_PINCTRL_E3XX)	+= pinctrl-e3xx.o
 obj-$(CONFIG_PINCTRL_FALCON)	+= pinctrl-falcon.o
 obj-$(CONFIG_PINCTRL_MESON)	+= meson/
 obj-$(CONFIG_PINCTRL_PALMAS)	+= pinctrl-palmas.o
drivers/pinctrl/pinctrl-e3xx.c new file +403 -0

403 lines not on this page · raw message

Signature · 1 line
2.4.3
#4 lore raw

Re: [RFC 2/3] pinctrl: e3xx: Adding support for NI Ettus Research USRP E3xx pinconf

Quoted 6 lines · Moritz Fischer

The USRP E3XX series requires pinctrl to configure the idle state FPGA image for minimizing power consumption.
This is required since different daughtercards have different uses for pins on a common connector.

+#include <linux/pinctrl/pinconf-generic.h>

+ empty line?

Quoted 18 lines
drivers/pinctrl/pinctrl-e3xx.c new file +17 -0
+#include "pinctrl-utils.h"
+#include "core.h"
 
+static int e3xx_pinconf_cfg_get(struct pinctrl_dev *pctldev,
+                               unsigned pin,
+                               unsigned long *config)
+{
+       u32 reg, mask;
+       int arg;
+       struct e3xx_pinctrl *pctrl;
+       unsigned int param;
+
+       param = pinconf_to_config_param(*config);
+       pctrl = pinctrl_dev_get_drvdata(pctldev);
+
+       if (pin >= E3XX_NUM_DB_PINS)
+               return -ENOTSUPP;
+

drivers/pinctrl/pinctrl-e3xx.c line 231

Quoted 10 lines
drivers/pinctrl/pinctrl-e3xx.c new file +10 -0
+       mask = BIT(pin % E3XX_PINS_PER_REG);
+
+       switch (param) {
+       case PIN_CONFIG_OUTPUT:
+               clk_enable(pctrl->clk);
+               reg = e3xx_pinctrl_read(pctrl, E3XX_DDR_OFFSET +
+                                       (pin / E3XX_PINS_PER_REG) * 4);
+
+               clk_disable(pctrl->clk);
+               arg = !!(reg & mask);

So, for now arg variable seems redundant, you may use expression inside call below.

Quoted 8 lines
drivers/pinctrl/pinctrl-e3xx.c new file +8 -0
+               break;
+       default:
+               dev_err(pctrl->dev, "requested illegal configuration");
+               return -ENOTSUPP;
+       };
+
+       *config = pinconf_to_config_packed(param, arg);
+

drivers/pinctrl/pinctrl-e3xx.c line 249

Quoted 10 lines
drivers/pinctrl/pinctrl-e3xx.c new file +10 -0
+       return 0;
+}
+
+static int e3xx_pinconf_cfg_set(struct pinctrl_dev *pctldev,
+                               unsigned pin,
+                               unsigned long *configs,
+                               unsigned num_configs)
+{
+       u32 reg, mask;
+       int i;

unsigned

Quoted 11 lines
drivers/pinctrl/pinctrl-e3xx.c new file +11 -0
+       struct e3xx_pinctrl *pctrl;
+       unsigned int param, arg;
+
+       if (pin >= E3XX_NUM_DB_PINS)
+               return -ENOTSUPP;
+       mask = BIT(pin % E3XX_PINS_PER_REG);
+
+       pctrl = pinctrl_dev_get_drvdata(pctldev);
+
+       clk_enable(pctrl->clk);
+

drivers/pinctrl/pinctrl-e3xx.c line 270

Quoted 10 lines
drivers/pinctrl/pinctrl-e3xx.c new file +10 -0
+       for (i = 0; i < num_configs; i++) {
+               param = pinconf_to_config_param(configs[i]);
+               arg = pinconf_to_config_argument(configs[i]);
+
+               switch (param) {
+               case PIN_CONFIG_OUTPUT:
+                       /* deal with value, set out bit if arg is 1 */
+                       reg = e3xx_pinctrl_read(pctrl, E3XX_OUT_OFFSET +
+                                               ((pin / E3XX_PINS_PER_REG) * 4))
+                               ;

Why not one the previous line?

Quoted 6 lines
drivers/pinctrl/pinctrl-e3xx.c new file +3 -0
+                       reg &= ~mask;
+                       if (arg)
+                               reg |= mask;
 
 
 

drivers/pinctrl/pinctrl-e3xx.c line 283

Quoted 10 lines
drivers/pinctrl/pinctrl-e3xx.c new file +10 -0
+
+                       /* addresses need to be 4 byte aligned */
+                       e3xx_pinctrl_write(pctrl, E3XX_OUT_OFFSET +
+                                          ((pin / E3XX_PINS_PER_REG) * 4), reg)
+                               ;
+
+                       /* set ddr bit to high for output */
+                       reg = e3xx_pinctrl_read(pctrl, E3XX_DDR_OFFSET +
+                                               ((pin / E3XX_PINS_PER_REG) * 4))
+                               ;

Ditto.

Quoted 49 lines
drivers/pinctrl/pinctrl-e3xx.c new file +49 -0
+                       reg |= mask;
+
+                       /* addresses need to be 4 byte aligned */
+                       e3xx_pinctrl_write(pctrl, E3XX_DDR_OFFSET +
+                                         ((pin / E3XX_PINS_PER_REG) * 4), reg);
+                       break;
+
+               default:
+                       clk_disable(pctrl->clk);
+                       return -ENOTSUPP;
+               };
+       }
+
+       clk_disable(pctrl->clk);
+
+       return 0;
+}
+
+static int e3xx_pinconf_group_set(struct pinctrl_dev *pctldev,
+                                 unsigned selector,
+                                 unsigned long *configs,
+                                 unsigned num_configs)
+{
+       return -EAGAIN;
+}
+
+static const struct pinconf_ops e3xx_pinconf_ops = {
+       .is_generic = true,
+       .pin_config_get = e3xx_pinconf_cfg_get,
+       .pin_config_set = e3xx_pinconf_cfg_set,
+       .pin_config_group_set = e3xx_pinconf_group_set,
+};
+
+static struct pinctrl_desc e3xx_desc = {
+       .name = "e3xx_pinctrl",
+       .pins = e3xx_pins,
+       .npins = ARRAY_SIZE(e3xx_pins),
+       .pctlops = &e3xx_pctrl_ops,
+       .confops = &e3xx_pinconf_ops,
+       .owner = THIS_MODULE,
+};
+
+static int e3xx_pinctrl_probe(struct platform_device *pdev)
+{
+       struct resource *res;
+       struct e3xx_pinctrl *pctrl;
+       int err;
+
+       pctrl = devm_kzalloc(&pdev->dev, sizeof(*pctrl), GFP_KERNEL);

drivers/pinctrl/pinctrl-e3xx.c line 341

Quoted 10 lines
drivers/pinctrl/pinctrl-e3xx.c new file +9 -0
+       if (!pctrl)
+               return -ENOMEM;
+       pctrl->dev = &pdev->dev;
+
+       res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 
+       if (!res) {
+               dev_err(&pdev->dev, "missing IO resource\n");
+               return -ENODEV;
+       }

Whole condition is redundant.

Quoted 70 lines
drivers/pinctrl/pinctrl-e3xx.c new file +62 -1
+
+       pctrl->io_base = devm_ioremap_resource(&pdev->dev, res);
+       if (IS_ERR(pctrl->io_base))
+               return PTR_ERR(pctrl->io_base);
+
+       pctrl->clk = devm_clk_get(&pdev->dev, NULL);
+       if (IS_ERR(pctrl->clk)) {
+               dev_err(&pdev->dev, "input clock not found");
+               return PTR_ERR(pctrl->clk);
+       }
+
+       err = clk_prepare(pctrl->clk);
+       if (err) {
+               dev_err(&pdev->dev, "unable to prepare clock");
+               return err;
+       }
+
+       pctrl->pctl = pinctrl_register(&e3xx_desc, &pdev->dev, pctrl);
+       if (!pctrl->pctl)
+               return -ENOMEM;
+
+       platform_set_drvdata(pdev, pctrl);
+
+       dev_info(&pdev->dev, "NI Ettus Research E3xx pinctrl initialized\n");
+
+       return 0;
+}
+
+static int e3xx_pinctrl_remove(struct platform_device *pdev)
+{
+       struct e3xx_pinctrl *pctrl = platform_get_drvdata(pdev);
+
+       pinctrl_unregister(pctrl->pctl);
+
+       clk_unprepare(pctrl->clk);
+
+       return 0;
+}
+
+#ifdef CONFIG_OF
+static const struct of_device_id e3xx_pinctrl_of_match[] = {
+       { .compatible = "ettus,e3xx-pinctrl-1.0", },
+       {},
+};
+
+MODULE_DEVICE_TABLE(of, e3xx_pinctrl_of_match);
+#endif
+
+static struct platform_driver e3xx_pinctrl_driver = {
+       .probe = e3xx_pinctrl_probe,
+       .remove = e3xx_pinctrl_remove,
+       .driver = {
+               .name = "e3xx_pinctrl",
+               .of_match_table = of_match_ptr(e3xx_pinctrl_of_match),
+       },
+};
+
+module_platform_driver(e3xx_pinctrl_driver);
+
+MODULE_AUTHOR("Moritz Fischer <[email protected]>");
+MODULE_DESCRIPTION("Ettus Research pinctrl driver");
+MODULE_LICENSE("GPL v2");
--

2.4.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#5 lore raw

Re: [RFC 2/3] pinctrl: e3xx: Adding support for NI Ettus Research USRP E3xx pinconf

In reply to Moritz Fischer
Quoted 6 lines · Moritz Fischer

The USRP E3XX series requires pinctrl to configure the idle state FPGA image for minimizing power consumption.
This is required since different daughtercards have different uses for pins on a common connector.

(...)

Quoted 4 lines
drivers/pinctrl/pinctrl-e3xx.c new file +4 -0
+static const struct pinctrl_pin_desc e3xx_pins[] = {
+       /* pin0 doesn't exist */
+       PINCTRL_PIN(1, "DB_1"),
+       PINCTRL_PIN(2, "DB_2"),

(...)

drivers/pinctrl/pinctrl-e3xx.c line 157

Quoted 3 lines
drivers/pinctrl/pinctrl-e3xx.c new file +3 -0
+       PINCTRL_PIN(119, "DB_119"),
+       PINCTRL_PIN(120, "DB_120"),
+};

These should be the names on the data sheet for the balls/pins on the ASIC. Is this the case? I saw some discussion with Arnd that indicated it was rather rail names for a certain board and that is not OK.

Quoted 8 lines
drivers/pinctrl/pinctrl-e3xx.c new file +8 -0
+static int e3xx_pinctrl_get_groups_count(struct pinctrl_dev *pctldev)
+{
+       return 0;
+}
+
+static const char *e3xx_pinctrl_get_group_name(struct pinctrl_dev *pctldev,
+                                              unsigned selector)
+{

drivers/pinctrl/pinctrl-e3xx.c line 197

Quoted 10 lines
drivers/pinctrl/pinctrl-e3xx.c new file +10 -0
+       return NULL;
+}
+
+static int e3xx_pinctrl_get_group_pins(struct pinctrl_dev *pctldev,
+                                      unsigned selector,
+                                      const unsigned **pins,
+                                      unsigned *num_pins)
+{
+       return -ENOTSUPP;
+}

Hm maybe we should make these group callbacks optional in the pinctrl core?

Quoted 7 lines
drivers/pinctrl/pinctrl-e3xx.c new file +7 -0
+static int e3xx_pinconf_cfg_set(struct pinctrl_dev *pctldev,
+                               unsigned pin,
+                               unsigned long *configs,
+                               unsigned num_configs)
+{
+       u32 reg, mask;
+       int i;

drivers/pinctrl/pinctrl-e3xx.c line 259

Quoted 10 lines
drivers/pinctrl/pinctrl-e3xx.c new file +10 -0
+       struct e3xx_pinctrl *pctrl;
+       unsigned int param, arg;
+
+       if (pin >= E3XX_NUM_DB_PINS)
+               return -ENOTSUPP;
+       mask = BIT(pin % E3XX_PINS_PER_REG);
+
+       pctrl = pinctrl_dev_get_drvdata(pctldev);
+
+       clk_enable(pctrl->clk);

Have you considered using pm_runtime_get_sync() etc with callbacks instead of hammering clk_enable/disable all the time? See drivers/hwtracing/coresight/coresight-replicator.c for an example of how to do it in the runtime PM ops callbacks. It requires some tweaks (look closely at all setup there) but it pays off.

drivers/pinctrl/pinctrl-e3xx.c line 308

Quoted 7 lines
drivers/pinctrl/pinctrl-e3xx.c new file +7 -0
+static int e3xx_pinconf_group_set(struct pinctrl_dev *pctldev,
+                                 unsigned selector,
+                                 unsigned long *configs,
+                                 unsigned num_configs)
+{
+       return -EAGAIN;
+}

Maybe you should group this with the other group callbacks.

Apart from these remarks it looks pretty nice.

Yours,
Linus Walleij

#6 lore raw

Re: [RFC 2/3] pinctrl: e3xx: Adding support for NI Ettus Research USRP E3xx pinconf

Linus,

Thanks for your review!

Quoted 15 lines · Linus Walleij
Quoted 6 lines · Moritz Fischer

The USRP E3XX series requires pinctrl to configure the idle state FPGA image for minimizing power consumption.
This is required since different daughtercards have different uses for pins on a common connector.

(...)

drivers/pinctrl/pinctrl-e3xx.c line 39

Quoted 4 lines
drivers/pinctrl/pinctrl-e3xx.c new file +4 -0
+static const struct pinctrl_pin_desc e3xx_pins[] = {
+       /* pin0 doesn't exist */
+       PINCTRL_PIN(1, "DB_1"),
+       PINCTRL_PIN(2, "DB_2"),
Quoted 8 lines

(...)

drivers/pinctrl/pinctrl-e3xx.c line 157

Quoted 3 lines
drivers/pinctrl/pinctrl-e3xx.c new file +3 -0
+       PINCTRL_PIN(119, "DB_119"),
+       PINCTRL_PIN(120, "DB_120"),
+};

These should be the names on the data sheet for the balls/pins on the ASIC. Is this the case? I saw some discussion with Arnd that indicated it was rather rail names for a certain board and that is not OK.

Well so the chip is an FPGA, so in theory you can connect any logic inside to (almost)
any ball on the outside (at design time). In our case we have a daughter-board slot that gives
different meanings to what I call DB_1-DB_120. The pinctrl chip is a soft-core in that FPGA.
Are you suggesting to use the balls of the FPGA as pin names instead?

Quoted 13 lines
Quoted 13 lines
drivers/pinctrl/pinctrl-e3xx.c new file +13 -0
+static int e3xx_pinctrl_get_groups_count(struct pinctrl_dev *pctldev)
+{
+       return 0;
+}
+
+static const char *e3xx_pinctrl_get_group_name(struct pinctrl_dev *pctldev,
+                                              unsigned selector)
+{
+       return NULL;
+}
+
+static int e3xx_pinctrl_get_group_pins(struct pinctrl_dev *pctldev,
+                                      unsigned selector,
Quoted 8 lines

drivers/pinctrl/pinctrl-e3xx.c line 197

Quoted 5 lines
drivers/pinctrl/pinctrl-e3xx.c new file +5 -0
+                                      const unsigned **pins,
+                                      unsigned *num_pins)
+{
+       return -ENOTSUPP;
+}

Hm maybe we should make these group callbacks optional in the pinctrl core?

I'll submit a patchset separately, seems like a good idea.

Quoted 19 lines
Quoted 8 lines
drivers/pinctrl/pinctrl-e3xx.c new file +7 -0
+static int e3xx_pinconf_cfg_set(struct pinctrl_dev *pctldev,
+                               unsigned pin,daughterboard
+                               unsigned long *configs,
+                               unsigned num_configs)
+{
+       u32 reg, mask;
+       int i;

drivers/pinctrl/pinctrl-e3xx.c line 259

Quoted 10 lines
drivers/pinctrl/pinctrl-e3xx.c new file +10 -0
+       struct e3xx_pinctrl *pctrl;
+       unsigned int param, arg;
+
+       if (pin >= E3XX_NUM_DB_PINS)
+               return -ENOTSUPP;
+       mask = BIT(pin % E3XX_PINS_PER_REG);
+
+       pctrl = pinctrl_dev_get_drvdata(pctldev);
+
+       clk_enable(pctrl->clk);
Quoted 7 lines

Have you considered using pm_runtime_get_sync() etc with callbacks instead of hammering clk_enable/disable all the time? See drivers/hwtracing/coresight/coresight-replicator.c for an example of how to do it in the runtime PM ops callbacks. It requires some tweaks (look closely at all setup there) but it pays off.

Thanks for the pointer, I'll take a look.

Quoted 9 lines

drivers/pinctrl/pinctrl-e3xx.c line 308

Quoted 7 lines
drivers/pinctrl/pinctrl-e3xx.c new file +7 -0
+static int e3xx_pinconf_group_set(struct pinctrl_dev *pctldev,
+                                 unsigned selector,
+                                 unsigned long *configs,
+                                 unsigned num_configs)
+{
+       return -EAGAIN;
+}

Maybe you should group this with the other group callbacks.

Will do.

Quoted 2 lines

Apart from these remarks it looks pretty nice.

While testing I found some more (minor) issues, that I'll need to iron out before I submit a real patch. In my cover letter I had a question about how to deal with a situation where I'm exclusively either input or output, Any suggestions on the correct semantics for expressing that?
The documentation seems to indicate that 'input-enable' *must not* influence the output of a pin. How do I reconfigure a output to no longer be an output?

Cheers,

Moritz

#7 lore raw

RFC 3/3 ARM: e3xx: Add header file for pinctrl constants

In reply to Moritz Fischer

This new header file defines pincontrol constants for USRP E3xx to use from E3xx's DTS file for pincontrol properties option.

---
 include/dt-bindings/pinctrl/pinctrl-e3xx.h | 142 +++++++++++++++++++++++++++++
 1 file changed, 142 insertions(+)
 create mode 100644 include/dt-bindings/pinctrl/pinctrl-e3xx.h
include/dt-bindings/pinctrl/pinctrl-e3xx.h new file +142 -0
new file mode 100644
index 0000000..7b35ad2
@@ -0,0 +1,142 @@
+/*
+ * Copyright (C) 2015 National Instruments Corp
+ *
+ * This header provides constants for USRP E3xx pinctrl bindings
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+
+#ifndef _DT_BINDINGS_PINCTRL_E3XX_H
+#define _DT_BINDINGS_PINCTRL_E3XX_H
+
+/* Pin names for the E31x usecase */
+#define E31X_TX_BANDSEL_2	"DB_1"
+#define E31X_RX1B_BANDSEL_0	"DB_3"
+#define E31X_RX1B_BANDSEL_1	"DB_5"
+#define E31X_VCTXRX2_V2		"DB_7"
+#define E31X_TX_ENABLE1A	"DB_9"
+#define E31X_TX_ENABLE2A	"DB_11"
+#define E31X_TX_BANDSEL_0	"DB_12"
+#define E31X_TX_ENABLE1B	"DB_13"
+#define E31X_TX_ENABLE2B	"DB_15"
+#define E31X_RX1C_BANDSEL_0	"DB_17"
+#define E31X_RX1C_BANDSEL_1	"DB_19"
+#define E31X_VCTXRX2_V1		"DB_21"
+#define E31X_VCTXRX1_V2		"DB_23"
+#define E31X_VCTXRX1_V1		"DB_25"
+#define E31X_VCRX1_V1		"DB_27"
+#define E31X_VCRX1_V2		"DB_29"
+#define E31X_VCRX2_V1		"DB_31"
+#define E31X_VCRX2_V2		"DB_33"
+#define E31X_CAT_CTRL_IN2	"DB_35"
+#define E31X_CAT_CTRL_IN3	"DB_37"
+#define E31X_CAT_CTRL_OUT0	"DB_39"
+#define E31X_CAT_CTRL_OUT1	"DB_41"
+#define E31X_CAT_CTRL_OUT2	"DB_43"
+#define E31X_CAT_CTRL_OUT3	"DB_45"
+/* pin 47 is nc */
+/* pin 49 is nc */
+/* pin 51 is nc */
+/* pin 53 is nc */
+/* pin 55 is nc */
+/* pin 57 is nc */
+/* pin 59 is nc */
+/* pin 61 is nc */
+/* pin 63 is nc */
+/* pin 65 is nc */
+#define E31X_CAT_TXNRX		"DB_67"
+#define E31X_CAT_ENABLE		"DB_69"
+#define E31X_CAT_ENAGC		"DB_71"
+/* pin 73 is nc */
+#define E31X_CAT_P0_D5		"DB_75"
+#define E31X_CAT_P0_D7		"DB_77"
+#define E31X_CAT_P0_D3		"DB_79"
+#define E31X_CAT_P0_D9		"DB_81"
+#define E31X_CAT_P0_D1		"DB_83"
+#define E31X_CAT_P0_D6		"DB_85"
+#define E31X_CAT_P0_D0		"DB_87"
+#define E31X_CAT_P0_D2		"DB_89"
+#define E31X_CAT_P0_D4		"DB_91"
+#define E31X_CAT_P0_D11		"DB_93"
+#define E31X_CAT_P0_D10		"DB_95"
+#define E31X_CAT_P0_D8		"DB_97"
+#define E31X_CAT_RX_FRAME	"DB_99"
+#define E31X_CAT_DATA_CLK	"DB_101"
+/* pin 103 is nc */
+/* pin 105 is nc */
+#define E31X_RX2_BANDSEL_2	"DB_107"
+#define E31X_RX2_BANDSEL_1	"DB_109"
+#define E31X_RX2_BANDSEL_0	"DB_111"
+#define E31X_RX2C_BANDSEL_1	"DB_113"
+#define E31X_RX2C_BANDSEL_0	"DB_115"
+#define E31X_RX2B_BANDSEL_0	"DB_117"
+#define E31X_RX2B_BANDSEL_1	"DB_119"
+
+/* pin 2 is nc */
+/* pin 4 is nc */
+#define E31X_RX1_BANDSEL_0	"DB_6"
+#define E31X_RX1_BANDSEL_1	"DB_8"
+#define E31X_RX1_BANDSEL_2	"DB_10"
+#define E31X_TX_BANDSEL_1	"DB_14"
+#define E31X_DB_SCL		"DB_16"
+#define E31X_DB_SCA		"DB_18"
+#define E31X_TUNE_DAC_SYNC_N	"DB_20"
+#define E31X_TUNE_DAC_SCLK	"DB_22"
+#define E31X_TUNE_DAC_SDIN	"DB_24"
+/* pin 26 is nc */
+/* pin 28 is nc */
+#define E31X_VCTCXO_TO_MB	"DB_30"
+/* pin 32 is nc */
+/* pin 34 is nc */
+/* pin 36 is nc */
+/* pin 38 is nc */
+#define E31X_CAT_CTRL_OUT4	"DB_40"
+#define E31X_CAT_CTRL_OUT5	"DB_42"
+#define E31X_CAT_CTRL_OUT6	"DB_44"
+#define E31X_CAT_CTRL_OUT7	"DB_46"
+#define E31X_CAT_RESET		"DB_48"
+#define E31X_CAT_CS		"DB_50"
+#define E31X_CAT_SCLK		"DB_52"
+#define E31X_CAT_MOSI		"DB_54"
+#define E31X_CAT_MISO		"DB_56"
+#define E31X_CAT_CTRL_IN0	"DB_58"
+#define E31X_CAT_CTRL_IN1	"DB_60"
+/* pin 62 is nc */
+/* pin 64 is nc */
+/* pin 66 is nc */
+/* pin 68 is nc */
+#define E31X_CAT_BBCLK_OUT	"DB_70"
+/* pin 72 is nc */
+#define E31X_CAT_SYNC		"DB_74"
+#define E31X_CAT_P1_D11		"DB_78"
+#define E31X_CAT_P1_D1		"DB_80"
+#define E31X_CAT_P1_D3		"DB_82"
+#define E31X_CAT_P1_D0		"DB_84"
+#define E31X_CAT_P1_D5		"DB_86"
+#define E31X_CAT_P1_D2		"DB_88"
+#define E31X_CAT_P1_D4		"DB_90"
+#define E31X_CAT_P1_D7		"DB_92"
+#define E31X_CAT_P1_D6		"DB_94"
+#define E31X_CAT_P1_D9		"DB_96"
+#define E31X_CAT_P1_D8		"DB_98"
+#define E31X_CAT_P1_D10		"DB_100"
+#define E31X_CAT_TX_FRAME	"DB_102"
+#define E31X_CAT_FB_CLK		"DB_104"
+/* pin 106 is nc */
+#define E31X_LED_TXRX1_TX	"DB_108"
+#define E31X_LED_TXRX1_RX	"DB_110"
+#define E31X_LED_RX1_RX		"DB_112"
+#define E31X_LED_TXRX2_TX	"DB_114"
+#define E31X_LED_TXRX2_RX	"DB_116"
+#define E31X_LED_RX2_RX		"DB_118"
+/* pin 120 is nc */
+
+#endif /* _DT_BINDINGS_PINCTRL_E3XX_H */
Signature · 1 line
2.4.3
#8 lore raw

Re: [RFC 3/3] ARM: e3xx: Add header file for pinctrl constants

include/dt-bindings/pinctrl/pinctrl-e3xx.h line 27

Quoted 8 lines · On Thursday 05 November 2015 15:41:23 Moritz Fischer wrote:
include/dt-bindings/pinctrl/pinctrl-e3xx.h new file +8 -0
+/* Pin names for the E31x usecase */
+#define E31X_TX_BANDSEL_2      "DB_1"
+#define E31X_RX1B_BANDSEL_0    "DB_3"
+#define E31X_RX1B_BANDSEL_1    "DB_5"
+#define E31X_VCTXRX2_V2                "DB_7"
+#define E31X_TX_ENABLE1A       "DB_9"
+#define E31X_TX_ENABLE2A       "DB_11"
+#define E31X_TX_BANDSEL_0      "DB_12"

Why not put the strings directly into the .dts files and change the lookup table in the driver accordingly:

+static const struct pinctrl_pin_desc e3xx_pins[] = {

+       /* pin0 doesn't exist */
+       PINCTRL_PIN(1, "TX_BANDSEL_2"),
+       PINCTRL_PIN(3, "RX1B_BANDSEL_0"),
+       PINCTRL_PIN(5, "RX1B_BANDSEL_1"),
+       PINCTRL_PIN(7, "VCTXRX2_V2"),

That would save you the hassle of the three-way dependency between the dts file, the driver and the header when you want to change something going through three different maintainer trees.

arnd

#9 lore raw

Re: [RFC 3/3] ARM: e3xx: Add header file for pinctrl constants

Hi Arnd,

Quoted 13 lines · Arnd Bergmann

include/dt-bindings/pinctrl/pinctrl-e3xx.h line 27

Quoted 8 lines · On Thursday 05 November 2015 15:41:23 Moritz Fischer wrote:
include/dt-bindings/pinctrl/pinctrl-e3xx.h new file +8 -0
+/* Pin names for the E31x usecase */
+#define E31X_TX_BANDSEL_2      "DB_1"
+#define E31X_RX1B_BANDSEL_0    "DB_3"
+#define E31X_RX1B_BANDSEL_1    "DB_5"
+#define E31X_VCTXRX2_V2                "DB_7"
+#define E31X_TX_ENABLE1A       "DB_9"
+#define E31X_TX_ENABLE2A       "DB_11"
+#define E31X_TX_BANDSEL_0      "DB_12"

Why not put the strings directly into the .dts files and change the lookup table in the driver accordingly:

Review

Quoted 6 lines
(quoted diff) +6 -0
+static const struct pinctrl_pin_desc e3xx_pins[] = {
+       /* pin0 doesn't exist */
+       PINCTRL_PIN(1, "TX_BANDSEL_2"),
+       PINCTRL_PIN(3, "RX1B_BANDSEL_0"),
+       PINCTRL_PIN(5, "RX1B_BANDSEL_1"),
+       PINCTRL_PIN(7, "VCTXRX2_V2"),

That's actually the way I initially had it, however the pin names literally changed
in the schematic depending on which daughter-board you stick into the slot. So my plan was to add the #defines for the second daughter-board in a follow up patch
once the pin assignment is final. This would allow me to have something like:

pins = E31X_TX_BANDSEL_2;
output-low;

in one .dts, while having something like

pins = E33X_TX_BANDSEL_2
output low;

in the second dts

The other option would have been to stick a e31x_pins and a e33x_pins into the driver,
and set them according to a compatible string or "ettus,daughterboard" property on probe.

Does that make sense, or do you think there's a cleaner / better way to achieve this sort of behavior?

Thanks for your feedback!

Cheers,
Moritz
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#10 lore raw

Re: [RFC 3/3] ARM: e3xx: Add header file for pinctrl constants

Quoted 33 lines · On Friday 06 November 2015 08:01:25 Moritz Fischer wrote:

Hi Arnd,

Quoted 13 lines · Arnd Bergmann

include/dt-bindings/pinctrl/pinctrl-e3xx.h line 27

Quoted 8 lines · On Thursday 05 November 2015 15:41:23 Moritz Fischer wrote:
include/dt-bindings/pinctrl/pinctrl-e3xx.h new file +8 -0
+/* Pin names for the E31x usecase */
+#define E31X_TX_BANDSEL_2      "DB_1"
+#define E31X_RX1B_BANDSEL_0    "DB_3"
+#define E31X_RX1B_BANDSEL_1    "DB_5"
+#define E31X_VCTXRX2_V2                "DB_7"
+#define E31X_TX_ENABLE1A       "DB_9"
+#define E31X_TX_ENABLE2A       "DB_11"
+#define E31X_TX_BANDSEL_0      "DB_12"

Why not put the strings directly into the .dts files and change the lookup table in the driver accordingly:

Review

Quoted 6 lines
(quoted diff) +6 -0
+static const struct pinctrl_pin_desc e3xx_pins[] = {
+       /* pin0 doesn't exist */
+       PINCTRL_PIN(1, "TX_BANDSEL_2"),
+       PINCTRL_PIN(3, "RX1B_BANDSEL_0"),
+       PINCTRL_PIN(5, "RX1B_BANDSEL_1"),
+       PINCTRL_PIN(7, "VCTXRX2_V2"),

That's actually the way I initially had it, however the pin names literally changed
in the schematic depending on which daughter-board you stick into the slot. So my plan was to add the #defines for the second daughter-board in a follow up patch
once the pin assignment is final. This would allow me to have something like:

pins = E31X_TX_BANDSEL_2;
output-low;

Quoted 6 lines

in one .dts, while having something like

pins = E33X_TX_BANDSEL_2
output low;

in the second dts

That doesn't seem helpful though, because the assignment of the pins is not hidden from the source file that should be documenting
it: if someone wants to know how the pins are muxed, they now have to cross-reference the dts file with the header. If you just put the pin number directly into the dts, it becomes completely clear what the setting is.

Quoted 7 lines

The other option would have been to stick a e31x_pins and a e33x_pins into the driver,
and set them according to a compatible string or "ettus,daughterboard" property on probe.

Does that make sense, or do you think there's a cleaner / better way to achieve this sort of behavior?

The driver should not be board specific.

Arnd

#11 lore raw

Re: [RFC 3/3] ARM: e3xx: Add header file for pinctrl constants

Quoted 39 lines · Arnd Bergmann
Quoted 38 lines · On Friday 06 November 2015 08:01:25 Moritz Fischer wrote:

Hi Arnd,

Quoted 13 lines · Arnd Bergmann

include/dt-bindings/pinctrl/pinctrl-e3xx.h line 27

Quoted 8 lines · On Thursday 05 November 2015 15:41:23 Moritz Fischer wrote:
include/dt-bindings/pinctrl/pinctrl-e3xx.h new file +8 -0
+/* Pin names for the E31x usecase */
+#define E31X_TX_BANDSEL_2      "DB_1"
+#define E31X_RX1B_BANDSEL_0    "DB_3"
+#define E31X_RX1B_BANDSEL_1    "DB_5"
+#define E31X_VCTXRX2_V2                "DB_7"
+#define E31X_TX_ENABLE1A       "DB_9"
+#define E31X_TX_ENABLE2A       "DB_11"
+#define E31X_TX_BANDSEL_0      "DB_12"

Why not put the strings directly into the .dts files and change the lookup table in the driver accordingly:

Review

Quoted 6 lines
(quoted diff) +6 -0
+static const struct pinctrl_pin_desc e3xx_pins[] = {
+       /* pin0 doesn't exist */
+       PINCTRL_PIN(1, "TX_BANDSEL_2"),
+       PINCTRL_PIN(3, "RX1B_BANDSEL_0"),
+       PINCTRL_PIN(5, "RX1B_BANDSEL_1"),
+       PINCTRL_PIN(7, "VCTXRX2_V2"),

That's actually the way I initially had it, however the pin names literally changed
in the schematic depending on which daughter-board you stick into the slot. So my plan was to add the #defines for the second daughter-board in a follow up patch
once the pin assignment is final. This would allow me to have something like:

pins = E31X_TX_BANDSEL_2;
output-low;

in one .dts, while having something like

pins = E33X_TX_BANDSEL_2
output low;

Quoted 8 lines
Quoted 1 line

in the second dts

That doesn't seem helpful though, because the assignment of the pins is not hidden from the source file that should be documenting
it: if someone wants to know how the pins are muxed, they now have to cross-reference the dts file with the header. If you just put the pin number directly into the dts, it becomes completely clear what the setting is.

Just to clarify, you're suggesting using "DB_0" etc in the dts file? At that point
the name becomes kinda useless. I found the PINCTRL_PIN_ANON macro, but haven't found any use throughout the tree, is using it discouraged?

Quoted 9 lines
Quoted 7 lines

The other option would have been to stick a e31x_pins and a e33x_pins into the driver,
and set them according to a compatible string or "ettus,daughterboard" property on probe.

Does that make sense, or do you think there's a cleaner / better way to achieve this sort of behavior?

The driver should not be board specific.

Agreed, thank you!

Cheers,

Moritz

#12 lore raw

Re: [RFC 3/3] ARM: e3xx: Add header file for pinctrl constants

Quoted 19 lines · On Friday 06 November 2015 09:55:28 Moritz Fischer wrote:
Quoted 9 lines · Arnd Bergmann
Quoted 8 lines · On Friday 06 November 2015 08:01:25 Moritz Fischer wrote:

pins = E31X_TX_BANDSEL_2;
output-low;

in one .dts, while having something like

pins = E33X_TX_BANDSEL_2
output low;

Quoted 8 lines
Quoted 1 line

in the second dts

That doesn't seem helpful though, because the assignment of the pins is not hidden from the source file that should be documenting
it: if someone wants to know how the pins are muxed, they now have to cross-reference the dts file with the header. If you just put the pin number directly into the dts, it becomes completely clear what the setting is.

Quoted 4 lines

Just to clarify, you're suggesting using "DB_0" etc in the dts file? At that point
the name becomes kinda useless. I found the PINCTRL_PIN_ANON macro, but haven't found any use throughout the tree, is using it discouraged?

I don't know if that is the best approach, but it's better than using macros here. You should only add a header file with macros if you absolutely have to define a common namespace between the driver and the dts files, but you don't do that here: the header file is only used in one place.

Arnd

#13 lore raw
In reply to Moritz Fischer
Quoted 5 lines · Moritz Fischer

I'm planning to use this pinctrl driver to set pins to either input (do nothing, default), or output with a value of (1 or 0).

Can I use the 'output-low', 'output-high' bindings to achieve this, or am I supposed to implement a gpio controller to do this kind of stuff?

I'm pretty sure you should implement a GPIO chip for this. output-low and output-high are for things like lines going to a RAM memory that need to be set up as part of a pin control state.

Quoted 3 lines

I'm not sure if I'm using the pinctrl framework correctly to achieve this, any suggestions on how to change a pin from output to input, as the bindings documentation explicitly states 'input-enable' does *not* affect output.

Look at pin controllers also implementing GPIO chips.

Yours,
Linus Walleij