Commit Graph

569 Commits

Author SHA1 Message Date
Rup Gajurel 113413ad43 drivers: ethernet: stm32: add support for disabling auto-negotiation
drivers: support disabling auto-negotiation for stm32 eth drivers

Signed-off-by: Rup Gajurel <rup@fb.com>
2021-07-14 07:28:57 -04:00
Gerard Marull-Paretas 26ad8376bd pm: remove callback from control function
The callback is not used anymore, so just delete it from the pm_control
callback signature.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-07-13 09:36:45 -04:00
Gerard Marull-Paretas 217e610d8f pm: remove redundant callback usage
the device PM callback is not used anymore by the device PM subsystem,
so remove it from all drivers/tests using it.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-07-13 09:36:45 -04:00
Gerard Marull-Paretas cc2f0e9c08 pm: use enum for device PM states
Move all PM_DEVICE_STATE_* definitions to an enum. The
PM_DEVICE_STATE_SET and PM_DEVICE_STATE_GET definitions have been kept
out of the enum since they do not represent any state. However, their
name has not been changed since they will be removed soon.

All drivers and tests have been adjusted accordingly.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-07-07 14:13:12 -04:00
Immo Birnbaum dabe728eef drivers: ethernet: add support for Xilinx GEM controller
Add support for the Xilinx GEM Ethernet controller, which is integrated
in both the Xilinx Zynq and ZynqMP (UltraScale) SoC families. The driver
supports the management of a PHY attached to the respective GEM's MDIO
interface.

This driver was developed with ultimately the Zynq-7000 series in mind,
but at the time being, it is limited to use in conjunction with the
ZynqMP RPU (Cortex-R5) cores. The differences are minor when it comes
to the adjustment of the TX clock frequency derived from the current
link speed reported by the PHY, but for use in conjunction with the
Zynq-7000, some larger adjustments will have to be made when it comes
to the placement of the DMA memory area, as this involves the confi-
guration of the MMU in Cortex-A CPUs.

The driver was developed under the qemu_cortex_r5 target. The Marvell
88E1111 PHY simulated by QEMU is supported by the driver.

Limitations currently exist when it comes to timestamping or VLAN
support and other minor things. Those haven't been implemented yet,
although they are supported by the hardware. In order to be fully
supported by the ZynqMP APU, 64-bit DMA address descriptor format
support will be added.

Signed-off-by: Immo Birnbaum <Immo.Birnbaum@weidmueller.com>
2021-06-21 20:11:00 -04:00
Parthiban Nallathambi dac8a6ef7d ethernet: w5500: reset_gpio isn't mandatory
reset_gpio pin isn't mandatory for function w5500.

Signed-off-by: Parthiban Nallathambi <parthiban@linumiz.com>
2021-06-17 18:38:15 -05:00
Piotr Mienkowski aaf64e0bdf soc: atmel_sam: Add _INST to ATMEL_SAM_DT_PIN* macros
The macros are used to get the pin(s) of a given driver instance. Add
_INST prefix to match convention used by the devicetree.h. The original
macros can now be used to obtain pin(s) of an arbitrary device instance
identified by the nodelabel.

Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
2021-06-14 09:50:41 -05:00
Jukka Rissanen 0b36b22146 drivers: eth: Enable TXTIME and PTP clock properly
Mark qemu_x86 and native_posix drivers to support both
TXTIME and PTP clock so that we can use txtime sample application
for testing.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-06-14 07:00:10 -04:00
Erwan Gouriou fcc3177509 drivers/pinmux: stm32: Move stm32 driver from stm32/
Since we removed various series headers, move stm32 driver
under main driver/pinmux folder.
Take this change into account into various drivers.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2021-06-11 08:04:39 -05:00
Jamie McCrae 6637c5bb4a drivers: ethernet: enc424j600: Add config get support for driver
This allows the current speed of the connection (100Mbps/10Mbps) and
if it is operating in half or full duplex to be queried

