Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 65025079 authored by David S. Miller's avatar David S. Miller
Browse files

Merge branch 'ptp-next'



Richard Cochran says:

====================
ptp: dynamic pin control

This patch series introduces a way of changing the auxiliary PTP
Hardware Clock functions (periodic output signals and time stamping
external signals) at run time. In the past on the netdev list, we have
discussed other ways to handle this, such as module parameters and
ethtool. This series implements a new PHC ioctl because that is the
most natural way. Users already activate the auxiliary functions via
the ioctls. The sysfs interface has also been expanded so that the pin
configuration can be programmed using shell scripts.

The first patch adds the new ioctls. The PHC subsystem does most of
the work of maintaining the function-to-pin mapping. Drivers will only
need to allocate and initialize a pin configuration table and also
provide a new method that validates a particular assignment.

Patches 5 and 6 just clean up a couple of issues in the phyter driver,
and the remaining patches actually hook the phyter's pins into the new
system.

* ChangeLog
** V3
   - simplify locking in the set pin logic
** V2
   - fix bug in sysfs code on init error path
   - rename ptp_setpin() to ptp_set_pinfunc()
   - rename .setpin() to .verify() in the driver interface
   - simplify ptp_find_pin() logic
   - use correct test when checking whether the pin with the
     calibration function is being reprogrammed
====================

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents a85ae0e9 621bdecc
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -54,6 +54,26 @@ Description:
		This file contains the number of programmable periodic
		output channels offered by the PTP hardware clock.

What:		/sys/class/ptp/ptpN/n_pins
Date:		March 2014
Contact:	Richard Cochran <richardcochran@gmail.com>
Description:
		This file contains the number of programmable pins
		offered by the PTP hardware clock.

What:		/sys/class/ptp/ptpN/pins
Date:		March 2014
Contact:	Richard Cochran <richardcochran@gmail.com>
Description:
		This directory contains one file for each programmable
		pin offered by the PTP hardware clock. The file name
		is the hardware dependent pin name. Reading from this
		file produces two numbers, the assigned function (see
		the PTP_PF_ enumeration values in linux/ptp_clock.h)
		and the channel number. The function and channel
		assignment may be changed by two writing numbers into
		the file.

What:		/sys/class/ptp/ptpN/pps_avaiable
Date:		September 2010
Contact:	Richard Cochran <richardcochran@gmail.com>
+55 −3
Original line number Diff line number Diff line
@@ -120,6 +120,13 @@ static void usage(char *progname)
		" -i val     index for event/trigger\n"
		" -k val     measure the time offset between system and phc clock\n"
		"            for 'val' times (Maximum 25)\n"
		" -l         list the current pin configuration\n"
		" -L pin,val configure pin index 'pin' with function 'val'\n"
		"            the channel index is taken from the '-i' option\n"
		"            'val' specifies the auxiliary function:\n"
		"            0 - none\n"
		"            1 - external time stamp\n"
		"            2 - periodic output\n"
		" -p val     enable output with a period of 'val' nanoseconds\n"
		" -P val     enable or disable (val=1|0) the system clock PPS\n"
		" -s         set the ptp clock time from the system time\n"
@@ -134,6 +141,7 @@ int main(int argc, char *argv[])
	struct ptp_extts_event event;
	struct ptp_extts_request extts_request;
	struct ptp_perout_request perout_request;
	struct ptp_pin_desc desc;
	struct timespec ts;
	struct timex tx;

@@ -156,11 +164,13 @@ int main(int argc, char *argv[])
	int extts = 0;
	int gettime = 0;
	int index = 0;
	int list_pins = 0;
	int oneshot = 0;
	int pct_offset = 0;
	int n_samples = 0;
	int periodic = 0;
	int perout = -1;
	int pin_index = -1, pin_func;
	int pps = -1;
	int settime = 0;

@@ -169,7 +179,7 @@ int main(int argc, char *argv[])

	progname = strrchr(argv[0], '/');
	progname = progname ? 1+progname : argv[0];
	while (EOF != (c = getopt(argc, argv, "a:A:cd:e:f:ghi:k:p:P:sSt:v"))) {
	while (EOF != (c = getopt(argc, argv, "a:A:cd:e:f:ghi:k:lL:p:P:sSt:v"))) {
		switch (c) {
		case 'a':
			oneshot = atoi(optarg);
@@ -199,6 +209,16 @@ int main(int argc, char *argv[])
			pct_offset = 1;
			n_samples = atoi(optarg);
			break;
		case 'l':
			list_pins = 1;
			break;
		case 'L':
			cnt = sscanf(optarg, "%d,%d", &pin_index, &pin_func);
			if (cnt != 2) {
				usage(progname);
				return -1;
			}
			break;
		case 'p':
			perout = atoi(optarg);
			break;
@@ -245,12 +265,14 @@ int main(int argc, char *argv[])
			       "  %d programmable alarms\n"
			       "  %d external time stamp channels\n"
			       "  %d programmable periodic signals\n"
			       "  %d pulse per second\n",
			       "  %d pulse per second\n"
			       "  %d programmable pins\n",
			       caps.max_adj,
			       caps.n_alarm,
			       caps.n_ext_ts,
			       caps.n_per_out,
			       caps.pps);
			       caps.pps,
			       caps.n_pins);
		}
	}

@@ -331,6 +353,24 @@ int main(int argc, char *argv[])
		}
	}

	if (list_pins) {
		int n_pins = 0;
		if (ioctl(fd, PTP_CLOCK_GETCAPS, &caps)) {
			perror("PTP_CLOCK_GETCAPS");
		} else {
			n_pins = caps.n_pins;
		}
		for (i = 0; i < n_pins; i++) {
			desc.index = i;
			if (ioctl(fd, PTP_PIN_GETFUNC, &desc)) {
				perror("PTP_PIN_GETFUNC");
				break;
			}
			printf("name %s index %u func %u chan %u\n",
			       desc.name, desc.index, desc.func, desc.chan);
		}
	}

	if (oneshot) {
		install_handler(SIGALRM, handle_alarm);
		/* Create a timer. */
@@ -392,6 +432,18 @@ int main(int argc, char *argv[])
		}
	}

	if (pin_index >= 0) {
		memset(&desc, 0, sizeof(desc));
		desc.index = pin_index;
		desc.func = pin_func;
		desc.chan = index;
		if (ioctl(fd, PTP_PIN_SETFUNC, &desc)) {
			perror("PTP_PIN_SETFUNC");
		} else {
			puts("set pin function okay");
		}
	}

	if (pps != -1) {
		int enable = pps ? 1 : 0;
		if (ioctl(fd, PTP_ENABLE_PPS, enable)) {
+1 −0
Original line number Diff line number Diff line
@@ -1040,6 +1040,7 @@ static struct ptp_clock_info bfin_ptp_caps = {
	.n_alarm	= 0,
	.n_ext_ts	= 0,
	.n_per_out	= 0,
	.n_pins		= 0,
	.pps		= 0,
	.adjfreq	= bfin_ptp_adjfreq,
	.adjtime	= bfin_ptp_adjtime,
+1 −0
Original line number Diff line number Diff line
@@ -6322,6 +6322,7 @@ static const struct ptp_clock_info tg3_ptp_caps = {
	.n_alarm	= 0,
	.n_ext_ts	= 0,
	.n_per_out	= 1,
	.n_pins		= 0,
	.pps		= 0,
	.adjfreq	= tg3_ptp_adjfreq,
	.adjtime	= tg3_ptp_adjtime,
+1 −0
Original line number Diff line number Diff line
@@ -372,6 +372,7 @@ void fec_ptp_init(struct platform_device *pdev)
	fep->ptp_caps.n_alarm = 0;
	fep->ptp_caps.n_ext_ts = 0;
	fep->ptp_caps.n_per_out = 0;
	fep->ptp_caps.n_pins = 0;
	fep->ptp_caps.pps = 0;
	fep->ptp_caps.adjfreq = fec_ptp_adjfreq;
	fep->ptp_caps.adjtime = fec_ptp_adjtime;
Loading