aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Cochran <richardcochran@gmail.com>2012-10-29 04:45:19 -0400
committerDavid S. Miller <davem@davemloft.net>2012-11-01 12:21:32 -0400
commit00ab94eeaf6c1ad38ad7368c5148fed31403c8a2 (patch)
treee76e94fe6e4ff9ac7b48dfedd0584bf2bb5164de
parent78ca0b287314ad6b7b06161b3ff9b13e8a8bcce0 (diff)
cpts: specify the input clock frequency via DT
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>
-rw-r--r--Documentation/devicetree/bindings/net/cpsw.txt6
-rw-r--r--drivers/net/ethernet/ti/cpsw.c14
-rw-r--r--include/linux/platform_data/cpsw.h2
3 files changed, 22 insertions, 0 deletions
diff --git a/Documentation/devicetree/bindings/net/cpsw.txt b/Documentation/devicetree/bindings/net/cpsw.txt
index 9f61f2b51681..221460714c56 100644
--- a/Documentation/devicetree/bindings/net/cpsw.txt
+++ b/Documentation/devicetree/bindings/net/cpsw.txt
@@ -24,6 +24,8 @@ Required properties:
24 for the specific platform 24 for the specific platform
25- slaves : Specifies number for slaves 25- slaves : Specifies number for slaves
26- cpts_active_slave : Specifies the slave to use for time stamping 26- cpts_active_slave : Specifies the slave to use for time stamping
27- cpts_clock_mult : Numerator to convert input clock ticks into nanoseconds
28- cpts_clock_shift : Denominator to convert input clock ticks into nanoseconds
27- slave_reg_ofs : Specifies slave register offset 29- slave_reg_ofs : Specifies slave register offset
28- sliver_reg_ofs : Specifies slave sliver register offset 30- sliver_reg_ofs : Specifies slave sliver register offset
29- phy_id : Specifies slave phy id 31- phy_id : Specifies slave phy id
@@ -62,6 +64,8 @@ Examples:
62 mac_control = <0x20>; 64 mac_control = <0x20>;
63 slaves = <2>; 65 slaves = <2>;
64 cpts_active_slave = <0>; 66 cpts_active_slave = <0>;
67 cpts_clock_mult = <0x80000000>;
68 cpts_clock_shift = <29>;
65 cpsw_emac0: slave@0 { 69 cpsw_emac0: slave@0 {
66 slave_reg_ofs = <0x200>; 70 slave_reg_ofs = <0x200>;
67 sliver_reg_ofs = <0xd80>; 71 sliver_reg_ofs = <0xd80>;
@@ -98,6 +102,8 @@ Examples:
98 mac_control = <0x20>; 102 mac_control = <0x20>;
99 slaves = <2>; 103 slaves = <2>;
100 cpts_active_slave = <0>; 104 cpts_active_slave = <0>;
105 cpts_clock_mult = <0x80000000>;
106 cpts_clock_shift = <29>;
101 cpsw_emac0: slave@0 { 107 cpsw_emac0: slave@0 {
102 slave_reg_ofs = <0x200>; 108 slave_reg_ofs = <0x200>;
103 sliver_reg_ofs = <0xd80>; 109 sliver_reg_ofs = <0xd80>;
diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
index f16579123c1b..c04627cd60dd 100644
--- a/drivers/net/ethernet/ti/cpsw.c
+++ b/drivers/net/ethernet/ti/cpsw.c
@@ -854,6 +854,20 @@ static int cpsw_probe_dt(struct cpsw_platform_data *data,
854 } 854 }
855 data->cpts_active_slave = prop; 855 data->cpts_active_slave = prop;
856 856
857 if (of_property_read_u32(node, "cpts_clock_mult", &prop)) {
858 pr_err("Missing cpts_clock_mult property in the DT.\n");
859 ret = -EINVAL;
860 goto error_ret;
861 }
862 data->cpts_clock_mult = prop;
863
864 if (of_property_read_u32(node, "cpts_clock_shift", &prop)) {
865 pr_err("Missing cpts_clock_shift property in the DT.\n");
866 ret = -EINVAL;
867 goto error_ret;
868 }
869 data->cpts_clock_shift = prop;
870
857 data->slave_data = kzalloc(sizeof(struct cpsw_slave_data) * 871 data->slave_data = kzalloc(sizeof(struct cpsw_slave_data) *
858 data->slaves, GFP_KERNEL); 872 data->slaves, GFP_KERNEL);
859 if (!data->slave_data) { 873 if (!data->slave_data) {
diff --git a/include/linux/platform_data/cpsw.h b/include/linux/platform_data/cpsw.h
index 15a077eb0689..b5c16c3df458 100644
--- a/include/linux/platform_data/cpsw.h
+++ b/include/linux/platform_data/cpsw.h
@@ -34,6 +34,8 @@ struct cpsw_platform_data {
34 u32 slaves; /* number of slave cpgmac ports */ 34 u32 slaves; /* number of slave cpgmac ports */
35 struct cpsw_slave_data *slave_data; 35 struct cpsw_slave_data *slave_data;
36 u32 cpts_active_slave; /* time stamping slave */ 36 u32 cpts_active_slave; /* time stamping slave */
37 u32 cpts_clock_mult; /* convert input clock ticks to nanoseconds */
38 u32 cpts_clock_shift; /* convert input clock ticks to nanoseconds */
37 39
38 u32 ale_reg_ofs; /* address lookup engine reg offset */ 40 u32 ale_reg_ofs; /* address lookup engine reg offset */
39 u32 ale_entries; /* ale table size */ 41 u32 ale_entries; /* ale table size */