dp83640: let the periodic pin from the module parameter be a default.
authorRichard Cochran <richardcochran@gmail.com>
Thu, 20 Mar 2014 21:22:00 +0000 (22:22 +0100)
committerDavid S. Miller <davem@davemloft.net>
Fri, 21 Mar 2014 18:21:15 +0000 (14:21 -0400)
This patch changes the driver use the new pin configuration method when
programming the periodic output signal.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/phy/dp83640.c

index 93db564389158c971c5d14fb7b9835888a244325..352c5e45fe9cc4477286970612a15b72a1e9dd81 100644 (file)
@@ -298,15 +298,22 @@ static u64 phy2txts(struct phy_txts *p)
        return ns;
 }
 
-static void periodic_output(struct dp83640_clock *clock,
-                           struct ptp_clock_request *clkreq, bool on)
+static int periodic_output(struct dp83640_clock *clock,
+                          struct ptp_clock_request *clkreq, bool on)
 {
        struct dp83640_private *dp83640 = clock->chosen;
        struct phy_device *phydev = dp83640->phydev;
        u32 sec, nsec, pwidth;
        u16 gpio, ptp_trig, trigger, val;
 
-       gpio = on ? gpio_tab[PEROUT_GPIO] : 0;
+       if (on) {
+               gpio = 1 + ptp_find_pin(clock->ptp_clock, PTP_PF_PEROUT, 0);
+               if (gpio < 1)
+                       return -EINVAL;
+       } else {
+               gpio = 0;
+       }
+
        trigger = PER_TRIGGER;
 
        ptp_trig = TRIG_WR |
@@ -323,7 +330,7 @@ static void periodic_output(struct dp83640_clock *clock,
                ext_write(0, phydev, PAGE5, PTP_TRIG, ptp_trig);
                ext_write(0, phydev, PAGE4, PTP_CTL, val);
                mutex_unlock(&clock->extreg_lock);
-               return;
+               return 0;
        }
 
        sec = clkreq->perout.start.sec;
@@ -352,6 +359,7 @@ static void periodic_output(struct dp83640_clock *clock,
        ext_write(0, phydev, PAGE4, PTP_CTL, val);
 
        mutex_unlock(&clock->extreg_lock);
+       return 0;
 }
 
 /* ptp clock methods */
@@ -484,8 +492,7 @@ static int ptp_dp83640_enable(struct ptp_clock_info *ptp,
        case PTP_CLK_REQ_PEROUT:
                if (rq->perout.index != 0)
                        return -EINVAL;
-               periodic_output(clock, rq, on);
-               return 0;
+               return periodic_output(clock, rq, on);
 
        default:
                break;