Skip to content

Commit df0b394

Browse files
kolacinskikarolanguy11
authored andcommitted
ice: Disable shared pin on E810 on setfunc
When setting a new supported function for a pin on E810, disable other enabled pin that shares the same GPIO. Reviewed-by: Arkadiusz Kubalewski <[email protected]> Signed-off-by: Karol Kolacinski <[email protected]> Reviewed-by: Simon Horman <[email protected]> Tested-by: Pucha Himasekhar Reddy <[email protected]> (A Contingent worker at Intel) Signed-off-by: Tony Nguyen <[email protected]>
1 parent d755a7e commit df0b394

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed

drivers/net/ethernet/intel/ice/ice_ptp.c

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1838,6 +1838,63 @@ static void ice_ptp_enable_all_perout(struct ice_pf *pf)
18381838
true);
18391839
}
18401840

1841+
/**
1842+
* ice_ptp_disable_shared_pin - Disable enabled pin that shares GPIO
1843+
* @pf: Board private structure
1844+
* @pin: Pin index
1845+
* @func: Assigned function
1846+
*
1847+
* Return: 0 on success, negative error code otherwise
1848+
*/
1849+
static int ice_ptp_disable_shared_pin(struct ice_pf *pf, unsigned int pin,
1850+
enum ptp_pin_function func)
1851+
{
1852+
unsigned int gpio_pin;
1853+
1854+
switch (func) {
1855+
case PTP_PF_PEROUT:
1856+
gpio_pin = pf->ptp.ice_pin_desc[pin].gpio[1];
1857+
break;
1858+
case PTP_PF_EXTTS:
1859+
gpio_pin = pf->ptp.ice_pin_desc[pin].gpio[0];
1860+
break;
1861+
default:
1862+
return -EOPNOTSUPP;
1863+
}
1864+
1865+
for (unsigned int i = 0; i < pf->ptp.info.n_pins; i++) {
1866+
struct ptp_pin_desc *pin_desc = &pf->ptp.pin_desc[i];
1867+
unsigned int chan = pin_desc->chan;
1868+
1869+
/* Skip pin idx from the request */
1870+
if (i == pin)
1871+
continue;
1872+
1873+
if (pin_desc->func == PTP_PF_PEROUT &&
1874+
pf->ptp.ice_pin_desc[i].gpio[1] == gpio_pin) {
1875+
pf->ptp.perout_rqs[chan].period.sec = 0;
1876+
pf->ptp.perout_rqs[chan].period.nsec = 0;
1877+
pin_desc->func = PTP_PF_NONE;
1878+
pin_desc->chan = 0;
1879+
dev_dbg(ice_pf_to_dev(pf), "Disabling pin %u with shared output GPIO pin %u\n",
1880+
i, gpio_pin);
1881+
return ice_ptp_cfg_perout(pf, &pf->ptp.perout_rqs[chan],
1882+
false);
1883+
} else if (pf->ptp.pin_desc->func == PTP_PF_EXTTS &&
1884+
pf->ptp.ice_pin_desc[i].gpio[0] == gpio_pin) {
1885+
pf->ptp.extts_rqs[chan].flags &= ~PTP_ENABLE_FEATURE;
1886+
pin_desc->func = PTP_PF_NONE;
1887+
pin_desc->chan = 0;
1888+
dev_dbg(ice_pf_to_dev(pf), "Disabling pin %u with shared input GPIO pin %u\n",
1889+
i, gpio_pin);
1890+
return ice_ptp_cfg_extts(pf, &pf->ptp.extts_rqs[chan],
1891+
false);
1892+
}
1893+
}
1894+
1895+
return 0;
1896+
}
1897+
18411898
/**
18421899
* ice_verify_pin - verify if pin supports requested pin function
18431900
* @info: the driver's PTP info structure
@@ -1872,6 +1929,14 @@ static int ice_verify_pin(struct ptp_clock_info *info, unsigned int pin,
18721929
return -EOPNOTSUPP;
18731930
}
18741931

1932+
/* On adapters with SMA_CTRL disable other pins that share same GPIO */
1933+
if (ice_is_feature_supported(pf, ICE_F_SMA_CTRL)) {
1934+
ice_ptp_disable_shared_pin(pf, pin, func);
1935+
pf->ptp.pin_desc[pin].func = func;
1936+
pf->ptp.pin_desc[pin].chan = chan;
1937+
return ice_ptp_set_sma_cfg(pf);
1938+
}
1939+
18751940
return 0;
18761941
}
18771942

0 commit comments

Comments
 (0)