Skip to contentSkip to conversation

Add support for kosagi novena

PATCH Superseded Sean Cross 2 participants 5 messages Dec 19, 2014

Subsystems (5)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Sean Cross

author
#0 lore raw

cover Add support for kosagi novena

The Kosagi Novena mainboard contains an i.MX6, along with a PCI Express slot. This patchset adds regulator support to the PCI Express slot, and adds device tree support for the Novena mainboard.

Sean Cross (2):
PCI: imx6: Add power-supply support
ARM: dts: imx6q: add Novena board

 .../devicetree/bindings/pci/fsl,imx6q-pcie.txt     |   3 +
 arch/arm/boot/dts/Makefile                         |   1 +
 arch/arm/boot/dts/imx6q-novena.dts                 | 893 +++++++++++++++++++++
 drivers/pci/host/pci-imx6.c                        |  20 +-
 4 files changed, 916 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/boot/dts/imx6q-novena.dts
Signature · 1 line
2.1.3
author
#1 lore raw

PATCH 1/2 PCI: imx6: Add power-supply support

Some PCIe ports gate power to the slot. In order to prevent system lockup, these boards must enable power to the slot before attempting communication over the PCI bus.

---
 .../devicetree/bindings/pci/fsl,imx6q-pcie.txt       |  3 +++
 drivers/pci/host/pci-imx6.c                          | 20 +++++++++++++++++++-
 2 files changed, 22 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt +3 -0
index 6fbba53..fe912bd 100644
@@ -13,6 +13,9 @@ Required properties:
 - clock-names: Must include the following additional entries:
 	- "pcie_phy"
 
+Optional properties:
+- power-supply: A regulator that controls power to the port
+
 Example:
 
 	pcie@0x01000000 {
drivers/pci/host/pci-imx6.c +19 -1
index 69202d1..9c2140e 100644
@@ -22,6 +22,7 @@
 #include <linux/pci.h>
 #include <linux/platform_device.h>
 #include <linux/regmap.h>
+#include <linux/regulator/consumer.h>
 #include <linux/resource.h>
 #include <linux/signal.h>
 #include <linux/types.h>
@@ -39,6 +40,7 @@ struct imx6_pcie {
 	struct pcie_port	pp;
 	struct regmap		*iomuxc_gpr;
 	void __iomem		*mem_base;
+	struct regulator	*power_reg;
 };
 
 /* PCIe Root Complex registers (memory-mapped) */
@@ -588,6 +590,19 @@ static int __init imx6_pcie_probe(struct platform_device *pdev)
 		}
 	}
 
+	/* Fetch power supply */
+	imx6_pcie->power_reg = devm_regulator_get(&pdev->dev, "power");
+	if (IS_ERR(imx6_pcie->power_reg))
+		imx6_pcie->power_reg = 0;
+
+	if (imx6_pcie->power_reg) {
+		ret = regulator_enable(imx6_pcie->power_reg);
+		if (ret) {
+			dev_err(&pdev->dev, "Unable to enable power regulator");
+			return ret;
+		}
+	}
+
 	/* Fetch clocks */
 	imx6_pcie->pcie_phy = devm_clk_get(&pdev->dev, "pcie_phy");
 	if (IS_ERR(imx6_pcie->pcie_phy)) {
@@ -619,8 +634,11 @@ static int __init imx6_pcie_probe(struct platform_device *pdev)
 	}
 
 	ret = imx6_add_pcie_port(pp, pdev);
-	if (ret < 0)
+	if (ret < 0) {
+		if (imx6_pcie->power_reg)
+			regulator_disable(imx6_pcie->power_reg);
 		return ret;
+	}
 
 	platform_set_drvdata(pdev, imx6_pcie);
 	return 0;
Signature · 1 line
2.1.3
author
#3 lore raw

PATCH 2/2 ARM: dts: imx6q: add Novena board

In reply to Sean Cross

Novena is an open-hardware laptop/desktop/bare board.

See http://www.kosagi.com/w/index.php?title=Novena_Main_Page

This device tree contains additional nodes for FPGA support.

---
 arch/arm/boot/dts/Makefile         |   1 +
 arch/arm/boot/dts/imx6q-novena.dts | 893 +++++++++++++++++++++++++++++++++++++
 2 files changed, 894 insertions(+)
 create mode 100644 arch/arm/boot/dts/imx6q-novena.dts
arch/arm/boot/dts/Makefile +1 -0
index 38c89ca..b2b4770 100644
@@ -234,6 +234,7 @@ dtb-$(CONFIG_ARCH_MXC) += \
 	imx6q-gw552x.dtb \
 	imx6q-hummingboard.dtb \
 	imx6q-nitrogen6x.dtb \
+	imx6q-novena.dtb \
 	imx6q-phytec-pbab01.dtb \
 	imx6q-rex-pro.dtb \
 	imx6q-sabreauto.dtb \
