Skip to contentSkip to conversation

drivers: bus: Add ti-sysc bus driver

PATCH Applied Teresa Remmet 2 participants 8 messages Feb 13, 2019

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

PATCH v2 1/7 drivers: bus: Add ti-sysc bus driver

Adds minimal support for the sysc interconnect target module found on many TI SoCs. With this device tree includes have been rearagned. We need the driver to probe the child devices of the bus.

---
Changes in v2:
- set driver in Kconfig to default y
- Use postcore_platform_driver() call
- Use global of_default_bus_match_table() instead of local table

 drivers/bus/Kconfig   |  8 ++++++++
 drivers/bus/Makefile  |  1 +
 drivers/bus/ti-sysc.c | 37 +++++++++++++++++++++++++++++++++++++
 3 files changed, 46 insertions(+)
 create mode 100644 drivers/bus/ti-sysc.c
drivers/bus/Kconfig +8 -0
index 202df59762e8..219982d878a8 100644
@@ -6,6 +6,14 @@ config BUS_OMAP_GPMC
 	depends on OMAP_GPMC
 	bool "TI OMAP/AM33xx GPMC support"
 
+config TI_SYSC
+	depends on ARCH_OMAP
+	bool "TI sysc interconnect target module driver"
+	default y
+	help
+	  Generic driver for Texas Instruments interconnect target module
+	  found on many TI SoCs.
+
 config IMX_WEIM
 	depends on ARCH_IMX
 	bool "i.MX WEIM driver"
drivers/bus/Makefile +1 -0
index 4b7aa888aba8..ba5cee40636b 100644
@@ -1,3 +1,4 @@
 obj-$(CONFIG_BUS_OMAP_GPMC)	+= omap-gpmc.o
 obj-$(CONFIG_IMX_WEIM)		+= imx-weim.o
 obj-$(CONFIG_MVEBU_MBUS)	+= mvebu-mbus.o
+obj-$(CONFIG_TI_SYSC)		+= ti-sysc.o
drivers/bus/ti-sysc.c new file +37 -0
new file mode 100644
index 000000000000..af52d839bdd5
@@ -0,0 +1,37 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2019 Phytec Messtechnik GmbH, Teresa Remmet <[email protected]>
+ */
+
+#include <common.h>
+#include <init.h>
+#include <of.h>
+#include <linux/err.h>
+
+static int ti_sysc_probe(struct device_d *dev)
+{
+	int ret;
+
+	ret = of_platform_populate(dev->device_node,
+					of_default_bus_match_table, dev);
+	if (ret)
+		dev_err(dev, "%s fail to create devices.\n",
+					dev->device_node->full_name);
+	return ret;
+};
+
+static struct of_device_id ti_sysc_dt_ids[] = {
+	{ .compatible = "ti,sysc-omap4",},
+	{ .compatible = "ti,sysc-omap4-simple",},
+	{ .compatible = "ti,sysc-omap4-timer",},
+	{ .compatible = "ti,sysc-omap2",},
+	{ },
+};
+
+static struct driver_d ti_sysc_driver = {
+	.name = "ti-sysc",
+	.probe = ti_sysc_probe,
+	.of_compatible = DRV_OF_COMPAT(ti_sysc_dt_ids),
+};
+
+postcore_platform_driver(ti_sysc_driver);
Signature · 7 lines
2.7.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#1 lore raw

PATCH v2 2/7 arm: configs: omap_defconfig: Enable ti-sysc bus driver

---
 arch/arm/configs/omap_defconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/configs/omap_defconfig +1 -1
index 128027a6406b..8615283453d4 100644
@@ -97,7 +97,6 @@ CONFIG_CMD_BOOTCHOOSER=y
 CONFIG_NET=y
 CONFIG_NET_NFS=y
 CONFIG_NET_NETCONSOLE=y
-CONFIG_NET_RESOLV=y
 CONFIG_OF_BAREBOX_DRIVERS=y
 CONFIG_DRIVER_SERIAL_NS16550=y
 CONFIG_DRIVER_SERIAL_NS16550_OMAP_EXTENSIONS=y
@@ -141,6 +140,7 @@ CONFIG_WATCHDOG_OMAP=y
 CONFIG_GPIO_GENERIC_PLATFORM=y
 CONFIG_PINCTRL_SINGLE=y
 CONFIG_BUS_OMAP_GPMC=y
+CONFIG_TI_SYSC=y
 CONFIG_FS_EXT4=y
 CONFIG_FS_TFTP=y
 CONFIG_FS_NFS=y
Signature · 7 lines
2.7.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#2 lore raw

PATCH v2 3/7 arm: configs: am33xx_mlo_defconfig: Enable ti-sysc bus driver

In reply to Teresa Remmet
---
 arch/arm/configs/am335x_mlo_defconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/configs/am335x_mlo_defconfig +1 -1
index 58034b6cea15..b58b71a85937 100644
@@ -8,7 +8,6 @@ CONFIG_MACH_PHYTEC_SOM_AM335X=y
 CONFIG_THUMB2_BAREBOX=y
 # CONFIG_MEMINFO is not set
 CONFIG_MMU=y
-CONFIG_TEXT_BASE=0x0
 CONFIG_BAREBOX_MAX_PBLX_SIZE=0x1b400
 CONFIG_MALLOC_SIZE=0x0
 CONFIG_MALLOC_TLSF=y
@@ -38,6 +37,7 @@ CONFIG_MCI=y
 CONFIG_MCI_OMAP_HSMMC=y
 CONFIG_PINCTRL_SINGLE=y
 CONFIG_BUS_OMAP_GPMC=y
+CONFIG_TI_SYSC=y
 # CONFIG_FS_DEVFS is not set
 CONFIG_FS_FAT=y
 CONFIG_FS_FAT_LFN=y
Signature · 7 lines
2.7.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#3 lore raw

PATCH v2 4/7 drivers: of: Add function to enable and register a device by alias

In reply to Teresa Remmet

In some cases node names are not unique and passing the full path is really long. So make add a new device by passing the alias string possible.

---
 drivers/of/platform.c | 19 +++++++++++++++++++
 include/of.h          |  8 ++++++++
 2 files changed, 27 insertions(+)
drivers/of/platform.c +19 -0
index ef8969ca8b19..d3795d799a13 100644
@@ -207,6 +207,25 @@ struct device_d *of_device_enable_and_register_by_name(const char *name)
 }
 EXPORT_SYMBOL(of_device_enable_and_register_by_name);
 
