This code fixes following issue:
The TX data chunk (with NORX set) is send to chip (via SPI) and at the
same time a frame is received (by the LAN8651 chip), there will be no IRQ
(the CS is still asserted), just the footer will indicate this with the
rca > 0.
Afterwards, new frames are received by LAN865x, but as the previous footer
already is larger than zero there is no IRQ generated.
To be more specific (from [1], chapter 7.7):
----->8-------
RCA – Receive Chunks Available
Asserted:
The MAC-PHY detects CSn deasserted and the previous data footer had no
receive data chunks available (RCA = 0). The IRQn pin will be asserted
when receive data chunks become available for reading while CSn is
deasserted.
Deasserted:
On reception of the first data header following CSn being asserted
------8<------
Doc:
[1] - "OPEN Alliance 10BASE-T1x MAC-PHY Serial Interface"
OPEN_Alliance_10BASET1x_MAC-PHY_Serial_Interface_V1.1.pdf
Signed-off-by: Lukasz Majewski <lukma@denx.de>
With the current approach, the driver prevents from TX transmission
when waiting on timeout (standard 100ms) for available memory to be
able to allocate memory for RX packet.
It is safe to just protect the part of reading chunks. In that way
pending TX transmission can be performed.
Signed-off-by: Lukasz Majewski <lukma@denx.de>
Handle the situation when OA TC6 compliant device signals to the host
that its configuration is lost - i.e. the SYNC bit in the footer is
cleared.
In this (unlikely happen) situation the device is reset and reconfigured.
Signed-off-by: Lukasz Majewski <lukma@denx.de>
According to the OPEN Alliance 10Base-T1x standard (point 7.7), it is
mandatory to read at least single data chunk (no matter if received data
is valid or not) to deassert the interrupt in the LAN865x (then the tc6
structure fields are also updated from the footer).
Current approach with reading OA_BUFSTS register was providing the
required information (RCA and TXC), but could cause transmission "stalls"
as this operation (i.e. control, not data transmission) is not causing
deassertion of the interrupt IRQ_N line from OA TC6 compliant device.
With this patch - the transmission is always performed at least once, so
interrupt is always deasserted.
As the functionality of oa_tc6_update_buf_info() - i.e reading value of
RCA and TXC - has been replaced with extracting data from footer, this
function can be safely removed.
Signed-off-by: Lukasz Majewski <lukma@denx.de>
This commit provides support for changing PLCA parameters stored in
lan865x_config_plca structure.
After values are updated, the LAN865x needs to be reset and then
configured with new values.
Signed-off-by: Lukasz Majewski <lukma@denx.de>
The LAN865x device after HW reset supports only the non-protected control
transmission mode. When it is reset alone - without resetting already
configured HOST system - one must assure that in HOST's OA TC6 driver
the protection SPI transmission support is disabled.
Signed-off-by: Lukasz Majewski <lukma@denx.de>
The ctx->reset member of struct lan865x_data shall be cleared each time
one wants to reset the LAN8651 device.
Before this change this value was only initialized in the lan865x_init().
Signed-off-by: Lukasz Majewski <lukma@denx.de>
This change allows modification of the PLCA configuration in the lan865x
driver.
Values in this structure can be set via device tree as well as modified
by the user program.
Without this change the latter use case would not be possible as the
struct lan865x_config structure is defined as read only and its data
is only provided by device tree.
Signed-off-by: Lukasz Majewski <lukma@denx.de>
The code to handle OA TC6 compliant device's status is generic and can
be moved to device agnostic driver (oa_tc6.c).
Moreover, the original code has been augmented with LOG_WRN() messages.
Signed-off-by: Lukasz Majewski <lukma@denx.de>
This change fixes semaphores' definition. To be more specific - the
limit was wrongly set to UINT_MAX. With those changes - the 'tx_rx_sem'
now assures that only one execution path (i.e. receiving or sending
data) is executed at a time.
Moreover, the change in 'int_sem' now assures that this semaphore limit,
when reached, is saturated.
Signed-off-by: Lukasz Majewski <lukma@denx.de>
This commit ensures that whole receive function (called from interrupt
handler) is protected by the RX/TX semaphore.
Signed-off-by: Lukasz Majewski <lukma@denx.de>
The oa_tc6_update_buf_info() function returns error code when read
(protected or not) of OA_BUFSTS has been detected.
In that situation - one shall re-start the interrupt thread handling
(and hence correctly re-read value of this register) than use old
(stalled) RCA(RBA) data to read chunks (which may result in lockup).
Signed-off-by: Lukasz Majewski <lukma@denx.de>
Zephyr's network stack has issues with network IP header split across
fragments.
To alleviate this problem, the frame would be now aligned to first byte
of the chunk. This would ensure that the header is stored at one network
buffer fragment (as we explicitly set its size to 64B).
Signed-off-by: Lukasz Majewski <lukma@denx.de>
This patch set provides support for T1S ethernet device - LAN8651.
For SPI communication the implementation of Open Alliance TC6
specification is used.
The driver implementation focuses mostly on reducing memory footprint,
as the used SoC (STM32G491) for development has only 32 KiB RAM in total.
Signed-off-by: Lukasz Majewski <lukma@denx.de>