Commit graph

14 commits

Author SHA1 Message Date
Lukasz Majewski eccc64fc49 drivers: ethernet: lan865x: Trigger IRQ routine when rca>0 read from TX ftr
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>
2023-12-19 08:51:27 +01:00
Lukasz Majewski d2e864f17b drivers: ethernet: lan865x: Don't wait on semaphore if no memory for pkt
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>
2023-12-19 08:51:27 +01:00
Lukasz Majewski 32e64cb8c5 drivers: net: tc6: Handle lost of device synchronization (SYNC == 0)
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>
2023-12-01 10:54:27 +00:00
Lukasz Majewski 953c5f2d32 drivers: net: lan865x: Always read at least one chunk on IRQ received
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>
2023-12-01 10:54:27 +00:00
Lukasz Majewski f4a039e218 drivers: net: lan865x: Add support for setting T1S PLCA configuration
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>
2023-11-29 10:06:30 +01:00
Lukasz Majewski dd5027067a drivers: net: lan865x: Disable protected transmission mode before reset
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>
2023-11-29 10:06:30 +01:00
Lukasz Majewski 5cdf2f0eb7 drivers: net: lan865x: Move reset setup code to dedicated function
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>
2023-11-29 10:06:30 +01:00
Lukasz Majewski 9d8100f43f drivers: net: lan865x: Move PLCA configuration to dedicated structure
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>
2023-11-29 10:06:30 +01:00
Lukasz Majewski b0b57dac72 drivers: net: tc6: Provide separate function to check IC status
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>
2023-11-27 19:58:13 +01:00
Lukasz Majewski 8df4482f4c drivers: net: lan865x: Fix initialization of semaphores
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>
2023-11-27 19:58:13 +01:00
Lukasz Majewski ecfe5f1167 drivers: net: lan865x: Fix use of RX/TX semaphore in read chunks function
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>
2023-11-27 19:58:13 +01:00
Lukasz Majewski c2f5a9d67c drivers: net: lan865x: Do not read chunks if protected read error detected
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>
2023-11-27 19:58:13 +01:00
Lukasz Majewski d378e64508 drivers: net: Force LAN865x to start received frames at first chunk word
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>
2023-11-27 19:58:13 +01:00
Lukasz Majewski 12665a0dc1 driver: eth: Support for lan8651 T1S ETH
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>
2023-11-09 15:35:01 +01:00