1. 05 Jul, 2024 8 commits
    • Serge Semin's avatar
      net: pcs: xpcs: Add Synopsys DW xPCS platform device driver · f6bb3e9d
      Serge Semin authored
      Synopsys DesignWare XPCS IP-core can be synthesized with the device CSRs
      being accessible over the MCI or APB3 interface instead of the MDIO bus
      (see the CSR_INTERFACE HDL parameter). Thus all the PCS registers can be
      just memory mapped and be a subject of the standard MMIO operations of
      course taking into account the peculiarities of the Clause C45 CSRs
      mapping. From that perspective the DW XPCS devices would look as just
      normal platform devices for the kernel.
      
      On the other hand in order to have the DW XPCS devices handled by the
      pcs-xpcs.c driver they need to be registered in the framework of the
      MDIO-subsystem. So the suggested change is about providing a DW XPCS
      platform device driver registering a virtual MDIO-bus with a single
      MDIO-device representing the DW XPCS device.
      
      DW XPCS platform device is supposed to be described by the respective
      compatible string "snps,dw-xpcs" (or with the PMA-specific compatible
      string), CSRs memory space and optional peripheral bus and reference clock
      sources. Depending on the INDIRECT_ACCESS IP-core synthesize parameter the
      memory-mapped reg-space can be represented as either directly or
      indirectly mapped Clause 45 space. In the former case the particular
      address is determined based on the MMD device and the registers offset (5
      + 16 bits all together) within the device reg-space. In the later case
      there is only 8 lower address bits are utilized for the registers mapping
      (255 CSRs). The upper bits are supposed to be written into the respective
      viewport CSR in order to select the respective MMD sub-page.
      
      Note, only the peripheral bus clock source is requested in the platform
      device probe procedure. The core and pad clocks handling has been
      implemented in the framework of the xpcs_create() method intentionally
      since the clocks-related setups are supposed to be performed later, during
      the DW XPCS main configuration procedures. (For instance they will be
      required for the DW Gen5 10G PMA configuration.)
      Signed-off-by: default avatarSerge Semin <fancer.lancer@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      f6bb3e9d
    • Serge Semin's avatar
      dt-bindings: net: Add Synopsys DW xPCS bindings · 664690eb
      Serge Semin authored
      Synopsys DesignWare XPCS IP-core is a Physical Coding Sublayer (PCS) layer
      providing an interface between the Media Access Control (MAC) and Physical
      Medium Attachment Sublayer (PMA) through a Media independent interface.
      From software point of view it exposes IEEE std. Clause 45 CSR space and
      can be accessible either by MDIO or MCI/APB3 bus interfaces. In the former
      case the PCS device is supposed to be defined under the respective MDIO
      bus DT-node. In the later case the DW xPCS will be just a normal IO
      memory-mapped device.
      
      Besides of that DW XPCS DT-nodes can have an interrupt signal and clock
      source properties specified. The former one indicates the Clause 73/37
      auto-negotiation events like: negotiation page received, AN is completed
      or incompatible link partner. The clock DT-properties can describe up to
      three clock sources: peripheral bus clock source, internal reference clock
      and the externally connected reference clock.
      
      Finally the DW XPCS IP-core can be optionally synthesized with a
      vendor-specific interface connected to the Synopsys PMA (also called
      DesignWare Consumer/Enterprise PHY). Alas that isn't auto-detectable in a
      portable way. So if the DW XPCS device has the respective PMA attached
      then it should be reflected in the DT-node compatible string so the driver
      would be aware of the PMA-specific device capabilities (mainly connected
      with CSRs available for the fine-tunings).
      Signed-off-by: default avatarSerge Semin <fancer.lancer@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      664690eb
    • Serge Semin's avatar
      net: pcs: xpcs: Introduce DW XPCS info structure · bcac735c
      Serge Semin authored
      The being introduced structure will preserve the PCS and PMA IDs retrieved
      from the respective DW XPCS MMDs or potentially pre-defined by the client
      drivers. (The later change will be introduced later in the framework of
      the commit adding the memory-mapped DW XPCS devices support.)
      
      The structure fields are filled in in the xpcs_get_id() function, which
      used to be responsible for the PCS Device ID getting only. Besides of the
      PCS ID the method now fetches the PMA/PMD IDs too from MMD 1, which used
      to be done in xpcs_dev_flag(). The retrieved PMA ID will be from now
      utilized for the PMA-specific tweaks like it was introduced for the
      Wangxun TxGBE PCS in the commit f629acc6 ("net: pcs: xpcs: support to
      switch mode for Wangxun NICs").
      
      Note 1. The xpcs_get_id() error-handling semantics has been changed. From
      now the error number will be returned from the function. There is no point
      in the next IOs or saving 0xffs and then looping over the actual device
      IDs if device couldn't be reached. -ENODEV will be returned if the very
      first IO operation failed thus indicating that no device could be found.
      
      Note 2. The PCS and PMA IDs macros have been converted to enum'es. The
      enum'es will be populated later in another commit with the virtual IDs
      identifying the DW XPCS devices which have some platform-specifics, but
      have been synthesized with the default PCS/PMA ID.
      Signed-off-by: default avatarSerge Semin <fancer.lancer@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      bcac735c
    • Serge Semin's avatar
      net: pcs: xpcs: Convert xpcs_compat to dw_xpcs_compat · 410232ab
      Serge Semin authored
      The xpcs_compat structure has been left as the only dw-prefix-less
      structure since the previous commit. Let's unify at least the structures
      naming in the driver by adding the dw_-prefix to it.
      Signed-off-by: default avatarSerge Semin <fancer.lancer@gmail.com>
      Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      410232ab
    • Serge Semin's avatar
      net: pcs: xpcs: Convert xpcs_id to dw_xpcs_desc · 71b200b3
      Serge Semin authored
      A structure with the PCS/PMA MMD IDs data is being introduced in one of
      the next commits. In order to prevent the names ambiguity let's convert
      the xpcs_id structure name to dw_xpcs_desc. The later version is more
      suitable since the structure content is indeed the device descriptor
      containing the data and callbacks required for the driver to correctly set
      the device up.
      Signed-off-by: default avatarSerge Semin <fancer.lancer@gmail.com>
      Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      71b200b3
    • Serge Semin's avatar
      net: pcs: xpcs: Split up xpcs_create() body to sub-functions · 03b3be07
      Serge Semin authored
      As an initial preparation before adding the fwnode-based DW XPCS device
      support let's split the xpcs_create() function code up to a set of the
      small sub-functions. Thus the xpcs_create() implementation will get to
      look simpler and turn to be more coherent. Further updates will just touch
      the new sub-functions a bit: add platform-specific device info, add the
      reference clock getting and enabling.
      
      The xpcs_create() method will now contain the next static methods calls:
      
      xpcs_create_data() - create the DW XPCS device descriptor, pre-initialize
      it' fields and increase the mdio device refcount-er;
      
      xpcs_init_id() - find XPCS ID instance and save it in the device
      descriptor;
      
      xpcs_init_iface() - find MAC/PCS interface descriptor and perform
      basic initialization specific to it: soft-reset, disable polling.
      
      The update doesn't imply any semantic change but merely makes the code
      looking simpler and more ready for adding new features support.
      
      Note the xpcs_destroy() has been moved to being defined below the
      xpcs_create_mdiodev() function as the driver now implies having the
      protagonist-then-antagonist functions definition order.
      Signed-off-by: default avatarSerge Semin <fancer.lancer@gmail.com>
      Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      03b3be07
    • Serge Semin's avatar
      net: pcs: xpcs: Move native device ID macro to linux/pcs/pcs-xpcs.h · f37bee95
      Serge Semin authored
      One of the next commits will alter the DW XPCS driver to support setting a
      custom device ID for the particular MDIO-device detected on the platform.
      The generic DW XPCS ID can be used as a custom ID as well in case if the
      DW XPCS-device was erroneously synthesized with no or some undefined ID.
      In addition to that having all supported DW XPCS device IDs defined in a
      single place will improve the code maintainability and readability.
      
      Note while at it rename the macros to being shorter and looking alike to
      the already defined NXP XPCS ID macro.
      Signed-off-by: default avatarSerge Semin <fancer.lancer@gmail.com>
      Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      f37bee95
    • Rob Herring (Arm)'s avatar
      dt-bindings: net: Define properties at top-level · 390b14b5
      Rob Herring (Arm) authored
      Convention is DT schemas should define all properties at the top-level
      and not inside of if/then schemas. That minimizes the if/then schemas
      and is more future proof.
      Signed-off-by: default avatarRob Herring (Arm) <robh@kernel.org>
      Reviewed-by: default avatarKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
      Reviewed-by: default avatarSerge Semin <fancer.lancer@gmail.com>
      Link: https://patch.msgid.link/20240703195827.1670594-2-robh@kernel.orgSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      390b14b5
  2. 04 Jul, 2024 32 commits