From patchwork Thu Dec 5 07:20:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacky Chou X-Patchwork-Id: 13894769 X-Patchwork-Delegate: kuba@kernel.org Received: from TWMBX01.aspeed.com (mail.aspeedtech.com [211.20.114.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 30DFE1AB510; Thu, 5 Dec 2024 07:22:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=211.20.114.72 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733383330; cv=none; b=Vg4ZLGvouSAMjHOsADcmSMP2c7pJmsXWblQxqZunGC9/9WTWbHT5n6sEsHN8E2tPOtB5rlegqlbqWE5ryKnsDD/+P5C4WCSsB8MnancGM4AomVU2ABSqrjEz6sP5Nzs5wAiOQLBlYkcqg1gL9x8pCps/+gZsY85OGdrRob2XBNI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733383330; c=relaxed/simple; bh=Dj9AAR6qPKTUh2KtZ7JY6BYTjL6njVKcVqNOH11sqfc=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ZGlqDdLk0JG7bD0VQWHPQtsYLAX3gk5pMP1tjnihPAJmrHQQscXcC1OccIlpLuxpFxIafg+4qaC/Kabd1iAvYQvSaHoXRkomYIdtFoY/0ZnF4GkeOCj2wE3OGSrLVdTyNhj3ZLnki8EMv4tpyfHlTxpjnZODUjcqqOrlHUIOX0Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=aspeedtech.com; spf=pass smtp.mailfrom=aspeedtech.com; arc=none smtp.client-ip=211.20.114.72 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=aspeedtech.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=aspeedtech.com Received: from TWMBX01.aspeed.com (192.168.0.62) by TWMBX01.aspeed.com (192.168.0.62) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.12; Thu, 5 Dec 2024 15:20:49 +0800 Received: from mail.aspeedtech.com (192.168.10.10) by TWMBX01.aspeed.com (192.168.0.62) with Microsoft SMTP Server id 15.2.1258.12 via Frontend Transport; Thu, 5 Dec 2024 15:20:49 +0800 From: Jacky Chou To: , , , , , , , , , , , CC: Subject: [PATCH net-next v4 5/7] net: ftgmac100: add pin strap configuration for AST2700 Date: Thu, 5 Dec 2024 15:20:46 +0800 Message-ID: <20241205072048.1397570-6-jacky_chou@aspeedtech.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241205072048.1397570-1-jacky_chou@aspeedtech.com> References: <20241205072048.1397570-1-jacky_chou@aspeedtech.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org On AST2700, the RMII/RGMII pin strap is configured by setting MAC 0x50 bit 20. Set to 0 is RGMII and set to 1 is RMII. Use compatible property to distinguish different generations for configuration. Signed-off-by: Jacky Chou --- drivers/net/ethernet/faraday/ftgmac100.c | 5 +++++ drivers/net/ethernet/faraday/ftgmac100.h | 1 + 2 files changed, 6 insertions(+) diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c index c0540645d151..abee1ef1e293 100644 --- a/drivers/net/ethernet/faraday/ftgmac100.c +++ b/drivers/net/ethernet/faraday/ftgmac100.c @@ -323,6 +323,7 @@ static void ftgmac100_init_hw(struct ftgmac100 *priv) static void ftgmac100_start_hw(struct ftgmac100 *priv) { u32 maccr = ioread32(priv->base + FTGMAC100_OFFSET_MACCR); + struct phy_device *phydev = priv->netdev->phydev; /* Keep the original GMAC and FAST bits */ maccr &= (FTGMAC100_MACCR_FAST_MODE | FTGMAC100_MACCR_GIGA_MODE); @@ -351,6 +352,10 @@ static void ftgmac100_start_hw(struct ftgmac100 *priv) if (priv->netdev->features & NETIF_F_HW_VLAN_CTAG_RX) maccr |= FTGMAC100_MACCR_RM_VLAN; + if (of_device_is_compatible(priv->dev->of_node, "aspeed,ast2700-mac") && + phydev && phydev->interface == PHY_INTERFACE_MODE_RMII) + maccr |= FTGMAC100_MACCR_RMII_ENABLE; + /* Hit the HW */ iowrite32(maccr, priv->base + FTGMAC100_OFFSET_MACCR); } diff --git a/drivers/net/ethernet/faraday/ftgmac100.h b/drivers/net/ethernet/faraday/ftgmac100.h index 4968f6f0bdbc..c87aa7d7f14c 100644 --- a/drivers/net/ethernet/faraday/ftgmac100.h +++ b/drivers/net/ethernet/faraday/ftgmac100.h @@ -166,6 +166,7 @@ #define FTGMAC100_MACCR_RX_MULTIPKT (1 << 16) #define FTGMAC100_MACCR_RX_BROADPKT (1 << 17) #define FTGMAC100_MACCR_DISCARD_CRCERR (1 << 18) +#define FTGMAC100_MACCR_RMII_ENABLE (1 << 20) /* defined in ast2700 */ #define FTGMAC100_MACCR_FAST_MODE (1 << 19) #define FTGMAC100_MACCR_SW_RST (1 << 31)