cpts: specify the input clock frequency via DT
authorRichard Cochran <richardcochran@gmail.com>
Mon, 29 Oct 2012 08:45:19 +0000 (08:45 +0000)
committerDavid S. Miller <davem@davemloft.net>
Thu, 1 Nov 2012 16:21:32 +0000 (12:21 -0400)
This patch adds a way to configure the CPTS input clock scaling factors
via the device tree.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Documentation/devicetree/bindings/net/cpsw.txt
drivers/net/ethernet/ti/cpsw.c
include/linux/platform_data/cpsw.h

index 9f61f2b51681648c2ff714d13a891f69ccbb24be..221460714c56a56309867005254432edf046e4bb 100644 (file)
@@ -24,6 +24,8 @@ Required properties:
                          for the specific platform
 - slaves               : Specifies number for slaves
 - cpts_active_slave    : Specifies the slave to use for time stamping
+- cpts_clock_mult      : Numerator to convert input clock ticks into nanoseconds
+- cpts_clock_shift     : Denominator to convert input clock ticks into nanoseconds
 - slave_reg_ofs                : Specifies slave register offset
 - sliver_reg_ofs       : Specifies slave sliver register offset
 - phy_id               : Specifies slave phy id
@@ -62,6 +64,8 @@ Examples:
                mac_control = <0x20>;
                slaves = <2>;
                cpts_active_slave = <0>;
+               cpts_clock_mult = <0x80000000>;
+               cpts_clock_shift = <29>;
                cpsw_emac0: slave@0 {
                        slave_reg_ofs = <0x200>;
                        sliver_reg_ofs = <0xd80>;
@@ -98,6 +102,8 @@ Examples:
                mac_control = <0x20>;
                slaves = <2>;
                cpts_active_slave = <0>;
+               cpts_clock_mult = <0x80000000>;
+               cpts_clock_shift = <29>;
                cpsw_emac0: slave@0 {
                        slave_reg_ofs = <0x200>;
                        sliver_reg_ofs = <0xd80>;
index f16579123c1bd595d5753ec83499c70f90d03931..c04627cd60dd3e33ac0289a34dff1069ae5b3382 100644 (file)
@@ -854,6 +854,20 @@ static int cpsw_probe_dt(struct cpsw_platform_data *data,
        }
        data->cpts_active_slave = prop;
 
+       if (of_property_read_u32(node, "cpts_clock_mult", &prop)) {
+               pr_err("Missing cpts_clock_mult property in the DT.\n");
+               ret = -EINVAL;
+               goto error_ret;
+       }
+       data->cpts_clock_mult = prop;
+
+       if (of_property_read_u32(node, "cpts_clock_shift", &prop)) {
+               pr_err("Missing cpts_clock_shift property in the DT.\n");
+               ret = -EINVAL;
+               goto error_ret;
+       }
+       data->cpts_clock_shift = prop;
+
        data->slave_data = kzalloc(sizeof(struct cpsw_slave_data) *
                                   data->slaves, GFP_KERNEL);
        if (!data->slave_data) {
index 15a077eb0689266a36fb6e2708ad0d943910aed2..b5c16c3df4581909ee35ad7d1a5f5c5ff10ef50b 100644 (file)
@@ -34,6 +34,8 @@ struct cpsw_platform_data {
        u32     slaves;         /* number of slave cpgmac ports */
        struct cpsw_slave_data  *slave_data;
        u32     cpts_active_slave; /* time stamping slave */
+       u32     cpts_clock_mult;  /* convert input clock ticks to nanoseconds */
+       u32     cpts_clock_shift; /* convert input clock ticks to nanoseconds */
 
        u32     ale_reg_ofs;    /* address lookup engine reg offset */
        u32     ale_entries;    /* ale table size */