Skip to content

Commit c5ca120

Browse files
committed
ice: Disable shared pin on E810 on setfunc
JIRA: https://issues.redhat.com/browse/RHEL-29207 Upstream commit(s): commit df0b394 Author: Karol Kolacinski <karol.kolacinski@intel.com> Date: Fri Aug 30 13:07:21 2024 +0200 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 <arkadiusz.kubalewski@intel.com> Signed-off-by: Karol Kolacinski <karol.kolacinski@intel.com> Reviewed-by: Simon Horman <horms@kernel.org> Tested-by: Pucha Himasekhar Reddy <himasekharx.reddy.pucha@intel.com> (A Contingent worker at Intel) Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com> Signed-off-by: Petr Oros <poros@redhat.com>
1 parent af66c68 commit c5ca120

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
@@ -1856,6 +1856,63 @@ static void ice_ptp_enable_all_perout(struct ice_pf *pf)
18561856
true);
18571857
}
18581858

1859+
/**
1860+
* ice_ptp_disable_shared_pin - Disable enabled pin that shares GPIO
1861+
* @pf: Board private structure
1862+
* @pin: Pin index
1863+
* @func: Assigned function
1864+
*
1865+
* Return: 0 on success, negative error code otherwise
1866+
*/
1867+
static int ice_ptp_disable_shared_pin(struct ice_pf *pf, unsigned int pin,
1868+
enum ptp_pin_function func)
1869+
{
1870+
unsigned int gpio_pin;
1871+
1872+
switch (func) {
1873+
case PTP_PF_PEROUT:
1874+
gpio_pin = pf->ptp.ice_pin_desc[pin].gpio[1];
1875+
break;
1876+
case PTP_PF_EXTTS:
1877+
gpio_pin = pf->ptp.ice_pin_desc[pin].gpio[0];
1878+
break;
1879+
default:
1880+
return -EOPNOTSUPP;
1881+
}
1882+
1883+
for (unsigned int i = 0; i < pf->ptp.info.n_pins; i++) {
1884+
struct ptp_pin_desc *pin_desc = &pf->ptp.pin_desc[i];
1885+
unsigned int chan = pin_desc->chan;
1886+
1887+
/* Skip pin idx from the request */
1888+
if (i == pin)
1889+
continue;
1890+
1891+
if (pin_desc->func == PTP_PF_PEROUT &&
1892+
pf->ptp.ice_pin_desc[i].gpio[1] == gpio_pin) {
1893+
pf->ptp.perout_rqs[chan].period.sec = 0;
1894+
pf->ptp.perout_rqs[chan].period.nsec = 0;
1895+
pin_desc->func = PTP_PF_NONE;
1896+
pin_desc->chan = 0;
1897+
dev_dbg(ice_pf_to_dev(pf), "Disabling pin %u with shared output GPIO pin %u\n",
1898+
i, gpio_pin);
1899+
return ice_ptp_cfg_perout(pf, &pf->ptp.perout_rqs[chan],
1900+
false);
1901+
} else if (pf->ptp.pin_desc->func == PTP_PF_EXTTS &&
1902+
pf->ptp.ice_pin_desc[i].gpio[0] == gpio_pin) {
1903+
pf->ptp.extts_rqs[chan].flags &= ~PTP_ENABLE_FEATURE;
1904+
pin_desc->func = PTP_PF_NONE;
1905+
pin_desc->chan = 0;
1906+
dev_dbg(ice_pf_to_dev(pf), "Disabling pin %u with shared input GPIO pin %u\n",
1907+
i, gpio_pin);
1908+
return ice_ptp_cfg_extts(pf, &pf->ptp.extts_rqs[chan],
1909+
false);
1910+
}
1911+
}
1912+
1913+
return 0;
1914+
}
1915+
18591916
/**
18601917
* ice_verify_pin - verify if pin supports requested pin function
18611918
* @info: the driver's PTP info structure
@@ -1890,6 +1947,14 @@ static int ice_verify_pin(struct ptp_clock_info *info, unsigned int pin,
18901947
return -EOPNOTSUPP;
18911948
}
18921949

1950+
/* On adapters with SMA_CTRL disable other pins that share same GPIO */
1951+
if (ice_is_feature_supported(pf, ICE_F_SMA_CTRL)) {
1952+
ice_ptp_disable_shared_pin(pf, pin, func);
1953+
pf->ptp.pin_desc[pin].func = func;
1954+
pf->ptp.pin_desc[pin].chan = chan;
1955+
return ice_ptp_set_sma_cfg(pf);
1956+
}
1957+
18931958
return 0;
18941959
}
18951960

0 commit comments

Comments
 (0)