arch/arm/boot/dts/imx6q-novena.dts new file +893 -0

893 lines not on this page · raw message

Signature · 1 line
2.1.3
#2 lore raw

Re: [PATCH 1/2] PCI: imx6: Add power-supply support

In reply to Sean Cross

Am Freitag, den 19.12.2014, 16:10 +0800 schrieb Sean Cross:

Quoted 15 lines

Some PCIe ports gate power to the slot. In order to prevent system lockup, these boards must enable power to the slot before attempting communication over the PCI bus.

---
 .../devicetree/bindings/pci/fsl,imx6q-pcie.txt       |  3 +++
 drivers/pci/host/pci-imx6.c                          | 20 +++++++++++++++++++-
 2 files changed, 22 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt +0 -0
index 6fbba53..fe912bd 100644

Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt Required properties: · line 17

Quoted 5 lines
Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt +2 -0
@@ -13,6 +13,9 @@ Required properties:
 - clock-names: Must include the following additional entries:
 	- "pcie_phy"
 
+Optional properties:
+- power-supply: A regulator that controls power to the port

This is a way too generic name. In order to provide the functionality you are intending, this regulator needs to supply the whole bus (remember not every board has just a single slot). It should be named accordingly.

So I would expect this to look something like the following:

bus-supply: A regulator that controls main power to every device on the bus.

Quoted 25 lines
Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt +1 -0
+
 Example:
 
 	pcie@0x01000000 {
drivers/pci/host/pci-imx6.c +2 -0
index 69202d1..9c2140e 100644
@@ -22,6 +22,7 @@
 #include <linux/pci.h>
 #include <linux/platform_device.h>
 #include <linux/regmap.h>
+#include <linux/regulator/consumer.h>
 #include <linux/resource.h>
 #include <linux/signal.h>
 #include <linux/types.h>
@@ -39,6 +40,7 @@ struct imx6_pcie {
 	struct pcie_port	pp;
 	struct regmap		*iomuxc_gpr;
 	void __iomem		*mem_base;
+	struct regulator	*power_reg;
 };
 
 /* PCIe Root Complex registers (memory-mapped) */

drivers/pci/host/pci-imx6.c static int __init imx6_pcie_probe(struct platform_device *pdev) · line 594

Quoted 5 lines
drivers/pci/host/pci-imx6.c +2 -0
@@ -588,6 +590,19 @@ static int __init imx6_pcie_probe(struct platform_device *pdev)
 		}
 	}
 
+	/* Fetch power supply */
+	imx6_pcie->power_reg = devm_regulator_get(&pdev->dev, "power");

Use devm_regulator_get_optional instead.

drivers/pci/host/pci-imx6.c static int __init imx6_pcie_probe(struct platform_device *pdev) · line 596

Quoted 2 lines
drivers/pci/host/pci-imx6.c +2 -0
+	if (IS_ERR(imx6_pcie->power_reg))
+		imx6_pcie->power_reg = 0;

This can go away if you use the above, but really? 0 to a pointer? I know it isn't invalid, but it's also bad style.

You must handle -EPROBE_DEFER here instead.

drivers/pci/host/pci-imx6.c static int __init imx6_pcie_probe(struct platform_device *pdev) · line 605

Quoted 9 lines
drivers/pci/host/pci-imx6.c +9 -0
+
+	if (imx6_pcie->power_reg) {
+		ret = regulator_enable(imx6_pcie->power_reg);
+		if (ret) {
+			dev_err(&pdev->dev, "Unable to enable power regulator");
+			return ret;
+		}
+	}
+

I'm not really comfortable with enabling directly at probe time, but given our failure paths are horrible enough as they are right now I agree that this is the sanest solution for now.

But please move both enabling and disabling at failure into imx6_add_pcie_port().

Quoted 6 lines
drivers/pci/host/pci-imx6.c +0 -0
 	/* Fetch clocks */
 	imx6_pcie->pcie_phy = devm_clk_get(&pdev->dev, "pcie_phy");
 	if (IS_ERR(imx6_pcie->pcie_phy)) {
@@ -619,8 +634,11 @@ static int __init imx6_pcie_probe(struct platform_device *pdev)
 	}
 

drivers/pci/host/pci-imx6.c static int __init imx6_pcie_probe(struct platform_device *pdev) · line 644

Quoted 10 lines
drivers/pci/host/pci-imx6.c +4 -1
 	ret = imx6_add_pcie_port(pp, pdev);
-	if (ret < 0)
+	if (ret < 0) {
+		if (imx6_pcie->power_reg)
+			regulator_disable(imx6_pcie->power_reg);
 		return ret;
+	}
 
 	platform_set_drvdata(pdev, imx6_pcie);
 	return 0;

Regards,
Lucas

Signature · 2 lines
Pengutronix e.K.             | Lucas Stach                 |
Industrial Linux Solutions   | http://www.pengutronix.de/  |
#4 lore raw

