Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752974AbbHEO65 (ORCPT ); Wed, 5 Aug 2015 10:58:57 -0400 Received: from mail-bl2on0145.outbound.protection.outlook.com ([65.55.169.145]:44056 "EHLO na01-bl2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751657AbbHEO6y (ORCPT ); Wed, 5 Aug 2015 10:58:54 -0400 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=freescale.com; freescale.mail.onmicrosoft.com; dkim=none (message not signed) header.d=none; From: Madalin Bucur To: , , , CC: , , , Madalin Bucur Subject: [PATCH RFC 2/2] fsl_fman: use fixed_phy_status for MEMAC Date: Wed, 5 Aug 2015 17:42:25 +0300 Message-ID: <1438785745-15517-3-git-send-email-madalin.bucur@freescale.com> X-Mailer: git-send-email 1.5.6.5 In-Reply-To: <1438785745-15517-1-git-send-email-madalin.bucur@freescale.com> References: <1438785745-15517-1-git-send-email-madalin.bucur@freescale.com> Reply-To: X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1;BY2FFO11FD051;1:rAndDvdIYZMcr96iWJvGvZ9aXwf10AQSLwKsKIJbw43eXE70O8N7U2DnFq/sNVPzuDNLJNlmV8lXb3Zt+/wbnrHTFuejqtuoBowBaa7T5ZjFBRzPYK9Y4HH46ECSInI0P6uozvII6ZpUqpXWqEvqinY8YNoCUO3wKypj+BdscCufx1oXyk6Llo+TqLecSmVJ7OhEpf/Vrfje0qqtnIM24prVauJtUJKYAZUCJvtx/+lgODJk73N2/yiobQT+mSD0PvSubBjQudYOM2EaGvAD4v9mAK2cfKX1KuOs3DPaNkn3qdQ87JSyaqdcr9wdhD9Fl3rqNtWhckFDpuu+c/8mDA== X-Forefront-Antispam-Report: CIP:192.88.168.50;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10019020)(6009001)(2980300002)(339900001)(199003)(189002)(33646002)(5001960100002)(4001540100001)(50466002)(48376002)(5001830100001)(77156002)(97736004)(104016003)(229853001)(5001770100001)(50226001)(36756003)(5003940100001)(107886002)(189998001)(106466001)(85426001)(81156007)(86362001)(62966003)(575784001)(68736005)(77096005)(46102003)(53806999)(105606002)(50986999)(47776003)(5001860100001)(87936001)(76176999)(43066003)(19580395003)(6806004)(2950100001)(64706001)(19580405001)(49486002)(4001430100001)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:BY2PR03MB508;H:tx30smr01.am.freescale.net;FPR:;SPF:Fail;PTR:InfoDomainNonexistent;A:1;MX:1;LANG:en; MIME-Version: 1.0 Content-Type: text/plain X-Microsoft-Exchange-Diagnostics: 1;BY2PR03MB508;2:Fep3+1KDrxQ10NbWr42Imc+NkYpX3IEXlm/b8gsE+Mm5ZUEXDz8NCcsWtnv1jzNX8VGET8aYX3TVu9qowqMbprNLCALfJlNtIJz1rDSlp496ULZmGCk/ZCEiCy40B+2AzC9CBefYoBo7+vCqYs1WWHPeR8FG8Uly4S45iPX5ZIU=;3:UJkfTYnW3LqU7HdgimajX19RybXalVBO2QAY9PUXACVP4rQY8r+GYsUi3rF7EqNHM12S8IcYq776mj4vM7Ta+Jnj2qnCXnpazbQISkoZsRosCe/azc4JltRk5B9fO84VxkAqWuTMac9Re3uW+egCcOgE4s4GNe1vfx9xn1UuAPx7hgo+cU/tgFZgV4VaABn80Hj9B4EONX++AU3LUlp0nCR2EtRbtKIPZuoctijiupg=;25:3Tg4weba1qGiGuwPT/eZWxds3TQsNLDeV2eladun9yBebc8gX4UZUuWk//XNgf6vMc5dsClq7ZCCJGxdcME2uj2IKO9nrVV9ZS83pqq3VG+tlvPCnfm7L1zbjisFQZ1VdUED7B3apqbKwiiaYhZ/SnreI/8PKzzRsSVIFHLOc+xthViGXC7KKKGqrGnh5/7cuMHkWJAynEC7HTRymMy49UV0QcfXVXE44/Vx16wWRXMvExNcYfQGWIXhOv5c3J7FfBVJ+TheL9VJ/O2G6QZOhw== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY2PR03MB508; X-Microsoft-Exchange-Diagnostics: 1;BY2PR03MB508;20:fv020h7ugFZVMZztVB4nhLAlZnORe5sIZH/8ytFmNRq/lZeIr0gMI74Kj0WqrKfVTT5WxR2nykyie1UE+TuA1udHDSoafKklwEXseOoqBOdm35fLjXX/yejkjzEwcDujIWOUsOCdclU1q+JvyUy/M0y4DAJk2vmxqBCKHH4Rod02Q0r/iX39DzO+gkXl8iAFa88B2LMQcRu2eXt7gAZpICQQ4lCvjZB7f5mm7dtSnoGW43S/4funhXJ3oMmpbM6TaqcX4x+VToUdqnUzeQbns4TEBjIGJDphzZm9edKnAmXCGePZiPVVt5gNQjwf54FoLVrlWADszOF6ko/1ym7nSdtfjH31ypZUlaHX40C6GJo=;4:Nuq/yHe99C4twxRsw9NmCcJgZlULNjtAp17zMoFZbN7vSueb+JxWf8Prkzj30/xJMg/0IaWQh68vTMiPj0svAbSyaTb1IcuwyCASL7oA+9Lw0OU3mnQFpHPq8ooA2gJQSsR7XAdz02gumENgs8nKyKknHWgKRVi5Qb+5HdUdYEja54RT//2prJZ40NzNqBrCpMKQH7yncYMNUuAKxCGVf9VJqG2yvkFKTbur+dgrkGDxoNh2U9mFTaP15vofStVwVeWiovGW2ot1m2aCCfrAbvs+I1cUpOti+qFAmscosZs= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(5005006)(3002001);SRVR:BY2PR03MB508;BCL:0;PCL:0;RULEID:;SRVR:BY2PR03MB508; X-Forefront-PRVS: 06592CCE58 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BY2PR03MB508;23:hCcMp7T2vStuzEG6RxA3RTc1GkeIuI6vXOQyAjQncu?= =?us-ascii?Q?9hiPb4biUEsdqtc0nEsG5mSa5J07Tn4OtUMx85d12mpkPbGqfwvFoEPQ0/7D?= =?us-ascii?Q?X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qTSsY?= =?us-ascii?Q?yvY2AgGoOIAVwEJTR7LHiMgSv9J/4wH/v937u2Tbg8mlI+BHhneYCnYp+fZm?= =?us-ascii?Q?pe45+AjP+euYaWQbMFFBj7gCtrV1jfvsOzfgOC5FMs/rzerpWHwxmBejTsUt?= =?us-ascii?Q?oEHYqSdhDLJE2o/1VclVWGk5pvxOy7SDXx71hsdMbTPBA0Ry3cVLyEaC2ya9?= =?us-ascii?Q?wt0PZfZi8yfKDdcKuatgkvaKjZVn+uvWPBQhMSFGX9idT98LsxJG8Xig=3D?= =?us-ascii?Q?=3D?= X-Microsoft-Exchange-Diagnostics: 1;BY2PR03MB508;5:CwqWGnZoeVbsvWkcrOqFcajciN6yrZh+i6eGH8dmhVH8It8PHNfGAEW+38oPD2hJtXbXI0Cuvr6mTU+BkZDGTn1lzobpsR8deE5YEZEnXZTF5F8QGXs5HMzyB3Ie6JDOBx6webhS+FhkuQTb1t0/mA==;24:m6qEnYKRpsSZVPmH7nunaIg3p7kh1aOUzrMvzILw5c00t2uMdJz9EI86eBV1ko3Km5jM4+sdKCuG286CmzueVIbi/zmhfQKBxuoAqVMaies=;20:uNpU+vpRxBLG+mLuvfrnXbNXHowUiB9u3L7rqVHym2ljKFzvt7KUikjD0pniSl6NxtWQAs3A3cihGaaRdUD9xQ== X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Aug 2015 14:44:09.2124 (UTC) X-MS-Exchange-CrossTenant-Id: 710a03f5-10f6-4d38-9ff4-a80b81da590d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=710a03f5-10f6-4d38-9ff4-a80b81da590d;Ip=[192.88.168.50];Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR03MB508 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 7732 Lines: 219 Use the speed and duplex information from the device tree fixed link node accessing the status structure parsed by of_phy_parse_fixed_link(). Signed-off-by: Madalin Bucur --- .../ethernet/freescale/fman/flib/fsl_fman_memac.h | 6 ++-- drivers/net/ethernet/freescale/fman/inc/mac.h | 2 +- drivers/net/ethernet/freescale/fman/mac/fm_memac.c | 42 ++++++++++++++++------ drivers/net/ethernet/freescale/fman/mac/fm_memac.h | 3 +- drivers/net/ethernet/freescale/fman/mac/mac.c | 18 +++++++--- 5 files changed, 52 insertions(+), 19 deletions(-) diff --git a/drivers/net/ethernet/freescale/fman/flib/fsl_fman_memac.h b/drivers/net/ethernet/freescale/fman/flib/fsl_fman_memac.h index ebf7989..50bed14 100644 --- a/drivers/net/ethernet/freescale/fman/flib/fsl_fman_memac.h +++ b/drivers/net/ethernet/freescale/fman/flib/fsl_fman_memac.h @@ -33,8 +33,10 @@ #define __FSL_FMAN_MEMAC_H #include - +#include +#include #include "fsl_enet.h" + /* Num of additional exact match MAC adr regs */ #define MEMAC_NUM_OF_PADDRS 7 @@ -373,7 +375,7 @@ struct memac_cfg { bool tx_pbl_fwd; bool debug_mode; bool wake_on_lan; - bool fixed_link; + struct fixed_phy_status *fixed_link; u16 max_frame_length; u16 pause_quanta; u32 tx_ipg_length; diff --git a/drivers/net/ethernet/freescale/fman/inc/mac.h b/drivers/net/ethernet/freescale/fman/inc/mac.h index f86d0bc..fbeb957 100644 --- a/drivers/net/ethernet/freescale/fman/inc/mac.h +++ b/drivers/net/ethernet/freescale/fman/inc/mac.h @@ -62,7 +62,7 @@ struct mac_device { phy_interface_t phy_if; u32 if_support; bool link; - bool fixed_link; + struct fixed_phy_status *fixed_link; u16 speed; u16 max_speed; struct device_node *phy_node; diff --git a/drivers/net/ethernet/freescale/fman/mac/fm_memac.c b/drivers/net/ethernet/freescale/fman/mac/fm_memac.c index becbb88..3d5ede3 100644 --- a/drivers/net/ethernet/freescale/fman/mac/fm_memac.c +++ b/drivers/net/ethernet/freescale/fman/mac/fm_memac.c @@ -71,9 +71,10 @@ static int memac_mii_write_phy_reg(struct memac_t *memac, u8 phy_addr, } static void setup_sgmii_internal_phy(struct memac_t *memac, u8 phy_addr, - bool fixed_link) + struct fixed_phy_status *fixed_link) { u16 tmp_reg16; + enum ethernet_interface enet_if; enum e_enet_mode enet_mode; /* In case the higher MACs are used (i.e. the MACs that should @@ -81,20 +82,37 @@ static void setup_sgmii_internal_phy(struct memac_t *memac, u8 phy_addr, * Temporary modify enet mode to 1G one, so MII functions can * work correctly. */ + enet_if = ENET_INTERFACE_FROM_MODE(memac->enet_mode); enet_mode = memac->enet_mode; - memac->enet_mode = - MAKE_ENET_MODE(ENET_INTERFACE_FROM_MODE(memac->enet_mode), - ENET_SPEED_1000); + memac->enet_mode = MAKE_ENET_MODE(enet_if, ENET_SPEED_1000); /* SGMII mode */ tmp_reg16 = PHY_SGMII_IF_MODE_SGMII; if (!fixed_link) /* AN enable */ tmp_reg16 |= PHY_SGMII_IF_MODE_AN; - else - /* Fixed link 1Gb FD */ - tmp_reg16 |= PHY_SGMII_IF_MODE_SPEED_GB | - PHY_SGMII_IF_MODE_DUPLEX_FULL; + else { + switch (fixed_link->speed) { + case 10: + tmp_reg16 |= PHY_SGMII_IF_MODE_SPEED_10M; + memac->enet_mode = MAKE_ENET_MODE(enet_if, + ENET_SPEED_10); + break; + case 100: + tmp_reg16 |= PHY_SGMII_IF_MODE_SPEED_100M; + memac->enet_mode = MAKE_ENET_MODE(enet_if, + ENET_SPEED_100); + break; + case 1000: /* fallthrough */ + default: + tmp_reg16 |= PHY_SGMII_IF_MODE_SPEED_GB; + break; + } + if (fixed_link->duplex) + tmp_reg16 |= PHY_SGMII_IF_MODE_DUPLEX_FULL; + else + tmp_reg16 |= PHY_SGMII_IF_MODE_DUPLEX_HALF; + } memac_mii_write_phy_reg(memac, phy_addr, 0x14, tmp_reg16); /* Device ability according to SGMII specification */ @@ -120,6 +138,7 @@ static void setup_sgmii_internal_phy(struct memac_t *memac, u8 phy_addr, /* Restart AN */ tmp_reg16 = PHY_SGMII_CR_DEF_VAL | PHY_SGMII_CR_RESET_AN; else + /* AN disabled */ tmp_reg16 = PHY_SGMII_CR_DEF_VAL & ~PHY_SGMII_CR_AN_ENABLE; memac_mii_write_phy_reg(memac, phy_addr, 0x0, tmp_reg16); @@ -370,14 +389,15 @@ int memac_cfg_reset_on_init(struct fm_mac_dev *fm_mac_dev, bool enable) return 0; } -int memac_cfg_fixed_link(struct fm_mac_dev *fm_mac_dev, bool enable) +int memac_cfg_fixed_link(struct fm_mac_dev *fm_mac_dev, + struct fixed_phy_status *fixed_link) { struct memac_t *memac = (struct memac_t *)fm_mac_dev; if (is_init_done(memac->memac_drv_param)) return -EINVAL; - memac->memac_drv_param->fixed_link = enable; + memac->memac_drv_param->fixed_link = fixed_link; return 0; } @@ -524,7 +544,7 @@ int memac_init(struct fm_mac_dev *fm_mac_dev) enet_addr_t eth_addr; enum fm_mac_type port_type; bool slow_10g_if = false; - bool fixed_link; + struct fixed_phy_status *fixed_link; int err; u32 reg32 = 0; diff --git a/drivers/net/ethernet/freescale/fman/mac/fm_memac.h b/drivers/net/ethernet/freescale/fman/mac/fm_memac.h index 8fcbd64..7c13706 100644 --- a/drivers/net/ethernet/freescale/fman/mac/fm_memac.h +++ b/drivers/net/ethernet/freescale/fman/mac/fm_memac.h @@ -104,7 +104,8 @@ int memac_adjust_link(struct fm_mac_dev *fm_mac_dev, enum ethernet_speed speed); int memac_cfg_max_frame_len(struct fm_mac_dev *fm_mac_dev, u16 new_val); int memac_cfg_reset_on_init(struct fm_mac_dev *fm_mac_dev, bool enable); -int memac_cfg_fixed_link(struct fm_mac_dev *fm_mac_dev, bool enable); +int memac_cfg_fixed_link(struct fm_mac_dev *fm_mac_dev, + struct fixed_phy_status *fixed_link); int memac_enable(struct fm_mac_dev *fm_mac_dev, enum comm_mode mode); int memac_disable(struct fm_mac_dev *fm_mac_dev, enum comm_mode mode); int memac_init(struct fm_mac_dev *fm_mac_dev); diff --git a/drivers/net/ethernet/freescale/fman/mac/mac.c b/drivers/net/ethernet/freescale/fman/mac/mac.c index c44544b..4a0ab7e 100644 --- a/drivers/net/ethernet/freescale/fman/mac/mac.c +++ b/drivers/net/ethernet/freescale/fman/mac/mac.c @@ -39,6 +39,8 @@ #include #include #include +#include +#include #include "mac.h" @@ -363,7 +365,6 @@ static int mac_probe(struct platform_device *_of_dev) } mac_dev->link = false; - mac_dev->fixed_link = false; mac_dev->speed = phy2speed[mac_dev->phy_if]; mac_dev->max_speed = mac_dev->speed; mac_dev->if_support = DTSEC_SUPPORTED; @@ -383,10 +384,18 @@ static int mac_probe(struct platform_device *_of_dev) /* Get the rest of the PHY information */ mac_dev->phy_node = of_parse_phandle(mac_node, "phy-handle", 0); if (!mac_dev->phy_node && of_phy_is_fixed_link(mac_node)) { - err = of_phy_register_fixed_link(mac_node); - if (err) + struct phy_device *phy; + + mac_dev->fixed_link = kzalloc(sizeof(*mac_dev->fixed_link), + GFP_KERNEL); + if (of_phy_parse_fixed_link(mac_node, mac_dev->fixed_link)) + goto _return_dev_set_drvdata; + + phy = fixed_phy_register(PHY_POLL, mac_dev->fixed_link, + mac_node); + if (IS_ERR(phy)) goto _return_dev_set_drvdata; - mac_dev->fixed_link = true; + mac_dev->phy_node = of_node_get(mac_node); } @@ -429,6 +438,7 @@ static int mac_probe(struct platform_device *_of_dev) _return_of_node_put: of_node_put(dev_node); _return_dev_set_drvdata: + kfree(mac_dev->fixed_link); dev_set_drvdata(dev, NULL); _return: return err; -- 1.7.11.7 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/