Signed-off-by: Jamie McCrae <jamie.mccrae@lairdconnect.com>
2021-06-09 11:45:10 +03:00
Jamie McCrae 5719e545af drivers: ethernet: enc424j600: Reduce interrupt command lengths
The enc424j600 chipet has 1-byte commands to enable or disable
interrupts which an be used rather than the currently used 4-byte
commands to speed the process up by a factor of 4x

Signed-off-by: Jamie McCrae <jamie.mccrae@lairdconnect.com>
2021-06-08 15:42:59 -05:00
Johann Fischer de974efebb drivers: eth_enc424j600: explicitly disable INTIE after reset
After system reset (SETETHRST) interrupt enable register (EIE)
has the default value 0x8010 and global interrupt enable flag (INTIE)
is set. This is not desired and the INTIE flag should be set only at
the end of the initialization.

Disable INTIE flag and set desired interrupts sources in
a single write command just right after system reset.

Resolves: #35091

Reported-by: Jamie McCrae <jamie.mccrae@lairdconnect.com>
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2021-05-21 07:35:19 -04:00
Johann Fischer 6de9c18f03 drivers: eth_enc424j600: terminate driver thread only when debugging
The controller has several interrupt sources which are signaled
via a single INT pin. Only the interrupt sources that are explicitly
switched on during controller initialization may generate an interrupt
signal. Currently there are only PHY Link Status Change Interrupt
and RX Packet Pending Interrupt enabled. So there is no other reason why
an interrupt can be triggered.

Terminate interrupt handling thread on unknown interrupt
only when debugging, as there are concerns that stopping
thread in the field is going too far.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2021-05-21 07:35:19 -04:00
Alexandre Bourdiol d915eb8252 drivers: ethernet: stm32: enable IRQ at the end of iface init
This avoid IRQ to be handle before iface init is finished
(especially before iface address is set)
Fixes #32771

Signed-off-by: Alexandre Bourdiol <alexandre.bourdiol@st.com>
2021-05-17 10:59:43 -04:00
Flavio Ceolin 0c607adb63 pm: device: Align state names with system states
Change device pm states to the same pattern used by system power
management.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-05-07 18:35:12 -04:00
Flavio Ceolin 7eba310220 power: device: void *context -> uint32_t *state
The context parameter used across device power management is
actually the power state. Just use it and avoid a lot of
unnecessary casts.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-05-07 16:55:31 -04:00
Gerard Marull-Paretas 56f1a8ce98 pm: rename PM_DEVICE_GET/SET_POWER_STATE to PM_DEVICE_STATE_GET/SET
Adjust name to be consistent with device PM naming conventions.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-05-05 18:35:49 -04:00
Gerard Marull-Paretas dbf46b3815 pm: rename device_pm_cb to pm_device_cb
Prefix all device PM functions/data structures with pm.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-05-05 18:35:49 -04:00
Gerard Marull-Paretas 2c7b763e47 pm: replace DEVICE_PM_* states with PM_DEVICE_*
Prefix device PM states with PM.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-05-05 18:35:49 -04:00
Gerard Marull-Paretas 27ed0fa0c5 drivers: ethernet: remove usage of device_pm_control_nop
device_pm_control_nop is now deprecated in favour of NULL.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-04-28 10:55:22 -04:00
Mario Jaun c276088567 drivers: ethernet: stm32: SRAM3 / MPU configuration
Fixes #29915.

Implements the memory layout and MPU configuration for Ethernet buffers
for STM32H7 controllers as recommended by ST. 16 KB of SRAM3 are
are reserved for this. The first 256 B are for the RX/TX descriptors and
configured as strongly ordered, shareable memory. The rest is for RX/TX
buffers and configured as non cacheable memory. This configuration is
automatically applied for H7 chips if the SRAM3 memory is enabled in the
device tree.