Re: [PATCH 2/2] ARM: dts: imx6q: add Novena board

In reply to Sean Cross

Am Freitag, den 19.12.2014, 16:10 +0800 schrieb Sean Cross:

Quoted 6 lines

Novena is an open-hardware laptop/desktop/bare board.

See http://www.kosagi.com/w/index.php?title=Novena_Main_Page

This device tree contains additional nodes for FPGA support.

I only skimmed the DT for now.

There are lots of occurrences of the "kosagi" vendor prefix, which is is not documented right now. Please add it to Documentation/devicetree/bindings/vendor-prefixes.txt first.

Quoted 25 lines
---
 arch/arm/boot/dts/Makefile         |   1 +
 arch/arm/boot/dts/imx6q-novena.dts | 893 +++++++++++++++++++++++++++++++++++++
 2 files changed, 894 insertions(+)
 create mode 100644 arch/arm/boot/dts/imx6q-novena.dts
arch/arm/boot/dts/Makefile +1 -0
index 38c89ca..b2b4770 100644
@@ -234,6 +234,7 @@ dtb-$(CONFIG_ARCH_MXC) += \
 	imx6q-gw552x.dtb \
 	imx6q-hummingboard.dtb \
 	imx6q-nitrogen6x.dtb \
+	imx6q-novena.dtb \
 	imx6q-phytec-pbab01.dtb \
 	imx6q-rex-pro.dtb \
 	imx6q-sabreauto.dtb \
arch/arm/boot/dts/imx6q-novena.dts new file +0 -0
new file mode 100644
index 0000000..143b3bd
@@ -0,0 +1,893 @@

[...]

arch/arm/boot/dts/imx6q-novena.dts line 219

Quoted 2 lines
arch/arm/boot/dts/imx6q-novena.dts new file +2 -0
+	fpga@1 {
+		compatible = "kosagi,novena-fpga";

This is missing a proper binding documentation.

arch/arm/boot/dts/imx6q-novena.dts line 231

Quoted 12 lines
arch/arm/boot/dts/imx6q-novena.dts new file +12 -0
+
+		spi-max-frequency = <30000000>;
+		reg = <1>;
+
+		pinctrl-names = "default", "state-eim", "state-gpio";
+		pinctrl-0 = <&pinctrl_fpga_gpio>;
+		pinctrl-1 = <&pinctrl_fpga_eim>;
+		pinctrl-2 = <&pinctrl_fpga_gpio>;
+		clocks = <&clks IMX6QDL_CLK_LVDS2_SEL>, <&clks IMX6QDL_CLK_LVDS2_GATE>, <&clks IMX6QDL_CLK_ENET_REF>, <&clks IMX6QDL_CLK_EIM_SLOW>;
+		clock-names = "lvds", "lvds-switch", "lvds-parent", "eim-slow";
+		reset-switch = <&gpio1 17 GPIO_ACTIVE_HIGH>;
+		power-switch = <&gpio5 7 GPIO_ACTIVE_HIGH>;

Custom property names without vendor namespacing. Also I don't know what they should do without the binding.

Quoted 9 lines
arch/arm/boot/dts/imx6q-novena.dts new file +9 -0
+
+		kosagi,weim-cs0-timing = <0x31910BBF 0x00001000 0x09014000
+					  0x00000000 0x09080800 0x00000000>;
+		kosagi,weim-cs1-timing = <0x81910CBF 0x00001000 0x07001000
+					  0x00000200 0x02040400 0x00000000>;
+		kosagi,weim-cs-mapping = <2>;
+	};
+};
+

[...]

Quoted 12 lines

+&ldb {

arch/arm/boot/dts/imx6q-novena.dts new file +11 -0
+	fsl,dual-channel;
+	status = "okay";
+	lvds-channel@0 {
+		fsl,data-mapping = "jeida";
+		fsl,data-width = <24>;
+		status = "okay";
+		display-timings {
+			1920x1080p60 {
+				clock-frequency = <148500000>;
+				hactive = <1920>;
+				vactive = <1080>;

arch/arm/boot/dts/imx6q-novena.dts line 822

Quoted 10 lines
arch/arm/boot/dts/imx6q-novena.dts new file +10 -0
+				hback-porch = <148>;
+				hfront-porch = <88>;
+				hsync-len = <44>;
+				vback-porch = <36>;
+				vfront-porch = <4>;
+				vsync-len = <5>;
+				hsync-active = <1>;
+				vsync-active = <1>;
+			};
+		};

Please don't use this for new devicetrees. Add a proper panel driver instead. Looks like this panel can be represented with the simple-panel driver.

Regards,
Lucas

Signature · 2 lines
Pengutronix e.K.             | Lucas Stach                 |
Industrial Linux Solutions   | http://www.pengutronix.de/  |