Skip to contentSkip to conversation

QE clock source improvements

PATCH In review Timur Tabi 1 participant 4 messages Oct 10, 2007

Subsystems (4)
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, updates some other functions to use an enum instead of an integer, and updates the ucc_geth driver to take advantage of all this.

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.

Update qe_setbrg() to take an enum qe_clock instead of an integer as its first paramter.

---

This patch applies to Kumar's for-2.6.24 branch.

 arch/powerpc/sysdev/qe_lib/qe.c |   13 +++--
 include/asm-powerpc/qe.h        |   98 +++++++++++++++++++--------------------
 2 files changed, 56 insertions(+), 55 deletions(-)
arch/powerpc/sysdev/qe_lib/qe.c +8 -5
index 3ccd360..8551e74 100644
@@ -167,7 +167,7 @@ unsigned int get_brg_clk(void)
 
 /* Program the BRG to the given sampling rate and multiplier
  *
- * @brg: the BRG, 1-16
+ * @brg: the BRG, QE_BRG1 - QE_BRG16
  * @rate: the desired sampling rate
  * @multiplier: corresponds to the value programmed in GUMR_L[RDCR] or
  * GUMR_L[TDCR].  E.g., if this BRG is the RX clock, and GUMR_L[RDCR]=01,
@@ -175,11 +175,14 @@ unsigned int get_brg_clk(void)
  *
  * Also note that the value programmed into the BRGC register must be even.
  */
-void qe_setbrg(unsigned int brg, unsigned int rate, unsigned int multiplier)
+void qe_setbrg(enum qe_clock brg, unsigned int rate, unsigned int multiplier)
 {
 	u32 divisor, tempval;
 	u32 div16 = 0;
 
+	if ((brg < QE_BRG1) || (brg > QE_BRG16))
+		return;
+
 	divisor = get_brg_clk() / (rate * multiplier);
 
 	if (divisor > QE_BRGC_DIVISOR_MAX + 1) {
@@ -196,7 +199,7 @@ void qe_setbrg(unsigned int brg, unsigned int rate, unsigned int multiplier)
 	tempval = ((divisor - 1) << QE_BRGC_DIVISOR_SHIFT) |
 		QE_BRGC_ENABLE | div16;
 
-	out_be32(&qe_immr->brg.brgc[brg - 1], tempval);
+	out_be32(&qe_immr->brg.brgc[brg - QE_BRG1], tempval);
 }
 
 /* Convert a string to a QE clock source enum
@@ -214,7 +217,7 @@ enum qe_clock qe_clock_source(const char *source)
 	if (strncasecmp(source, "brg", 3) == 0) {
 		i = simple_strtoul(source + 3, NULL, 10);
 		if ((i >= 1) && (i <= 16))
-			return QE_BRG1 + i - 1;
+			return (QE_BRG1 - 1) + i;
 		else
 			return QE_CLK_DUMMY;
 	}
@@ -222,7 +225,7 @@ enum qe_clock qe_clock_source(const char *source)
 	if (strncasecmp(source, "clk", 3) == 0) {
 		i = simple_strtoul(source + 3, NULL, 10);
 		if ((i >= 1) && (i <= 24))
-			return QE_CLK1 + i - 1;
+			return (QE_CLK1 - 1) + i;
 		else
 			return QE_CLK_DUMMY;
 	}
include/asm-powerpc/qe.h +48 -50

116 lines not on this page · raw message

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

This patch 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.

The device trees for 832x, 836x, and 8568 have been updated to contain the new property names only.

---

This patch applies to Kumar's for-2.6.24 branch, on top of my other patch titled "qe: add function qe_clock_source".

 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                |   12 +++++-------
 5 files changed, 21 insertions(+), 23 deletions(-)
arch/powerpc/boot/dts/mpc832x_mds.dts +4 -4
index fcd333c..b57485b 100644
@@ -217,8 +217,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 >;
 		};
@@ -238,8 +238,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 fbd1573..7a54072 100644
@@ -245,8 +245,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 >;
@@ -267,8 +267,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 +5 -7
index a147d6e..9308397 100644
@@ -3863,7 +3863,7 @@ static int ucc_geth_probe(struct of_device* ofdev, const struct of_device_id *ma
 	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_CLK1) ||
+		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");
@@ -3873,12 +3873,12 @@ static int ucc_geth_probe(struct of_device* ofdev, const struct of_device_id *ma
 		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. */
+			   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_CLK1) || (*prop > QE_CLK24)) {
+		if ((*prop < QE_CLK_NONE) || (*prop > QE_CLK24)) {
 			printk(KERN_ERR
 				"ucc_geth: invalid rx-clock propperty\n");
 			return -EINVAL;
@@ -3889,7 +3889,7 @@ static int ucc_geth_probe(struct of_device* ofdev, const struct of_device_id *ma
 	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_CLK1) ||
+		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");
@@ -3902,7 +3902,7 @@ static int ucc_geth_probe(struct of_device* ofdev, const struct of_device_id *ma
 				"ucc_geth: mising tx-clock-name property\n");
 			return -EINVAL;
 		}
-		if ((*prop < QE_CLK1) || (*prop > QE_CLK24)) {
+		if ((*prop < QE_CLK_NONE) || (*prop > QE_CLK24)) {
 			printk(KERN_ERR
 				"ucc_geth: invalid tx-clock property\n");
 			return -EINVAL;
@@ -3910,8 +3910,6 @@ static int ucc_geth_probe(struct of_device* ofdev, const struct of_device_id *ma
 		ug_info->uf_info.tx_clock = *prop;
 	}
 
-	prop = of_get_property(np, "tx-clock", NULL);
-	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
author
#3 lore raw
In reply to Timur Tabi

Sorry, please ignore this set. Something got screwed up with the patches. I'm going to resend.

Quoted 10 lines · Timur Tabi

This patch set adds a new property to make specifying QE clock sources easier, adds a function to help parse the property, updates some other functions to use an enum instead of an integer, and updates the ucc_geth driver to take advantage of all this.

_______________________________________________
Linuxppc-dev mailing list
[email protected]
https://ozlabs.org/mailman/listinfo/linuxppc-dev

Signature · 2 lines
Timur Tabi
Linux Kernel Developer @ Freescale