Signed-off-by: Mario Jaun <mario.jaun@gmail.com>
2021-04-27 14:16:35 +02:00
Jukka Rissanen ccadbe2e7d drivers: eth: e1000: Add simulated PTP clock device
For testing purposes, add simulated PTP clock device to e1000
Ethernet driver that is used in qemu_x86 board. The PTP clock
does nothing useful as there is no real hw behind this device.
We just emulate the clock in order to do some SO_TXTIME testing.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-04-27 12:02:19 +03:00
Jukka Rissanen 476b1885ce drivers: eth: mcux: Separate PTP clock from gPTP support
It is possible that user wants to access PTP clock but does
not need gPTP support. The networking txtime sample does exactly
this.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-04-27 12:02:19 +03:00
Jukka Rissanen 567860a5e2 drivers: eth: gmac: Separate PTP clock from gPTP support
It is possible that user wants to access PTP clock but does
not need gPTP support. The networking txtime sample does exactly
this.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-04-27 12:02:19 +03:00
Arvin Farahmand 835b875c17 drivers: ethernet: eth_sam_gmac: allow changing mac address
Support setting MAC address manually at runtime for Atmel SAM Ethernet
driver. The MAC address can be set using an ethernet management
request, e.g. (`net_mgmt(NET_REQUEST_ETHERNET_SET_MAC_ADDRESS, ...)`).

Signed-off-by: Arvin Farahmand <arvinf@ip-logix.com>
2021-04-15 10:43:21 +03:00
Peter Bigot 659fe50ff0 drivers: ethernet: rote conversion of k_work API
Replace all existing deprecated API with the recommended alternative.

Be aware that this does not address architectural errors in the use
of the work API.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2021-04-14 07:07:40 -04:00
Lukasz Majewski 344397fba5 fix: dsa: Initialize ethernet contexts for DSA switch lan interfaces
After the commit c1f7b9f45a ("net: l2: ethernet: fix k_work API usage
in carrier on/off handling") each ethernet interface (including DSA
ports) shall first call ethernet_init() before carrier_on_of() function
is called.

As DSA ethernet interfaces (lan{123}) have their own k_work item to
monitor the carrier status (by reading switch IC registers), it was
necessary to move functions, which initialize it after the code which
sets up necessary interfaces (i.e. call ethernet_init(iface)).

In that way the error when accessing uninitialized members of ethernet
context is avoided.

Signed-off-by: Lukasz Majewski <lukma@denx.de>
2021-04-07 14:17:05 +02:00
Flavio Ceolin 799147f43a drivers: ethernet: Fix variable type
net_recv_data returns an int, so we should not use an unsigned type.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-03-26 07:13:13 -04:00
Kumar Gala 0bb4665df7 include: Move ptp_clock.h to drivers/ptp_clock.h
Move ptp_clock.h out of the top level include/ dir into
include/drivers/ptp_clock.h and deprecated the old location.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-03-25 10:09:33 +02:00
Anas Nashif 5d6c219210 drivers: device: do not reuse tag name 'device'
Do not reuse tag name (misra rule 5.7).

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-03-22 19:48:14 -04:00
Anas Nashif a518f48796 clock: renmae z_timeout_end_calc -> sys_clock_timeout_end_calc
Do not use z_ for internal APIs, z_ is for private APIs within one
subsystem only.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-03-19 11:22:17 -04:00
Anas Nashif fe0872c0ab clocks: rename z_tick_get -> sys_clock_tick_get
Do not use z_ for internal APIs, z_ is for private APIs within one
subsystem only.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-03-19 11:22:17 -04:00
Guðni Már Gilbert bf93d4f1a0 drivers: ethernet: gmac: fix coverity issue
If return value is negative (failed) then log the error with a
message.

Coverity-CID: 219519
Fixes #32927

Signed-off-by: Guðni Már Gilbert <gudni.m.g@gmail.com>
2021-03-11 08:49:10 -05:00
James Harris b10428163a kernel: sem: add K_SEM_MAX_LIMIT
Currently there is no way to distinguish between a caller
explicitly asking for a semaphore with a limit that
happens to be `UINT_MAX` and a semaphore that just
has a limit "as large as possible".

Add `K_SEM_MAX_LIMIT`, currently defined to `UINT_MAX`, and akin
to `K_FOREVER` versus just passing some very large wait time.

In addition, the `k_sem_*` APIs were type-confused, where
the internal data structure was `uint32_t`, but the APIs took
and returned `unsigned int`. This changes the underlying data
structure to also use `unsigned int`, as changing the APIs
would be a (potentially) breaking change.

These changes are backwards-compatible, but it is strongly suggested
to take a quick scan for `k_sem_init` and `K_SEM_DEFINE` calls with
`UINT_MAX` (or `UINT32_MAX`) and replace them with `K_SEM_MAX_LIMIT`
where appropriate.

Signed-off-by: James Harris <james.harris@intel.com>
2021-03-05 08:13:53 -06:00
Kumar Gala c320bb0522 drivers: ethernet: remove stale Kconfig IRQ priority
Either get priority from devicetree (liteeth) or remove Kconfig symbols
that aren't used anywhere for IRQ priority (gecko, stm32_hal).

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-03-03 12:16:06 +03:00
Kumar Gala dd58d5e47f drivers: eth: mcux: Convert clock control to use DEVICE_DT_GET
Replace device_get_binding with DEVICE_DT_GET for getting access
to the clock controller device.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-02-19 05:36:35 -06:00
Kumar Gala b275fec8c4 soc: stm32: convert to use DEVICE_DT_GET for clocks
Convert from device_get_binding to DEVICE_DT_GET.  In doing this we
no longer need the label in the devicetree node so we remove that.

Removed all __ASSERT_NO_MSG(clk) since we'll get a build error if
DEVICE_DT_GET cant be satisfied, and the clock control api's will
handle reporting if the device_is_ready.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-02-16 17:01:37 -06:00
Anas Nashif 5d1c535fc8 license: add missing SPDX headers
Add SPDX header to files with existing license.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-02-11 08:05:16 -05:00
Pawel Sagan 0ce0f63036 drivers: ethernet: Verify returned value from net_if_set_link_addr
This commit verifies if the mac configuration is done correctly
during liteeth setup, and prompts a warning when not.

Signed-off-by: Pawel Sagan <psagan@antmicro.com>
Signed-off-by: Mateusz Holenko <mholenko@antmicro.com>
2021-01-20 13:54:32 +02:00
Pawel Sagan 4324356a6e drivers: ethernet: Add timeout when waiting for LITEETH_TX_READY
This commit eliminates an inifite waiting for the TX ready flag
in the eth liteeth driver, exiting with error after a defined
number of attempts.

Signed-off-by: Pawel Sagan <psagan@antmicro.com>
Signed-off-by: Mateusz Holenko <mholenko@antmicro.com>
2021-01-20 13:54:32 +02:00
Lukasz Majewski 6b440a1a13 eth: mcux: Add support for Distributed Switch Architecture devices
This patch adds support for DSA devices - like ksz8794 switch to the
mcux Kinetics driver.

Signed-off-by: Lukasz Majewski <lukma@denx.de>
2021-01-20 10:03:42 +02:00
Lukasz Majewski ca5e3ea654 eth: Add support for Distributed Switch Architecture [DSA] switches
This patch add support for DSA switches to Zephyr.

Signed-off-by: Lukasz Majewski <lukma@denx.de>
2021-01-20 10:03:42 +02:00
Lukasz Majewski 23961f75a6 drivers: ethernet: Add support for KSZ8794 DSA device
This patch adds support for Microchip's KSZ8794 DSA device, which for
switch and PHY control uses SPI communication.

This driver also provides support for handling tail tagging added and
decoded in the KSZ8794 device as well as modifying entries in the
static MAC address table.

It is also possible to use GPIO pin to reset KSZ8794 switch.
When the "reset-gpios" property is not defined, software based reset
is performed instead.

The KSZ8794 can now be used on boards which have SPI CS only available
as GPIO pin.

Signed-off-by: Stefan Bigler <stefan.bigler@securiton.ch>
Signed-off-by: Lukasz Majewski <lukma@denx.de>
2021-01-20 10:03:42 +02:00
Kumar Gala 02703e60d9 device: Remove DEVICE_DT_DECLARE / DEVICE_DT_INST_DECLARE
Now that we generate a header that extern's all possible devicetree
based device struct we can remove DEVICE_DT_DECLARE and
DEVICE_DT_INST_DECLARE as they aren't needed anymore.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-01-15 07:16:21 -06:00
Kumar Gala ce6088380f drivers: ethernet: Convert DEVICE_AND_API_INIT to DEVICE_DEFINE
Convert driver(s) to DEVICE_DEFINE instead of DEVICE_AND_API_INIT
so we can deprecate DEVICE_AND_API_INIT in the future.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-12-19 20:01:24 -05:00
Kumar Gala ae9e086802 drivers: ethernet: Convert drivers to new DT device macros
Convert ethernet drivers from:

    DEVICE_AND_API_INIT -> DEVICE_DT_INST_DEFINE
    DEVICE_GET -> DEVICE_DT_INST_GET
    DEVICE_DECLARE -> DEVICE_DT_INST_DECLARE
    ETH_NET_DEVICE_INIT -> ETH_NET_DEVICE_DT_INST_DEFINE
    NET_DEVICE_INIT -> NET_DEVICE_DT_INST_DEFINE

etc...

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-12-17 11:02:11 -06:00
Anas Nashif dd931f93a2 power: standarize PM Kconfigs and cleanup
- Remove SYS_ prefix
- shorten POWER_MANAGEMENT to just PM
- DEVICE_POWER_MANAGEMENT -> PM_DEVICE

and use PM_ as the prefix for all PM related Kconfigs

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-12-09 15:18:29 -05:00
Lukasz Majewski bcbe4e8f1f eth: mcux: Fix proper handling of the 'local-mac-address' property
After the change SHA1: 3498d43784 the
local-mac-address property is no longer parsed correctly when it is
defined in the '&enet` DTS node on k6x SoCs (e.g. frdm_k64f and
ip_k66f).

The problem is with value to which the
NODE_HAS_VALID_MAC_ADDR(DT_DRV_INST(n)) macro is resolved.

If the 'local-mac-address' is present it returns
'(!((0 == 0) && (0 == 0) && (18 == 0) && (19 == 0) && (0 == 0) && \
 (16 == 0)))' [*], otherwise it is 0.

As COND_CODE_{01} only accepts 0 or 1 as its first argument, it all
worked until the 'local-mac-address' was not defined. When present
the first argument to COND_CODE_{01} macro was [*] and it caused
build break.

Fixes issue: #30354
https://github.com/zephyrproject-rtos/zephyr/issues/30354

Signed-off-by: Lukasz Majewski <lukma@denx.de>
2020-12-07 12:56:32 +01:00
Lukasz Majewski db6015b53b eth: mcux: Replace DT_ALIAS() macro with DT_NODELABEL() for fixed link
After the commit SHA1: 370d02743a the
alias for 'eth' was removed. As a result DT_ALIAS(eth) for the mcux
enet driver was not providing a valid DTS node reference.

As a result the 'fixed-link' child node property was not recognized at
all.

The 'enet' is a valid DTS label for mcux enet driver, so lets use it
instead.

Signed-off-by: Lukasz Majewski <lukma@denx.de>
2020-12-02 09:28:44 -06:00
Maximilian Bachmann 3c8e98cb39 drivers/pcie: Change pcie_get_mbar() to return size and flags
currently pcie_get_mbar only returns the physical address.
This changes the function to return the size of the mbar and
the flags (IO Bar vs MEM BAR).

Signed-off-by: Maximilian Bachmann <m.bachmann@acontis.com>
2020-11-20 09:36:22 +02:00