Skip to contentSkip to conversation

QE clock source improvements

PATCH Applied Timur Tabi 3 participants 8 messages Dec 3, 2007 – Dec 14, 2007

Subsystems (5)
lore
Share & tools
lore

Timur Tabi

author
#0 lore raw

cover QE clock source improvements

This patch set adds a new property to make specifying QE clock sources easier, adds a function to help parse the property, and updates the ucc_geth driver to take advantage of all this.

Patch #1 is an arch/powerpc patch meant for Kumar's for-2.6.25 branch. Patch #2 is a netdev patch, so it's either for Jeff G and/or Kumar.

author
#1 lore raw

PATCH 1/2 qe: add function qe_clock_source()

Add function qe_clock_source() which takes a string containing the name of a QE clock source (as is typically found in device trees) and returns the matching enum qe_clock value.

Update booting-without-of.txt to indicate that the UCC properties rx-clock and tx-clock are deprecated and replaced with rx-clock-name and tx-clock-name, which use strings instead of numbers to indicate QE clock sources.

---

This patch applies to Kumar's for-2.6.25 branch. You may need to apply my other pending patch, "qe: add ability to upload QE firmware", first.

 Documentation/powerpc/booting-without-of.txt |   13 ++++++++++
 arch/powerpc/sysdev/qe_lib/qe.c              |   32 ++++++++++++++++++++++++++
 include/asm-powerpc/qe.h                     |    1 +
 3 files changed, 46 insertions(+), 0 deletions(-)
Documentation/powerpc/booting-without-of.txt +13 -0
index e9a3cb1..c4342d3 100644
@@ -1626,6 +1626,19 @@ platforms are moved over to use the flattened-device-tree model.
    - interrupt-parent : the phandle for the interrupt controller that
      services interrupts for this device.
    - pio-handle : The phandle for the Parallel I/O port configuration.
+   - rx-clock-name: the UCC receive clock source
+     "none": clock source is disabled
+     "brg1" through "brg16": clock source is BRG1-BRG16, respectively
+     "clk1" through "clk24": clock source is CLK1-CLK24, respectively
+   - tx-clock-name: the UCC transmit clock source
+     "none": clock source is disabled
+     "brg1" through "brg16": clock source is BRG1-BRG16, respectively
+     "clk1" through "clk24": clock source is CLK1-CLK24, respectively
+   The following two properties are deprecated.  rx-clock has been replaced
+   with rx-clock-name, and tx-clock has been replaced with tx-clock-name.
+   Drivers that currently use the deprecated properties should continue to
+   do so, in order to support older device trees, but they should be updated
+   to check for the new properties first.
    - rx-clock : represents the UCC receive clock source.
      0x00 : clock source is disabled;
      0x1~0x10 : clock source is BRG1~BRG16 respectively;
arch/powerpc/sysdev/qe_lib/qe.c +32 -0
index 865277b..5df8530 100644
@@ -204,6 +204,38 @@ int qe_setbrg(enum qe_clock brg, unsigned int rate, unsigned int multiplier)
 }
 EXPORT_SYMBOL(qe_setbrg);
 
+/* Convert a string to a QE clock source enum
+ *
+ * This function takes a string, typically from a property in the device
+ * tree, and returns the corresponding "enum qe_clock" value.
+*/
+enum qe_clock qe_clock_source(const char *source)
+{
+	unsigned int i;
+
+	if (strcasecmp(source, "none") == 0)
+		return QE_CLK_NONE;
+
+	if (strncasecmp(source, "brg", 3) == 0) {
+		i = simple_strtoul(source + 3, NULL, 10);
+		if ((i >= 1) && (i <= 16))
+			return (QE_BRG1 - 1) + i;
+		else
+			return QE_CLK_DUMMY;
+	}
+
+	if (strncasecmp(source, "clk", 3) == 0) {
+		i = simple_strtoul(source + 3, NULL, 10);
+		if ((i >= 1) && (i <= 24))
+			return (QE_CLK1 - 1) + i;
+		else
+			return QE_CLK_DUMMY;
+	}
+
+	return QE_CLK_DUMMY;
+}
+EXPORT_SYMBOL(qe_clock_source);
+
 /* Initialize SNUMs (thread serial numbers) according to
  * QE Module Control chapter, SNUM table
  */
