Commit 22820017 authored by John Efstathiades's avatar John Efstathiades Committed by David S. Miller

Support LAN743x PTP periodic output on any GPIO

The LAN743x Ethernet controller provides two independent PTP event
channels. Each one can be used to generate a periodic output from
the PTP clock. The output can be routed to any one of the available
GPIO pins on the device.

The PTP clock API can now be used to:
- select any LAN743x GPIO pin to function as a periodic output
- select either LAN743x PTP event channel to generate the output

The LAN7430 has 4 GPIO pins that are multiplexed with its internal
PHY LED control signals. A pin assigned to the LED control function
will be assigned to the GPIO function if selected for PTP periodic
output.
Signed-off-by: default avatarJohn Efstathiades <john.efstathiades@pebblebay.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 26285f13
...@@ -7,6 +7,18 @@ ...@@ -7,6 +7,18 @@
#include "linux/ptp_clock_kernel.h" #include "linux/ptp_clock_kernel.h"
#include "linux/netdevice.h" #include "linux/netdevice.h"
#define LAN7430_N_LED 4
#define LAN7430_N_GPIO 4 /* multiplexed with PHY LEDs */
#define LAN7431_N_GPIO 12
#define LAN743X_PTP_N_GPIO LAN7431_N_GPIO
/* the number of periodic outputs is limited by number of
* PTP clock event channels
*/
#define LAN743X_PTP_N_EVENT_CHAN 2
#define LAN743X_PTP_N_PEROUT LAN743X_PTP_N_EVENT_CHAN
struct lan743x_adapter; struct lan743x_adapter;
/* GPIO */ /* GPIO */
...@@ -40,9 +52,14 @@ int lan743x_ptp_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd); ...@@ -40,9 +52,14 @@ int lan743x_ptp_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd);
#define LAN743X_PTP_NUMBER_OF_TX_TIMESTAMPS (4) #define LAN743X_PTP_NUMBER_OF_TX_TIMESTAMPS (4)
#define PTP_FLAG_PTP_CLOCK_REGISTERED BIT(1) #define PTP_FLAG_PTP_CLOCK_REGISTERED BIT(1)
#define PTP_FLAG_ISR_ENABLED BIT(2) #define PTP_FLAG_ISR_ENABLED BIT(2)
struct lan743x_ptp_perout {
int event_ch; /* PTP event channel (0=channel A, 1=channel B) */
int gpio_pin; /* GPIO pin where output appears */
};
struct lan743x_ptp { struct lan743x_ptp {
int flags; int flags;
...@@ -51,13 +68,13 @@ struct lan743x_ptp { ...@@ -51,13 +68,13 @@ struct lan743x_ptp {
struct ptp_clock *ptp_clock; struct ptp_clock *ptp_clock;
struct ptp_clock_info ptp_clock_info; struct ptp_clock_info ptp_clock_info;
struct ptp_pin_desc pin_config[1]; struct ptp_pin_desc pin_config[LAN743X_PTP_N_GPIO];
#define LAN743X_PTP_NUMBER_OF_EVENT_CHANNELS (2)
unsigned long used_event_ch; unsigned long used_event_ch;
struct lan743x_ptp_perout perout[LAN743X_PTP_N_PEROUT];
int perout_event_ch; bool leds_multiplexed;
int perout_gpio_bit; bool led_enabled[LAN7430_N_LED];
/* tx_ts_lock: used to prevent concurrent access to timestamp arrays */ /* tx_ts_lock: used to prevent concurrent access to timestamp arrays */
spinlock_t tx_ts_lock; spinlock_t tx_ts_lock;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment