mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sean Anderson <sean.anderson@seco.com>
To: Camelia Alexandra Groza <camelia.groza@nxp.com>,
	"David S . Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	Madalin Bucur <madalin.bucur@nxp.com>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>,
	Eric Dumazet <edumazet@google.com>,
	"linux-arm-kernel@lists.infradead.org" 
	<linux-arm-kernel@lists.infradead.org>,
	Russell King <linux@armlinux.org.uk>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH net-next v3 39/47] net: fman: memac: Add serdes support
Date: Thu, 21 Jul 2022 11:38:06 -0400	[thread overview]
Message-ID: <ecc9051b-63dc-131b-9f87-138af7dc88aa@seco.com> (raw)
In-Reply-To: <VI1PR04MB58071192E279070C90F81843F2919@VI1PR04MB5807.eurprd04.prod.outlook.com>



On 7/21/22 9:30 AM, Camelia Alexandra Groza wrote:
>> -----Original Message-----
>> From: Sean Anderson <sean.anderson@seco.com>
>> Sent: Saturday, July 16, 2022 1:00
>> To: David S . Miller <davem@davemloft.net>; Jakub Kicinski
>> <kuba@kernel.org>; Madalin Bucur <madalin.bucur@nxp.com>;
>> netdev@vger.kernel.org
>> Cc: Paolo Abeni <pabeni@redhat.com>; Eric Dumazet
>> <edumazet@google.com>; linux-arm-kernel@lists.infradead.org; Russell
>> King <linux@armlinux.org.uk>; linux-kernel@vger.kernel.org; Sean Anderson
>> <sean.anderson@seco.com>
>> Subject: [PATCH net-next v3 39/47] net: fman: memac: Add serdes support
>> 
>> This adds support for using a serdes which has to be configured. This is
>> primarly in preparation for the next commit, which will then change the
>> serdes mode dynamically.
>> 
>> Signed-off-by: Sean Anderson <sean.anderson@seco.com>
>> ---
>> 
>> (no changes since v1)
>> 
>>  .../net/ethernet/freescale/fman/fman_memac.c  | 48
>> ++++++++++++++++++-
>>  1 file changed, 46 insertions(+), 2 deletions(-)
>> 
>> diff --git a/drivers/net/ethernet/freescale/fman/fman_memac.c
>> b/drivers/net/ethernet/freescale/fman/fman_memac.c
>> index 02b3a0a2d5d1..a62fe860b1d0 100644
>> --- a/drivers/net/ethernet/freescale/fman/fman_memac.c
>> +++ b/drivers/net/ethernet/freescale/fman/fman_memac.c
>> @@ -13,6 +13,7 @@
>>  #include <linux/io.h>
>>  #include <linux/phy.h>
>>  #include <linux/phy_fixed.h>
>> +#include <linux/phy/phy.h>
>>  #include <linux/of_mdio.h>
>> 
>>  /* PCS registers */
>> @@ -324,6 +325,7 @@ struct fman_mac {
>>  	void *fm;
>>  	struct fman_rev_info fm_rev_info;
>>  	bool basex_if;
>> +	struct phy *serdes;
>>  	struct phy_device *pcsphy;
>>  	bool allmulti_enabled;
>>  };
>> @@ -1203,17 +1205,55 @@ int memac_initialization(struct mac_device
>> *mac_dev,
>>  		}
>>  	}
>> 
>> +	memac->serdes = devm_of_phy_get(mac_dev->dev, mac_node,
>> "serdes");
> 
> devm_of_phy_get returns -ENOSYS on PPC builds because CONFIG_GENERIC_PHY isn't
> enabled by default. Please add a dependency.
> 
>> +	if (PTR_ERR(memac->serdes) == -ENODEV) {

I think it is better to add -ENOSYS to the condition here. That way,
the phy subsystem stays optional.

--Sean

>> +		memac->serdes = NULL;
>> +	} else if (IS_ERR(memac->serdes)) {
>> +		err = PTR_ERR(memac->serdes);
>> +		dev_err_probe(mac_dev->dev, err, "could not get
>> serdes\n");
>> +		goto _return_fm_mac_free;
>> +	} else {
>> +		err = phy_init(memac->serdes);
>> +		if (err) {
>> +			dev_err_probe(mac_dev->dev, err,
>> +				      "could not initialize serdes\n");
>> +			goto _return_fm_mac_free;
>> +		}
>> +
>> +		err = phy_power_on(memac->serdes);
>> +		if (err) {
>> +			dev_err_probe(mac_dev->dev, err,
>> +				      "could not power on serdes\n");
>> +			goto _return_phy_exit;
>> +		}
>> +
>> +		if (memac->phy_if == PHY_INTERFACE_MODE_SGMII ||
>> +		    memac->phy_if == PHY_INTERFACE_MODE_1000BASEX ||
>> +		    memac->phy_if == PHY_INTERFACE_MODE_2500BASEX ||
>> +		    memac->phy_if == PHY_INTERFACE_MODE_QSGMII ||
>> +		    memac->phy_if == PHY_INTERFACE_MODE_XGMII) {
>> +			err = phy_set_mode_ext(memac->serdes,
>> PHY_MODE_ETHERNET,
>> +					       memac->phy_if);
>> +			if (err) {
>> +				dev_err_probe(mac_dev->dev, err,
>> +					      "could not set serdes mode
>> to %s\n",
>> +					      phy_modes(memac->phy_if));
>> +				goto _return_phy_power_off;
>> +			}
>> +		}
>> +	}
>> +
>>  	if (!mac_dev->phy_node && of_phy_is_fixed_link(mac_node)) {
>>  		struct phy_device *phy;
>> 
>>  		err = of_phy_register_fixed_link(mac_node);
>>  		if (err)
>> -			goto _return_fm_mac_free;
>> +			goto _return_phy_power_off;
>> 
>>  		fixed_link = kzalloc(sizeof(*fixed_link), GFP_KERNEL);
>>  		if (!fixed_link) {
>>  			err = -ENOMEM;
>> -			goto _return_fm_mac_free;
>> +			goto _return_phy_power_off;
>>  		}
>> 
>>  		mac_dev->phy_node = of_node_get(mac_node);
>> @@ -1242,6 +1282,10 @@ int memac_initialization(struct mac_device
>> *mac_dev,
>> 
>>  	goto _return;
>> 
>> +_return_phy_power_off:
>> +	phy_power_off(memac->serdes);
>> +_return_phy_exit:
>> +	phy_exit(memac->serdes);
>>  _return_fixed_link_free:
>>  	kfree(fixed_link);
> 
> _return_fixed_link_free should execute before _return_phy_power_off and _return_phy_exit
> 
>>  _return_fm_mac_free:
>> --
>> 2.35.1.1320.gc452695387.dirty
> 

  reply	other threads:[~2022-07-21 15:42 UTC|newest]

Thread overview: 123+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-15 21:59 [PATCH net-next v3 00/47] [RFT] net: dpaa: Convert to phylink Sean Anderson
2022-07-15 21:59 ` [PATCH net-next v3 01/47] dt-bindings: phy: Add Lynx 10G phy binding Sean Anderson
2022-07-20 22:17   ` Rob Herring
2022-07-21 16:05     ` Sean Anderson
2022-07-21 18:29       ` Rob Herring
2022-07-21 23:35         ` Sean Anderson
2022-07-26 15:44           ` Sean Anderson
2022-07-15 21:59 ` [PATCH net-next v3 02/47] dt-bindings: net: Expand pcs-handle to an array Sean Anderson
2022-07-15 21:59 ` [PATCH net-next v3 03/47] dt-bindings: net: Convert FMan MAC bindings to yaml Sean Anderson
2022-07-15 23:06   ` Rob Herring
2022-07-16 22:47     ` Sean Anderson
2022-07-21 14:42       ` Krzysztof Kozlowski
2022-07-22 16:50         ` Sean Anderson
2022-07-15 21:59 ` [PATCH net-next v3 04/47] dt-bindings: net: fman: Add additional interface properties Sean Anderson
2022-07-15 21:59 ` [PATCH net-next v3 05/47] net: phy: Add 1000BASE-KX interface mode Sean Anderson
2022-07-15 21:59 ` [PATCH net-next v3 06/47] [RFT] phy: fsl: Add Lynx 10G SerDes driver Sean Anderson
2022-07-16 22:39   ` kernel test robot
2022-07-15 21:59 ` [PATCH net-next v3 07/47] net: phy: Add support for rate adaptation Sean Anderson
2022-07-16 19:39   ` Andrew Lunn
2022-07-16 21:55     ` Sean Anderson
2022-07-15 21:59 ` [PATCH net-next v3 08/47] net: phylink: Support differing link speeds and interface speeds Sean Anderson
2022-07-16 20:06   ` Andrew Lunn
2022-07-16 22:29     ` Sean Anderson
2022-07-17  1:26       ` Andrew Lunn
2022-07-18 15:49         ` Sean Anderson
2022-07-18 16:06     ` Russell King (Oracle)
2022-07-18 16:38       ` Sean Anderson
2022-07-18 17:28         ` Andrew Lunn
2022-07-18 17:40           ` Sean Anderson
2022-07-18 18:01           ` Russell King (Oracle)
2022-07-15 21:59 ` [PATCH net-next v3 09/47] net: phylink: Adjust advertisement based on rate adaptation Sean Anderson
2022-07-15 21:59 ` [PATCH net-next v3 10/47] net: phylink: Adjust link settings " Sean Anderson
2022-07-16 20:17   ` Andrew Lunn
2022-07-16 22:37     ` Sean Anderson
2022-07-17  1:39       ` Andrew Lunn
2022-07-18 16:22         ` Russell King (Oracle)
2022-07-18 16:29         ` Sean Anderson
2022-07-18 16:14       ` Russell King (Oracle)
2022-07-18 16:12   ` Russell King (Oracle)
2022-07-18 16:45     ` Sean Anderson
2022-07-18 17:58       ` Russell King (Oracle)
2022-07-15 21:59 ` [PATCH net-next v3 11/47] [RFC] net: phylink: Add support for CRS-based " Sean Anderson
2022-07-15 21:59 ` [PATCH net-next v3 12/47] net: phy: aquantia: Add support for AQR115 Sean Anderson
2022-07-16 18:17   ` Andrew Lunn
2022-07-16 22:42     ` Sean Anderson
2022-07-15 21:59 ` [PATCH net-next v3 13/47] net: phy: aquantia: Add some additional phy interfaces Sean Anderson
2022-07-16 18:18   ` Andrew Lunn
2022-07-15 21:59 ` [PATCH net-next v3 14/47] net: phy: aquantia: Add support for rate adaptation Sean Anderson
2022-07-16 18:38   ` Andrew Lunn
2022-07-16 22:45     ` Sean Anderson
2022-07-17  1:42       ` Andrew Lunn
2022-07-15 21:59 ` [PATCH net-next v3 15/47] net: fman: Convert to SPDX identifiers Sean Anderson
2022-07-15 21:59 ` [PATCH net-next v3 16/47] net: fman: Don't pass comm_mode to enable/disable Sean Anderson
2022-07-15 21:59 ` [PATCH net-next v3 17/47] net: fman: Store en/disable in mac_device instead of mac_priv_s Sean Anderson
2022-07-15 21:59 ` [PATCH net-next v3 18/47] net: fman: dtsec: Always gracefully stop/start Sean Anderson
2022-07-15 21:59 ` [PATCH net-next v3 19/47] net: fman: Get PCS node in per-mac init Sean Anderson
2022-07-21 12:39   ` Camelia Alexandra Groza
2022-07-15 21:59 ` [PATCH net-next v3 20/47] net: fman: Store initialization function in match data Sean Anderson
2022-07-21 12:51   ` Camelia Alexandra Groza
2022-07-21 15:34     ` Sean Anderson
2022-07-15 21:59 ` [PATCH net-next v3 21/47] net: fman: Move struct dev to mac_device Sean Anderson
2022-07-21 12:52   ` Camelia Alexandra Groza
2022-07-15 21:59 ` [PATCH net-next v3 22/47] net: fman: Configure fixed link in memac_initialization Sean Anderson
2022-07-21 12:57   ` Camelia Alexandra Groza
2022-07-15 21:59 ` [PATCH net-next v3 23/47] net: fman: Export/rename some common functions Sean Anderson
2022-07-21 12:58   ` Camelia Alexandra Groza
2022-07-15 21:59 ` [PATCH net-next v3 24/47] net: fman: memac: Use params instead of priv for max_speed Sean Anderson
2022-07-21 12:58   ` Camelia Alexandra Groza
2022-07-15 21:59 ` [PATCH net-next v3 25/47] net: fman: Move initialization to mac-specific files Sean Anderson
2022-07-21 12:59   ` Camelia Alexandra Groza
2022-07-15 21:59 ` [PATCH net-next v3 26/47] net: fman: Mark mac methods static Sean Anderson
2022-07-21 12:59   ` Camelia Alexandra Groza
2022-07-15 21:59 ` [PATCH net-next v3 27/47] net: fman: Inline several functions into initialization Sean Anderson
2022-07-21 13:01   ` Camelia Alexandra Groza
2022-07-21 15:33     ` Sean Anderson
2022-07-22 12:30       ` Camelia Alexandra Groza
2022-07-15 21:59 ` [PATCH net-next v3 28/47] net: fman: Remove internal_phy_node from params Sean Anderson
2022-07-21 13:03   ` Camelia Alexandra Groza
2022-07-15 21:59 ` [PATCH net-next v3 29/47] net: fman: Map the base address once Sean Anderson
2022-07-21 13:04   ` Camelia Alexandra Groza
2022-07-21 15:34     ` Sean Anderson
2022-07-15 21:59 ` [PATCH net-next v3 30/47] net: fman: Pass params directly to mac init Sean Anderson
2022-07-21 13:05   ` Camelia Alexandra Groza
2022-07-15 21:59 ` [PATCH net-next v3 31/47] net: fman: Use mac_dev for some params Sean Anderson
2022-07-21 13:05   ` Camelia Alexandra Groza
2022-07-15 21:59 ` [PATCH net-next v3 32/47] net: fman: Specify type of mac_dev for exception_cb Sean Anderson
2022-07-21 13:06   ` Camelia Alexandra Groza
2022-07-15 21:59 ` [PATCH net-next v3 33/47] net: fman: Clean up error handling Sean Anderson
2022-07-21 13:06   ` Camelia Alexandra Groza
2022-07-15 21:59 ` [PATCH net-next v3 34/47] net: fman: Change return type of disable to void Sean Anderson
2022-07-21 13:08   ` Camelia Alexandra Groza
2022-07-15 21:59 ` [PATCH net-next v3 35/47] net: dpaa: Use mac_dev variable in dpaa_netdev_init Sean Anderson
2022-07-21 13:15   ` Camelia Alexandra Groza
2022-07-21 15:36     ` Sean Anderson
2022-07-15 21:59 ` [PATCH net-next v3 36/47] soc: fsl: qbman: Add helper for sanity checking cgr ops Sean Anderson
2022-07-21 13:16   ` Camelia Alexandra Groza
2022-07-15 21:59 ` [PATCH net-next v3 37/47] soc: fsl: qbman: Add CGR update function Sean Anderson
2022-07-21 13:18   ` Camelia Alexandra Groza
2022-07-21 15:36     ` Sean Anderson
2022-07-15 21:59 ` [PATCH net-next v3 38/47] net: dpaa: Adjust queue depth on rate change Sean Anderson
2022-07-21 13:18   ` Camelia Alexandra Groza
2022-07-15 21:59 ` [PATCH net-next v3 39/47] net: fman: memac: Add serdes support Sean Anderson
2022-07-21 13:30   ` Camelia Alexandra Groza
2022-07-21 15:38     ` Sean Anderson [this message]
2022-07-22 12:43       ` Camelia Alexandra Groza
2022-07-15 21:59 ` [PATCH net-next v3 40/47] net: fman: memac: Use lynx pcs driver Sean Anderson
2022-07-15 21:59 ` [PATCH net-next v3 41/47] [RFT] net: dpaa: Convert to phylink Sean Anderson
2022-07-16 21:27   ` kernel test robot
2022-07-15 21:59 ` [PATCH net-next v3 42/47] powerpc: dts: qoriq: Add nodes for QSGMII PCSs Sean Anderson
2022-07-21 13:48   ` Camelia Alexandra Groza
2022-07-21 17:51     ` Sean Anderson
2022-07-15 21:59 ` [PATCH net-next v3 43/47] arm64: dts: layerscape: " Sean Anderson
2022-07-15 21:59 ` [PATCH net-next v3 44/47] arm64: dts: ls1046a: Add serdes bindings Sean Anderson
2022-07-15 21:59 ` [PATCH net-next v3 45/47] arm64: dts: ls1088a: " Sean Anderson
2022-07-15 21:59 ` [PATCH net-next v3 46/47] arm64: dts: ls1046ardb: " Sean Anderson
2022-07-21 14:20   ` Camelia Alexandra Groza
2022-07-21 15:40     ` Sean Anderson
2022-07-22 12:41       ` Camelia Alexandra Groza
2022-07-25 20:02         ` Sean Anderson
2022-07-26 11:35           ` Camelia Alexandra Groza
2022-07-15 21:59 ` [PATCH net-next v3 47/47] [WIP] arm64: dts: ls1088ardb: " Sean Anderson
2022-07-21 14:26 ` [PATCH net-next v3 00/47] [RFT] net: dpaa: Convert to phylink Camelia Alexandra Groza
2022-07-21 15:39   ` Sean Anderson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ecc9051b-63dc-131b-9f87-138af7dc88aa@seco.com \
    --to=sean.anderson@seco.com \
    --cc=camelia.groza@nxp.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=madalin.bucur@nxp.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®