include/asm-powerpc/qe.h +1 -0
index 35c7b8d..430dc77 100644
@@ -84,6 +84,7 @@ extern int par_io_data_set(u8 port, u8 pin, u8 val);
 
 /* QE internal API */
 int qe_issue_cmd(u32 cmd, u32 device, u8 mcn_protocol, u32 cmd_input);
+enum qe_clock qe_clock_source(const char *source);
 int qe_setbrg(enum qe_clock brg, unsigned int rate, unsigned int multiplier);
 int qe_get_snum(void);
 void qe_put_snum(u8 snum);
Signature · 1 line
1.5.2.4
author
#2 lore raw

PATCH 2/2 ucc_geth: use rx-clock-name and tx-clock-name device tree properties

Updates the ucc_geth device driver to check the new rx-clock-name and tx-clock-name properties first. If present, it uses the new function qe_clock_source() to obtain the clock source. Otherwise, it checks the deprecated rx-clock and tx-clock properties.

Update the device trees for 832x, 836x, and 8568 to contain the new property names only.

---

This patch applies to Kumar's for-2.6.25 branch. ucc_geth will compile but not run if my other patch, "qe: add function qe_clock_source" has not also been applied.

 arch/powerpc/boot/dts/mpc832x_mds.dts |    8 ++--
 arch/powerpc/boot/dts/mpc832x_rdb.dts |    8 ++--
 arch/powerpc/boot/dts/mpc836x_mds.dts |    8 ++--
 arch/powerpc/boot/dts/mpc8568mds.dts  |    8 ++--
 drivers/net/ucc_geth.c                |   55 ++++++++++++++++++++++++++++++--
 5 files changed, 67 insertions(+), 20 deletions(-)
arch/powerpc/boot/dts/mpc832x_mds.dts +4 -4
index c64f303..fe54489 100644
@@ -223,8 +223,8 @@
 			 */
 			mac-address = [ 00 00 00 00 00 00 ];
 			local-mac-address = [ 00 00 00 00 00 00 ];
-			rx-clock = <19>;
-			tx-clock = <1a>;
+			rx-clock-name = "clk9";
+			tx-clock-name = "clk10";
 			phy-handle = < &phy3 >;
 			pio-handle = < &pio3 >;
 		};
@@ -244,8 +244,8 @@
 			 */
 			mac-address = [ 00 00 00 00 00 00 ];
 			local-mac-address = [ 00 00 00 00 00 00 ];
-			rx-clock = <17>;
-			tx-clock = <18>;
+			rx-clock-name = "clk7";
+			tx-clock-name = "clk8";
 			phy-handle = < &phy4 >;
 			pio-handle = < &pio4 >;
 		};
arch/powerpc/boot/dts/mpc832x_rdb.dts +4 -4
index 388c8a7..e68a08b 100644
@@ -202,8 +202,8 @@
 			 */
 			mac-address = [ 00 00 00 00 00 00 ];
 			local-mac-address = [ 00 00 00 00 00 00 ];
-			rx-clock = <20>;
-			tx-clock = <13>;
+			rx-clock-name = "clk16";
+			tx-clock-name = "clk3";
 			phy-handle = <&phy00>;
 			pio-handle = <&ucc2pio>;
 		};
@@ -223,8 +223,8 @@
 			 */
 			mac-address = [ 00 00 00 00 00 00 ];
 			local-mac-address = [ 00 00 00 00 00 00 ];
-			rx-clock = <19>;
-			tx-clock = <1a>;
+			rx-clock-name = "clk9";
+			tx-clock-name = "clk10";
 			phy-handle = <&phy04>;
 			pio-handle = <&ucc3pio>;
 		};
arch/powerpc/boot/dts/mpc836x_mds.dts +4 -4
index 0b2d2b5..bfd48d0 100644
@@ -254,8 +254,8 @@
 			 */
 			mac-address = [ 00 00 00 00 00 00 ];
 			local-mac-address = [ 00 00 00 00 00 00 ];
-			rx-clock = <0>;
-			tx-clock = <19>;
+			rx-clock-name = "none";
+			tx-clock-name = "clk9";
 			phy-handle = < &phy0 >;
 			phy-connection-type = "rgmii-id";
 			pio-handle = < &pio1 >;
@@ -276,8 +276,8 @@
 			 */
 			mac-address = [ 00 00 00 00 00 00 ];
 			local-mac-address = [ 00 00 00 00 00 00 ];
-			rx-clock = <0>;
-			tx-clock = <14>;
+			rx-clock-name = "none";
+			tx-clock-name = "clk4";
 			phy-handle = < &phy1 >;
 			phy-connection-type = "rgmii-id";
 			pio-handle = < &pio2 >;
