Commit graph

621 commits

Author SHA1 Message Date
Gerard Marull-Paretas 5dc6ed3ce3 pinctrl: require ; after PINCTRL_DT_(INST_)DEFINE macros
The PINCTRL_DT_(INST_)DEFINE macros already defined the trailing ;,
making its usage inconsistent with other macros such as
DEVICE_DT_DEFINE.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-01-01 07:39:08 -05:00
Gerard Marull-Paretas 7a4d3f72f9 drivers: ethernet: phy_mii: use instance based DT macros
Replace usages of DT_DRV_INST(n) with instance based macros.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-12-17 17:30:06 +01:00
Alex Sergeev 40b81e6b76 drivers: ethernet: stm32: PTP L2 timestamping support
Add support for IEEE 1588-2008 (PTP L2) for STM32F7 and STM32H7
families.

Signed-off-by: Alex Sergeev <asergeev@carbonrobotics.com>
2021-12-13 22:19:25 -05:00
Brad Rushbrook 6d0e83f89e eth: Add promiscious mode support to stm32 ethernet abstraction
Simply adds the definitions in the stm32 hal to define ethernet
promiscious mode.

Signed-off-by: Brad Rushbrook <rushybrook@gmail.com>

Fixes error and resetting promisc mode, adds support for STM23H7x

Signed-off-by: Brad Rushbrook <rushybrook@gmail.com>

Co-authored-by: Alexander Kozhinov <AlexanderKozhinov@yandex.com>

Readability improvement; coding-style compliance

Signed-off-by: Brad Rushbrook <rushybrook@gmail.com>

Co-authored-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2021-12-09 19:32:25 -05:00
Mahesh Mahadevan 0a2464b89f drivers: ethernet: Add support for new PHY API
SDK 2.10 changed the PHY API. These updates are
needed as part of moving to SDK 2.10

1. add phy / mdio ops init
2. update PHY_Read/Write HAL call

Signed-off-by: Hake Huang <hake.huang@oss.nxp.com>
Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>
2021-12-09 09:18:10 -06:00
Lukasz Majewski 90f36ac16d net: dsa: ksz8794: Fix the port numbering for DSA tag setting
After the commit "dts: ksz8974: change port number to start at zero."
(SHA1: aa6217697e)

the lan ports are numbered starting from zero (not as previously from
one), so code assigning tags shall take this into account.

Signed-off-by: Lukasz Majewski <lukma@denx.de>
2021-12-01 13:58:08 -06:00
Lukasz Majewski cb4f7bc15c net: dsa: ksz8794: Fix the port numbering for this ETH switch IC
After the "dts: ksz8974: add support for ksz8863"
(SHA1: b0e4886dfa) commit the port numbering
for KSZ8794 was wrong.

This IC has 3 ETH ports (with linear offset), with port 4 being the
"master" with non linear offset (i.e. 0x50 instead of linear 0x40).

Such situation can be explained with similarity of this IC to ksz8795,
which has 4 LAN ports, and then the 0x40 offset is used.

Signed-off-by: Lukasz Majewski <lukma@denx.de>
2021-12-01 13:58:08 -06:00
Lukasz Majewski ab1f0b55d5 net: dsa: ksz8794: Use CONFIG_DSA_KSZ_TAIL_TAGGING in preprocessor macros
The name of macro to enable tail tagging support in DSA KSZ driver is
CONFIG_DSA_KSZ_TAIL_TAGGING, not DSA_KSZ_TAIL_TAGGING.

Signed-off-by: Lukasz Majewski <lukma@denx.de>
2021-12-01 13:58:08 -06:00
Lukasz Majewski 5b957e4e46 net: dsa: ksz8794: Remove check for CPU port in the switch setup
The check for CPU port on the KSZ8794 when the switch is initialized,
is not required as the last port number is always smaller than the CPU
port.

Signed-off-by: Lukasz Majewski <lukma@denx.de>
2021-12-01 13:58:08 -06:00
Gerard Marull-Paretas 89a4f36fc8 device: remove inclusion of pm/device.h
The device PM subsystem _depends_ on device, not vice-versa. Devices
only hold a reference to struct pm_device now, and initialize this
reference with the value provided in Z_DEVICE_DEFINE. This requirement
can be solved with a forward struct declaration, meaning there is no
need to include device PM headers.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-11-29 11:08:38 +01:00
Erwan Gouriou 18ae799b73 drivers/ethernet: dwmac_stm32h7x: use new pinctrl API
Use the new pinctrl API to configure pins.

Additionally, rename eth0_pins to eth0_pcfg to better fit
new pinctrl API.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2021-11-26 11:36:42 +01:00
Erwan Gouriou 87438e4587 drivers/ethernet: stm32_hal: use new pinctrl API
Use the new pinctrl API to configure pins.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2021-11-26 11:36:42 +01:00
Ryan McClelland b7bedb5c1e drivers: fix double promotion warnings
With -Wdouble-promotion added to the warning base, fix warnings given
by the compiler.

Signed-off-by: Ryan McClelland <ryanmcclelland@fb.com>
2021-11-24 17:14:25 -05:00
Nicolas Pitre e915dcad13 ethernet: dwmac: fix promiscuous mode
The dedicated PR (Promiscuous Mode) bit should be used instead of
the RA (Receive All) bit.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2021-11-23 10:31:29 -05:00
Gerard Marull-Paretas 88a69674c0 drivers: use new PM macros
Port some drivers to the recently introduced macros to showcase its
usage and be able to do some initial testing (nRF52840).

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-11-19 10:11:32 +01:00
Gerard Marull-Paretas c759a35d08 drivers: use DT_INST_ENUM_IDX(_OR) macros
Replace `DT_ENUM_IDX(_OR)(DT_DRV_INST(...),` pattern with
`DT_INST_ENUM_IDX(_OR)(...,`.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-11-18 19:12:07 -05:00
Alex Sergeev 1c53e68459 drivers: ethernet: mcux: Bugfix ptp_clock_adjust
ptp_clock_adjust() API call for mcux driver has a bug where
increment gets compared with an unsigned int, causing it to
always return -EINVAL.

Signed-off-by: Alex Sergeev <asergeev@carbonrobotics.com>
2021-11-11 07:05:22 -05:00
Gerard Marull-Paretas 4baf1e01ff drivers: use common PM action callback naming
The PM callback is no longer referenced as "pm_control" but
"pm_action_cb", so reflect this new naming on the callbacks.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-11-03 20:27:18 -04:00
Immo Birnbaum 266875ead0 drivers: ethernet: xlnx_gem: Zynq-7000 support for the Xilinx GEM driver
Add support for the Xilinx Zynq-7000 SoC family to this driver. This
includes some SoC-specific register accesses when setting an updated
TX clock divider, also, the device tree binding now supports higher
MDC clock divisor values when the current target SoC is a Zynq rather
than a ZynqMP.

With regards to the use of this driver in a QEMU simulation of the
Zynq-7000, the Kconfig file is modified so that the driver is not
enabled unless QEMU networking is set to Ethernet mode.

Signed-off-by: Immo Birnbaum <Immo.Birnbaum@weidmueller.com>
2021-10-28 15:26:50 +02:00
Nicolas Pitre bc41234104 ethernet: Synopsys DesignWare MAC driver
This is a driver for the Synopsys DesignWare MAC. It should work
with the "DesignWare Cores Ethernet Quality-of-Service" versions 4.x
and 5.x.

This driver uses a zero-copy strategy, meaning that the hardware
reads and writes data directly from/to packet fragment buffers
provided by the network subsystem without first copying the data into
a dedicated DMA bounce buffer.

Platform specific setup is necessary for the hardware to work.
Currently, only the STM32H7X series is implemented and tested.
While this part needs refinement, this driver performs better and uses
far less code space than the HAL-based alternative.

Not yet implemented:

- MDIO (it is WIP, currently relying on default PHY config)
- PTP support
- VLAN support
- various hardware offloads (when available)

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2021-10-27 10:43:05 -04:00
Torsten Rasmussen 36f5600387 kconfig: net: experimental settings now uses select EXPERIMENTAL
With the introduction of `EXPERIMENTAL` and `WARN_EXPERIMENTAL` in
Zephyr all subsys/net and drivers/ethernet/Kconfig.e1000 settings
having `[EXPERIMENTAL]` in their prompt has has been updated to include
`select EXPERIMENTAL` so that developers can enable warnings when
experimental features are enabled.

The following settings has EXPERIMENTAL removed as they are considered
mature:
- NET_OFFLOAD
- NET_PROMISCUOUS_MODE

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-10-25 10:46:48 +02:00
Markus Fuchs a283cb3311 drivers: Update drivers to use new multicast monitor API
Update drivers regarding latest multicast group join/leave monitor
changes which now supports both IPv6 and IPv4 multicast addresses.

Signed-off-by: Markus Fuchs <markus.fuchs@ch.sauter-bc.com>
2021-09-28 20:04:49 -04:00
Alex Sergeev 851cccb67e drivers: ethernet: mcux: generalize gPTP code to support PTP L2
Update eth_mcux.c to use CONFIG_NET_L2_PTP instead of CONFIG_NET_GPTP.

Signed-off-by: Alex Sergeev <asergeev@carbonrobotics.com>
2021-09-28 20:01:16 -04:00
Torsten Rasmussen e8eb8a8c2c drivers: ethernet: remove dedicated drivers__ethernet__native_posix lib
Fixes: #38403

The two eth_native_posix.c and eth_native_posix_adapt.c are now added
to the common drivers__ethernet Zephyr library.

Instead of creating a dedicated library for just two files those files
are now added to the common ethernet library, see also #8826.
Instead, the dedicated compile definitions required for those files are
specified using COMPILE_DEFINITIONS on the source files.

This also avoids the following warning as the ethernet library is no
longer empty.

> No SOURCES given to Zephyr library: drivers__ethernet
>
> Excluding target from build.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-09-28 12:13:23 +02:00
Torsten Rasmussen 8e64038559 drivers: net: adding NET_DRIVERS menuconfig
Fixes: #38403

Adding NET_DRIVERS menuconfig so that network drivers are grouped
together in its own menu entry under drivers, similar to most other
drivers.

This further has the advantages that `CONFIG_NET_DRIVERS` can be used
for testing to determine if network drivers has been selected.

This changed revealed a dependency loop where both `select` (for SLIP)
and `depends` (for PPP) which both depends on NET_DRIVERS` where in use
in the dependency tree for Qemu networking, especially NET_SLIP_TAP.

This is handled by defaulting `NET_DRIVERS` to `y` when building for a
Qemu target.
`SLIP` had a dependency to `!QEMU_TARGET || NET_QEMU_SLIP`. This is
changed so that SLIP prompt depends on `!QEMU_TARGET` which provides
full user control in hardware but makes the symbol promptless on Qemu
targets.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-09-28 12:13:23 +02:00
Xabier Marquiegui 3566cf11ba drivers: eth: e1000: only enable e1000 clock on e1000 configured
e1000 clock should only be enabled by default if e1000 driver is
configured

Signed-off-by: Xabier Marquiegui <xmarquiegui@ainguraiiot.com>
2021-09-24 17:05:11 -04:00
David Leach fb5192656a drivers: eth: mcux: Fix PTP clock init priority dependency
The net_core device initialization has a subtle dependency
on the PTP clock initialization. Adding a Kconfig and set
it to a priority level less than net_core. This will ensure
the initialization sequence.

Fixes #38571

Signed-off-by: David Leach <david.leach@nxp.com>
2021-09-17 10:56:35 +02:00
Arvin Farahmand 276996d754 drivers: eth_sam_gmac: use PHY driver
This commit removes PHY and MDIO specific code from the ATSAM
Ethernet driver and instead relies on a separate PHY driver to
handle the PHY.

Signed-off-by: Arvin Farahmand <arvinf@ip-logix.com>
2021-08-27 11:43:48 -04:00
Arvin Farahmand f845cddcf7 drivers: Add Ethernet PHY API
This commit adds support for Ethernet PHY drivers via a PHY API.

It also includes a driver for a generic MII compliant PHY
which supports most PHYs on the market.

Separating PHY driver from the SoC specific Ethernet driver
simplifies the Ethernet driver code and enables code re-use.
Drivers for specific PHYs with more advanced features, such as
RGMII delay in PHY can be developed independent of the Ethernet
MAC driver.

Signed-off-by: Arvin Farahmand <arvinf@ip-logix.com>
2021-08-27 11:43:48 -04:00
Tomasz Bursztyka f70ecc1099 drivers/pcie: Improve and fix MBAR retrieval depending on use cases
So far pcie_get_mbar() has been the only way to retrieve a MBAR. But
it's logic does not fit all uses cases as we will see further.
The meaning of its parameter "index" is not about BAR index but about
a valid Base Address count instead. It's an arbitrary way to index
MBARs unrelated to the actual BAR index.

While this has proven to be just the function we needed so far, this has
not been the case for MSI-X, which one (through BIR info) needs to
access the BAR by their actual index. Same as ivshmem in fact, though
that one did not generate any bug since it never has IO BARs nor 64bits
BARs (so far?).

So:

- renaming existing pcie_get_mbar() to pcie_probe_mbar(), which is a
  more relevant name as it indeed probes the BARs to find the nth valid
  one.
- Introducing a new pcie_get_mbar() which this time really asks for the
  BAR index.
- Applying the change where relevant. So all use pcie_probe_mbar() now
  but MSI-X and ivshmem.

Fixes #37444

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2021-08-20 06:30:20 -04:00
Daniel Leung e912a0533a drivers: ethernet: build as static library
Instead of putting object files inside libzephyr.a,
simply build a separate static library as most other
driver types are doing this already.

Note that the include to subsys has been moved from
under the drivers into subsys, as it is actually
the subsystem's job to make sure the include
directories are correct.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2021-08-17 06:06:03 -04:00
David Leach f3435b75ef hal: nxp: Update to SDK 2.10.0
Updating to the SDK 2.10.0 for select platforms.

west.yml:
- Update to point to the NXP HAL update with SDK 2.10.0 files
- modules/tee/tfm needed to be updated to synchronize the
  LPCXPRESSO55S69 platform SDK to version 2.10.0 to be in sync
  with Zephyr usage of SDK 2.10.0

drivers/counter/counter_mcux_pit.c:
- underlying SDK 2.10.0 adjusted the setting by -1 so need
  to adjust the reported value set by +1

drivers/ethernet/eth_mcux.c:
- SDK2.10 ethernet driver provided an assert test that highlighted
  we were using the wrong clock source on various platforms.

drivers/memc/memc_mcux_flexspi.c:
- SDK2.10 added compile time conditional on whether a field was
  defined for the flexspi configuration structure.

Signed-off-by: David Leach <david.leach@nxp.com>
2021-08-13 15:37:48 -05:00
Jordan Yates 3085c4d070 ethernet: w5500: convert to _dt_spec
Convert w5500 ethernet driver to `spi_dt_spect` and `gpio_dt_spec`.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2021-08-09 19:50:53 -04:00
Jordan Yates 128e8a4a6f ethernet: enc424j600: convert to _dt_spec
Convert enc424j600 ethernet driver to `spi_dt_spect` and `gpio_dt_spec`.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2021-08-09 19:50:53 -04:00
Jordan Yates a94cfb42a3 ethernet: enc28j60: convert to _dt_spec
Convert enc28j60 ethernet driver to `spi_dt_spect` and `gpio_dt_spec`.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2021-08-09 19:50:53 -04:00
Jan Pohanka 1df0569001 drivers: ethernet: eth_stm32_hal.c: add wait time for buffer allocation
Driver's RX thread can wait some time before a free buffer is available.
When resources are limited we can easily run out of them.

Fixes #36891.

Signed-off-by: Jan Pohanka <xhpohanka@gmail.com>
2021-08-05 11:32:42 -04:00
Gerard Marull-Paretas 7ccc1a41bc pm: use actions for device PM control
Instead of passing target states, use actions for device PM control.
Actions represent better the meaning of the callback argument.
Furthermore, they are more future proof as they can be suitable for
other PM actions that have no direct mapping to a state. If we compare
with Linux, we could have a multi-stage suspend/resume. Such scenario
would not have a good mapping when using target states.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-08-04 08:23:01 -04:00
Gerard Marull-Paretas 495672ab62 pm: cleanup pm control callback implementations
- Return -ENOTSUP if the requested state is not supported
- Remove redundant "noop style" functions.
- Use switch everywhere to handle requested state (not necessary in all
  drivers, but better take off with consistency in place after current
  changes).

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-08-04 08:23:01 -04:00
Gerard Marull-Paretas d41dadc569 pm: rename PM_DEVICE_STATE_SUSPEND to PM_DEVICE_STATE_SUSPENDED
The verb tense for the suspended state was not consistent with other
states. The likely reason: state was being used as a command/action.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-08-04 08:23:01 -04:00
Gerard Marull-Paretas 11eef4d8c8 pm: device: remove pointer usage for state
Since the state is no longer modified by the device PM callback, just
use the state value.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-08-04 08:23:01 -04:00
Gerard Marull-Paretas 9e7d545bb4 pm: device: remove ctrl_command callback argument
The ctrl_command is not used anymore, so remove it from the callback
signature.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-08-04 08:23:01 -04:00
Gerard Marull-Paretas da0ff4ae46 pm: device: remove usage of ctrl_command
The callback is now invoked to set the device PM state in all cases, so
the usage of ctrl_command is redundant.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-08-04 08:23:01 -04:00
Arvin Farahmand c95e0825d2 dsa: updated api to use net_if
Change DSA API to use `net_if` directly to make API calls instead of
indirectly via `dsa_context` and `switch_id`.
Remove unused `switch_id`, `switch_enable_port`, and `dsa_get_context`.

Signed-off-by: Arvin Farahmand <arvinf@ip-logix.com>
2021-07-26 19:37:22 -04:00
Arvin Farahmand 9cb353a97e dts: ksz8974: rename driver to ksz8xxxx
Renamed driver to reflect that it supports different KSZ8 series chips.

Signed-off-by: Arvin Farahmand <arvinf@ip-logix.com>
2021-07-26 19:37:22 -04:00
Arvin Farahmand b0e4886dfa dts: ksz8974: add support for ksz8863
Add DSA support for KSZ8863 chip.

Signed-off-by: Arvin Farahmand <arvinf@ip-logix.com>
2021-07-26 19:37:22 -04:00
Arvin Farahmand 47f4a86835 dts: ksz8974: improve slave interface initialization
Changed slave interface initialization code to be more generic and less
dependent on a specific number of ports.

Signed-off-by: Arvin Farahmand <arvinf@ip-logix.com>
2021-07-26 19:37:22 -04:00
Arvin Farahmand cb3aa1b1b5 dts: ksz8974: add private data structure for each device
Added a private structure pointer to each DSA device to store device
specific data.

Signed-off-by: Arvin Farahmand <arvinf@ip-logix.com>
2021-07-26 19:37:22 -04:00
Arvin Farahmand fe4f6969ac dts: ksz8974: fix compilation error if no tail tagging is enabled.
Compiling the driver without `CONFIG_DSA_KSZ8794_TAIL_TAGGING` would
generate an error.

Signed-off-by: Arvin Farahmand <arvinf@ip-logix.com>
2021-07-26 19:37:22 -04:00
Arvin Farahmand aa6217697e dts: ksz8974: change port number to start at zero.
Changed port numbers to start at zero since they're used as indexes
into various arrays in the code.

Signed-off-by: Arvin Farahmand <arvinf@ip-logix.com>
2021-07-26 19:37:22 -04:00
Arvin Farahmand b164baa3e9 dts: ksz8974: code clean-up
Removed superfluous port status read.

Signed-off-by: Arvin Farahmand <arvinf@ip-logix.com>
2021-07-26 19:37:22 -04:00