[POWERPC] ucc_geth: use rx-clock-name and tx-clock-name device tree properties
authorTimur Tabi <timur@freescale.com>
Mon, 3 Dec 2007 21:17:59 +0000 (15:17 -0600)
committerKumar Gala <galak@kernel.crashing.org>
Fri, 14 Dec 2007 07:16:58 +0000 (01:16 -0600)
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.

Signed-off-by: Timur Tabi <timur@freescale.com>
Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
arch/powerpc/boot/dts/mpc832x_mds.dts
arch/powerpc/boot/dts/mpc832x_rdb.dts
arch/powerpc/boot/dts/mpc836x_mds.dts
arch/powerpc/boot/dts/mpc8568mds.dts
drivers/net/ucc_geth.c

index 5a88187fe6bef241655459e76fcf952659543114..26ac467b10ea910c265e940fa8acea7b24616bd7 100644 (file)
                        interrupts = <22>;
                        interrupt-parent = < &qeic >;
                        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 >;
                };
                        interrupts = <23>;
                        interrupt-parent = < &qeic >;
                        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 >;
                };
index d3149862830749acd6d981573bc0a52bfb828251..10ff7aadf9dcce63335cc1e8640ac4f3e52ee487 100644 (file)
                        interrupts = <21>;
                        interrupt-parent = <&qeic>;
                        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>;
                };
                        interrupts = <22>;
                        interrupt-parent = <&qeic>;
                        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>;
                };
index ea07a6f03332aebbe9ed044a498684eeea92d4ca..fd841b2fddd016375b08e3f694a719b1756f23d7 100644 (file)
                        interrupts = <20>;
                        interrupt-parent = < &qeic >;
                        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 >;
                        interrupts = <21>;
                        interrupt-parent = < &qeic >;
                        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 >;
index 90545b16130dfe3e964a7f4d6a760736a211bd51..5818a7c861e734c9a1e5dd5d379cb4556a01a48c 100644 (file)
                        interrupts = <20>;
                        interrupt-parent = <&qeic>;
                        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";
                        interrupts = <21>;
                        interrupt-parent = <&qeic>;
                        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";
index 7f689907ac28485c537559dfb3f90be2898ff741..0f7626856a6b39fe963c39dc07d4227bb4d330ed 100644 (file)
@@ -3822,6 +3822,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;
+       const char *sprop;
        const void *mac_addr;
        phy_interface_t phy_interface;
        static const int enet_to_speed[] = {
@@ -3854,10 +3855,56 @@ static int ucc_geth_probe(struct of_device* ofdev, const struct of_device_id *ma
 
        ug_info->uf_info.ucc_num = ucc_num;
 
-       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;