arch/powerpc/boot/dts/mpc8568mds.dts +4 -4
index 5439437..cf45aab 100644
@@ -333,8 +333,8 @@
 			 */
 			mac-address = [ 00 00 00 00 00 00 ];
 			local-mac-address = [ 00 00 00 00 00 00 ];
-			rx-clock = <0>;
-			tx-clock = <20>;
+			rx-clock-name = "none";
+			tx-clock-name = "clk16";
 			pio-handle = <&pio1>;
 			phy-handle = <&phy0>;
 			phy-connection-type = "rgmii-id";
@@ -355,8 +355,8 @@
 			 */
 			mac-address = [ 00 00 00 00 00 00 ];
 			local-mac-address = [ 00 00 00 00 00 00 ];
-			rx-clock = <0>;
-			tx-clock = <20>;
+			rx-clock-name = "none";
+			tx-clock-name = "clk16";
 			pio-handle = <&pio2>;
 			phy-handle = <&phy1>;
 			phy-connection-type = "rgmii-id";
drivers/net/ucc_geth.c +51 -4

67 lines not on this page · raw message

Signature · 1 line
1.5.2.4
author
#3 lore raw

Re: [PATCH 2/2] ucc_geth: use rx-clock-name and tx-clock-name device tree properties

Quoted 9 lines · Timur Tabi

Updates the ucc_geth device driver to check the new rx-clock-name and tx-clock-name properties first. If present, it uses the new function qe_clock_source() to obtain the clock source. Otherwise, it checks the deprecated rx-clock and tx-clock properties.

Update the device trees for 832x, 836x, and 8568 to contain the new property names only.

If there are no objections, I'd like this patch to be pulled into 2.6.25. Thanks.

Signature · 2 lines
Timur Tabi
Linux kernel developer at Freescale
#4 lore raw

Re: [PATCH 2/2] ucc_geth: use rx-clock-name and tx-clock-name device tree properties

In reply to Timur Tabi
Quoted 8 lines · Timur Tabi

Updates the ucc_geth device driver to check the new rx-clock-name and tx-clock-name properties first. If present, it uses the new function qe_clock_source() to obtain the clock source. Otherwise, it checks the deprecated rx-clock and tx-clock properties.

Update the device trees for 832x, 836x, and 8568 to contain the new property names only.

Quoted 6 lines

---

This patch applies to Kumar's for-2.6.25 branch. ucc_geth will compile but not run if my other patch, "qe: add function qe_clock_source" has not also been applied.

Jeff, I'll take this patch via powerpc.git if you don't have any issue since its just touching probe/setup bits.

- k

Quoted 189 lines
arch/powerpc/boot/dts/mpc832x_mds.dts |    8 ++--
arch/powerpc/boot/dts/mpc832x_rdb.dts |    8 ++--
arch/powerpc/boot/dts/mpc836x_mds.dts |    8 ++--
arch/powerpc/boot/dts/mpc8568mds.dts  |    8 ++--
drivers/net/ucc_geth.c                |   55 ++++++++++++++++++++++++ 
++++++--
5 files changed, 67 insertions(+), 20 deletions(-)
arch/powerpc/boot/dts/mpc832x_mds.dts +4 -4
index c64f303..fe54489 100644
@@ -223,8 +223,8 @@
 			 */
 			mac-address = [ 00 00 00 00 00 00 ];
 			local-mac-address = [ 00 00 00 00 00 00 ];
-			rx-clock = <19>;
-			tx-clock = <1a>;
+			rx-clock-name = "clk9";
+			tx-clock-name = "clk10";
 			phy-handle = < &phy3 >;
 			pio-handle = < &pio3 >;
 		};
@@ -244,8 +244,8 @@
 			 */
 			mac-address = [ 00 00 00 00 00 00 ];
 			local-mac-address = [ 00 00 00 00 00 00 ];
-			rx-clock = <17>;
-			tx-clock = <18>;
+			rx-clock-name = "clk7";
+			tx-clock-name = "clk8";
 			phy-handle = < &phy4 >;
 			pio-handle = < &pio4 >;
 		};
arch/powerpc/boot/dts/mpc832x_rdb.dts +4 -4
index 388c8a7..e68a08b 100644
@@ -202,8 +202,8 @@
 			 */
 			mac-address = [ 00 00 00 00 00 00 ];
 			local-mac-address = [ 00 00 00 00 00 00 ];
-			rx-clock = <20>;
-			tx-clock = <13>;
+			rx-clock-name = "clk16";
+			tx-clock-name = "clk3";
 			phy-handle = <&phy00>;
 			pio-handle = <&ucc2pio>;
 		};
@@ -223,8 +223,8 @@
 			 */
 			mac-address = [ 00 00 00 00 00 00 ];
 			local-mac-address = [ 00 00 00 00 00 00 ];
-			rx-clock = <19>;
-			tx-clock = <1a>;
+			rx-clock-name = "clk9";
+			tx-clock-name = "clk10";
 			phy-handle = <&phy04>;
 			pio-handle = <&ucc3pio>;
 		};
arch/powerpc/boot/dts/mpc836x_mds.dts +4 -4
index 0b2d2b5..bfd48d0 100644
@@ -254,8 +254,8 @@
 			 */
 			mac-address = [ 00 00 00 00 00 00 ];
 			local-mac-address = [ 00 00 00 00 00 00 ];
-			rx-clock = <0>;
-			tx-clock = <19>;
+			rx-clock-name = "none";
+			tx-clock-name = "clk9";
 			phy-handle = < &phy0 >;
 			phy-connection-type = "rgmii-id";
 			pio-handle = < &pio1 >;
@@ -276,8 +276,8 @@
 			 */
 			mac-address = [ 00 00 00 00 00 00 ];
 			local-mac-address = [ 00 00 00 00 00 00 ];
-			rx-clock = <0>;
-			tx-clock = <14>;
+			rx-clock-name = "none";
+			tx-clock-name = "clk4";
 			phy-handle = < &phy1 >;
 			phy-connection-type = "rgmii-id";
 			pio-handle = < &pio2 >;
arch/powerpc/boot/dts/mpc8568mds.dts +4 -4
index 5439437..cf45aab 100644
@@ -333,8 +333,8 @@
 			 */
 			mac-address = [ 00 00 00 00 00 00 ];
 			local-mac-address = [ 00 00 00 00 00 00 ];
-			rx-clock = <0>;
-			tx-clock = <20>;
+			rx-clock-name = "none";
+			tx-clock-name = "clk16";
 			pio-handle = <&pio1>;
 			phy-handle = <&phy0>;
 			phy-connection-type = "rgmii-id";
@@ -355,8 +355,8 @@
 			 */
 			mac-address = [ 00 00 00 00 00 00 ];
 			local-mac-address = [ 00 00 00 00 00 00 ];
-			rx-clock = <0>;
-			tx-clock = <20>;
+			rx-clock-name = "none";
+			tx-clock-name = "clk16";
 			pio-handle = <&pio2>;
 			phy-handle = <&phy1>;
 			phy-connection-type = "rgmii-id";
drivers/net/ucc_geth.c +0 -0
index a3ff270..a93342e 100644
@@ -3814,6 +3814,7 @@ static int ucc_geth_probe(struct of_device*  

ofdev, const struct of_device_id *ma

	int err, ucc_num, max_speed = 0;
	const phandle *ph;
	const unsigned int *prop;
drivers/net/ucc_geth.c +1 -0
+	const char *sprop;
	const void *mac_addr;
	phy_interface_t phy_interface;
	static const int enet_to_speed[] = {
drivers/net/ucc_geth.c +0 -0
@@ -3846,10 +3847,56 @@ static int ucc_geth_probe(struct of_device*  

ofdev, const struct of_device_id *ma

	ug_info->uf_info.ucc_num = ucc_num;
drivers/net/ucc_geth.c +50 -4
-	prop = of_get_property(np, "rx-clock", NULL);
-	ug_info->uf_info.rx_clock = *prop;
-	prop = of_get_property(np, "tx-clock", NULL);
-	ug_info->uf_info.tx_clock = *prop;
+	sprop = of_get_property(np, "rx-clock-name", NULL);
+	if (sprop) {
+		ug_info->uf_info.rx_clock = qe_clock_source(sprop);
+		if ((ug_info->uf_info.rx_clock < QE_CLK_NONE) ||
+		    (ug_info->uf_info.rx_clock > QE_CLK24)) {
+			printk(KERN_ERR
+				"ucc_geth: invalid rx-clock-name property\n");
+			return -EINVAL;
+		}
+	} else {
+		prop = of_get_property(np, "rx-clock", NULL);
+		if (!prop) {
+			/* If both rx-clock-name and rx-clock are missing,
+			   we want to tell people to use rx-clock-name. */
+			printk(KERN_ERR
+				"ucc_geth: missing rx-clock-name property\n");
+			return -EINVAL;
+		}
+		if ((*prop < QE_CLK_NONE) || (*prop > QE_CLK24)) {
+			printk(KERN_ERR
+				"ucc_geth: invalid rx-clock propperty\n");
+			return -EINVAL;
+		}
+		ug_info->uf_info.rx_clock = *prop;
+	}
+
+	sprop = of_get_property(np, "tx-clock-name", NULL);
+	if (sprop) {
+		ug_info->uf_info.tx_clock = qe_clock_source(sprop);
+		if ((ug_info->uf_info.tx_clock < QE_CLK_NONE) ||
+		    (ug_info->uf_info.tx_clock > QE_CLK24)) {
+			printk(KERN_ERR
+				"ucc_geth: invalid tx-clock-name property\n");
+			return -EINVAL;
+		}
+	} else {
+		prop = of_get_property(np, "rx-clock", NULL);
+		if (!prop) {
+			printk(KERN_ERR
+				"ucc_geth: mising tx-clock-name property\n");
+			return -EINVAL;
+		}
+		if ((*prop < QE_CLK_NONE) || (*prop > QE_CLK24)) {
+			printk(KERN_ERR
+				"ucc_geth: invalid tx-clock property\n");
+			return -EINVAL;
+		}
+		ug_info->uf_info.tx_clock = *prop;
+	}
+
	err = of_address_to_resource(np, 0, &res);
	if (err)
		return -EINVAL;
Signature · 1 line
1.5.2.4
#5 lore raw

Re: [PATCH 2/2] ucc_geth: use rx-clock-name and tx-clock-name device tree properties

Quoted 11 lines · Kumar Gala
Quoted 8 lines · Timur Tabi

Updates the ucc_geth device driver to check the new rx-clock-name and tx-clock-name properties first. If present, it uses the new function qe_clock_source() to obtain the clock source. Otherwise, it checks the deprecated rx-clock and tx-clock properties.

Update the device trees for 832x, 836x, and 8568 to contain the new property names only.

Quoted 8 lines
Quoted 6 lines

---

This patch applies to Kumar's for-2.6.25 branch. ucc_geth will compile but not run if my other patch, "qe: add function qe_clock_source" has not also been applied.

Jeff, I'll take this patch via powerpc.git if you don't have any issue since its just touching probe/setup bits.

ACK

Applied
#6 lore raw

Re: [PATCH 2/2] ucc_geth: use rx-clock-name and tx-clock-name device tree properties

In reply to Timur Tabi
Quoted 15 lines · Timur Tabi

Updates the ucc_geth device driver to check the new rx-clock-name and tx-clock-name properties first. If present, it uses the new function qe_clock_source() to obtain the clock source. Otherwise, it checks the deprecated rx-clock and tx-clock properties.

Update the device trees for 832x, 836x, and 8568 to contain the new property names only.

---

This patch applies to Kumar's for-2.6.25 branch. ucc_geth will compile but not run if my other patch, "qe: add function qe_clock_source" has not also been applied.

Quoted 7 lines
arch/powerpc/boot/dts/mpc832x_mds.dts |    8 ++--
arch/powerpc/boot/dts/mpc832x_rdb.dts |    8 ++--
arch/powerpc/boot/dts/mpc836x_mds.dts |    8 ++--
arch/powerpc/boot/dts/mpc8568mds.dts  |    8 ++--
drivers/net/ucc_geth.c                |   55 ++++++++++++++++++++++++ 
++++++--
5 files changed, 67 insertions(+), 20 deletions(-)

applied.

- k

author
#7 lore raw

Re: [PATCH 1/2] qe: add function qe_clock_source()

In reply to Timur Tabi
Quoted 9 lines · Timur Tabi

Add function qe_clock_source() which takes a string containing the name of a QE clock source (as is typically found in device trees) and returns the matching enum qe_clock value.

Update booting-without-of.txt to indicate that the UCC properties rx-clock and tx-clock are deprecated and replaced with rx-clock-name and tx-clock-name, which use strings instead of numbers to indicate QE clock sources.

If there are no objections, I'd like this patch to be pulled into 2.6.25. Thanks.

Signature · 2 lines
Timur Tabi
Linux kernel developer at Freescale