From patchwork Fri Jun 26 18:17:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grygorii Strashko X-Patchwork-Id: 191884 Delivered-To: patch@linaro.org Received: by 2002:a54:3249:0:0:0:0:0 with SMTP id g9csp646882ecs; Fri, 26 Jun 2020 11:17:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxddt0YR7pXRsixCE6c+R2yktaY6XbG6Dx3s7PNe7+7sXdk4WyWo9TPCNSWGtKrU/pdPtY7 X-Received: by 2002:a17:906:1ed2:: with SMTP id m18mr3570706ejj.529.1593195464565; Fri, 26 Jun 2020 11:17:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593195464; cv=none; d=google.com; s=arc-20160816; b=MFx++DgEOzcYimxURcjKWn47gfBpuZ+DndxdFCC7q25QHNGQu6FXonfIeI9EecVQu8 azthR/1gTvyMc1a21o/io8+QPMMDdQpHwfXpihbeQ5lLu+dMfaPN9ol79bVt7+s7JVkq SFgcwuBFsOupE8sfdfYW6y1mGO6yDJsmum6lLEjIavwRImp9ZqJ3OV4KpP1PkxqBLhVC 1AizTEBFbnwvEk3qjPffuEwRAd7zTjhlnG1lgD8GPkIaOsaRHJyJFCms1Iod3HXUrrvI xkRDDOZhvxTy8ZfWcsf1i8hYuVoEk5E2+1jqxnb9/HMDrynrAUuaCzQplXnwcqB2X9p9 MavA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=BNg+DQH/3TSrqnuqngB8EXZIV8fz3RCqpdutiE3KweQ=; b=LVya6FfRLuumWUJGz+OWG6nTD8AkdCFo/VQ4prwxi6JQxe+45StXda08OUcc8bK/oq f9FnqTwA1jiwxSmqLC9rCRB8qKhKqa3SrKBywvGyLLXCoBxBnfndpkQvozxyOW47Eosa LJGUdkbNrFYATR9MeuWnEzPMBTlGwu8fwgV/ZWym9QmDYEryg2u7oQCBXmqoRWRaCqs+ cfqLF0Czz0ZghrslR+VQ9n8Dj2WqYvMCBHj04262vDqvm/qdQC1LIDSbSPWLWvfjQmn5 PlV6vNC6l/K7PmGQS9Widtp73Zz5spcfOuzAh9M/Ef3+baEpxUNfLnguWVRQ9EMzkrbH UYew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=igXLvPGb; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v7si13555565edd.252.2020.06.26.11.17.44; Fri, 26 Jun 2020 11:17:44 -0700 (PDT) Received-SPF: pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=igXLvPGb; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725994AbgFZSRj (ORCPT + 9 others); Fri, 26 Jun 2020 14:17:39 -0400 Received: from lelv0142.ext.ti.com ([198.47.23.249]:48620 "EHLO lelv0142.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726416AbgFZSRe (ORCPT ); Fri, 26 Jun 2020 14:17:34 -0400 Received: from fllv0035.itg.ti.com ([10.64.41.0]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id 05QIHLZ1002436; Fri, 26 Jun 2020 13:17:21 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1593195441; bh=BNg+DQH/3TSrqnuqngB8EXZIV8fz3RCqpdutiE3KweQ=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=igXLvPGbyjxH+HFjg2vIA5Gby6uJ8R/ukJ4qN28rnhHe4QQNNPEVKscRbnLXLOrAa GX2hlYKwGhINjUajwP3/VEemWYQVRRUHRGz7n8e/WbpJvowoxSECg14RVoFLZo73At rIqsxgOD2O2Mosipsy5tfFsz2/tRGlSoPubpEj/c= Received: from DLEE114.ent.ti.com (dlee114.ent.ti.com [157.170.170.25]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTP id 05QIHLhW004381; Fri, 26 Jun 2020 13:17:21 -0500 Received: from DLEE103.ent.ti.com (157.170.170.33) by DLEE114.ent.ti.com (157.170.170.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1979.3; Fri, 26 Jun 2020 13:17:21 -0500 Received: from lelv0326.itg.ti.com (10.180.67.84) by DLEE103.ent.ti.com (157.170.170.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1979.3 via Frontend Transport; Fri, 26 Jun 2020 13:17:21 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by lelv0326.itg.ti.com (8.15.2/8.15.2) with ESMTP id 05QIHKcE081657; Fri, 26 Jun 2020 13:17:21 -0500 From: Grygorii Strashko To: "David S. Miller" , , Jakub Kicinski CC: Sekhar Nori , , , Murali Karicheri , Vignesh Raghavendra , Jan Kiszka , Grygorii Strashko Subject: [PATCH net-next 6/6] net: ethernet: ti: am65-cpsw-nuss: enable am65x sr2.0 support Date: Fri, 26 Jun 2020 21:17:09 +0300 Message-ID: <20200626181709.22635-7-grygorii.strashko@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200626181709.22635-1-grygorii.strashko@ti.com> References: <20200626181709.22635-1-grygorii.strashko@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The AM65x SR2.0 MCU CPSW has fixed errata i2027 "CPSW: CPSW Does Not Support CPPI Receive Checksum (Host to Ethernet) Offload Feature". This errata also fixed for J271E SoC. Use SOC bus data for K3 SoC identification and apply i2027 errata w/a only for the AM65x SR1.0 SoC. Signed-off-by: Grygorii Strashko --- drivers/net/ethernet/ti/am65-cpsw-nuss.c | 47 ++++++++++++++++++++---- drivers/net/ethernet/ti/am65-cpsw-nuss.h | 2 +- 2 files changed, 41 insertions(+), 8 deletions(-) -- 2.17.1 diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c index 7a921a480f29..9fdcd90e8323 100644 --- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c +++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -148,10 +149,11 @@ static void am65_cpsw_nuss_get_ver(struct am65_cpsw_common *common) common->nuss_ver = readl(common->ss_base); common->cpsw_ver = readl(common->cpsw_base); dev_info(common->dev, - "initializing am65 cpsw nuss version 0x%08X, cpsw version 0x%08X Ports: %u\n", + "initializing am65 cpsw nuss version 0x%08X, cpsw version 0x%08X Ports: %u quirks:%08x\n", common->nuss_ver, common->cpsw_ver, - common->port_num + 1); + common->port_num + 1, + common->pdata.quirks); } void am65_cpsw_nuss_adjust_link(struct net_device *ndev) @@ -1877,7 +1879,7 @@ static int am65_cpsw_nuss_init_ndev_2g(struct am65_cpsw_common *common) port->ndev->ethtool_ops = &am65_cpsw_ethtool_ops_slave; /* Disable TX checksum offload by default due to HW bug */ - if (common->pdata->quirks & AM65_CPSW_QUIRK_I2027_NO_TX_CSUM) + if (common->pdata.quirks & AM65_CPSW_QUIRK_I2027_NO_TX_CSUM) port->ndev->features &= ~NETIF_F_HW_CSUM; ndev_priv->stats = netdev_alloc_pcpu_stats(struct am65_cpsw_ndev_stats); @@ -1981,21 +1983,50 @@ static void am65_cpsw_nuss_cleanup_ndev(struct am65_cpsw_common *common) } } +struct am65_cpsw_soc_pdata { + u32 quirks_dis; +}; + +static const struct am65_cpsw_soc_pdata am65x_soc_sr2_0 = { + .quirks_dis = AM65_CPSW_QUIRK_I2027_NO_TX_CSUM, +}; + +static const struct soc_device_attribute am65_cpsw_socinfo[] = { + { .family = "AM65X", + .revision = "SR2.0", + .data = &am65x_soc_sr2_0 + }, + {/* sentinel */} +}; + static const struct am65_cpsw_pdata am65x_sr1_0 = { .quirks = AM65_CPSW_QUIRK_I2027_NO_TX_CSUM, }; -static const struct am65_cpsw_pdata j721e_sr1_0 = { +static const struct am65_cpsw_pdata j721e_pdata = { .quirks = 0, }; static const struct of_device_id am65_cpsw_nuss_of_mtable[] = { - { .compatible = "ti,am654-cpsw-nuss", .data = &am65x_sr1_0 }, - { .compatible = "ti,j721e-cpsw-nuss", .data = &j721e_sr1_0 }, + { .compatible = "ti,am654-cpsw-nuss", .data = &am65x_sr1_0}, + { .compatible = "ti,j721e-cpsw-nuss", .data = &j721e_pdata}, { /* sentinel */ }, }; MODULE_DEVICE_TABLE(of, am65_cpsw_nuss_of_mtable); +static void am65_cpsw_nuss_apply_socinfo(struct am65_cpsw_common *common) +{ + const struct soc_device_attribute *soc; + + soc = soc_device_match(am65_cpsw_socinfo); + if (soc && soc->data) { + const struct am65_cpsw_soc_pdata *socdata = soc->data; + + /* disable quirks */ + common->pdata.quirks &= ~socdata->quirks_dis; + } +} + static int am65_cpsw_nuss_probe(struct platform_device *pdev) { struct cpsw_ale_params ale_params = { 0 }; @@ -2014,7 +2045,9 @@ static int am65_cpsw_nuss_probe(struct platform_device *pdev) of_id = of_match_device(am65_cpsw_nuss_of_mtable, dev); if (!of_id) return -EINVAL; - common->pdata = of_id->data; + common->pdata = *(const struct am65_cpsw_pdata *)of_id->data; + + am65_cpsw_nuss_apply_socinfo(common); res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "cpsw_nuss"); common->ss_base = devm_ioremap_resource(&pdev->dev, res); diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.h b/drivers/net/ethernet/ti/am65-cpsw-nuss.h index 9faf4fb1409b..94f666ea0e53 100644 --- a/drivers/net/ethernet/ti/am65-cpsw-nuss.h +++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.h @@ -82,7 +82,7 @@ struct am65_cpsw_pdata { struct am65_cpsw_common { struct device *dev; struct device *mdio_dev; - const struct am65_cpsw_pdata *pdata; + struct am65_cpsw_pdata pdata; void __iomem *ss_base; void __iomem *cpsw_base;