+/**
+ * of_device_enable_and_register_by_alias - Enable and register device by alias
+ * @name: alias of the device node
+ *
+ * Returns pointer to created platform device, or NULL if a device was not
+ * registered. Unavailable devices will not get registered.
+ */
+struct device_d *of_device_enable_and_register_by_alias(const char *alias)
+{
+	struct device_node *node;
+
+	node = of_find_node_by_alias(NULL, alias);
+	if (!node)
+		return NULL;
+
+	return of_device_enable_and_register(node);
+}
+EXPORT_SYMBOL(of_device_enable_and_register_by_alias);
+
 #ifdef CONFIG_ARM_AMBA
 static struct device_d *of_amba_device_create(struct device_node *np)
 {
include/of.h +8 -0
index 184acb474136..b5f54dd4e5b5 100644
@@ -255,6 +255,8 @@ extern int of_platform_populate(struct device_node *root,
 extern struct device_d *of_find_device_by_node(struct device_node *np);
 extern struct device_d *of_device_enable_and_register(struct device_node *np);
 extern struct device_d *of_device_enable_and_register_by_name(const char *name);
+extern struct device_d *of_device_enable_and_register_by_alias(
+							const char *alias);
 
 struct cdev *of_parse_partition(struct cdev *cdev, struct device_node *node);
 int of_parse_partitions(struct cdev *cdev, struct device_node *node);
@@ -670,6 +672,12 @@ static inline struct device_d *of_device_enable_and_register_by_name(
 	return NULL;
 }
 
+static inline struct device_d *of_device_enable_and_register_by_alias(
+				const char *alias)
+{
+	return NULL;
+}
+
 static inline int of_register_fixup(int (*fixup)(struct device_node *, void *),
 				void *context)
 {
Signature · 7 lines
2.7.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#4 lore raw

PATCH v2 5/7 arm: mach-omap: am335x_generic: Enable nodes by alias where needed

In reply to Teresa Remmet

With the interconnet target module hierarchy the node names used to enable boot devices are not unique any more. Find those nodes by alias now.

---
 arch/arm/mach-omap/am33xx_generic.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
arch/arm/mach-omap/am33xx_generic.c +4 -4
index fe3c4a8b175a..7577df761cb7 100644
@@ -474,18 +474,18 @@ int am33xx_of_register_bootdevice(void)
 	switch (bootsource_get()) {
 	case BOOTSOURCE_MMC:
 		if (bootsource_get_instance() == 0)
-			dev = of_device_enable_and_register_by_name("mmc@48060000");
+			dev = of_device_enable_and_register_by_alias("mmc0");
 		else
-			dev = of_device_enable_and_register_by_name("mmc@481d8000");
+			dev = of_device_enable_and_register_by_alias("mmc1");
 		break;
 	case BOOTSOURCE_NAND:
 		dev = of_device_enable_and_register_by_name("gpmc@50000000");
 		break;
 	case BOOTSOURCE_SPI:
-		dev = of_device_enable_and_register_by_name("spi@48030000");
+		dev = of_device_enable_and_register_by_alias("spi0");
 		break;
 	case BOOTSOURCE_NET:
-		dev = of_device_enable_and_register_by_name("ethernet@4a100000");
+		dev = of_device_enable_and_register_by_alias("ethernet0");
 		break;
 	default:
 		/* Use nand fallback */
Signature · 7 lines
2.7.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#5 lore raw

PATCH v2 6/7 net: ethernet: cpsw: cpsw-phy-sel: Use phandle for phy sel

In reply to Teresa Remmet

With the usage of the interconnect target module hierarchy in device tree the cpsw-phy-sel node moved to the system control module. An phandle has been added instead to the device tree include.

Try to use the cpsw-phy-sel phandle first then fall back looking for the cpsw-phy-sel child.

This patch is based on the upstream kernel patch:
18eb8aea7fb2 ("net: ethernet: cpsw-phy-sel: prefer phandle for phy sel")

---
 drivers/net/cpsw.c | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)
drivers/net/cpsw.c +11 -6
index 432004ec9ca8..65f71c6fce5a 100644
@@ -1053,6 +1053,7 @@ static int cpsw_probe_dt(struct cpsw_priv *priv)
 {
 	struct device_d *dev = priv->dev;
 	struct device_node *np = dev->device_node, *child;
+	struct device_node *physel;
 	int ret, i = 0;
 
 	ret = of_property_read_u32(np, "slaves", &priv->num_slaves);
@@ -1061,13 +1062,17 @@ static int cpsw_probe_dt(struct cpsw_priv *priv)
 
 	priv->slaves = xzalloc(sizeof(struct cpsw_slave) * priv->num_slaves);
 
-	for_each_child_of_node(np, child) {
-		if (of_device_is_compatible(child, "ti,am3352-cpsw-phy-sel")) {
-			ret = cpsw_phy_sel_init(priv, child);
-			if (ret)
-				return ret;
-		}
+	physel = of_parse_phandle(dev->device_node, "cpsw-phy-sel", 0);
+	if (!physel) {
+		physel = of_get_child_by_name(dev->device_node, "cpsw-phy-sel");
+		if (!physel)
+			dev_err(dev, "Phy mode node not found\n");
+	}
+	ret = cpsw_phy_sel_init(priv, physel);
+	if (ret)
+		return ret;
 
+	for_each_child_of_node(np, child) {
 		if (of_device_is_compatible(child, "ti,davinci_mdio")) {
 			ret = of_pinctrl_select_state_default(child);
 			if (ret)
Signature · 7 lines
2.7.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#6 lore raw

PATCH v2 7/7 arm: dts: am335x-phytec: Use phy-handle instead of phy_id

In reply to Teresa Remmet

Update am335x-phytec som device trees and use phy-handle instead of phy_id.

---
 arch/arm/dts/am335x-phytec-phycard-som.dtsi |  7 ++++++-
 arch/arm/dts/am335x-phytec-phycore-som.dtsi |  7 ++++++-
 arch/arm/dts/am335x-phytec-phyflex-som.dtsi | 12 ++++++++++--
 3 files changed, 22 insertions(+), 4 deletions(-)
arch/arm/dts/am335x-phytec-phycard-som.dtsi +6 -1
index 6a0442916bcb..2320ca18070f 100644
@@ -122,6 +122,10 @@
 	pinctrl-names = "default";
 	pinctrl-0 = <&davinci_mdio_default>;
 	status = "okay";
+
+	phy0: ethernet-phy@0 {
+		reg = <0>;
+	};
 };
 
 &phy_sel {
@@ -129,8 +133,9 @@
 };
 
 &cpsw_emac0 {
-	phy_id = <&davinci_mdio>, <0>;
+	phy-handle = <&phy0>;
 	phy-mode = "rmii";
+	dual_emac_res_vlan = <1>;
 };
 
 &mac {
arch/arm/dts/am335x-phytec-phycore-som.dtsi +6 -1
index cb2d30a15ccd..0601f5ab7ba5 100644
@@ -244,6 +244,10 @@
 	pinctrl-names = "default";
 	pinctrl-0 = <&davinci_mdio_default>;
 	status = "okay";
+
+	phy0: ethernet-phy@0 {
+		reg = <0>;
+	};
 };
 
 &phy_sel {
@@ -251,8 +255,9 @@
 };
 
 &cpsw_emac0 {
-	phy_id = <&davinci_mdio>, <0>;
+	phy-handle = <&phy0>;
 	phy-mode = "rmii";
+	dual_emac_res_vlan = <1>;
 };
 
 &mac {
arch/arm/dts/am335x-phytec-phyflex-som.dtsi +10 -2
index 465d3fa16cd7..4d0a91398843 100644
@@ -197,6 +197,14 @@
 	pinctrl-names = "default", "sleep";
 	pinctrl-0 = <&davinci_mdio_default>;
 	status = "okay";
+
+	phy0: ethernet-phy@0 {
+		reg = <1>;
+	};
+
+	phy1: ethernet-phy@1 {
+		reg = <2>;
+	};
 };
 
 &phy_sel {
@@ -204,7 +212,7 @@
 };
 
 &cpsw_emac0 {
-	phy_id = <&davinci_mdio>, <1>;
+	phy-handle = <&phy0>;
 	phy-mode = "rgmii";
 	dual_emac_res_vlan = <1>;
 
@@ -221,7 +229,7 @@
 };
 
 &cpsw_emac1 {
-	phy_id = <&davinci_mdio>, <2>;
+	phy-handle = <&phy1>;
 	phy-mode = "rmii";
 	dual_emac_res_vlan = <2>;
 	status = "disabled";
Signature · 7 lines
2.7.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Applied
#7 lore raw
In reply to Teresa Remmet
Quoted 10 lines · Teresa Remmet

Adds minimal support for the sysc interconnect target module found on many TI SoCs. With this device tree includes have been rearagned. We need the driver to probe the child devices of the bus.

---
Changes in v2:
- set driver in Kconfig to default y
- Use postcore_platform_driver() call
- Use global of_default_bus_match_table() instead of local table

Applied to master, thanks

Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox