From patchwork Sat Jul 10 19:25:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Foster X-Patchwork-Id: 472617 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 51C7EC11F66 for ; Sat, 10 Jul 2021 19:26:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3E93E6135B for ; Sat, 10 Jul 2021 19:26:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231355AbhGJT3S (ORCPT ); Sat, 10 Jul 2021 15:29:18 -0400 Received: from mail-bn7nam10on2107.outbound.protection.outlook.com ([40.107.92.107]:9249 "EHLO NAM10-BN7-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229771AbhGJT3I (ORCPT ); Sat, 10 Jul 2021 15:29:08 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=b4Aqz1e156HUuac4XWyOwsJGxYUcYsRdoST1J88BtHjriY3swqIqx8s8IixgYj/lF951yE6X23PDcaw3vOg4lj5/ZgCnLkeqjM16zcXb3wD/UNc8k37kxEgN7wx9+ZsGsiSk9eQm8UuEk/+Nl3bLwMsovPSkjuL1LogPACQDszJtd9Tn4O8CtWIGeDxrU88D75PUyMBwPA4UmqM9aAXMgjdZYKzhi2GZkoREcmdjRrbpgJ29C688vbusMCKOlSxT6KdeQmYXbYMZJYYOnLnU96UAsK0TWuRgfh1qGqvyXunRWaj/xn0joJPLZf3v5wtWiCJTUIPhmZ8C08CQ+2R4IA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=K3Td32aNUuAy+MIpz4C721HcR5oE5o7gZH9hbwaeuJE=; b=fQvIdaGzKuhU3sn0EfO9ztgW9sP9LwxxqW4/B8M48y5ZcpJqTn8L9PraLT+19eiSqwJBZMgTNEqvy1pkdFIbnB3d4yTLmnoq2eykUVGbzu2McDRwx8Tc3hnpsyu5A+2+pZtg20zq4ww1LFFkczoBfEcE6rme3vIdEpiEi3ySBSo8aayA7yraHsw4x+Xvhg2nIMOaydXB5ZQnC5q1lWG0uc4SyxHqiEkr4Laj1Ts7YAgXiQJtbMbqa0WgGTL5J+6KyE2TghFeHLZS+fRcAqJxCXBcz5gEO3bLmdnG64vkQsZrpYoS8Vr3N/PEmcFxgnI8IwQN0GX0Vampice/SXV4Ig== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=in-advantage.com; dmarc=pass action=none header.from=in-advantage.com; dkim=pass header.d=in-advantage.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inadvantage.onmicrosoft.com; s=selector2-inadvantage-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=K3Td32aNUuAy+MIpz4C721HcR5oE5o7gZH9hbwaeuJE=; b=RV3IPvUswQSxd4zb1ZajMWu4Vuk7+0C9TYc9sQPc5y4xwGUeR3QS3Q+8ToSRoDZq38Rr6YPuP9EIncmqqLiXduYkRysKBLYCs/A9inu3nEh/b/7e6MdwbRihvKVvoBzqHUbRz5C/q1wOdhKcbTKvACjUfjpsWfM2RjlR5hMiWlo= Authentication-Results: lunn.ch; dkim=none (message not signed) header.d=none; lunn.ch; dmarc=none action=none header.from=in-advantage.com; Received: from MWHPR1001MB2351.namprd10.prod.outlook.com (2603:10b6:301:35::37) by MWHPR10MB1709.namprd10.prod.outlook.com (2603:10b6:301:7::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.22; Sat, 10 Jul 2021 19:26:17 +0000 Received: from MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::e81f:cf8e:6ad6:d24d]) by MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::e81f:cf8e:6ad6:d24d%3]) with mapi id 15.20.4287.033; Sat, 10 Jul 2021 19:26:17 +0000 From: Colin Foster To: andrew@lunn.ch, vivien.didelot@gmail.com, f.fainelli@gmail.com, olteanv@gmail.com, davem@davemloft.net, kuba@kernel.org, robh+dt@kernel.org, claudiu.manoil@nxp.com, alexandre.belloni@bootlin.com, UNGLinuxDriver@microchip.com, linux@armlinux.org.uk Cc: netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH v2 net-next 1/8] net: dsa: ocelot: remove unnecessary pci_bar variables Date: Sat, 10 Jul 2021 12:25:55 -0700 Message-Id: <20210710192602.2186370-2-colin.foster@in-advantage.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210710192602.2186370-1-colin.foster@in-advantage.com> References: <20210710192602.2186370-1-colin.foster@in-advantage.com> X-ClientProxiedBy: MWHPR12CA0042.namprd12.prod.outlook.com (2603:10b6:301:2::28) To MWHPR1001MB2351.namprd10.prod.outlook.com (2603:10b6:301:35::37) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (67.185.175.147) by MWHPR12CA0042.namprd12.prod.outlook.com (2603:10b6:301:2::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.19 via Frontend Transport; Sat, 10 Jul 2021 19:26:16 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8a260ce6-7b8d-466c-4e3b-08d943d896bb X-MS-TrafficTypeDiagnostic: MWHPR10MB1709: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5236; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8VasocAn40XXV0kKW/xpJ4vrWCNuf9EcbPMf7N0eaMGEQHofrpIOKVI/22wDJayBfsIClMQGJJo2bHtHtdOevZIpsppafLEyzFt+Xy67LuGRknkK3ot+fUEHBmSqtLK3MPy7yKAqHGeV1bm4KRHeClRmzr41ijPyHhY3v5TeU5ivNovX0smWrfxZy5iGGZKwC1bl9G+lwHU6IrA5l7xJfTmKOakvD+wCmz/rywVh1dxT21Nvo34kopzDIRgXGI9evw7+WJOhvd1LU76KR8TU5v6jWqLlxmJrOFibsamrckNQKqi+eKPYHXTbattbPeHGmRJI1DRPE2Ai5aLho4JAJ7dcLxRFQyzfcdIkXsEpGcIHwK+TSdGjaJwsKDv28xYRViSHXmNg4QTjfVzxdo2XRNuKOEoJRFmGlEBeanIUw13tD42CaAnwgz9WN6HW2R7rqLXUjE8qvxX0IZRYDI4k5Ngvp0IdKIw9n5wuZU348OGdtJWMJY1HVaQdHTZiAaAyOVfmhINxOdqT8/93YEZyJM1gmjMixVHHgkUpmedowpOG54CCkfPShXalgVOq34EgXVxSpVqUvoN4tGR+U6YEZzRzciCzV0+ZuQV9jK/0PhdG7GEyjZGcn61VlseLOPV5B826XBgM1OaEsJDbWWj5RCexfFVAvycCoaQGGLjY7gA4wwuXPmlqCya3+hv5ouj3i90mtTgMU8DVXE6z8KCxNnKYu7jQJTO2lp4XL/9NiPY= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MWHPR1001MB2351.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(346002)(396003)(376002)(39830400003)(136003)(366004)(8936002)(7416002)(6506007)(5660300002)(2906002)(66556008)(26005)(2616005)(8676002)(44832011)(6486002)(6512007)(66476007)(6666004)(38100700002)(38350700002)(52116002)(66946007)(921005)(4326008)(956004)(83380400001)(1076003)(316002)(36756003)(86362001)(186003)(478600001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: AXEzkf3+OI96IAjEuG+KnFiNYGoKJmet10344Pufum3EgmEOZeTgy/xhPe4122d3ELa1ecAnW9Hatgu6jKSRJoBjsE2zxwv70BOydwtPiBB4Lk+GsnIT66XJ1dGyAYsf/DxpGs36lu/KnO9Kses2eOpLVK9AE72Z+SvZQCYY8icplfSx+dvwDHq/ARPUYrA4tEYxToVZkRbh++0z0vw+me7rC7tKu2DTbNy/8k21PvfS0MBOYKieis/BIY48y6l5KjdF7UL8DfjCCUcpOlpORAjdpucVfkGkrdznIblMFhUK8KRYBcoScc2gDG0WKN/ml1KY7iiQoSIhxg7XWdT/70tyoO+7+Yum6hZMGPM4FV/8SpLQw4AH+Os2wxHwH3/EZCQlmzF275Ymhox+8Wt/U5TLEQLkt/KT5A63Cd10x+Wnc+nhoUdRwyNAmt6zSGPgGVAZzEbXadVt3bcsfUntLk3F4D3q3WmUH5HPdusSH4sHGs8fCOiEW7gkDPSaYkdHpYdUO+i3NfcfPDSlZ7lpF0AiDx8ZAdWoFbTGePCRbyN/U11pakmiyB6ttXLsEnOSNltrGNxO86GmlZG7QJDKDm9a/n2M5NuPz6r9AcZ4lYdRzzpcq1vaHEjo78QLP/5nti3uJxGkiWWYre/tmJN6wHFLrv3kQU65Vs/TRrimqBjGK2fm/W+LsCTsxQPRz00RVLCHF47/eGqIpwNI0/MJeolB183V5Ncp1lmIDoCl58vrHhVd6GhkgoHUV5LifJ5GGxRDgcikTAL27Nab+TQccQFn6hOHwAbOKU4iQNpsPq0UHWhShWGJAXpNpOfkyqQZm+N4MNb2WJEsktoRv2LObHX3bVhBgZCb19KtimHmZn0R7eHAruCB286jJTcYk8J6uy9t3kG5/ZQwABzwUWRR9ZNXTNO4jy1yShbYM0Q6Te3I+ADyu7D7hAnjFhtjCZUf9w3PBuqrCbkRXZBlDsUS01ILJwZ7Q9NqDhRemN+XoUo99NRRBT/ekPiEAFOREl2I3Js1khmjjKxN+qPfVDDg4kQVraXAMZ3B5qD6DvzA7BNeAqOmLsScoM7p5rEFJmxqCtB38cJHLVXN5XyWx21gqrexa7WmP3466eesX/T5w+p9Dy1xlg3QAaNAuDeSZEt5FMBHEv01EJEHBIogmpLTkrpPqTgD+qVqvRcHmmD5fC0mVR+Tiu1XNn7nXgliq2qV6O0vkk7PcQx763Na1qXAOvOP+C1ESNrPapXc7+h1LeqnvCCJtGJyNT5GUaLSu6r96pGxhrWX1DuIwPp1E9+h8M+PijEcmozpKB7msp1KGC11swrMujiffcAxEaSpOWRL X-OriginatorOrg: in-advantage.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8a260ce6-7b8d-466c-4e3b-08d943d896bb X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2351.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jul 2021 19:26:17.2009 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 48e842ca-fbd8-4633-a79d-0c955a7d3aae X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: CFrQBx42YYt429US1mxCb2pptj+KqU4ORRTTfdDoXxarhVW9zbEJRs+I+DntjBOP0lDYK/MlnIwICIbVWHK/yU4v/PvDI7rzPEPyDdBirvc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR10MB1709 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The pci_bar variables for the switch and imdio don't make sense for the generic felix driver. Moving them to felix_vsc9959 to limit scope and simplify the felix_info struct. Signed-off-by: Colin Foster Reviewed-by: Vladimir Oltean --- drivers/net/dsa/ocelot/felix.h | 2 -- drivers/net/dsa/ocelot/felix_vsc9959.c | 11 +++++------ 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/net/dsa/ocelot/felix.h b/drivers/net/dsa/ocelot/felix.h index 4d96cad815d5..47769dd386db 100644 --- a/drivers/net/dsa/ocelot/felix.h +++ b/drivers/net/dsa/ocelot/felix.h @@ -20,8 +20,6 @@ struct felix_info { int num_ports; int num_tx_queues; struct vcap_props *vcap; - int switch_pci_bar; - int imdio_pci_bar; const struct ptp_clock_info *ptp_caps; /* Some Ocelot switches are integrated into the SoC without the diff --git a/drivers/net/dsa/ocelot/felix_vsc9959.c b/drivers/net/dsa/ocelot/felix_vsc9959.c index f966a253d1c7..182ca749c8e2 100644 --- a/drivers/net/dsa/ocelot/felix_vsc9959.c +++ b/drivers/net/dsa/ocelot/felix_vsc9959.c @@ -1359,8 +1359,6 @@ static const struct felix_info felix_info_vsc9959 = { .num_mact_rows = 2048, .num_ports = 6, .num_tx_queues = OCELOT_NUM_TC, - .switch_pci_bar = 4, - .imdio_pci_bar = 0, .quirk_no_xtr_irq = true, .ptp_caps = &vsc9959_ptp_caps, .mdio_bus_alloc = vsc9959_mdio_bus_alloc, @@ -1388,6 +1386,9 @@ static irqreturn_t felix_irq_handler(int irq, void *data) return IRQ_HANDLED; } +#define VSC9959_SWITCH_PCI_BAR 4 +#define VSC9959_IMDIO_PCI_BAR 0 + static int felix_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) { @@ -1419,10 +1420,8 @@ static int felix_pci_probe(struct pci_dev *pdev, ocelot->dev = &pdev->dev; ocelot->num_flooding_pgids = OCELOT_NUM_TC; felix->info = &felix_info_vsc9959; - felix->switch_base = pci_resource_start(pdev, - felix->info->switch_pci_bar); - felix->imdio_base = pci_resource_start(pdev, - felix->info->imdio_pci_bar); + felix->switch_base = pci_resource_start(pdev, VSC9959_SWITCH_PCI_BAR); + felix->imdio_base = pci_resource_start(pdev, VSC9959_IMDIO_PCI_BAR); pci_set_master(pdev); From patchwork Sat Jul 10 19:25:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Foster X-Patchwork-Id: 472815 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, UNWANTED_LANGUAGE_BODY, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DDB5AC07E95 for ; Sat, 10 Jul 2021 19:26:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C5D826128C for ; Sat, 10 Jul 2021 19:26:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231458AbhGJT3T (ORCPT ); Sat, 10 Jul 2021 15:29:19 -0400 Received: from mail-bn7nam10on2107.outbound.protection.outlook.com ([40.107.92.107]:9249 "EHLO NAM10-BN7-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231124AbhGJT3K (ORCPT ); Sat, 10 Jul 2021 15:29:10 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DxqX3/blZh9JMs2NKjdbf3UZwgCQ6H36Bak9syw/ydIGj6PUQBBliqAJ/PZRaffTz13D5HyKGWc4iKVOo92ebwcqqPIlUqPNhAcx2cj1LY3JPa2jD4weL/jyqDC8zfq0zEtkgDRYjNWLOBWR9axW9nUAsHeLZNUgNQLEZ4b8TikhW169S8TR5nrUtdWcjSKHFLv8ZxGVaCCrciSOhbw2T4yW+KgM4gor8/PYTTAx0kBDGoQ5JiIST6W6asBXpyCw+gty2mxWA8q8nDlWjjnddamH/KjtXnB0HF2ZBuPEnA8NtIXEyOfBy2R63BSIgEJMfuT9RRVFKiFF4iUPLIIQug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=EUzr8oJMlUBhLd8/2h0ql3LcVVMC6AyLgA5o8dxo9RI=; b=TZ1hIOx5kfN0nabjl2smJHuPUXL+Bzcrt/Xtec1Uw+AkXbKgXfusuaJ1lryWs9y7DYcx54F5ttb+BPiGSZGlbpEbIvhb3g+vCJuFAbwdaacpUnfIU5ZWI1AcZhGrZggXWvlRomTxkGl0u9Il58xOCj1AANoeeYVQuBF+TQFAwI++n5ubgY/sVBKWUOM4QZoKaz7VhRBxNLzPCTwZhGIr1NeSVV7zisFliku0tBiAmk4xTQmRRiwJvUKTRr6XZ+CnQ1+eKnpAs5CiZhdNxV0/Afvn18CZBWrmPaUUySkgUTdCRBRB3byVANC04Iuu8OgzqeOYVCf9506DoIvtkmSJOg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=in-advantage.com; dmarc=pass action=none header.from=in-advantage.com; dkim=pass header.d=in-advantage.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inadvantage.onmicrosoft.com; s=selector2-inadvantage-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=EUzr8oJMlUBhLd8/2h0ql3LcVVMC6AyLgA5o8dxo9RI=; b=CrOKZS+JY13Ge+xZOyVBvR9KFntXbS1KfdW6/nsmMEY3HxL3IhOKoiAtNdnEzZ9LF+KQuPaOunQleBf6CbJIqKt9QgaEF4eeoQn6DYrQqYxsgFDPugMPzOLA1P3ttvwA17ED1IDpuVkWGObWTxsK6o2trqAfHoz4UHlLrqvvwxE= Authentication-Results: lunn.ch; dkim=none (message not signed) header.d=none; lunn.ch; dmarc=none action=none header.from=in-advantage.com; Received: from MWHPR1001MB2351.namprd10.prod.outlook.com (2603:10b6:301:35::37) by MWHPR10MB1709.namprd10.prod.outlook.com (2603:10b6:301:7::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.22; Sat, 10 Jul 2021 19:26:18 +0000 Received: from MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::e81f:cf8e:6ad6:d24d]) by MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::e81f:cf8e:6ad6:d24d%3]) with mapi id 15.20.4287.033; Sat, 10 Jul 2021 19:26:18 +0000 From: Colin Foster To: andrew@lunn.ch, vivien.didelot@gmail.com, f.fainelli@gmail.com, olteanv@gmail.com, davem@davemloft.net, kuba@kernel.org, robh+dt@kernel.org, claudiu.manoil@nxp.com, alexandre.belloni@bootlin.com, UNGLinuxDriver@microchip.com, linux@armlinux.org.uk Cc: netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH v2 net-next 2/8] net: dsa: ocelot: felix: move MDIO access to a common location Date: Sat, 10 Jul 2021 12:25:56 -0700 Message-Id: <20210710192602.2186370-3-colin.foster@in-advantage.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210710192602.2186370-1-colin.foster@in-advantage.com> References: <20210710192602.2186370-1-colin.foster@in-advantage.com> X-ClientProxiedBy: MWHPR12CA0042.namprd12.prod.outlook.com (2603:10b6:301:2::28) To MWHPR1001MB2351.namprd10.prod.outlook.com (2603:10b6:301:35::37) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (67.185.175.147) by MWHPR12CA0042.namprd12.prod.outlook.com (2603:10b6:301:2::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.19 via Frontend Transport; Sat, 10 Jul 2021 19:26:17 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 487a1e4b-9225-4d6e-96a8-08d943d8970c X-MS-TrafficTypeDiagnostic: MWHPR10MB1709: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:352; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rhhSaV0y+IfhXuTeNXayXw1Sc8o6OgIFK/1jWWi0MtzTjyfgIiNGNEmTPRYNQEQ7Ccoql1+jVuI5WYYlKNj/K9Xo3u3GnS8fpf4je4oNpEktbZzA82aGDsusxolRowCLDRrQFMDJ0RnkF4WxZtXQzIbpd03sA7Rrk3K+u7n/PH1Oq6qSp+sKW2+iZgTtfSveLX7LPs3byCKMc1tlQOmRMH2mo+LpZQ+6ZtEaGsL250BoJ5pvXUeds2S/gbKgXKdPPV7az1I0R9T/OZ82Nq9kpOTV7yod9fYpTNKCrVL7DgFZ79GmcUBvHLlscd++alTcHqnQcQd65QyufVRfx/JQh4EZ2M9yomDF7lSsyHSwKW4jWCFIvUWR3i5isWd2yyW8XBeSjgiF5OOYujOMkFirprbqQ9dy18NhCyUnlglX8ntRJJd9hDHp5xr2X56+i455x93L2rPa0yycQKwwHOsOopf1KN2mUtKzP1Jwj6lVxzM5/JpQi95OIIAM7sK6I40i4fiXBSt1/6ykwkZ8H82bw4cBx5m4ysZGvBniZn1cWU8o/FoJbRLGbswckSOWY/0zeVV/vEn89ezImv/Ck95iGLft40f5sobug1d8RwxVERW+z1ag0yGOo3hty1lAEyTI7wheSpXsM6VjJDUR9mH1h77heyHu8bUJ8sWh/3Xp7kl0YYBf7/IhzXfluSg9wsYOPQzt57agKdwabZOF+Av5tqiwpty94aTOhCKYQFLA78Y= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MWHPR1001MB2351.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(346002)(396003)(376002)(39830400003)(136003)(366004)(8936002)(7416002)(6506007)(5660300002)(2906002)(66556008)(26005)(2616005)(8676002)(44832011)(6486002)(6512007)(66476007)(6666004)(38100700002)(38350700002)(52116002)(66946007)(921005)(4326008)(956004)(83380400001)(1076003)(316002)(36756003)(86362001)(186003)(478600001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 1LaP3zl82at/tAY/q+Gc9onUJYSbA5+D3XdDbf+zFQGGuVeuqhLtOm2I6B4SfqnwCJxW93X/1DHs4uNYSiRA1jK7pReNRMtXtrtFWUo3n/e67+ufr4QTon1WP9l9ej3DXwziXhXxRKkGKtvkQaMoySs7zbFAzH/SHJdE9kioDLgD1YKymcCa1AxjAReO/cZA8PrPSsF/3gmwTt5G91A4c0PMFxvoTuDvYLa0JzQBUyeM6EjYp4ptIrG+FTgZJZ1GET+j6O6LF/OCXOrulNNm5WSFMXIcw3KKb7WJknCwFGs4uu0F/kS/5LWXEfQK23S/S2RasarA/b8nZFPZPagpj8QzCLA6OVFIqR896kWZS8uEbJSrhIXUEzGj/6XOXAH5fZng7cp2a2qQgkTLHH72TalSPHIDyj1cd0Ue+qMgDmhb5u4A675rqcBTw2WZEAWTyB332uKeSjkZZPm5EYftybNGqx0Kzqc/eb84+mf93fowqhvpKjgXsnsRD93QptnAZtbwdyCvMlNkAsXMvA+lsalU+iSGh1HirHzeCptbBAsNVihn2tFfPDCWCKzU722XbNH3SwQvtJ/1VGmlQxIcQjBb5N64UBzln/dEqwnzz18YL/FaDoF24XlE8dOY4H3+b6+Fmgl8jB/jEoq1UMzGpbIiGuhrDUebtWLSw7F1wncdjK/mpuuaABAxWN0TuboAICLQ8dC5XYtEjEhuHGr1mKEIrtNsBvTHFOYnat974Q9+OyfZeBhAwthWHPMtDP1kQJUhmWQrvR11XzCpkTeg13oIm8jLw1x7XDieZb8Bm+ao97/Tc2GGAeuxe0N5Bms+ZSMkMEq/3uLRhWj8BGHMg3YcuHRtdNz0P2NgXOMll4BS9g2gdWgu+ngVQfU8GVoyzextJ7+5XZ7OkbnQwGwnhljZW7YWbytpqpbljkyE7+UcK/ScRzcgTzG+bG63zsr+CDrbZh1K593iNmtq2Qx1gqK6MDCe//QTYsL3bimmVC3a08fZn1Gqkzj3iB6zjiHhAMFvUXxv5WT03v2UGsiE2Z0AT8sWq3OFRT1Qv5CQGOMkcSYCAqsQTUaWXqVm74eqTsN+YDfB5idBm+xK0Yxicz854ypQ0zIaLttMYPEpSHf9Ud+7BOni4yBpsbW1VqZhQ+m67dQH//btATSOeV8okFtLj0NGs61WR55HCfd+IeQ2Y194ewMrbfXFGFg2+jTVAifeEKxxbjJXQ2TF5bHVxyj7fqY3u/McyYozTgc0aMc8jWFxGJXBjru+zL/L23kxF6w3dszU06jDkU/UbfDMXUu2Rpzup8bUenM7VPzeb68o0GVgGa690nTHxmLx0l8U X-OriginatorOrg: in-advantage.com X-MS-Exchange-CrossTenant-Network-Message-Id: 487a1e4b-9225-4d6e-96a8-08d943d8970c X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2351.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jul 2021 19:26:17.7896 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 48e842ca-fbd8-4633-a79d-0c955a7d3aae X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 4rTCVV+t8UCeedk8bZfoCp56AUha1q8w9Ya8lgvv1PfML5EwIlvhw8VpgumyGamFDdu7tpU8j5qYInDhXFIpBMCtr1Gb0KWIszUDDtGGAmM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR10MB1709 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Indirect MDIO access is a feature that doesn't need to be specific to the Seville driver. Separate the feature to a common file so it can be shared. Signed-off-by: Colin Foster --- drivers/net/dsa/ocelot/Makefile | 1 + drivers/net/dsa/ocelot/felix_mdio.c | 145 +++++++++++++++++++++++ drivers/net/dsa/ocelot/felix_mdio.h | 11 ++ drivers/net/dsa/ocelot/seville_vsc9953.c | 108 ++--------------- 4 files changed, 165 insertions(+), 100 deletions(-) create mode 100644 drivers/net/dsa/ocelot/felix_mdio.c create mode 100644 drivers/net/dsa/ocelot/felix_mdio.h diff --git a/drivers/net/dsa/ocelot/Makefile b/drivers/net/dsa/ocelot/Makefile index f6dd131e7491..34b9b128efb8 100644 --- a/drivers/net/dsa/ocelot/Makefile +++ b/drivers/net/dsa/ocelot/Makefile @@ -8,4 +8,5 @@ mscc_felix-objs := \ mscc_seville-objs := \ felix.o \ + felix_mdio.o \ seville_vsc9953.o diff --git a/drivers/net/dsa/ocelot/felix_mdio.c b/drivers/net/dsa/ocelot/felix_mdio.c new file mode 100644 index 000000000000..d58583311c9a --- /dev/null +++ b/drivers/net/dsa/ocelot/felix_mdio.c @@ -0,0 +1,145 @@ +// SPDX-License-Identifier: (GPL-2.0 OR MIT) +/* Distributed Switch Architecture VSC9953 driver + * Copyright (C) 2020, Maxim Kochetkov + */ +#include +#include +#include +#include +#include "felix.h" + +#define MSCC_MIIM_CMD_OPR_WRITE BIT(1) +#define MSCC_MIIM_CMD_OPR_READ BIT(2) +#define MSCC_MIIM_CMD_WRDATA_SHIFT 4 +#define MSCC_MIIM_CMD_REGAD_SHIFT 20 +#define MSCC_MIIM_CMD_PHYAD_SHIFT 25 +#define MSCC_MIIM_CMD_VLD BIT(31) + +#define FELIX_MDIO_MII_TIMEOUT 10000 +#define FELIX_MDIO_MII_RETRY 10 + +static int felix_gcb_miim_pending_status(struct ocelot *ocelot) +{ + int val; + + ocelot_field_read(ocelot, GCB_MIIM_MII_STATUS_PENDING, &val); + + return val; +} + +static int felix_gcb_miim_busy_status(struct ocelot *ocelot) +{ + int val; + + ocelot_field_read(ocelot, GCB_MIIM_MII_STATUS_BUSY, &val); + + return val; +} + +static int felix_mdio_write(struct mii_bus *bus, int phy_id, int regnum, + u16 value) +{ + struct ocelot *ocelot = bus->priv; + int err, cmd, val; + + /* Wait while MIIM controller becomes idle */ + err = readx_poll_timeout(felix_gcb_miim_pending_status, ocelot, val, + !val, FELIX_MDIO_MII_RETRY, + FELIX_MDIO_MII_TIMEOUT); + if (err) { + dev_err(ocelot->dev, "MDIO write: pending timeout\n"); + goto out; + } + + cmd = MSCC_MIIM_CMD_VLD | (phy_id << MSCC_MIIM_CMD_PHYAD_SHIFT) | + (regnum << MSCC_MIIM_CMD_REGAD_SHIFT) | + (value << MSCC_MIIM_CMD_WRDATA_SHIFT) | + MSCC_MIIM_CMD_OPR_WRITE; + + ocelot_write(ocelot, cmd, GCB_MIIM_MII_CMD); + +out: + return err; +} + +static int felix_mdio_read(struct mii_bus *bus, int phy_id, int regnum) +{ + struct ocelot *ocelot = bus->priv; + int err, cmd, val; + + /* Wait until MIIM controller becomes idle */ + err = readx_poll_timeout(felix_gcb_miim_pending_status, ocelot, val, + !val, FELIX_MDIO_MII_RETRY, + FELIX_MDIO_MII_TIMEOUT); + if (err) { + dev_err(ocelot->dev, "MDIO read: pending timeout\n"); + goto out; + } + + /* Write the MIIM COMMAND register */ + cmd = MSCC_MIIM_CMD_VLD | (phy_id << MSCC_MIIM_CMD_PHYAD_SHIFT) | + (regnum << MSCC_MIIM_CMD_REGAD_SHIFT) | MSCC_MIIM_CMD_OPR_READ; + + ocelot_write(ocelot, cmd, GCB_MIIM_MII_CMD); + + /* Wait while read operation via the MIIM controller is in progress */ + err = readx_poll_timeout(felix_gcb_miim_busy_status, ocelot, val, !val, + FELIX_MDIO_MII_RETRY, FELIX_MDIO_MII_TIMEOUT); + if (err) { + dev_err(ocelot->dev, "MDIO read: busy timeout\n"); + goto out; + } + + val = ocelot_read(ocelot, GCB_MIIM_MII_DATA); + + err = val & 0xFFFF; +out: + return err; +} + +int felix_mdio_register(struct ocelot *ocelot) +{ + struct felix *felix = ocelot_to_felix(ocelot); + struct device *dev = ocelot->dev; + int rc; + + /* Needed in order to initialize the bus mutex lock */ + rc = mdiobus_register(felix->imdio); + if (rc < 0) { + dev_err(dev, "failed to register MDIO bus\n"); + felix->imdio = NULL; + } + + return rc; +} + +int felix_mdio_bus_alloc(struct ocelot *ocelot) +{ + struct felix *felix = ocelot_to_felix(ocelot); + struct device *dev = ocelot->dev; + struct mii_bus *bus; + + bus = devm_mdiobus_alloc(dev); + if (!bus) + return -ENOMEM; + + bus->name = "Felix internal MDIO bus"; + bus->read = felix_mdio_read; + bus->write = felix_mdio_write; + bus->parent = dev; + bus->priv = ocelot; + snprintf(bus->id, MII_BUS_ID_SIZE, "%s-imdio", dev_name(dev)); + + felix->imdio = bus; + + return 0; +} + +void felix_mdio_bus_free(struct ocelot *ocelot) +{ + struct felix *felix = ocelot_to_felix(ocelot); + + if (felix->imdio) + mdiobus_unregister(felix->imdio); +} + diff --git a/drivers/net/dsa/ocelot/felix_mdio.h b/drivers/net/dsa/ocelot/felix_mdio.h new file mode 100644 index 000000000000..46fd41f605a9 --- /dev/null +++ b/drivers/net/dsa/ocelot/felix_mdio.h @@ -0,0 +1,11 @@ +// SPDX-License-Identifier: (GPL-2.0 OR MIT) +/* Distributed Switch Architecture VSC9953 driver + * Copyright (C) 2020, Maxim Kochetkov + */ +#include +#include + +int felix_mdio_bus_alloc(struct ocelot *ocelot); +int felix_mdio_register(struct ocelot *ocelot); +void felix_mdio_bus_free(struct ocelot *ocelot); + diff --git a/drivers/net/dsa/ocelot/seville_vsc9953.c b/drivers/net/dsa/ocelot/seville_vsc9953.c index 84f93a874d50..0e06750db264 100644 --- a/drivers/net/dsa/ocelot/seville_vsc9953.c +++ b/drivers/net/dsa/ocelot/seville_vsc9953.c @@ -11,13 +11,7 @@ #include #include #include "felix.h" - -#define MSCC_MIIM_CMD_OPR_WRITE BIT(1) -#define MSCC_MIIM_CMD_OPR_READ BIT(2) -#define MSCC_MIIM_CMD_WRDATA_SHIFT 4 -#define MSCC_MIIM_CMD_REGAD_SHIFT 20 -#define MSCC_MIIM_CMD_PHYAD_SHIFT 25 -#define MSCC_MIIM_CMD_VLD BIT(31) +#include "felix_mdio.h" static const u32 vsc9953_ana_regmap[] = { REG(ANA_ADVLEARN, 0x00b500), @@ -857,7 +851,6 @@ static struct vcap_props vsc9953_vcap_props[] = { #define VSC9953_INIT_TIMEOUT 50000 #define VSC9953_GCB_RST_SLEEP 100 #define VSC9953_SYS_RAMINIT_SLEEP 80 -#define VCS9953_MII_TIMEOUT 10000 static int vsc9953_gcb_soft_rst_status(struct ocelot *ocelot) { @@ -877,82 +870,6 @@ static int vsc9953_sys_ram_init_status(struct ocelot *ocelot) return val; } -static int vsc9953_gcb_miim_pending_status(struct ocelot *ocelot) -{ - int val; - - ocelot_field_read(ocelot, GCB_MIIM_MII_STATUS_PENDING, &val); - - return val; -} - -static int vsc9953_gcb_miim_busy_status(struct ocelot *ocelot) -{ - int val; - - ocelot_field_read(ocelot, GCB_MIIM_MII_STATUS_BUSY, &val); - - return val; -} - -static int vsc9953_mdio_write(struct mii_bus *bus, int phy_id, int regnum, - u16 value) -{ - struct ocelot *ocelot = bus->priv; - int err, cmd, val; - - /* Wait while MIIM controller becomes idle */ - err = readx_poll_timeout(vsc9953_gcb_miim_pending_status, ocelot, - val, !val, 10, VCS9953_MII_TIMEOUT); - if (err) { - dev_err(ocelot->dev, "MDIO write: pending timeout\n"); - goto out; - } - - cmd = MSCC_MIIM_CMD_VLD | (phy_id << MSCC_MIIM_CMD_PHYAD_SHIFT) | - (regnum << MSCC_MIIM_CMD_REGAD_SHIFT) | - (value << MSCC_MIIM_CMD_WRDATA_SHIFT) | - MSCC_MIIM_CMD_OPR_WRITE; - - ocelot_write(ocelot, cmd, GCB_MIIM_MII_CMD); - -out: - return err; -} - -static int vsc9953_mdio_read(struct mii_bus *bus, int phy_id, int regnum) -{ - struct ocelot *ocelot = bus->priv; - int err, cmd, val; - - /* Wait until MIIM controller becomes idle */ - err = readx_poll_timeout(vsc9953_gcb_miim_pending_status, ocelot, - val, !val, 10, VCS9953_MII_TIMEOUT); - if (err) { - dev_err(ocelot->dev, "MDIO read: pending timeout\n"); - goto out; - } - - /* Write the MIIM COMMAND register */ - cmd = MSCC_MIIM_CMD_VLD | (phy_id << MSCC_MIIM_CMD_PHYAD_SHIFT) | - (regnum << MSCC_MIIM_CMD_REGAD_SHIFT) | MSCC_MIIM_CMD_OPR_READ; - - ocelot_write(ocelot, cmd, GCB_MIIM_MII_CMD); - - /* Wait while read operation via the MIIM controller is in progress */ - err = readx_poll_timeout(vsc9953_gcb_miim_busy_status, ocelot, - val, !val, 10, VCS9953_MII_TIMEOUT); - if (err) { - dev_err(ocelot->dev, "MDIO read: busy timeout\n"); - goto out; - } - - val = ocelot_read(ocelot, GCB_MIIM_MII_DATA); - - err = val & 0xFFFF; -out: - return err; -} /* CORE_ENA is in SYS:SYSTEM:RESET_CFG * MEM_INIT is in SYS:SYSTEM:RESET_CFG @@ -1086,7 +1003,6 @@ static int vsc9953_mdio_bus_alloc(struct ocelot *ocelot) { struct felix *felix = ocelot_to_felix(ocelot); struct device *dev = ocelot->dev; - struct mii_bus *bus; int port; int rc; @@ -1098,26 +1014,18 @@ static int vsc9953_mdio_bus_alloc(struct ocelot *ocelot) return -ENOMEM; } - bus = devm_mdiobus_alloc(dev); - if (!bus) - return -ENOMEM; - - bus->name = "VSC9953 internal MDIO bus"; - bus->read = vsc9953_mdio_read; - bus->write = vsc9953_mdio_write; - bus->parent = dev; - bus->priv = ocelot; - snprintf(bus->id, MII_BUS_ID_SIZE, "%s-imdio", dev_name(dev)); + rc = felix_mdio_bus_alloc(ocelot); + if (rc < 0) { + dev_err(dev, "failed to allocate MDIO bus\n"); + return rc; + } - /* Needed in order to initialize the bus mutex lock */ - rc = mdiobus_register(bus); + rc = felix_mdio_register(ocelot); if (rc < 0) { dev_err(dev, "failed to register MDIO bus\n"); return rc; } - felix->imdio = bus; - for (port = 0; port < felix->info->num_ports; port++) { struct ocelot_port *ocelot_port = ocelot->ports[port]; int addr = port + 4; @@ -1162,7 +1070,7 @@ static void vsc9953_mdio_bus_free(struct ocelot *ocelot) mdio_device_free(pcs->mdio); lynx_pcs_destroy(pcs); } - mdiobus_unregister(felix->imdio); + felix_mdio_bus_free(ocelot); } static const struct felix_info seville_info_vsc9953 = { From patchwork Sat Jul 10 19:25:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Foster X-Patchwork-Id: 472620 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 468C7C11F66 for ; Sat, 10 Jul 2021 19:26:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3553760FDA for ; Sat, 10 Jul 2021 19:26:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231728AbhGJT3V (ORCPT ); Sat, 10 Jul 2021 15:29:21 -0400 Received: from mail-bn7nam10on2110.outbound.protection.outlook.com ([40.107.92.110]:51932 "EHLO NAM10-BN7-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231184AbhGJT3M (ORCPT ); Sat, 10 Jul 2021 15:29:12 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Vl9RmSwFX0LoSZqJFOP/NBycuQkv+QYiLSUm2vI73uxHM1xWNEBau2NYYIG2t4UCQcWfv/WgasoqySU9j9VIBbSl7JOL0yJdzLsml8pP6yrSUPpp6oof9YIGm8QtozTxIhKmGxih5koCgvg9gk0CidX/se1FDuT1CGdm5fmD4xNBz+AuD99dLjwnWzvb/EyAyXcoPzFTz3UENtHuYZJAInFQvku8v/hzEzdfyQEZ6nsnBYUKq8dYF1rTrNElnviKrfS8PMYvjM1/6hsJRcbJYOtr7q76cOeq661mZeTg/YfR9eIk9yZNzz3FRUIZculIbcFdKrDKsQs9eFlJXGXckA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=aCPo/unyFkF2zHAE734bCvqx6zKhLBpbbjT0QENzyR0=; b=mqcqH02iZMj4ANck69ApfyeGcAfk1i7y3+tgn7yaUyb+RL3+Z6Pzl7Qd0bG4xRhQ/NeZ3yj8nD2brgcQcgTjPHHYC8wme7P74L6ChE+FK2xG4xlOF9fZ6XuXFK7g/BNkFnWleKLxRgQqE0MHPLXRIsQHI6tS6iX6kw/CQiDqncAiMN9NloqVZmIXaG0bqJ06TJBM22WZ0FP+vOdNxldPCOW063FHRWMUe7ZboG0MhmD1yYW01Te6uC/DSqzM1xYHHW5i3sL2Z8m80X4txbDQuYSxcsjsreQsZqn0LzCoZrDm5NcvwvBZ6SuCTlU8RyomaDn8/dPVYa4kroBRudb/Xg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=in-advantage.com; dmarc=pass action=none header.from=in-advantage.com; dkim=pass header.d=in-advantage.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inadvantage.onmicrosoft.com; s=selector2-inadvantage-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=aCPo/unyFkF2zHAE734bCvqx6zKhLBpbbjT0QENzyR0=; b=kWMy+5eCBWf2aFZn/ThdaRYXPBqZW9Chjn0VoAT5xZYPhQNpWmp2YFCI4QlfOI3XzWmJauj5TcrMVKUO/uIXkBR7ZZGKcHqQUV2GWB/CF+Q2Ti5aZ4X+EyU1mjRA/yOB8QOp+yN3HP43gBhXAN0GvJ90D5FunApQnEiL5YhT20w= Authentication-Results: lunn.ch; dkim=none (message not signed) header.d=none; lunn.ch; dmarc=none action=none header.from=in-advantage.com; Received: from MWHPR1001MB2351.namprd10.prod.outlook.com (2603:10b6:301:35::37) by MWHPR10MB1709.namprd10.prod.outlook.com (2603:10b6:301:7::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.22; Sat, 10 Jul 2021 19:26:18 +0000 Received: from MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::e81f:cf8e:6ad6:d24d]) by MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::e81f:cf8e:6ad6:d24d%3]) with mapi id 15.20.4287.033; Sat, 10 Jul 2021 19:26:18 +0000 From: Colin Foster To: andrew@lunn.ch, vivien.didelot@gmail.com, f.fainelli@gmail.com, olteanv@gmail.com, davem@davemloft.net, kuba@kernel.org, robh+dt@kernel.org, claudiu.manoil@nxp.com, alexandre.belloni@bootlin.com, UNGLinuxDriver@microchip.com, linux@armlinux.org.uk Cc: netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH v2 net-next 3/8] net: dsa: ocelot: felix: NULL check on variable Date: Sat, 10 Jul 2021 12:25:57 -0700 Message-Id: <20210710192602.2186370-4-colin.foster@in-advantage.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210710192602.2186370-1-colin.foster@in-advantage.com> References: <20210710192602.2186370-1-colin.foster@in-advantage.com> X-ClientProxiedBy: MWHPR12CA0042.namprd12.prod.outlook.com (2603:10b6:301:2::28) To MWHPR1001MB2351.namprd10.prod.outlook.com (2603:10b6:301:35::37) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (67.185.175.147) by MWHPR12CA0042.namprd12.prod.outlook.com (2603:10b6:301:2::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.19 via Frontend Transport; Sat, 10 Jul 2021 19:26:17 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7b4e773c-a08d-49b4-2812-08d943d89769 X-MS-TrafficTypeDiagnostic: MWHPR10MB1709: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1824; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YaMnyVj3dJwc6LtcB7oQXGDuUxAPY84W+P+Ftk/40lSGj5+4A5Q2wAfRr26I+EnaXI44XN5j0W3K7nowHDL5VvpL/znAJgIUid4qmrvPnX+7WgPaYjTxva/wf9wuuesFgVov7FA8bwODi/gZgWLzhwU+HtvFHnqrRxqKb6KtNp1lIYGCYaCoY+AlWb8upPuGUtIm9ExgxDifXgZpyjhyWgoS1rFRVjVzdY95GRplupJrTkOUVVfIS9PPMjpDi9RrRvD3j7+o5rapHEUC2MhwvB5Bcp/JC+1tszrkjD4IWM7DXiKGhho9xpYmLWvGkJp/FpMFa+UfxdqqfesalCIHYVNr0cdhNEDwgJ9AVqDnIGlJMmH9jaFXPtSy6XKYDeenf58aV2E4P9F98KmzJHSDi4ABSlWWyBvN+QAmNqdlg+A0OBn6c5Kc3NQicemxmhPtXXAIkNjAkkE50bJiCC5G/H16eTjpADleA9shZuIwvA+jf7G5e/T2i5CxFXbR/HgaUIqZldj6mYDm8gZ2dnT280AgpRxN5c2dKgO2gXD7KCl16HT8bNssoX/sFAB23AW58DBtQQtAVc/f9CFwXz8njnX+b+r305G2nyjx0mJpE/5Pq7cs/EOpqCZHU5rHVj93aB3MAoHR1TrIv4Xz0M+dbwzJuMnuvGEPIHb+anWVkXzgAXNaNtcAIeD0Y+pBzfMiHawewWS9EBuRBoDsbF3edidpTeJvDVcAntFMuwGce2w= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MWHPR1001MB2351.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(346002)(396003)(376002)(39830400003)(136003)(366004)(8936002)(7416002)(6506007)(5660300002)(2906002)(66556008)(26005)(2616005)(8676002)(44832011)(6486002)(6512007)(66476007)(6666004)(38100700002)(38350700002)(52116002)(66946007)(921005)(4326008)(956004)(83380400001)(1076003)(316002)(36756003)(86362001)(186003)(478600001)(4744005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: O/BF8q+QUfqTpxAh1xc/wey6Dj7W0x4kAF6cGoJGQvgXCp0Kw/Qk+0EPlLb8eehVgMNXFumxbS23xwspoPUJRZnECne91CrkyUWX4AZCkD8dEB99um79mj9e2zZPL8/a3mjFxCY8vj+qZChL2yQFnK+quV/9pqdkXKEBdm7k4YUixIGBUc1BjMNm164k5rPJs3mFwAHgsK13sFHpzQjiq2ijs4UV/jfhbhfGdIp00VEqhgVHPh/1m0npm9bmQrhgDwZydSaIl3fyyManoVIIWNv4OwABZeDpo8/9fMx/yPhR8ROgjmxop7Sat0MsG06cDCEhYTlbDgtGVGbPZCfbxZ+Wh1YpoOkz4zPBl/zj7hA3m5LXkT+4oij30CclS/ZuSl2K8mASRz2PaLfojiXJR6kT4Mb9BmRVJ1ue1DOu+IHmhFggisctwRrNI3+LVaWKePe3zUxFEAgIpVAmqg34NkEtMz9hSBRw63CLmZdifLrjsm6T1tGXoGBjnCKYZwBYjxi9sKQFYFYHYJqUAYciYrGL06oqGxvPotcDEbd1zRXoUs1v9c+qH1rctNsUzeKqYff6Tzu4AdZYgGb76EQy+/+XvlCif/31vnHYly0uY4VGHWNtGq+1wYO0m13qac3IUWBrNSAcJt4j8Cb5coLvJiAi4RVQliLOCwVBlwKJUd3xYAz32GXKicPFS4nQ+R/OIqpjN/6uvn366EFJLpWdDW3xrq9K4s+DmLWS3MSLvUtya85V70WslBUIdGItRgQHlj07VhHGOq85ARYx7Ii2zr66fdVyUqEKJkbl9LBrCeyQ105TlQbo0WmsD0Oi+HputQi24a3LDgEgpSsZmxxGC6tOTHQn3/zyb1QAWw/PBlF4OJ/+nJKpjMZ+kARMJGXFyjvbP0l7S8HdZGyqxEnlLdxU/hRx6HbFc9DGkLy3GwOwRL0iOIq9F0Rb881aKT8VP8RwsqULQVfRNIBZSgWUd9XJa7FLywHgipf1VGkOXOwb50YdeloWFCkFbg2i+MlrqZQntWZjf23YtNWpH5ZwOVpBrgvpveMm0e7hJJBnuALpzoT0+6Rp9B004paR7qYa8wudTa7gSRSDSGFxT1DzjY77OLLo9qCKP6bI1TkRIFtzIFNtreGYihr3h1SVDcFU+45Ek5h7rggkcEN62NGIuRdgqsc3UiY2BCoK4nfJXivfsHpUCUNbmqRRu2V/RbjKeV1e8bAbc7mASBnKST2jxGyH4wJvjozOaAS6sPweXZFiX4vbssbwq+9Z6OI9g7VQ2FhGB+RX1gpTHu7TzXFUSHmimwK2aC/yHyE3dzqD1Jyp14AVijngTJgDq5haUmpg X-OriginatorOrg: in-advantage.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7b4e773c-a08d-49b4-2812-08d943d89769 X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2351.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jul 2021 19:26:18.3682 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 48e842ca-fbd8-4633-a79d-0c955a7d3aae X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: YY6fX4+QaVndHUbcpS32iqisWGjg/roqKVv/F5/TGSdCXxAlv2d9vyR9jt23Kg5i+MUtdYVhjYowPFmWEUsNp2CbBHGm4rbHQH2uhNv9bkM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR10MB1709 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Add NULL check before dereferencing array Signed-off-by: Colin Foster --- drivers/net/dsa/ocelot/felix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/dsa/ocelot/felix.c b/drivers/net/dsa/ocelot/felix.c index ce607fbaaa3a..74ae322b2126 100644 --- a/drivers/net/dsa/ocelot/felix.c +++ b/drivers/net/dsa/ocelot/felix.c @@ -852,7 +852,7 @@ static void felix_phylink_mac_config(struct dsa_switch *ds, int port, struct felix *felix = ocelot_to_felix(ocelot); struct dsa_port *dp = dsa_to_port(ds, port); - if (felix->pcs[port]) + if (felix->pcs && felix->pcs[port]) phylink_set_pcs(dp->pl, &felix->pcs[port]->pcs); } From patchwork Sat Jul 10 19:25:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Foster X-Patchwork-Id: 472618 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7F4BCC11F6C for ; Sat, 10 Jul 2021 19:26:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 65B2561356 for ; Sat, 10 Jul 2021 19:26:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231880AbhGJT3Z (ORCPT ); Sat, 10 Jul 2021 15:29:25 -0400 Received: from mail-bn7nam10on2107.outbound.protection.outlook.com ([40.107.92.107]:9249 "EHLO NAM10-BN7-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231183AbhGJT3L (ORCPT ); Sat, 10 Jul 2021 15:29:11 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=B4wVgXL1KlZ07jRT9UH6yTpgx1PffDWX9HbpB9eHkPoB/2tKce9tXOfPStm2sjAVX15tHL47uWvq0qez7aBOmWqsn25pk1HKlPk4OYq6kmh3rheHSy+61M71uAo5QSzQsjwsyfaBQ9hfv/c5jawq/A5+niKfUgSlO3Pcr4kYvO1oNBwlq8rXMcvDZvv+1f7uHKEwNJocUxmoyckTvT+CynTFzc4rBbWVuMOWqiMRlqBlFmLmputbH17xOFQJYTAQXb49XEvh4AapVZeKN+aSPNQAR3oAZCUuOoMGslWNZ8PozJEE6Gl1MdfRn73fzHqNcig7UU7IBMlH43silpCb1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=haGDF6utMR0NRHVAWsXQLK3t+CT5JeyKOm5VYtRbnAE=; b=mNisK6c/DwuhkOedPnZ+SeTKn17dw0ZLNlojgStjvdt9llKjr4V7T888GRkzIXbEtKfx1k2BidBFRyvjV9GniNttwGNJYllIA2RsAGSL1YWelJVtMmVDMVnVW2Yf51XFks96WkALcbw4a3h1toYCkQ0MwiBr3eTTw20Z9SeENVvs49yYZeSlK/Uzn7sv8uJgvMf3tAGNoAMkjTX99OMNHgGXQC6tzQWUmRltYeqlCZYvF/4ZuQqvHWfmfgMAMt/BRFWYAyWsdRr9Zgs96DzHaXVJ0H0UqACmkXYS7fNN68Z+PnHODVEymqmboC4qAo9tKQGUdg5Y5vOxbARgH3Vxfw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=in-advantage.com; dmarc=pass action=none header.from=in-advantage.com; dkim=pass header.d=in-advantage.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inadvantage.onmicrosoft.com; s=selector2-inadvantage-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=haGDF6utMR0NRHVAWsXQLK3t+CT5JeyKOm5VYtRbnAE=; b=dThMGPppGECX6TmerjQYM+qVHLx4Wh/kJamGXym4kWib5GxEnt+myAclNLrV0pggAYpWxu0KbavqcbwVM1Rejaap0mVcj+YGc4eqGxb+msskkKsoaGzTPUeqAkJdc9a0+pL2JdnU9xoh/6R0TotVmZBxxpNeL20per8MZoECoEg= Authentication-Results: lunn.ch; dkim=none (message not signed) header.d=none; lunn.ch; dmarc=none action=none header.from=in-advantage.com; Received: from MWHPR1001MB2351.namprd10.prod.outlook.com (2603:10b6:301:35::37) by MWHPR10MB1709.namprd10.prod.outlook.com (2603:10b6:301:7::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.22; Sat, 10 Jul 2021 19:26:19 +0000 Received: from MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::e81f:cf8e:6ad6:d24d]) by MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::e81f:cf8e:6ad6:d24d%3]) with mapi id 15.20.4287.033; Sat, 10 Jul 2021 19:26:19 +0000 From: Colin Foster To: andrew@lunn.ch, vivien.didelot@gmail.com, f.fainelli@gmail.com, olteanv@gmail.com, davem@davemloft.net, kuba@kernel.org, robh+dt@kernel.org, claudiu.manoil@nxp.com, alexandre.belloni@bootlin.com, UNGLinuxDriver@microchip.com, linux@armlinux.org.uk Cc: netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH v2 net-next 4/8] net: dsa: ocelot: felix: add interface for custom regmaps Date: Sat, 10 Jul 2021 12:25:58 -0700 Message-Id: <20210710192602.2186370-5-colin.foster@in-advantage.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210710192602.2186370-1-colin.foster@in-advantage.com> References: <20210710192602.2186370-1-colin.foster@in-advantage.com> X-ClientProxiedBy: MWHPR12CA0042.namprd12.prod.outlook.com (2603:10b6:301:2::28) To MWHPR1001MB2351.namprd10.prod.outlook.com (2603:10b6:301:35::37) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (67.185.175.147) by MWHPR12CA0042.namprd12.prod.outlook.com (2603:10b6:301:2::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.19 via Frontend Transport; Sat, 10 Jul 2021 19:26:18 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 82d10a0d-03bb-4738-b081-08d943d897c9 X-MS-TrafficTypeDiagnostic: MWHPR10MB1709: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2150; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: iL6qJizkdoCgJ4uryOfk/iGMz8UuWb+6sL22Jri/sWQPwGn9mWDr5Ev6i8m5jwH4nX6J4PNXfRsNqWo4ruiegxr0d9Rw9yWmuPfZstLUOEcNCY3TyeMVUxjwPooGZk3RfiShOIK9gAzps+9wH2HKJoFUD0wEi95RziEq/l5gwHSZ7gfQUTSiz0Q+n+2zEHm2lqtn6sMCaS5q349KvJJ0FnQdcvklApQvV95G9UjphuVC95A/QbslWWrZiCYJmpP+kD1snmwxMWmvDUzULiaE6S/JSZqw/PSzkZEL0gx6hWgxFU4Yicg2YHX3+nrG/5jYRB/00/R3yM7pNf9cQqsDUuyInrfiVotfoOPKTTUMlsO6c1V8Jf+OaX6TG1ZgCEr/+8lh2hUCKcaLKY4T/ssNNukHNWahKvTIq1PVLGKAew01e0cYhktFsVjer5Yk1NEWyWsFN/jfg4Q7+en9taxaRb1QG6XgXnv1OOOszSxopFXTD6K3mdtEqt3XbaHsD+JM4ITE32Xe4rU+hw6LcXLkpQ09jR8HJyzlUaKtbJF2IVxM5YEPqAfUr9dHIzPB0CKLthogB4RIzVN1uUQ0HU767JV+oKLIQEcCdxdqyySElJMCn84MtFm/zCJ6LHlWIqQudcopHRaOXoqgEVigM3uNrADSxuJMRhYRK4jgo9/7Z4FodkB+StuRJc08iTfhNnD5bTF93kgjNB/5Wts/F7IqQ6KNvU+dwUJj1hS0Ln/oY1o= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MWHPR1001MB2351.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(346002)(396003)(376002)(39830400003)(136003)(366004)(8936002)(7416002)(6506007)(5660300002)(2906002)(66556008)(26005)(2616005)(8676002)(44832011)(6486002)(6512007)(66476007)(6666004)(38100700002)(38350700002)(52116002)(66946007)(921005)(4326008)(956004)(83380400001)(1076003)(316002)(36756003)(86362001)(186003)(478600001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: twsCcOfPocWpVzhA1oQUWnAnevy6zR6emL0vLy7Jsc1tfPMfXfdwZjyPd2cR61lcT3Bc3VT7pPZmWrbTDdwQSt17XJvQxmCG2qCcbYMRaUmCYeiBGtCH3Z+kWg9Dbo8n3dxgZrtCTm8oow0rOSfhREnpSWZFUNRzwoWaCJF7XEbMEt3xdfc8BWSwkO82lsmiEDWk308BW0PD/C4APs5/GQ5OtCtGMtxKWr9ewCeN1Kk61jsbSVlf/4cgV8xfSvklrfK8YWdnfN2dbBVDpHzy3Sq2t978cXROluy8KX2eiNcOWHtMlhzhSesl/mq0NUun3B1UkfE2f09AC8STRV7Y2D18oMvWf3lNWVwxAkzmnvt57xzi+4tQc63i6s+OQ1EopKtttWkL9+wohy0PVrxQBQWE5YeQAgtQo7UXrYFXMX43Un+tzv8+7v5bMu0dqhHSk1kmhIfl/QR568Dx6IB0sua0e4e78f4vD5QJzcln+qz3nIvblq4LrKaDpDbDkvCJ+wVIkvpRzRQjsIjWysW3YBR5EDAg//6yOvA10j72uEgkwod18j+OhA5UtfFtiht2xC4DVGDyOHMJi47oEdSVYHT7GSr8Mo8Do+Pq44yZBQk7A4/FxfNHO5IVEQDzFVImsY40hjT/ICeokZCQqXcnF/xKDy5RuRLHp+OqujyAwR87e5kqkha5Cypx1w2xA7gERn7F1winuEYFMkFrJ7NSpx4uaiF6vXIrfRpz7X26mszwaR568z874CwtOEIIgrKs5R9c6JiaOCm0evYTkKRPJq0HsFqqw9paZOw6FwUeneN8ck5kyB3RwxQX9mpkV1CCpneNsNskY/Cm1uxlRVmNYYMKlGCD0/5IQZLZQLw1H+KOvDLk77SXBRy9VgcZPXXFVub03VtGskZKYvInoL0pl3Mx8jUVndR3clqbwK2j+abRkt7E/X/JL/TeB9IYzw30yH/sdaUgJJtVMil/2QxsJQJOdMbZVyYgjdNfeqHQqi1zVPWl0rCQQa2hPyPBmusDOnzd7KuN8ufUKfNbq6QUqNlYPEvpp8yB8ichfRyQ9nlFK8VuKg5EyPHUEeEseTUZobP8GWZOFRV2AXrjReYdGblwEUIOAAuLwMz0JixHMJxMS7Nm/a3JcdYLH7Wdk+mYolpkjn7WQe1xFy8ko59Bdpozg6sMAaMySScTd2k9D92AAa/SM9BkpQXmLG7FLxFLmBvCd7kIQgiPGHrWKQ0MuqsfgrHYse6tC2Zq8Kik/N5Nuw3bOWl6P2yoHoPTps/pvtWg7VC0uEsm1puRt5y3WU+hMNYmY7XN8vwh9uEDJceZFfTtwOZmYZ1+yMQhUUmQ X-OriginatorOrg: in-advantage.com X-MS-Exchange-CrossTenant-Network-Message-Id: 82d10a0d-03bb-4738-b081-08d943d897c9 X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2351.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jul 2021 19:26:18.9749 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 48e842ca-fbd8-4633-a79d-0c955a7d3aae X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: A7KmysJDQDXjdkzvDE2NUOBo9392XFwVNQnHV+CJsH1vChMeyavCzA/hqIMHYKjDcwIV5tzqm8vmTnxgdOPTcvj2w0C2K57ZzHzCa2pHiys= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR10MB1709 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Add an interface so that non-mmio regmaps can be used Signed-off-by: Colin Foster --- drivers/net/dsa/ocelot/felix.c | 4 ++-- drivers/net/dsa/ocelot/felix.h | 2 ++ drivers/net/dsa/ocelot/felix_vsc9959.c | 1 + drivers/net/dsa/ocelot/seville_vsc9953.c | 1 + 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/net/dsa/ocelot/felix.c b/drivers/net/dsa/ocelot/felix.c index 74ae322b2126..77644deb4a35 100644 --- a/drivers/net/dsa/ocelot/felix.c +++ b/drivers/net/dsa/ocelot/felix.c @@ -1124,7 +1124,7 @@ static int felix_init_structs(struct felix *felix, int num_phys_ports) res.start += felix->switch_base; res.end += felix->switch_base; - target = ocelot_regmap_init(ocelot, &res); + target = felix->info->init_regmap(ocelot, &res); if (IS_ERR(target)) { dev_err(ocelot->dev, "Failed to map device memory space\n"); @@ -1161,7 +1161,7 @@ static int felix_init_structs(struct felix *felix, int num_phys_ports) res.start += felix->switch_base; res.end += felix->switch_base; - target = ocelot_regmap_init(ocelot, &res); + target = felix->info->init_regmap(ocelot, &res); if (IS_ERR(target)) { dev_err(ocelot->dev, "Failed to map memory space for port %d\n", diff --git a/drivers/net/dsa/ocelot/felix.h b/drivers/net/dsa/ocelot/felix.h index 47769dd386db..25f664ef4947 100644 --- a/drivers/net/dsa/ocelot/felix.h +++ b/drivers/net/dsa/ocelot/felix.h @@ -45,6 +45,8 @@ struct felix_info { enum tc_setup_type type, void *type_data); void (*port_sched_speed_set)(struct ocelot *ocelot, int port, u32 speed); + struct regmap *(*init_regmap)(struct ocelot *ocelot, + struct resource *res); }; extern const struct dsa_switch_ops felix_switch_ops; diff --git a/drivers/net/dsa/ocelot/felix_vsc9959.c b/drivers/net/dsa/ocelot/felix_vsc9959.c index 182ca749c8e2..31712a77f4b4 100644 --- a/drivers/net/dsa/ocelot/felix_vsc9959.c +++ b/drivers/net/dsa/ocelot/felix_vsc9959.c @@ -1367,6 +1367,7 @@ static const struct felix_info felix_info_vsc9959 = { .prevalidate_phy_mode = vsc9959_prevalidate_phy_mode, .port_setup_tc = vsc9959_port_setup_tc, .port_sched_speed_set = vsc9959_sched_speed_set, + .init_regmap = ocelot_regmap_init, }; static irqreturn_t felix_irq_handler(int irq, void *data) diff --git a/drivers/net/dsa/ocelot/seville_vsc9953.c b/drivers/net/dsa/ocelot/seville_vsc9953.c index 0e06750db264..540cf5bc9c54 100644 --- a/drivers/net/dsa/ocelot/seville_vsc9953.c +++ b/drivers/net/dsa/ocelot/seville_vsc9953.c @@ -1089,6 +1089,7 @@ static const struct felix_info seville_info_vsc9953 = { .mdio_bus_free = vsc9953_mdio_bus_free, .phylink_validate = vsc9953_phylink_validate, .prevalidate_phy_mode = vsc9953_prevalidate_phy_mode, + .init_regmap = ocelot_regmap_init, }; static int seville_probe(struct platform_device *pdev) From patchwork Sat Jul 10 19:25:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Foster X-Patchwork-Id: 472814 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, UPPERCASE_50_75,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 51BA2C11F69 for ; Sat, 10 Jul 2021 19:26:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 486356128C for ; Sat, 10 Jul 2021 19:26:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231764AbhGJT3W (ORCPT ); Sat, 10 Jul 2021 15:29:22 -0400 Received: from mail-bn7nam10on2110.outbound.protection.outlook.com ([40.107.92.110]:51932 "EHLO NAM10-BN7-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231276AbhGJT3N (ORCPT ); Sat, 10 Jul 2021 15:29:13 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HGFx/Gfh7sKEd4Fb3ex15R1j+OAq0JiP7l0CeYHfWsszzOmh33M/eWEG+Gme2pXMK6nhjsI4bE69Rq/nYF8FzfmEgSX2IfViJRnF57wQMYIiz6sHj/KBNzl5mcrOY/FM5cTQZEEkxPFlm7Hv7Z0jA7t068KUe4HJRbdwFTAwRKLfVhlVZHosiLLXG2YJfd+Tpq0b3mOT7mL+8vFHuclxWZCbhPgtvvGFZHnKSZQZ3sDTC5cY81lzjxwICi/IHrvdkv+ztrAcK84MviqL9KjkXe5lp2BYfp3zQ/jnXVcmzLxfMrXbgLFAXjdtSWSJr5kV392D51GzGipanp22LzBhcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=vPUngaTfjU119zLRv+8uICUhiMo/qbDfuSyRwnRsVqI=; b=Z/LtmNl918/uj4HiQj7G5ZNflxvaJEdYVDG5gbv5keJ85NoV2LcxHk/b3D6FCOBVgDckl2kEBRVzrR/yhOlaVpuXYpM8cD3adGFWXjrYJh7fQMj62UMMyWg/04k/2zd6cv+OM6x6RaximVXwkW32CrYuP/BOo88QQ2+DqRhTmh+FtYVD8WRL72xySQCHFdMaJb+U1KrGXBkaWyceRALL/o9jzYXVE40jEwW5qR+vVNryH9jQ3pxKMjiWj6t6PQgmfWS75LS3KiRMHwOOWiQuXjCI0fuCJRUvoKtyCzgIfcqIXSbYIa/hA9CNyF0i959sW+cO45bT3LxlILpY1z+vlg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=in-advantage.com; dmarc=pass action=none header.from=in-advantage.com; dkim=pass header.d=in-advantage.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inadvantage.onmicrosoft.com; s=selector2-inadvantage-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=vPUngaTfjU119zLRv+8uICUhiMo/qbDfuSyRwnRsVqI=; b=qRvjTu0SNLcolQYqXHHgS65muMvdTUNaKtWInnCeFly50bRf4Ubr9uDAJskrO9iYuJtN6zvfgccaCLctHqumWeaw9btCy2gOO3kUHJuESfwgBF0Iz4JMN0q/Xu7KKe2eXyom3H5jOrSY9So/PikNka44wFkCYRwF1CehEhg1L5A= Authentication-Results: lunn.ch; dkim=none (message not signed) header.d=none; lunn.ch; dmarc=none action=none header.from=in-advantage.com; Received: from MWHPR1001MB2351.namprd10.prod.outlook.com (2603:10b6:301:35::37) by MWHPR10MB1709.namprd10.prod.outlook.com (2603:10b6:301:7::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.22; Sat, 10 Jul 2021 19:26:19 +0000 Received: from MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::e81f:cf8e:6ad6:d24d]) by MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::e81f:cf8e:6ad6:d24d%3]) with mapi id 15.20.4287.033; Sat, 10 Jul 2021 19:26:19 +0000 From: Colin Foster To: andrew@lunn.ch, vivien.didelot@gmail.com, f.fainelli@gmail.com, olteanv@gmail.com, davem@davemloft.net, kuba@kernel.org, robh+dt@kernel.org, claudiu.manoil@nxp.com, alexandre.belloni@bootlin.com, UNGLinuxDriver@microchip.com, linux@armlinux.org.uk Cc: netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH v2 net-next 5/8] net: mscc: ocelot: split register definitions to a separate file Date: Sat, 10 Jul 2021 12:25:59 -0700 Message-Id: <20210710192602.2186370-6-colin.foster@in-advantage.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210710192602.2186370-1-colin.foster@in-advantage.com> References: <20210710192602.2186370-1-colin.foster@in-advantage.com> X-ClientProxiedBy: MWHPR12CA0042.namprd12.prod.outlook.com (2603:10b6:301:2::28) To MWHPR1001MB2351.namprd10.prod.outlook.com (2603:10b6:301:35::37) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (67.185.175.147) by MWHPR12CA0042.namprd12.prod.outlook.com (2603:10b6:301:2::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.19 via Frontend Transport; Sat, 10 Jul 2021 19:26:19 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3e092bff-0127-4a60-aeb4-08d943d89821 X-MS-TrafficTypeDiagnostic: MWHPR10MB1709: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:635; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZBH/vufzh9w6nFv+OaFPzUOyyoSi0uZgIzng7W5nALSh8eoI3uhVYiQPO4sTZ8qzQrw9rY6fSVWRtToPPSF1LgmhfwH1FTbhus4HcnekEWnUW+9pgHMWqKI0QujNjHG2XBTeA0f9CZ5/KR0+4TcbIRV2c/2pEyD796Sm3tElusYSwXjC4D+OLzaOjCdYPHvTA53nsQ5nK9sAnqUngx8dLuaDFjabPzWRW29xxmQWdHXCIg1kqLIIUnLikr162hhzfY1NZvsUzbBSpdzOElvPEEyQjWB8ILZtng87Kq3u+vBQU3DLbyvyCg9Gw+HWA4PPeHWt80Uzqe94JYoNWFymPr6uBV7Jha3nweYvpsiEVyzKFJWyp4AEKTk5OkiUGho/aGiaTu1d0gYgGsuVfCd2dMXeopsi1a7GHPHHpVT9MpFDtjQ5K2g5c6N5wzNwQ1yAxUpL0icPWKMm8OGZw+tqyUjiRVeK6FKcZGvgY/y+aOaRvuPARUamFlF6W/4CMa2C+swSxkObuKYAMW6h2DkNxZSflTgU+/6FzJnsk9+pnwF5vkX5uxPi+gGnwEf4H3nE/8W6zk4nqNu2r3pp/thckKjDeJbzhVK0teZ4iN6bzGcwihdvphIVfQU7Hnt+EBDxOEhXOL7yt8DejTShOMK5X+KQ5gUxJAWJxfJPA5804sGwDHVSbqYYEppQm3uFVQkbfndNUTwpeB3d0jnFZjFUSfSGhi/q2oBxY+oFrZYqypg= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MWHPR1001MB2351.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(346002)(396003)(376002)(39830400003)(136003)(366004)(8936002)(7416002)(6506007)(5660300002)(2906002)(66556008)(26005)(2616005)(8676002)(44832011)(6486002)(6512007)(66476007)(6666004)(38100700002)(38350700002)(52116002)(66946007)(921005)(4326008)(956004)(83380400001)(1076003)(316002)(30864003)(36756003)(86362001)(186003)(478600001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: A9cyC8jr7HbCvoPVm2qr2yjjQ/64IcNQLWAs3hqphLgnAj2qRFS0FL+zYAM4PjDYyIvHwIqzMORcq0ebMT3R25db5zg/ktPtQBV7fJ9RBp99hBqpioA8jSYnrRiBJGa7jL4+nbLj/wSAi3ERlsRWjpOTbMclma3GJvIwlBwkEMYW56gVc+ere5Rz4tM0qW2maZGlqnRLx/rDblosx9WdciH98GGZSD44Lsky2af4t/gyF5T/hE6VOXQWr+x9w36bMf2aD+9deuOcUqrlCoQciwi8pV2zJ6crg3BIzCHu9tkeUFnuH4/+FGAH85dNkhSMR7iGEmCEJubygNXFPfPbY7rVBDv0/zKWwaEEh0VjXPJ93cim339pth/IqyXdilFmqjMdrd+tCfMgcgi8nD3b6m7qJwW6ITOsRON6vEj7yP9KUnTfGV2AqSrMT05UYBdjSmEbTG74TBmVkngYRyojw5g/jz83bovEB4Htt6PDqJ9GxTwut6zSY9LjOGi6fWBIo6NeDWTiPwVpVuKedYVKw+cjC9pQelp19LpLV+HhHrhN+G03JLU+oMmDtdNs4QuYlfRSSY4zVmdFNP/20+s91eAmVX6sddy8kjeQCYNVOz3wvr+CFhMF56i0k+3Due8KZMzNj8yCB724AgBQo0qV+w1CGxczJqsqru8bF7KYgfGt09vp519wPOPTcmef7a5aGHt13rdU0KycQr0t+Ied2yHj+an6fd4zkX+jtP6NIIqspgqt28xmnDe2rrZvjpQ9OwLb7MhdFctaOC9rmGHRRGiVu33TxBgz5dXyj5GV4Y5CrL3mGDG3jD+axY8yiaOVqHVbpL5Zsod3i87DdKrTnhInDuBQjZFU3EdxtOvX4X29OoYYz1lUyGZSkO38vzzhwtAQ7fdN5wE/P0ynxYPaT0+wIQuxQu5y5YI0cr5EBk8hYKYXfQN4ogv2f/CmVS4iFnzFM+iCUYSlan1M6GtKJB2mOO+/RSSjc0oCPJNjZUrMXEtuZLtOvWuUhp1/CKem7CjRtAAf7nHr/lrbdTi1BbJV5/v2k+6uDyfejpwAQmJDF1pf7Xv03NzHrbFvQt5E+tPkZgEKIE0ZcuZ7v7cnxO3JoFE8puneYHQzotOxrUZf9iz1CGCg4R/L6ElPyH6XLrXQ6EiNQCAn1RIKEYLK34GbMosrMfqRWQS7nCc2C3Mc4sZB4DVuyaC56kwcnn73mbl4ujV6hnwUIk8v+hcNzcorUg5p0nQe31SatTOvYd04cm7MK9Mnj3wXJlmJLmigj5OtAxyLUYZast4CiQrqfV7L5S3n16+8WZgw2h35ivyckaBuhnsyKepO55KRwtes X-OriginatorOrg: in-advantage.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3e092bff-0127-4a60-aeb4-08d943d89821 X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2351.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jul 2021 19:26:19.5975 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 48e842ca-fbd8-4633-a79d-0c955a7d3aae X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: GOtoP6CvhKOcNbvjKd5sqVx1qTGFMAyb1v8LiCS37AAG44JXFICy64bOOWM14GKk9IG6BEHiPNVsi4ecIgJeEZOP2ArRZ/XsvpYni9dV1Vc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR10MB1709 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Moving these to a separate file will allow them to be shared to other drivers. Signed-off-by: Colin Foster --- drivers/net/ethernet/mscc/Makefile | 1 + drivers/net/ethernet/mscc/ocelot_regs.c | 310 +++++++++++++++++++++ drivers/net/ethernet/mscc/ocelot_vsc7514.c | 295 +------------------- include/soc/mscc/ocelot_regs.h | 21 ++ 4 files changed, 333 insertions(+), 294 deletions(-) create mode 100644 drivers/net/ethernet/mscc/ocelot_regs.c create mode 100644 include/soc/mscc/ocelot_regs.h diff --git a/drivers/net/ethernet/mscc/Makefile b/drivers/net/ethernet/mscc/Makefile index 722c27694b21..d539a231a478 100644 --- a/drivers/net/ethernet/mscc/Makefile +++ b/drivers/net/ethernet/mscc/Makefile @@ -7,6 +7,7 @@ mscc_ocelot_switch_lib-y := \ ocelot_vcap.o \ ocelot_flower.o \ ocelot_ptp.o \ + ocelot_regs.o \ ocelot_devlink.o mscc_ocelot_switch_lib-$(CONFIG_BRIDGE_MRP) += ocelot_mrp.o obj-$(CONFIG_MSCC_OCELOT_SWITCH) += mscc_ocelot.o diff --git a/drivers/net/ethernet/mscc/ocelot_regs.c b/drivers/net/ethernet/mscc/ocelot_regs.c new file mode 100644 index 000000000000..6ded6c705f14 --- /dev/null +++ b/drivers/net/ethernet/mscc/ocelot_regs.c @@ -0,0 +1,310 @@ +// SPDX-License-Identifier: (GPL-2.0 OR MIT) +/* + * Microsemi Ocelot Switch driver + * + * Copyright (c) 2017 Microsemi Corporation + */ +#include "ocelot.h" + +const u32 ocelot_ana_regmap[] = { + REG(ANA_ADVLEARN, 0x009000), + REG(ANA_VLANMASK, 0x009004), + REG(ANA_PORT_B_DOMAIN, 0x009008), + REG(ANA_ANAGEFIL, 0x00900c), + REG(ANA_ANEVENTS, 0x009010), + REG(ANA_STORMLIMIT_BURST, 0x009014), + REG(ANA_STORMLIMIT_CFG, 0x009018), + REG(ANA_ISOLATED_PORTS, 0x009028), + REG(ANA_COMMUNITY_PORTS, 0x00902c), + REG(ANA_AUTOAGE, 0x009030), + REG(ANA_MACTOPTIONS, 0x009034), + REG(ANA_LEARNDISC, 0x009038), + REG(ANA_AGENCTRL, 0x00903c), + REG(ANA_MIRRORPORTS, 0x009040), + REG(ANA_EMIRRORPORTS, 0x009044), + REG(ANA_FLOODING, 0x009048), + REG(ANA_FLOODING_IPMC, 0x00904c), + REG(ANA_SFLOW_CFG, 0x009050), + REG(ANA_PORT_MODE, 0x009080), + REG(ANA_PGID_PGID, 0x008c00), + REG(ANA_TABLES_ANMOVED, 0x008b30), + REG(ANA_TABLES_MACHDATA, 0x008b34), + REG(ANA_TABLES_MACLDATA, 0x008b38), + REG(ANA_TABLES_MACACCESS, 0x008b3c), + REG(ANA_TABLES_MACTINDX, 0x008b40), + REG(ANA_TABLES_VLANACCESS, 0x008b44), + REG(ANA_TABLES_VLANTIDX, 0x008b48), + REG(ANA_TABLES_ISDXACCESS, 0x008b4c), + REG(ANA_TABLES_ISDXTIDX, 0x008b50), + REG(ANA_TABLES_ENTRYLIM, 0x008b00), + REG(ANA_TABLES_PTP_ID_HIGH, 0x008b54), + REG(ANA_TABLES_PTP_ID_LOW, 0x008b58), + REG(ANA_MSTI_STATE, 0x008e00), + REG(ANA_PORT_VLAN_CFG, 0x007000), + REG(ANA_PORT_DROP_CFG, 0x007004), + REG(ANA_PORT_QOS_CFG, 0x007008), + REG(ANA_PORT_VCAP_CFG, 0x00700c), + REG(ANA_PORT_VCAP_S1_KEY_CFG, 0x007010), + REG(ANA_PORT_VCAP_S2_CFG, 0x00701c), + REG(ANA_PORT_PCP_DEI_MAP, 0x007020), + REG(ANA_PORT_CPU_FWD_CFG, 0x007060), + REG(ANA_PORT_CPU_FWD_BPDU_CFG, 0x007064), + REG(ANA_PORT_CPU_FWD_GARP_CFG, 0x007068), + REG(ANA_PORT_CPU_FWD_CCM_CFG, 0x00706c), + REG(ANA_PORT_PORT_CFG, 0x007070), + REG(ANA_PORT_POL_CFG, 0x007074), + REG(ANA_PORT_PTP_CFG, 0x007078), + REG(ANA_PORT_PTP_DLY1_CFG, 0x00707c), + REG(ANA_OAM_UPM_LM_CNT, 0x007c00), + REG(ANA_PORT_PTP_DLY2_CFG, 0x007080), + REG(ANA_PFC_PFC_CFG, 0x008800), + REG(ANA_PFC_PFC_TIMER, 0x008804), + REG(ANA_IPT_OAM_MEP_CFG, 0x008000), + REG(ANA_IPT_IPT, 0x008004), + REG(ANA_PPT_PPT, 0x008ac0), + REG(ANA_FID_MAP_FID_MAP, 0x000000), + REG(ANA_AGGR_CFG, 0x0090b4), + REG(ANA_CPUQ_CFG, 0x0090b8), + REG(ANA_CPUQ_CFG2, 0x0090bc), + REG(ANA_CPUQ_8021_CFG, 0x0090c0), + REG(ANA_DSCP_CFG, 0x009100), + REG(ANA_DSCP_REWR_CFG, 0x009200), + REG(ANA_VCAP_RNG_TYPE_CFG, 0x009240), + REG(ANA_VCAP_RNG_VAL_CFG, 0x009260), + REG(ANA_VRAP_CFG, 0x009280), + REG(ANA_VRAP_HDR_DATA, 0x009284), + REG(ANA_VRAP_HDR_MASK, 0x009288), + REG(ANA_DISCARD_CFG, 0x00928c), + REG(ANA_FID_CFG, 0x009290), + REG(ANA_POL_PIR_CFG, 0x004000), + REG(ANA_POL_CIR_CFG, 0x004004), + REG(ANA_POL_MODE_CFG, 0x004008), + REG(ANA_POL_PIR_STATE, 0x00400c), + REG(ANA_POL_CIR_STATE, 0x004010), + REG(ANA_POL_STATE, 0x004014), + REG(ANA_POL_FLOWC, 0x008b80), + REG(ANA_POL_HYST, 0x008bec), + REG(ANA_POL_MISC_CFG, 0x008bf0), +}; +EXPORT_SYMBOL(ocelot_ana_regmap); + +const u32 ocelot_qs_regmap[] = { + REG(QS_XTR_GRP_CFG, 0x000000), + REG(QS_XTR_RD, 0x000008), + REG(QS_XTR_FRM_PRUNING, 0x000010), + REG(QS_XTR_FLUSH, 0x000018), + REG(QS_XTR_DATA_PRESENT, 0x00001c), + REG(QS_XTR_CFG, 0x000020), + REG(QS_INJ_GRP_CFG, 0x000024), + REG(QS_INJ_WR, 0x00002c), + REG(QS_INJ_CTRL, 0x000034), + REG(QS_INJ_STATUS, 0x00003c), + REG(QS_INJ_ERR, 0x000040), + REG(QS_INH_DBG, 0x000048), +}; +EXPORT_SYMBOL(ocelot_qs_regmap); + +const u32 ocelot_qsys_regmap[] = { + REG(QSYS_PORT_MODE, 0x011200), + REG(QSYS_SWITCH_PORT_MODE, 0x011234), + REG(QSYS_STAT_CNT_CFG, 0x011264), + REG(QSYS_EEE_CFG, 0x011268), + REG(QSYS_EEE_THRES, 0x011294), + REG(QSYS_IGR_NO_SHARING, 0x011298), + REG(QSYS_EGR_NO_SHARING, 0x01129c), + REG(QSYS_SW_STATUS, 0x0112a0), + REG(QSYS_EXT_CPU_CFG, 0x0112d0), + REG(QSYS_PAD_CFG, 0x0112d4), + REG(QSYS_CPU_GROUP_MAP, 0x0112d8), + REG(QSYS_QMAP, 0x0112dc), + REG(QSYS_ISDX_SGRP, 0x011400), + REG(QSYS_TIMED_FRAME_ENTRY, 0x014000), + REG(QSYS_TFRM_MISC, 0x011310), + REG(QSYS_TFRM_PORT_DLY, 0x011314), + REG(QSYS_TFRM_TIMER_CFG_1, 0x011318), + REG(QSYS_TFRM_TIMER_CFG_2, 0x01131c), + REG(QSYS_TFRM_TIMER_CFG_3, 0x011320), + REG(QSYS_TFRM_TIMER_CFG_4, 0x011324), + REG(QSYS_TFRM_TIMER_CFG_5, 0x011328), + REG(QSYS_TFRM_TIMER_CFG_6, 0x01132c), + REG(QSYS_TFRM_TIMER_CFG_7, 0x011330), + REG(QSYS_TFRM_TIMER_CFG_8, 0x011334), + REG(QSYS_RED_PROFILE, 0x011338), + REG(QSYS_RES_QOS_MODE, 0x011378), + REG(QSYS_RES_CFG, 0x012000), + REG(QSYS_RES_STAT, 0x012004), + REG(QSYS_EGR_DROP_MODE, 0x01137c), + REG(QSYS_EQ_CTRL, 0x011380), + REG(QSYS_EVENTS_CORE, 0x011384), + REG(QSYS_CIR_CFG, 0x000000), + REG(QSYS_EIR_CFG, 0x000004), + REG(QSYS_SE_CFG, 0x000008), + REG(QSYS_SE_DWRR_CFG, 0x00000c), + REG(QSYS_SE_CONNECT, 0x00003c), + REG(QSYS_SE_DLB_SENSE, 0x000040), + REG(QSYS_CIR_STATE, 0x000044), + REG(QSYS_EIR_STATE, 0x000048), + REG(QSYS_SE_STATE, 0x00004c), + REG(QSYS_HSCH_MISC_CFG, 0x011388), +}; +EXPORT_SYMBOL(ocelot_qsys_regmap); + +const u32 ocelot_rew_regmap[] = { + REG(REW_PORT_VLAN_CFG, 0x000000), + REG(REW_TAG_CFG, 0x000004), + REG(REW_PORT_CFG, 0x000008), + REG(REW_DSCP_CFG, 0x00000c), + REG(REW_PCP_DEI_QOS_MAP_CFG, 0x000010), + REG(REW_PTP_CFG, 0x000050), + REG(REW_PTP_DLY1_CFG, 0x000054), + REG(REW_DSCP_REMAP_DP1_CFG, 0x000690), + REG(REW_DSCP_REMAP_CFG, 0x000790), + REG(REW_STAT_CFG, 0x000890), + REG(REW_PPT, 0x000680), +}; +EXPORT_SYMBOL(ocelot_rew_regmap); + +const u32 ocelot_sys_regmap[] = { + REG(SYS_COUNT_RX_OCTETS, 0x000000), + REG(SYS_COUNT_RX_UNICAST, 0x000004), + REG(SYS_COUNT_RX_MULTICAST, 0x000008), + REG(SYS_COUNT_RX_BROADCAST, 0x00000c), + REG(SYS_COUNT_RX_SHORTS, 0x000010), + REG(SYS_COUNT_RX_FRAGMENTS, 0x000014), + REG(SYS_COUNT_RX_JABBERS, 0x000018), + REG(SYS_COUNT_RX_CRC_ALIGN_ERRS, 0x00001c), + REG(SYS_COUNT_RX_SYM_ERRS, 0x000020), + REG(SYS_COUNT_RX_64, 0x000024), + REG(SYS_COUNT_RX_65_127, 0x000028), + REG(SYS_COUNT_RX_128_255, 0x00002c), + REG(SYS_COUNT_RX_256_1023, 0x000030), + REG(SYS_COUNT_RX_1024_1526, 0x000034), + REG(SYS_COUNT_RX_1527_MAX, 0x000038), + REG(SYS_COUNT_RX_PAUSE, 0x00003c), + REG(SYS_COUNT_RX_CONTROL, 0x000040), + REG(SYS_COUNT_RX_LONGS, 0x000044), + REG(SYS_COUNT_RX_CLASSIFIED_DROPS, 0x000048), + REG(SYS_COUNT_TX_OCTETS, 0x000100), + REG(SYS_COUNT_TX_UNICAST, 0x000104), + REG(SYS_COUNT_TX_MULTICAST, 0x000108), + REG(SYS_COUNT_TX_BROADCAST, 0x00010c), + REG(SYS_COUNT_TX_COLLISION, 0x000110), + REG(SYS_COUNT_TX_DROPS, 0x000114), + REG(SYS_COUNT_TX_PAUSE, 0x000118), + REG(SYS_COUNT_TX_64, 0x00011c), + REG(SYS_COUNT_TX_65_127, 0x000120), + REG(SYS_COUNT_TX_128_511, 0x000124), + REG(SYS_COUNT_TX_512_1023, 0x000128), + REG(SYS_COUNT_TX_1024_1526, 0x00012c), + REG(SYS_COUNT_TX_1527_MAX, 0x000130), + REG(SYS_COUNT_TX_AGING, 0x000170), + REG(SYS_RESET_CFG, 0x000508), + REG(SYS_CMID, 0x00050c), + REG(SYS_VLAN_ETYPE_CFG, 0x000510), + REG(SYS_PORT_MODE, 0x000514), + REG(SYS_FRONT_PORT_MODE, 0x000548), + REG(SYS_FRM_AGING, 0x000574), + REG(SYS_STAT_CFG, 0x000578), + REG(SYS_SW_STATUS, 0x00057c), + REG(SYS_MISC_CFG, 0x0005ac), + REG(SYS_REW_MAC_HIGH_CFG, 0x0005b0), + REG(SYS_REW_MAC_LOW_CFG, 0x0005dc), + REG(SYS_CM_ADDR, 0x000500), + REG(SYS_CM_DATA, 0x000504), + REG(SYS_PAUSE_CFG, 0x000608), + REG(SYS_PAUSE_TOT_CFG, 0x000638), + REG(SYS_ATOP, 0x00063c), + REG(SYS_ATOP_TOT_CFG, 0x00066c), + REG(SYS_MAC_FC_CFG, 0x000670), + REG(SYS_MMGT, 0x00069c), + REG(SYS_MMGT_FAST, 0x0006a0), + REG(SYS_EVENTS_DIF, 0x0006a4), + REG(SYS_EVENTS_CORE, 0x0006b4), + REG(SYS_CNT, 0x000000), + REG(SYS_PTP_STATUS, 0x0006b8), + REG(SYS_PTP_TXSTAMP, 0x0006bc), + REG(SYS_PTP_NXT, 0x0006c0), + REG(SYS_PTP_CFG, 0x0006c4), +}; +EXPORT_SYMBOL(ocelot_sys_regmap); + +const u32 ocelot_vcap_regmap[] = { + /* VCAP_CORE_CFG */ + REG(VCAP_CORE_UPDATE_CTRL, 0x000000), + REG(VCAP_CORE_MV_CFG, 0x000004), + /* VCAP_CORE_CACHE */ + REG(VCAP_CACHE_ENTRY_DAT, 0x000008), + REG(VCAP_CACHE_MASK_DAT, 0x000108), + REG(VCAP_CACHE_ACTION_DAT, 0x000208), + REG(VCAP_CACHE_CNT_DAT, 0x000308), + REG(VCAP_CACHE_TG_DAT, 0x000388), + /* VCAP_CONST */ + REG(VCAP_CONST_VCAP_VER, 0x000398), + REG(VCAP_CONST_ENTRY_WIDTH, 0x00039c), + REG(VCAP_CONST_ENTRY_CNT, 0x0003a0), + REG(VCAP_CONST_ENTRY_SWCNT, 0x0003a4), + REG(VCAP_CONST_ENTRY_TG_WIDTH, 0x0003a8), + REG(VCAP_CONST_ACTION_DEF_CNT, 0x0003ac), + REG(VCAP_CONST_ACTION_WIDTH, 0x0003b0), + REG(VCAP_CONST_CNT_WIDTH, 0x0003b4), + REG(VCAP_CONST_CORE_CNT, 0x0003b8), + REG(VCAP_CONST_IF_CNT, 0x0003bc), +}; +EXPORT_SYMBOL(ocelot_vcap_regmap); + +const u32 ocelot_ptp_regmap[] = { + REG(PTP_PIN_CFG, 0x000000), + REG(PTP_PIN_TOD_SEC_MSB, 0x000004), + REG(PTP_PIN_TOD_SEC_LSB, 0x000008), + REG(PTP_PIN_TOD_NSEC, 0x00000c), + REG(PTP_PIN_WF_HIGH_PERIOD, 0x000014), + REG(PTP_PIN_WF_LOW_PERIOD, 0x000018), + REG(PTP_CFG_MISC, 0x0000a0), + REG(PTP_CLK_CFG_ADJ_CFG, 0x0000a4), + REG(PTP_CLK_CFG_ADJ_FREQ, 0x0000a8), +}; +EXPORT_SYMBOL(ocelot_ptp_regmap); + +const u32 ocelot_dev_gmii_regmap[] = { + REG(DEV_CLOCK_CFG, 0x0), + REG(DEV_PORT_MISC, 0x4), + REG(DEV_EVENTS, 0x8), + REG(DEV_EEE_CFG, 0xc), + REG(DEV_RX_PATH_DELAY, 0x10), + REG(DEV_TX_PATH_DELAY, 0x14), + REG(DEV_PTP_PREDICT_CFG, 0x18), + REG(DEV_MAC_ENA_CFG, 0x1c), + REG(DEV_MAC_MODE_CFG, 0x20), + REG(DEV_MAC_MAXLEN_CFG, 0x24), + REG(DEV_MAC_TAGS_CFG, 0x28), + REG(DEV_MAC_ADV_CHK_CFG, 0x2c), + REG(DEV_MAC_IFG_CFG, 0x30), + REG(DEV_MAC_HDX_CFG, 0x34), + REG(DEV_MAC_DBG_CFG, 0x38), + REG(DEV_MAC_FC_MAC_LOW_CFG, 0x3c), + REG(DEV_MAC_FC_MAC_HIGH_CFG, 0x40), + REG(DEV_MAC_STICKY, 0x44), + REG(PCS1G_CFG, 0x48), + REG(PCS1G_MODE_CFG, 0x4c), + REG(PCS1G_SD_CFG, 0x50), + REG(PCS1G_ANEG_CFG, 0x54), + REG(PCS1G_ANEG_NP_CFG, 0x58), + REG(PCS1G_LB_CFG, 0x5c), + REG(PCS1G_DBG_CFG, 0x60), + REG(PCS1G_CDET_CFG, 0x64), + REG(PCS1G_ANEG_STATUS, 0x68), + REG(PCS1G_ANEG_NP_STATUS, 0x6c), + REG(PCS1G_LINK_STATUS, 0x70), + REG(PCS1G_LINK_DOWN_CNT, 0x74), + REG(PCS1G_STICKY, 0x78), + REG(PCS1G_DEBUG_STATUS, 0x7c), + REG(PCS1G_LPI_CFG, 0x80), + REG(PCS1G_LPI_WAKE_ERROR_CNT, 0x84), + REG(PCS1G_LPI_STATUS, 0x88), + REG(PCS1G_TSTPAT_MODE_CFG, 0x8c), + REG(PCS1G_TSTPAT_STATUS, 0x90), + REG(DEV_PCS_FX100_CFG, 0x94), + REG(DEV_PCS_FX100_STATUS, 0x98), +}; +EXPORT_SYMBOL(ocelot_dev_gmii_regmap); + diff --git a/drivers/net/ethernet/mscc/ocelot_vsc7514.c b/drivers/net/ethernet/mscc/ocelot_vsc7514.c index 4bd7e9d9ec61..ef1bf24f51b5 100644 --- a/drivers/net/ethernet/mscc/ocelot_vsc7514.c +++ b/drivers/net/ethernet/mscc/ocelot_vsc7514.c @@ -16,303 +16,10 @@ #include #include +#include #include #include "ocelot.h" -static const u32 ocelot_ana_regmap[] = { - REG(ANA_ADVLEARN, 0x009000), - REG(ANA_VLANMASK, 0x009004), - REG(ANA_PORT_B_DOMAIN, 0x009008), - REG(ANA_ANAGEFIL, 0x00900c), - REG(ANA_ANEVENTS, 0x009010), - REG(ANA_STORMLIMIT_BURST, 0x009014), - REG(ANA_STORMLIMIT_CFG, 0x009018), - REG(ANA_ISOLATED_PORTS, 0x009028), - REG(ANA_COMMUNITY_PORTS, 0x00902c), - REG(ANA_AUTOAGE, 0x009030), - REG(ANA_MACTOPTIONS, 0x009034), - REG(ANA_LEARNDISC, 0x009038), - REG(ANA_AGENCTRL, 0x00903c), - REG(ANA_MIRRORPORTS, 0x009040), - REG(ANA_EMIRRORPORTS, 0x009044), - REG(ANA_FLOODING, 0x009048), - REG(ANA_FLOODING_IPMC, 0x00904c), - REG(ANA_SFLOW_CFG, 0x009050), - REG(ANA_PORT_MODE, 0x009080), - REG(ANA_PGID_PGID, 0x008c00), - REG(ANA_TABLES_ANMOVED, 0x008b30), - REG(ANA_TABLES_MACHDATA, 0x008b34), - REG(ANA_TABLES_MACLDATA, 0x008b38), - REG(ANA_TABLES_MACACCESS, 0x008b3c), - REG(ANA_TABLES_MACTINDX, 0x008b40), - REG(ANA_TABLES_VLANACCESS, 0x008b44), - REG(ANA_TABLES_VLANTIDX, 0x008b48), - REG(ANA_TABLES_ISDXACCESS, 0x008b4c), - REG(ANA_TABLES_ISDXTIDX, 0x008b50), - REG(ANA_TABLES_ENTRYLIM, 0x008b00), - REG(ANA_TABLES_PTP_ID_HIGH, 0x008b54), - REG(ANA_TABLES_PTP_ID_LOW, 0x008b58), - REG(ANA_MSTI_STATE, 0x008e00), - REG(ANA_PORT_VLAN_CFG, 0x007000), - REG(ANA_PORT_DROP_CFG, 0x007004), - REG(ANA_PORT_QOS_CFG, 0x007008), - REG(ANA_PORT_VCAP_CFG, 0x00700c), - REG(ANA_PORT_VCAP_S1_KEY_CFG, 0x007010), - REG(ANA_PORT_VCAP_S2_CFG, 0x00701c), - REG(ANA_PORT_PCP_DEI_MAP, 0x007020), - REG(ANA_PORT_CPU_FWD_CFG, 0x007060), - REG(ANA_PORT_CPU_FWD_BPDU_CFG, 0x007064), - REG(ANA_PORT_CPU_FWD_GARP_CFG, 0x007068), - REG(ANA_PORT_CPU_FWD_CCM_CFG, 0x00706c), - REG(ANA_PORT_PORT_CFG, 0x007070), - REG(ANA_PORT_POL_CFG, 0x007074), - REG(ANA_PORT_PTP_CFG, 0x007078), - REG(ANA_PORT_PTP_DLY1_CFG, 0x00707c), - REG(ANA_OAM_UPM_LM_CNT, 0x007c00), - REG(ANA_PORT_PTP_DLY2_CFG, 0x007080), - REG(ANA_PFC_PFC_CFG, 0x008800), - REG(ANA_PFC_PFC_TIMER, 0x008804), - REG(ANA_IPT_OAM_MEP_CFG, 0x008000), - REG(ANA_IPT_IPT, 0x008004), - REG(ANA_PPT_PPT, 0x008ac0), - REG(ANA_FID_MAP_FID_MAP, 0x000000), - REG(ANA_AGGR_CFG, 0x0090b4), - REG(ANA_CPUQ_CFG, 0x0090b8), - REG(ANA_CPUQ_CFG2, 0x0090bc), - REG(ANA_CPUQ_8021_CFG, 0x0090c0), - REG(ANA_DSCP_CFG, 0x009100), - REG(ANA_DSCP_REWR_CFG, 0x009200), - REG(ANA_VCAP_RNG_TYPE_CFG, 0x009240), - REG(ANA_VCAP_RNG_VAL_CFG, 0x009260), - REG(ANA_VRAP_CFG, 0x009280), - REG(ANA_VRAP_HDR_DATA, 0x009284), - REG(ANA_VRAP_HDR_MASK, 0x009288), - REG(ANA_DISCARD_CFG, 0x00928c), - REG(ANA_FID_CFG, 0x009290), - REG(ANA_POL_PIR_CFG, 0x004000), - REG(ANA_POL_CIR_CFG, 0x004004), - REG(ANA_POL_MODE_CFG, 0x004008), - REG(ANA_POL_PIR_STATE, 0x00400c), - REG(ANA_POL_CIR_STATE, 0x004010), - REG(ANA_POL_STATE, 0x004014), - REG(ANA_POL_FLOWC, 0x008b80), - REG(ANA_POL_HYST, 0x008bec), - REG(ANA_POL_MISC_CFG, 0x008bf0), -}; - -static const u32 ocelot_qs_regmap[] = { - REG(QS_XTR_GRP_CFG, 0x000000), - REG(QS_XTR_RD, 0x000008), - REG(QS_XTR_FRM_PRUNING, 0x000010), - REG(QS_XTR_FLUSH, 0x000018), - REG(QS_XTR_DATA_PRESENT, 0x00001c), - REG(QS_XTR_CFG, 0x000020), - REG(QS_INJ_GRP_CFG, 0x000024), - REG(QS_INJ_WR, 0x00002c), - REG(QS_INJ_CTRL, 0x000034), - REG(QS_INJ_STATUS, 0x00003c), - REG(QS_INJ_ERR, 0x000040), - REG(QS_INH_DBG, 0x000048), -}; - -static const u32 ocelot_qsys_regmap[] = { - REG(QSYS_PORT_MODE, 0x011200), - REG(QSYS_SWITCH_PORT_MODE, 0x011234), - REG(QSYS_STAT_CNT_CFG, 0x011264), - REG(QSYS_EEE_CFG, 0x011268), - REG(QSYS_EEE_THRES, 0x011294), - REG(QSYS_IGR_NO_SHARING, 0x011298), - REG(QSYS_EGR_NO_SHARING, 0x01129c), - REG(QSYS_SW_STATUS, 0x0112a0), - REG(QSYS_EXT_CPU_CFG, 0x0112d0), - REG(QSYS_PAD_CFG, 0x0112d4), - REG(QSYS_CPU_GROUP_MAP, 0x0112d8), - REG(QSYS_QMAP, 0x0112dc), - REG(QSYS_ISDX_SGRP, 0x011400), - REG(QSYS_TIMED_FRAME_ENTRY, 0x014000), - REG(QSYS_TFRM_MISC, 0x011310), - REG(QSYS_TFRM_PORT_DLY, 0x011314), - REG(QSYS_TFRM_TIMER_CFG_1, 0x011318), - REG(QSYS_TFRM_TIMER_CFG_2, 0x01131c), - REG(QSYS_TFRM_TIMER_CFG_3, 0x011320), - REG(QSYS_TFRM_TIMER_CFG_4, 0x011324), - REG(QSYS_TFRM_TIMER_CFG_5, 0x011328), - REG(QSYS_TFRM_TIMER_CFG_6, 0x01132c), - REG(QSYS_TFRM_TIMER_CFG_7, 0x011330), - REG(QSYS_TFRM_TIMER_CFG_8, 0x011334), - REG(QSYS_RED_PROFILE, 0x011338), - REG(QSYS_RES_QOS_MODE, 0x011378), - REG(QSYS_RES_CFG, 0x012000), - REG(QSYS_RES_STAT, 0x012004), - REG(QSYS_EGR_DROP_MODE, 0x01137c), - REG(QSYS_EQ_CTRL, 0x011380), - REG(QSYS_EVENTS_CORE, 0x011384), - REG(QSYS_CIR_CFG, 0x000000), - REG(QSYS_EIR_CFG, 0x000004), - REG(QSYS_SE_CFG, 0x000008), - REG(QSYS_SE_DWRR_CFG, 0x00000c), - REG(QSYS_SE_CONNECT, 0x00003c), - REG(QSYS_SE_DLB_SENSE, 0x000040), - REG(QSYS_CIR_STATE, 0x000044), - REG(QSYS_EIR_STATE, 0x000048), - REG(QSYS_SE_STATE, 0x00004c), - REG(QSYS_HSCH_MISC_CFG, 0x011388), -}; - -static const u32 ocelot_rew_regmap[] = { - REG(REW_PORT_VLAN_CFG, 0x000000), - REG(REW_TAG_CFG, 0x000004), - REG(REW_PORT_CFG, 0x000008), - REG(REW_DSCP_CFG, 0x00000c), - REG(REW_PCP_DEI_QOS_MAP_CFG, 0x000010), - REG(REW_PTP_CFG, 0x000050), - REG(REW_PTP_DLY1_CFG, 0x000054), - REG(REW_DSCP_REMAP_DP1_CFG, 0x000690), - REG(REW_DSCP_REMAP_CFG, 0x000790), - REG(REW_STAT_CFG, 0x000890), - REG(REW_PPT, 0x000680), -}; - -static const u32 ocelot_sys_regmap[] = { - REG(SYS_COUNT_RX_OCTETS, 0x000000), - REG(SYS_COUNT_RX_UNICAST, 0x000004), - REG(SYS_COUNT_RX_MULTICAST, 0x000008), - REG(SYS_COUNT_RX_BROADCAST, 0x00000c), - REG(SYS_COUNT_RX_SHORTS, 0x000010), - REG(SYS_COUNT_RX_FRAGMENTS, 0x000014), - REG(SYS_COUNT_RX_JABBERS, 0x000018), - REG(SYS_COUNT_RX_CRC_ALIGN_ERRS, 0x00001c), - REG(SYS_COUNT_RX_SYM_ERRS, 0x000020), - REG(SYS_COUNT_RX_64, 0x000024), - REG(SYS_COUNT_RX_65_127, 0x000028), - REG(SYS_COUNT_RX_128_255, 0x00002c), - REG(SYS_COUNT_RX_256_1023, 0x000030), - REG(SYS_COUNT_RX_1024_1526, 0x000034), - REG(SYS_COUNT_RX_1527_MAX, 0x000038), - REG(SYS_COUNT_RX_PAUSE, 0x00003c), - REG(SYS_COUNT_RX_CONTROL, 0x000040), - REG(SYS_COUNT_RX_LONGS, 0x000044), - REG(SYS_COUNT_RX_CLASSIFIED_DROPS, 0x000048), - REG(SYS_COUNT_TX_OCTETS, 0x000100), - REG(SYS_COUNT_TX_UNICAST, 0x000104), - REG(SYS_COUNT_TX_MULTICAST, 0x000108), - REG(SYS_COUNT_TX_BROADCAST, 0x00010c), - REG(SYS_COUNT_TX_COLLISION, 0x000110), - REG(SYS_COUNT_TX_DROPS, 0x000114), - REG(SYS_COUNT_TX_PAUSE, 0x000118), - REG(SYS_COUNT_TX_64, 0x00011c), - REG(SYS_COUNT_TX_65_127, 0x000120), - REG(SYS_COUNT_TX_128_511, 0x000124), - REG(SYS_COUNT_TX_512_1023, 0x000128), - REG(SYS_COUNT_TX_1024_1526, 0x00012c), - REG(SYS_COUNT_TX_1527_MAX, 0x000130), - REG(SYS_COUNT_TX_AGING, 0x000170), - REG(SYS_RESET_CFG, 0x000508), - REG(SYS_CMID, 0x00050c), - REG(SYS_VLAN_ETYPE_CFG, 0x000510), - REG(SYS_PORT_MODE, 0x000514), - REG(SYS_FRONT_PORT_MODE, 0x000548), - REG(SYS_FRM_AGING, 0x000574), - REG(SYS_STAT_CFG, 0x000578), - REG(SYS_SW_STATUS, 0x00057c), - REG(SYS_MISC_CFG, 0x0005ac), - REG(SYS_REW_MAC_HIGH_CFG, 0x0005b0), - REG(SYS_REW_MAC_LOW_CFG, 0x0005dc), - REG(SYS_CM_ADDR, 0x000500), - REG(SYS_CM_DATA, 0x000504), - REG(SYS_PAUSE_CFG, 0x000608), - REG(SYS_PAUSE_TOT_CFG, 0x000638), - REG(SYS_ATOP, 0x00063c), - REG(SYS_ATOP_TOT_CFG, 0x00066c), - REG(SYS_MAC_FC_CFG, 0x000670), - REG(SYS_MMGT, 0x00069c), - REG(SYS_MMGT_FAST, 0x0006a0), - REG(SYS_EVENTS_DIF, 0x0006a4), - REG(SYS_EVENTS_CORE, 0x0006b4), - REG(SYS_CNT, 0x000000), - REG(SYS_PTP_STATUS, 0x0006b8), - REG(SYS_PTP_TXSTAMP, 0x0006bc), - REG(SYS_PTP_NXT, 0x0006c0), - REG(SYS_PTP_CFG, 0x0006c4), -}; - -static const u32 ocelot_vcap_regmap[] = { - /* VCAP_CORE_CFG */ - REG(VCAP_CORE_UPDATE_CTRL, 0x000000), - REG(VCAP_CORE_MV_CFG, 0x000004), - /* VCAP_CORE_CACHE */ - REG(VCAP_CACHE_ENTRY_DAT, 0x000008), - REG(VCAP_CACHE_MASK_DAT, 0x000108), - REG(VCAP_CACHE_ACTION_DAT, 0x000208), - REG(VCAP_CACHE_CNT_DAT, 0x000308), - REG(VCAP_CACHE_TG_DAT, 0x000388), - /* VCAP_CONST */ - REG(VCAP_CONST_VCAP_VER, 0x000398), - REG(VCAP_CONST_ENTRY_WIDTH, 0x00039c), - REG(VCAP_CONST_ENTRY_CNT, 0x0003a0), - REG(VCAP_CONST_ENTRY_SWCNT, 0x0003a4), - REG(VCAP_CONST_ENTRY_TG_WIDTH, 0x0003a8), - REG(VCAP_CONST_ACTION_DEF_CNT, 0x0003ac), - REG(VCAP_CONST_ACTION_WIDTH, 0x0003b0), - REG(VCAP_CONST_CNT_WIDTH, 0x0003b4), - REG(VCAP_CONST_CORE_CNT, 0x0003b8), - REG(VCAP_CONST_IF_CNT, 0x0003bc), -}; - -static const u32 ocelot_ptp_regmap[] = { - REG(PTP_PIN_CFG, 0x000000), - REG(PTP_PIN_TOD_SEC_MSB, 0x000004), - REG(PTP_PIN_TOD_SEC_LSB, 0x000008), - REG(PTP_PIN_TOD_NSEC, 0x00000c), - REG(PTP_PIN_WF_HIGH_PERIOD, 0x000014), - REG(PTP_PIN_WF_LOW_PERIOD, 0x000018), - REG(PTP_CFG_MISC, 0x0000a0), - REG(PTP_CLK_CFG_ADJ_CFG, 0x0000a4), - REG(PTP_CLK_CFG_ADJ_FREQ, 0x0000a8), -}; - -static const u32 ocelot_dev_gmii_regmap[] = { - REG(DEV_CLOCK_CFG, 0x0), - REG(DEV_PORT_MISC, 0x4), - REG(DEV_EVENTS, 0x8), - REG(DEV_EEE_CFG, 0xc), - REG(DEV_RX_PATH_DELAY, 0x10), - REG(DEV_TX_PATH_DELAY, 0x14), - REG(DEV_PTP_PREDICT_CFG, 0x18), - REG(DEV_MAC_ENA_CFG, 0x1c), - REG(DEV_MAC_MODE_CFG, 0x20), - REG(DEV_MAC_MAXLEN_CFG, 0x24), - REG(DEV_MAC_TAGS_CFG, 0x28), - REG(DEV_MAC_ADV_CHK_CFG, 0x2c), - REG(DEV_MAC_IFG_CFG, 0x30), - REG(DEV_MAC_HDX_CFG, 0x34), - REG(DEV_MAC_DBG_CFG, 0x38), - REG(DEV_MAC_FC_MAC_LOW_CFG, 0x3c), - REG(DEV_MAC_FC_MAC_HIGH_CFG, 0x40), - REG(DEV_MAC_STICKY, 0x44), - REG(PCS1G_CFG, 0x48), - REG(PCS1G_MODE_CFG, 0x4c), - REG(PCS1G_SD_CFG, 0x50), - REG(PCS1G_ANEG_CFG, 0x54), - REG(PCS1G_ANEG_NP_CFG, 0x58), - REG(PCS1G_LB_CFG, 0x5c), - REG(PCS1G_DBG_CFG, 0x60), - REG(PCS1G_CDET_CFG, 0x64), - REG(PCS1G_ANEG_STATUS, 0x68), - REG(PCS1G_ANEG_NP_STATUS, 0x6c), - REG(PCS1G_LINK_STATUS, 0x70), - REG(PCS1G_LINK_DOWN_CNT, 0x74), - REG(PCS1G_STICKY, 0x78), - REG(PCS1G_DEBUG_STATUS, 0x7c), - REG(PCS1G_LPI_CFG, 0x80), - REG(PCS1G_LPI_WAKE_ERROR_CNT, 0x84), - REG(PCS1G_LPI_STATUS, 0x88), - REG(PCS1G_TSTPAT_MODE_CFG, 0x8c), - REG(PCS1G_TSTPAT_STATUS, 0x90), - REG(DEV_PCS_FX100_CFG, 0x94), - REG(DEV_PCS_FX100_STATUS, 0x98), -}; - static const u32 *ocelot_regmap[TARGET_MAX] = { [ANA] = ocelot_ana_regmap, [QS] = ocelot_qs_regmap, diff --git a/include/soc/mscc/ocelot_regs.h b/include/soc/mscc/ocelot_regs.h new file mode 100644 index 000000000000..56e169818954 --- /dev/null +++ b/include/soc/mscc/ocelot_regs.h @@ -0,0 +1,21 @@ +/* SPDX-License-Identifier: (GPL-2.0 OR MIT) */ +/* + * Microsemi Ocelot Switch driver + * + * Copyright (c) 2021 Innovative Advantage Inc. + */ + +#ifndef OCELOT_REGS_H +#define OCELOT_REGS_H + +extern const u32 ocelot_ana_regmap[]; +extern const u32 ocelot_qs_regmap[]; +extern const u32 ocelot_qsys_regmap[]; +extern const u32 ocelot_rew_regmap[]; +extern const u32 ocelot_sys_regmap[]; +extern const u32 ocelot_vcap_regmap[]; +extern const u32 ocelot_ptp_regmap[]; +extern const u32 ocelot_dev_gmii_regmap[]; + +#endif + From patchwork Sat Jul 10 19:26:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Foster X-Patchwork-Id: 472619 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 62BA1C11F68 for ; Sat, 10 Jul 2021 19:26:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 55F7260FDA for ; Sat, 10 Jul 2021 19:26:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231843AbhGJT3Y (ORCPT ); Sat, 10 Jul 2021 15:29:24 -0400 Received: from mail-bn7nam10on2107.outbound.protection.outlook.com ([40.107.92.107]:9249 "EHLO NAM10-BN7-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231250AbhGJT3M (ORCPT ); Sat, 10 Jul 2021 15:29:12 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JzXByueDt9zQcwhzHrV57Xs1vPmhZzDFhQGsefKousPUDhUbGP2ei/etwiD8FIoJ/5PoV61FNCCf8dD6etS7ySSIzOo3rOFQzo6KmnH5eXtjQRp+gIsOdiR41QCEmMKTmvp9lG95iC4doBq/TKez+bD5fRn1DQVHQ98lDbsJ05X+cVUlsupkX6VWidqqu+mMuWxfZPRwOPSHGnu4ZrbiPaFV51eUHsHQ/z1jApaPl/KrpWR9LgDSIh32k9qcTmW/MZR8FuMv64RziUfnJBLj1aE/awHA9aSomPonZ8qqUj8DCahrsZm1igpPdi6f30GS6de5QJNODDNoW7gNrsvZBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=djsFpEiieRGtj4ktu+HG/gTHru21HG3VhDOiWR3q+S4=; b=dSzwwW03zkW3+GDbRwFQlWUVADSeL4cs3tHzrqSo3OS9CvTL2B/BgLbiW1L7Ve0xCEnfA2cgrMOGjtlwLkw8K9WkZZzsKg4niqIItzqJEkBmOiPeX+Cdy5crJQ24IK5om4aMG7KqDgWyXbmMnXuaMv9Y39jyHt2z0ffO37LDTWyR6OFF0kFse9+0MxWtD6yvkTmWcj9MNfaxZ7X0ZsE5gKKidnmlctQQrJb2T5XZcEHKXF2l/h+FAQQZdzYXVJhHegxd+uNLTHmPdmx+VMQuMgy2j9WEUr+jciT2A6OLFlw/+3W27O2MFvxAn6zpi7GjtiDTG2mkEZOiGu8fHk3C7Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=in-advantage.com; dmarc=pass action=none header.from=in-advantage.com; dkim=pass header.d=in-advantage.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inadvantage.onmicrosoft.com; s=selector2-inadvantage-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=djsFpEiieRGtj4ktu+HG/gTHru21HG3VhDOiWR3q+S4=; b=biJIL/UGKjKq94sC1WkGRFtoGMg9piuJ53XPbodhuWvcuVF0fHa7pBD2EDgegEL3+kChSXfM9QNQ+5+5I6XlTaf+5BUDhJmqqbYJkkQ3jFuhHADJpuu8vYRkJXXPJCKaD4xxPXhAig9NW+3MUBVuPlBWyWawl3eABkAbk/kcKhg= Authentication-Results: lunn.ch; dkim=none (message not signed) header.d=none; lunn.ch; dmarc=none action=none header.from=in-advantage.com; Received: from MWHPR1001MB2351.namprd10.prod.outlook.com (2603:10b6:301:35::37) by MWHPR10MB1709.namprd10.prod.outlook.com (2603:10b6:301:7::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.22; Sat, 10 Jul 2021 19:26:20 +0000 Received: from MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::e81f:cf8e:6ad6:d24d]) by MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::e81f:cf8e:6ad6:d24d%3]) with mapi id 15.20.4287.033; Sat, 10 Jul 2021 19:26:20 +0000 From: Colin Foster To: andrew@lunn.ch, vivien.didelot@gmail.com, f.fainelli@gmail.com, olteanv@gmail.com, davem@davemloft.net, kuba@kernel.org, robh+dt@kernel.org, claudiu.manoil@nxp.com, alexandre.belloni@bootlin.com, UNGLinuxDriver@microchip.com, linux@armlinux.org.uk Cc: netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH v2 net-next 6/8] net: mscc: ocelot: expose ocelot wm functions Date: Sat, 10 Jul 2021 12:26:00 -0700 Message-Id: <20210710192602.2186370-7-colin.foster@in-advantage.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210710192602.2186370-1-colin.foster@in-advantage.com> References: <20210710192602.2186370-1-colin.foster@in-advantage.com> X-ClientProxiedBy: MWHPR12CA0042.namprd12.prod.outlook.com (2603:10b6:301:2::28) To MWHPR1001MB2351.namprd10.prod.outlook.com (2603:10b6:301:35::37) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (67.185.175.147) by MWHPR12CA0042.namprd12.prod.outlook.com (2603:10b6:301:2::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.19 via Frontend Transport; Sat, 10 Jul 2021 19:26:19 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0e94c2a1-9648-41e4-853c-08d943d89882 X-MS-TrafficTypeDiagnostic: MWHPR10MB1709: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2582; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: KaFxKc3f+NxwnZGkJTo33K6C3pzgiLKVxS9mlyqpSJSuujqYJuIoy9CBFLYA6gOkYhO+qxpVp6e2eBs51lTy7ZxxFURLj1LOo4ZULcfKgJ4sh1JyLyYYxICB+O+qRCH9TiFVPAkibvPoqKoH1yLkfuoKd09Q5wjWSnJgG0xdXU1zua5S2t86qLgh75i9xZO3VFzHeH3k4cg6RuxGiRPrR6uRZ8uCEhWc9q8DjjEUTNu2NNvdeqxnSK5i7xoXmdFToOeJ8E8M5ZYZFh7gjwZHGfBB3GjCDy31BtaSfMWpQUVEpJelZdWp1IyJ1apArr4+t0XGUQwweWheUntJWG+OLAjjq3mmldOFZE1dLSlG0R4KwOymKzc04OAI0y5sd5nrDhREaai0kTFoyjk7zL1IbW6VZAVezuMDZ0Psx8O1YASBYu5O4mqg3+0TshbnVMeyYUodV7Af9t2j9l4M6iFX9KCl0oAGe8LVLb+tU2oX8z/L4vglxpYnQ4UaOFAF1KDtmWKyMX54QbbMTXYkjEjzWPXWvg4Ky/F+gqiydtrvvX2I8PV0fopCxOVIJ0hi7SFU3zS3LQgEYYJp+gLunEx+4YWPmZ2bFFykvlZWq99RAIXUgDgVGgnl3jvKzaRv/XJl9cg9uC6sE3O+Iutze3fCtEm1qjASQweIIdyAbtjsMLewoniiNTQuRyIvSBSM5IKQMj+BAtTohJD19w5gEBbq41IcymPJ1XmW9QgAuHBjq1A= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MWHPR1001MB2351.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(346002)(396003)(376002)(39830400003)(136003)(366004)(8936002)(7416002)(6506007)(5660300002)(2906002)(66556008)(26005)(2616005)(8676002)(44832011)(6486002)(6512007)(66476007)(6666004)(38100700002)(38350700002)(52116002)(66946007)(921005)(4326008)(956004)(83380400001)(1076003)(316002)(36756003)(86362001)(186003)(478600001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: bl4tecyLqSpT4qIYcd/hOatlfDBmjlWWm+JMV6EMAcTZBdXvuR5IMMHe3xYqtWyuDFV5i4sq7Urva3UVKKL3xlAHtz0mweGq/GHzMITJ2AO1KxyIcYVmfTmzE5Gh4QzuFI2+bIEojZP2JwHZTUisNuzpV955swWu6FS2OJQJ1/s5rQ56j6dOYI9hZ5UxrGvlJ1Qn30zlbIbhFL3kfHgLHBfc1MRBwxxMj3bKSDOMU1aztB6w6G8Z0z3eps+7bMUj7m1PKwAsgxi4n9+ryj2OqYgOTa5RsZpTrJHXu1Ow7znHofixfF7ZQJcwiCmEHwF7Mqa7hd5B/c+56n35r5mHpbFUgB3uq3t+kMncqn10ZsHMwRi7zBBnh4NJPE/j4FFnow7dHr1gxHnEE0mZKd2LjiEcgZmyvBL99ug/lBA9sZZQFLOsmLtB7fQJULIDIT2zhT5kj0nwI2JhDArRZYqJhl4qLR89tijp2xpN5Tv3OSUCVJHyIbOEAczUvSIY8vaXGtxq6x4eDlG1QSi4uaoJXjF81s+FU/b9Ci9k0BYJYVBH0yw/7aEp/Uku0YpRPFeFkZePJn+lLQIXLC+Xe3qgNhaSqtN5HDQA/iGhUc/HMvzWWgK+NNVPKfnPQxBeG6EoJHOCPr6TmmJkTjXCdkahurDu8lADMv/Ks5b6dG2VdkhKquO48lI908eswsSwH2C1SVyQGpDFuPeDpaHZduTA/O3uqqcperkVORufH/VhSUfw69fs3d5dxc5PUbnRNOvZFl4xqDvTH/TBSFDVT/jeQpC1GvBfCuom2ENZmL8KbknB2dOvyKThHktXeuX4B5wDdcIL6k4OsZqGhGX//9xBJBWquXJOTeL1ZhiBWKTrVWjdkufLmtOX3xC8vkFO2hf545VniZEwe1ZIB5iAUnohd6dGcglNri5cHgq3gCcUEst7uDDaz58I6EvndbwYjQUhbB8GN5B9e3VXY62MmSkD9rnIxr9k5+xfrGm3NbyWOQMXArB+wyGqEQU0Eu88139nvtQ0IsnzXpFrvZ79PTWH/6gO/7C9Zhdr6TUNt5/LUpwKZgq2KLIH2UqajRWTYtUdfq5suRMLnvbrUzjtIDjfEO1F4oOxyBgSOybuQbQBr/iW9NcuLY1DqIrGsXi58a/nrFbLURB7Dtea/T+J7KvB5CWRpgvJPDAGDdxHJJDYTvngWJnXkYy+oy3mXLRJ888alO3c45zgEZ3JpPiJvD5KTZ4WAGppI+q6O7LauAlj+jVSdlVsc1hQVeF4AUPYLNhV+KYf+1gqsngDQjIMG1qFF7uULzO3VnHczyza5MKKgmTl9NaoEuult7Exp3rLaNQV X-OriginatorOrg: in-advantage.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0e94c2a1-9648-41e4-853c-08d943d89882 X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2351.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jul 2021 19:26:20.1802 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 48e842ca-fbd8-4633-a79d-0c955a7d3aae X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: +pHS6d+jSmlS0qc+B8go9dLkpp9goYlnbIyOS2Ezui8+InLGXKyFhAjB/1nxbN654Q6Nq+2nISvhFhiLB6QZKMjn/4gOaeosUIYBRbabH9k= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR10MB1709 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Expose ocelot_wm functions so they can be shared with other drivers. Signed-off-by: Colin Foster --- drivers/net/ethernet/mscc/Makefile | 1 + drivers/net/ethernet/mscc/ocelot_vsc7514.c | 28 --------------- drivers/net/ethernet/mscc/ocelot_wm.c | 40 ++++++++++++++++++++++ include/soc/mscc/ocelot.h | 5 +++ 4 files changed, 46 insertions(+), 28 deletions(-) create mode 100644 drivers/net/ethernet/mscc/ocelot_wm.c diff --git a/drivers/net/ethernet/mscc/Makefile b/drivers/net/ethernet/mscc/Makefile index d539a231a478..4ea9ecdfa60c 100644 --- a/drivers/net/ethernet/mscc/Makefile +++ b/drivers/net/ethernet/mscc/Makefile @@ -8,6 +8,7 @@ mscc_ocelot_switch_lib-y := \ ocelot_flower.o \ ocelot_ptp.o \ ocelot_regs.o \ + ocelot_wm.o \ ocelot_devlink.o mscc_ocelot_switch_lib-$(CONFIG_BRIDGE_MRP) += ocelot_mrp.o obj-$(CONFIG_MSCC_OCELOT_SWITCH) += mscc_ocelot.o diff --git a/drivers/net/ethernet/mscc/ocelot_vsc7514.c b/drivers/net/ethernet/mscc/ocelot_vsc7514.c index ef1bf24f51b5..6e58f95a8dad 100644 --- a/drivers/net/ethernet/mscc/ocelot_vsc7514.c +++ b/drivers/net/ethernet/mscc/ocelot_vsc7514.c @@ -302,34 +302,6 @@ static int ocelot_reset(struct ocelot *ocelot) return 0; } -/* Watermark encode - * Bit 8: Unit; 0:1, 1:16 - * Bit 7-0: Value to be multiplied with unit - */ -static u16 ocelot_wm_enc(u16 value) -{ - WARN_ON(value >= 16 * BIT(8)); - - if (value >= BIT(8)) - return BIT(8) | (value / 16); - - return value; -} - -static u16 ocelot_wm_dec(u16 wm) -{ - if (wm & BIT(8)) - return (wm & GENMASK(7, 0)) * 16; - - return wm; -} - -static void ocelot_wm_stat(u32 val, u32 *inuse, u32 *maxuse) -{ - *inuse = (val & GENMASK(23, 12)) >> 12; - *maxuse = val & GENMASK(11, 0); -} - static const struct ocelot_ops ocelot_ops = { .reset = ocelot_reset, .wm_enc = ocelot_wm_enc, diff --git a/drivers/net/ethernet/mscc/ocelot_wm.c b/drivers/net/ethernet/mscc/ocelot_wm.c new file mode 100644 index 000000000000..f9a11a6a059d --- /dev/null +++ b/drivers/net/ethernet/mscc/ocelot_wm.c @@ -0,0 +1,40 @@ +// SPDX-License-Identifier: (GPL-2.0 OR MIT) +/* + * Microsemi Ocelot Switch driver + * + * Copyright (c) 2017 Microsemi Corporation + */ + +#include "ocelot.h" + +/* Watermark encode + * Bit 8: Unit; 0:1, 1:16 + * Bit 7-0: Value to be multiplied with unit + */ +u16 ocelot_wm_enc(u16 value) +{ + WARN_ON(value >= 16 * BIT(8)); + + if (value >= BIT(8)) + return BIT(8) | (value / 16); + + return value; +} +EXPORT_SYMBOL(ocelot_wm_enc); + +u16 ocelot_wm_dec(u16 wm) +{ + if (wm & BIT(8)) + return (wm & GENMASK(7, 0)) * 16; + + return wm; +} +EXPORT_SYMBOL(ocelot_wm_dec); + +void ocelot_wm_stat(u32 val, u32 *inuse, u32 *maxuse) +{ + *inuse = (val & GENMASK(23, 12)) >> 12; + *maxuse = val & GENMASK(11, 0); +} +EXPORT_SYMBOL(ocelot_wm_stat); + diff --git a/include/soc/mscc/ocelot.h b/include/soc/mscc/ocelot.h index 2f5ce4d4fdbf..ff6e65a266d6 100644 --- a/include/soc/mscc/ocelot.h +++ b/include/soc/mscc/ocelot.h @@ -797,6 +797,11 @@ void ocelot_deinit(struct ocelot *ocelot); void ocelot_init_port(struct ocelot *ocelot, int port); void ocelot_deinit_port(struct ocelot *ocelot, int port); +/* Watermark interface */ +u16 ocelot_wm_enc(u16 value); +u16 ocelot_wm_dec(u16 wm); +void ocelot_wm_stat(u32 val, u32 *inuse, u32 *maxuse); + /* DSA callbacks */ void ocelot_port_enable(struct ocelot *ocelot, int port, struct phy_device *phy); From patchwork Sat Jul 10 19:26:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Foster X-Patchwork-Id: 472813 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, UNWANTED_LANGUAGE_BODY, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A0F36C07E95 for ; Sat, 10 Jul 2021 19:26:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7DE1F61356 for ; Sat, 10 Jul 2021 19:26:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230432AbhGJT31 (ORCPT ); Sat, 10 Jul 2021 15:29:27 -0400 Received: from mail-bn7nam10on2110.outbound.protection.outlook.com ([40.107.92.110]:51932 "EHLO NAM10-BN7-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231286AbhGJT3O (ORCPT ); Sat, 10 Jul 2021 15:29:14 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jxCzBYq7DhA5ACJyiEykDYLP2KM49a89+0HrTKUieqrbfZDm0oMTc7s7uRAwX8tuwXDpygU8SBPydmxR0RGMDt3MXRTTTs2ElAz9f1ZdRwxjxmhous+tAM++1WAu4nomoyZVYiHCuOA5ytZT7IPA2yk6zuoeXVdbsmDrpPcoaoBNk6GzshPCY6MACSRJjH6Y1kT+gWzFsqfjKyULQfAr8pJSjVAdn91CHNiaT9mSFamMKw5RZuZDSqkYfSJWgx+vzGnY0+Hv90sDSCNkC8fwvO0hZMj1IUbiHMg/IM/XNGEwS/IeDi4jlB3h7ddXf3qLoy8cxGdhFY3vtj/RQcm1Uw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5yj2QgVgaWHhnroy/hd1RTTPXmhsNSCSjUMHFjDU6ho=; b=DG28OtDeepm4jD44zMJIfcoLiBsqpZXU3LZ3pUZn0yugpWIZKp8oOHQGnV5enMgtUmx2QWpvr1po1Y+l7H8D5TXFAxTyO7C32Fc2jaGZcmQz5TqspgpXcWWfCxc6hsplYE3b29bI+LRDBy81bgxhF1FskcVYqJL05xFo7f+BNktDb60CZJhG/AhaOCpc+tRahZ/Ti5GdKRa9f18JcLIgCgvJk2bLh8Dgb1MWKP1OghiCP/SsgxHAaSKeS4ZPTTj0dTTFH8WXdSFZHl31x5E+XQ5/9Dn73ILGJzyQjEwmuUU42SnHy1nDeYsz+rr5h5Cz5G2XaSd1XBtU75UkdhM/aw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=in-advantage.com; dmarc=pass action=none header.from=in-advantage.com; dkim=pass header.d=in-advantage.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inadvantage.onmicrosoft.com; s=selector2-inadvantage-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5yj2QgVgaWHhnroy/hd1RTTPXmhsNSCSjUMHFjDU6ho=; b=ucoMfyGoNFPLNno+Aup5KGc6lRNgF7tQIPigKF4ifBZOeyWZmGLuxKIpV6+znZ8XKzXLMYQAqL3BfEpESI+In7Z/lZCyAAWVZ7vYj1wlQJ0E7Xw96GIIsG6+r40PEuTcIiruxtG/RdxYOK5m9EKOd3RBCDGYiiUc4Zc6l0i7fuY= Authentication-Results: lunn.ch; dkim=none (message not signed) header.d=none; lunn.ch; dmarc=none action=none header.from=in-advantage.com; Received: from MWHPR1001MB2351.namprd10.prod.outlook.com (2603:10b6:301:35::37) by MWHPR10MB1709.namprd10.prod.outlook.com (2603:10b6:301:7::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.22; Sat, 10 Jul 2021 19:26:20 +0000 Received: from MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::e81f:cf8e:6ad6:d24d]) by MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::e81f:cf8e:6ad6:d24d%3]) with mapi id 15.20.4287.033; Sat, 10 Jul 2021 19:26:20 +0000 From: Colin Foster To: andrew@lunn.ch, vivien.didelot@gmail.com, f.fainelli@gmail.com, olteanv@gmail.com, davem@davemloft.net, kuba@kernel.org, robh+dt@kernel.org, claudiu.manoil@nxp.com, alexandre.belloni@bootlin.com, UNGLinuxDriver@microchip.com, linux@armlinux.org.uk Cc: netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH v2 net-next 7/8] net: dsa: ocelot: felix: add support for VSC75XX control over SPI Date: Sat, 10 Jul 2021 12:26:01 -0700 Message-Id: <20210710192602.2186370-8-colin.foster@in-advantage.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210710192602.2186370-1-colin.foster@in-advantage.com> References: <20210710192602.2186370-1-colin.foster@in-advantage.com> X-ClientProxiedBy: MWHPR12CA0042.namprd12.prod.outlook.com (2603:10b6:301:2::28) To MWHPR1001MB2351.namprd10.prod.outlook.com (2603:10b6:301:35::37) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (67.185.175.147) by MWHPR12CA0042.namprd12.prod.outlook.com (2603:10b6:301:2::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.19 via Frontend Transport; Sat, 10 Jul 2021 19:26:20 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f9156d6d-4b18-4913-8bbd-08d943d898df X-MS-TrafficTypeDiagnostic: MWHPR10MB1709: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:983; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: F/+JVrZ3je+vD6DVyT6EiIZIF8oDmDa85FlYBc0MXIX3qS9s5o5aHVrNavKLz5+zAbiHgMEbbvu5GPnz0jkpjhOiQ0Nw54OEEadoaDd0rFQYSinsyliVRmZWVcfh72UaxLNctBumLxo/bD+WGoXeOB0pB1IgI9dpZfF087nGuB4kT6B3r4TNbAENAGVCq7ML85Zli22uFlOORPc4PKZVBDy6stcRuX21vFnPvOIFqat1o21R26lDrFp49LPMzycMOzqGJ6aYz3I19m+US7So4O2W6HRMOzZMxa+BrLS0B+QoH7GUCRWPCVFuQFcqGfE8A85R3g10gpxlDlHOO35luURxnxhYfm6L74yHOWBHe3ZneI89ZYlOzUQNGI7VqYMEnimCUZSlDfK2kQ5LKVl1TXS2hQsAWLzxbVmo3i/L0zx4uQNF3lEDxMCQaXhOfsSODhY4XrmOxyHDj5aThiHHdbfzh8FfrUS3dSZeOK4f30wT77O6nWZtUrucjgmFphVv8zXIdkHT8nTyq8VC10r59K/NaPnKXEXxKSfe0tvgCYGSGk4JUiLcMAkseMf6GafcFzFIjEsTVyQVTdZUxhSo9GVWBJ4xbfa7vbf8XHqc+p7pa96Dk7MPYE7ZdRzr/TwdS6TuMNZBV5VdNztKikFAjWzVTy7mVvmhelshnmLOPGW0L+S4PWjF4Ogqf1IyldgcjPRTXU5Vlav6uf/f5+C6PIOx+GV6S2Yx1eFjw41pR4I= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MWHPR1001MB2351.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(346002)(396003)(376002)(39830400003)(136003)(366004)(8936002)(7416002)(6506007)(5660300002)(2906002)(66556008)(26005)(2616005)(8676002)(44832011)(6486002)(6512007)(66476007)(6666004)(38100700002)(38350700002)(52116002)(66946007)(921005)(4326008)(956004)(83380400001)(1076003)(316002)(30864003)(36756003)(86362001)(186003)(478600001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: LGIh4ZsLmmIRwRuQ9yfzVmzwSkISWbj1h+eID31y4ELAqqlm4Cn8MjzUZajJ3GGrsgJv2iHYfN1p0iMXebaFgS5CgULbLphw+dyJXXvloo4Q8YUe+IJnq/Zvs7GEsAkk+7Y2PILt5HuqLRjHWh1xfzbvrcPqIdEUz+Q/ezag3K81dNE/g4vE/Kifam/F37zuNlVNOW7Ym5mQom37ycTKhAls1ldifJ4BadYo9HfAEp/OMXSk6o7Ctrg4SGyM3w2U95rhTjysWWAIr5HGlzUntVQCd05ofl9M0avgZ5ITl627M9Qw2LbVr8YCuKtPy+XaWEKbiwB6moVyre3rPsbUV2kd5EBXwqAtly64/DkIA281lc58Z2wSlULcKlPmw0JD5fPVHA6V1Ek5c0olo7WA8WhHPSQvad3vV1QlnmVDyEEG2+EN3QjFxni6uGKSCl5FFqZnYFlYkp5iPG7wRkHt4apCBppgNKi7YoGKzQuyWG3Crlnzv/W4gT4jwG5u9dEMN8H3DM48m8CmVPcBemRrA0exuIAQtza7tVwjwTn5E39nE7uok0Frx3MMhGVbFxjV/WMD11COw22zY4fDewWPCoFYaiENMMYdpjh2RpkhzBeKxxTKud9na4ickmKwLBdSLrUV5Ae/uDg2dPtSH5eIcvj3/P/htMeTLrvPTn/61gZplfGUQ0xg+qNaGTuiw4Om37cUd44VNMgWuwTKKIRssRNCywzSy1vIFIBTI4gUSA6hrrazmQDPCj+wcexu61NC1WV6q+VpuloiGEfZwNvYwBkR8U5C7d21TEYJufMK2Qx973zFZb2HDl8WqEFtT9KSpavrfZUmHk8yZJOXH6jrMW+HDXzNtuWcQqf+gbYIzuenTGLUTYg59yLiCTPKHBO4+m+i3/TtLPFIAHYcTCKFmw7a/rqD9hFaGXZSnOEdXmRZ0ReConclI2Cl8f+EVEZa30hz9yWh+ppw5PAtIlva9IVtBc8MMmDFNGuoY4ouGOb6TghdRBA2iiNXjF1dtr+wKqm8P01j3cdZhSjtboB09zxSS1dvZOhW64BaTa82aIgYwrnmWEy301IR4ksTu+gra1Iuuun3Pj8wiHi58c5xDfRvCwvWL/ZvKU+i2LxfySRyOQK1JtUsLkcx+e1d/EXybU0TkQhfxRquVogjtLZNJkb/POv+0b8kEK0Z6TVTZmmWXL5qAr4C/biICXHEtWbjj8+Bid9V8RYJwenL9lTP8C4DcTb4Wccz/M93xJuMEbN+jMHMQZ40VgV/uj9mM4y2FSi9obtmlvqcsEvhwp9PVjUJ4OGoT1ikJZ/zeZfwE08hal9AaDKfXZwpPXfRy2TQ X-OriginatorOrg: in-advantage.com X-MS-Exchange-CrossTenant-Network-Message-Id: f9156d6d-4b18-4913-8bbd-08d943d898df X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2351.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jul 2021 19:26:20.8368 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 48e842ca-fbd8-4633-a79d-0c955a7d3aae X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: tofSgv0CCuBkrK3vDfBHjLlI2JYKN5PXbfaphYBvQXLsQNdxsfc0JZWnWtTRBwPLwjy89Iy9bjKPSnCkbKq8oaC0/6jzuZ3kOHDz9x97Z2c= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR10MB1709 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Utilize the Felix and Ocelot drivers to allow control of the VSC7511, VSC7512, VSC7513 and VAC7514 chips from an external CPU over SPI. Signed-off-by: Colin Foster --- drivers/net/dsa/ocelot/Kconfig | 12 + drivers/net/dsa/ocelot/Makefile | 6 + drivers/net/dsa/ocelot/ocelot_vsc7512_spi.c | 1068 +++++++++++++++++++ drivers/net/ethernet/mscc/ocelot.c | 8 + include/soc/mscc/ocelot.h | 19 + 5 files changed, 1113 insertions(+) create mode 100644 drivers/net/dsa/ocelot/ocelot_vsc7512_spi.c diff --git a/drivers/net/dsa/ocelot/Kconfig b/drivers/net/dsa/ocelot/Kconfig index 932b6b6fe817..4528a0bb0a18 100644 --- a/drivers/net/dsa/ocelot/Kconfig +++ b/drivers/net/dsa/ocelot/Kconfig @@ -14,6 +14,18 @@ config NET_DSA_MSCC_FELIX This driver supports the VSC9959 (Felix) switch, which is embedded as a PCIe function of the NXP LS1028A ENETC RCiEP. +config NET_DSA_MSCC_OCELOT_SPI + tristate "Ocelot Ethernet SPI switch support" + depends on NET_DSA && SPI + depends on NET_VENDOR_MICROSEMI + select MSCC_OCELOT_SWITCH_LIB + select NET_DSA_TAG_OCELOT_8021Q + select NET_DSA_TAG_OCELOT + help + This driver supports the VSC7511, VSC7512, VSC7513 and VSC7514 chips + when controlled through SPI. It can be used with the Microsemi dev + boards and an external CPU or custom hardware. + config NET_DSA_MSCC_SEVILLE tristate "Ocelot / Seville Ethernet switch support" depends on NET_DSA diff --git a/drivers/net/dsa/ocelot/Makefile b/drivers/net/dsa/ocelot/Makefile index 34b9b128efb8..6ccd5482de7b 100644 --- a/drivers/net/dsa/ocelot/Makefile +++ b/drivers/net/dsa/ocelot/Makefile @@ -1,11 +1,17 @@ # SPDX-License-Identifier: GPL-2.0-only obj-$(CONFIG_NET_DSA_MSCC_FELIX) += mscc_felix.o +obj-$(CONFIG_NET_DSA_MSCC_OCELOT_SPI) += mscc_ocelot_spi.o obj-$(CONFIG_NET_DSA_MSCC_SEVILLE) += mscc_seville.o mscc_felix-objs := \ felix.o \ felix_vsc9959.o +mscc_ocelot_spi-objs := \ + felix.o \ + felix_mdio.o \ + ocelot_vsc7512_spi.o + mscc_seville-objs := \ felix.o \ felix_mdio.o \ diff --git a/drivers/net/dsa/ocelot/ocelot_vsc7512_spi.c b/drivers/net/dsa/ocelot/ocelot_vsc7512_spi.c new file mode 100644 index 000000000000..5ff028572a5a --- /dev/null +++ b/drivers/net/dsa/ocelot/ocelot_vsc7512_spi.c @@ -0,0 +1,1068 @@ +// SPDX-License-Identifier: (GPL-2.0 OR MIT) +/* Copyright 2017 Microsemi Corporation + * Copyright 2018-2019 NXP Semiconductors + * Copyright 2021 Innovative Advantage Inc. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "felix.h" +#include "felix_mdio.h" + +struct ocelot_spi_data { + int spi_padding_bytes; + struct felix felix; + struct spi_device *spi; +}; + +static const u32 vsc7512_dev_cpuorg_regmap[] = { + REG(DEV_CPUORG_IF_CTRL, 0x0000), + REG(DEV_CPUORG_IF_CFGSTAT, 0x0004), + REG(DEV_CPUORG_ORG_CFG, 0x0008), + REG(DEV_CPUORG_ERR_CNTS, 0x000c), + REG(DEV_CPUORG_TIMEOUT_CFG, 0x0010), + REG(DEV_CPUORG_GPR, 0x0014), + REG(DEV_CPUORG_MAILBOX_SET, 0x0018), + REG(DEV_CPUORG_MAILBOX_CLR, 0x001c), + REG(DEV_CPUORG_MAILBOX, 0x0020), + REG(DEV_CPUORG_SEMA_CFG, 0x0024), + REG(DEV_CPUORG_SEMA0, 0x0028), + REG(DEV_CPUORG_SEMA0_OWNER, 0x002c), + REG(DEV_CPUORG_SEMA1, 0x0030), + REG(DEV_CPUORG_SEMA1_OWNER, 0x0034), +}; + +static const u32 vsc7512_gcb_regmap[] = { + REG(GCB_SOFT_RST, 0x0008), + REG(GCB_MIIM_MII_STATUS, 0x009c), + REG(GCB_MIIM_MII_CMD, 0x00a4), + REG(GCB_MIIM_MII_DATA, 0x00a8), + REG(GCB_PHY_PHY_CFG, 0x00f0), + REG(GCB_PHY_PHY_STAT, 0x00f4), +}; + +static const u32 *vsc7512_regmap[TARGET_MAX] = { + [ANA] = ocelot_ana_regmap, + [QS] = ocelot_qs_regmap, + [QSYS] = ocelot_qsys_regmap, + [REW] = ocelot_rew_regmap, + [SYS] = ocelot_sys_regmap, + [S0] = ocelot_vcap_regmap, + [S1] = ocelot_vcap_regmap, + [S2] = ocelot_vcap_regmap, + [PTP] = ocelot_ptp_regmap, + [GCB] = vsc7512_gcb_regmap, + [DEV_GMII] = ocelot_dev_gmii_regmap, + [DEV_CPUORG] = vsc7512_dev_cpuorg_regmap, +}; + +#define VSC7512_BYTE_ORDER_LE 0x00000000 +#define VSC7512_BYTE_ORDER_BE 0x81818181 +#define VSC7512_BIT_ORDER_MSB 0x00000000 +#define VSC7512_BIT_ORDER_LSB 0x42424242 + +static void ocelot_spi_reset_phys(struct ocelot *ocelot) +{ + ocelot_write(ocelot, 0x1ff, GCB_PHY_PHY_CFG); +} + +struct ocelot_spi_data *felix_to_ocelot_spi(struct felix *felix) +{ + return container_of(felix, struct ocelot_spi_data, felix); +} + +struct ocelot_spi_data *ocelot_to_ocelot_spi(struct ocelot *ocelot) +{ + struct felix *felix = ocelot_to_felix(ocelot); + + return felix_to_ocelot_spi(felix); +} + +static int ocelot_spi_init_bus(struct ocelot *ocelot) +{ + struct ocelot_spi_data *ocelot_spi; + struct spi_device *spi; + u32 val, check; + + ocelot_spi = ocelot_to_ocelot_spi(ocelot); + spi = ocelot_spi->spi; + + val = 0; + +#ifdef __LITTLE_ENDIAN + val |= VSC7512_BYTE_ORDER_LE; +#else + val |= VSC7512_BYTE_ORDER_BE; +#endif + + ocelot_write(ocelot, val, DEV_CPUORG_IF_CTRL); + + val = ocelot_spi->spi_padding_bytes; + ocelot_write(ocelot, val, DEV_CPUORG_IF_CFGSTAT); + + check = val | 0x02000000; + + val = ocelot_read(ocelot, DEV_CPUORG_IF_CFGSTAT); + if (check != val) { + dev_err(&spi->dev, + "Error configuring SPI bus. V: 0x%08x != 0x%08x\n", val, + check); + return -ENODEV; + } + + /* The internal copper phys need to be enabled before the mdio bus is + * scanned. + */ + ocelot_spi_reset_phys(ocelot); + + return 0; +} + +static int vsc7512_reset(struct ocelot *ocelot) +{ + int retries = 100; + int ret, val; + + ocelot_field_write(ocelot, GCB_SOFT_RST_CHIP_RST, 1); + + /* Note: This is adapted from the PCIe reset strategy. The manual doesn't + * suggest how to do a reset over SPI, and the register strategy isn't + * possible. + */ + msleep(100); + + ret = ocelot_spi_init_bus(ocelot); + if (ret) + return ret; + + regmap_field_write(ocelot->regfields[SYS_RESET_CFG_MEM_INIT], 1); + regmap_field_write(ocelot->regfields[SYS_RESET_CFG_MEM_ENA], 1); + + do { + msleep(1); + regmap_field_read(ocelot->regfields[SYS_RESET_CFG_MEM_INIT], + &val); + } while (val && --retries); + + if (!retries) + return -ETIMEDOUT; + + regmap_field_write(ocelot->regfields[SYS_RESET_CFG_CORE_ENA], 1); + + return 0; +} + +static int vsc7512_spi_bus_init(struct ocelot *ocelot) +{ + struct felix *felix = ocelot_to_felix(ocelot); + int rval; + + rval = ocelot_spi_init_bus(ocelot); + if (rval) { + dev_err(ocelot->dev, "error initializing SPI bus\n"); + goto clear_mdio; + } + + rval = felix_mdio_register(ocelot); + if (rval) + dev_err(ocelot->dev, "error registering MDIO bus\n"); + + felix->ds->slave_mii_bus = felix->imdio; + + return rval; + +clear_mdio: + felix->imdio = NULL; + return rval; +} + +static const struct ocelot_ops vsc7512_ops = { + .bus_init = vsc7512_spi_bus_init, + .reset = vsc7512_reset, + .wm_enc = ocelot_wm_enc, + .wm_dec = ocelot_wm_dec, + .wm_stat = ocelot_wm_stat, + .port_to_netdev = felix_port_to_netdev, + .netdev_to_port = felix_netdev_to_port, +}; + +/* Addresses are relative to the SPI device's base address, downshifted by 2*/ +static const struct resource vsc7512_target_io_res[TARGET_MAX] = { + [ANA] = { + .start = 0x71880000, + .end = 0x7188ffff, + .name = "ana", + }, + [QS] = { + .start = 0x71080000, + .end = 0x710800ff, + .name = "qs", + }, + [QSYS] = { + .start = 0x71800000, + .end = 0x719fffff, + .name = "qsys", + }, + [REW] = { + .start = 0x71030000, + .end = 0x7103ffff, + .name = "rew", + }, + [SYS] = { + .start = 0x71010000, + .end = 0x7101ffff, + .name = "sys", + }, + [S0] = { + .start = 0x71040000, + .end = 0x710403ff, + .name = "s0", + }, + [S1] = { + .start = 0x71050000, + .end = 0x710503ff, + .name = "s1", + }, + [S2] = { + .start = 0x71060000, + .end = 0x710603ff, + .name = "s2", + }, + [GCB] = { + .start = 0x71070000, + .end = 0x710701ff, + .name = "devcpu_gcb", + }, + [DEV_CPUORG] = { + .start = 0x71000000, + .end = 0x710003ff, + .name = "devcpu_org", + }, +}; + +static const struct resource vsc7512_port_io_res[] = { + { + .start = 0x711e0000, + .end = 0x711effff, + .name = "port0", + }, + { + .start = 0x711f0000, + .end = 0x711fffff, + .name = "port1", + }, + { + .start = 0x71200000, + .end = 0x7120ffff, + .name = "port2", + }, + { + .start = 0x71210000, + .end = 0x7121ffff, + .name = "port3", + }, + { + .start = 0x71220000, + .end = 0x7122ffff, + .name = "port4", + }, + { + .start = 0x71230000, + .end = 0x7123ffff, + .name = "port5", + }, + { + .start = 0x71240000, + .end = 0x7124ffff, + .name = "port6", + }, + { + .start = 0x71250000, + .end = 0x7125ffff, + .name = "port7", + }, + { + .start = 0x71260000, + .end = 0x7126ffff, + .name = "port8", + }, + { + .start = 0x71270000, + .end = 0x7127ffff, + .name = "port9", + }, + { + .start = 0x71280000, + .end = 0x7128ffff, + .name = "port10", + }, +}; + +static const struct reg_field vsc7512_regfields[REGFIELD_MAX] = { + [ANA_ADVLEARN_VLAN_CHK] = REG_FIELD(ANA_ADVLEARN, 11, 11), + [ANA_ADVLEARN_LEARN_MIRROR] = REG_FIELD(ANA_ADVLEARN, 0, 10), + [ANA_ANEVENTS_MSTI_DROP] = REG_FIELD(ANA_ANEVENTS, 27, 27), + [ANA_ANEVENTS_ACLKILL] = REG_FIELD(ANA_ANEVENTS, 26, 26), + [ANA_ANEVENTS_ACLUSED] = REG_FIELD(ANA_ANEVENTS, 25, 25), + [ANA_ANEVENTS_AUTOAGE] = REG_FIELD(ANA_ANEVENTS, 24, 24), + [ANA_ANEVENTS_VS2TTL1] = REG_FIELD(ANA_ANEVENTS, 23, 23), + [ANA_ANEVENTS_STORM_DROP] = REG_FIELD(ANA_ANEVENTS, 22, 22), + [ANA_ANEVENTS_LEARN_DROP] = REG_FIELD(ANA_ANEVENTS, 21, 21), + [ANA_ANEVENTS_AGED_ENTRY] = REG_FIELD(ANA_ANEVENTS, 20, 20), + [ANA_ANEVENTS_CPU_LEARN_FAILED] = REG_FIELD(ANA_ANEVENTS, 19, 19), + [ANA_ANEVENTS_AUTO_LEARN_FAILED] = REG_FIELD(ANA_ANEVENTS, 18, 18), + [ANA_ANEVENTS_LEARN_REMOVE] = REG_FIELD(ANA_ANEVENTS, 17, 17), + [ANA_ANEVENTS_AUTO_LEARNED] = REG_FIELD(ANA_ANEVENTS, 16, 16), + [ANA_ANEVENTS_AUTO_MOVED] = REG_FIELD(ANA_ANEVENTS, 15, 15), + [ANA_ANEVENTS_DROPPED] = REG_FIELD(ANA_ANEVENTS, 14, 14), + [ANA_ANEVENTS_CLASSIFIED_DROP] = REG_FIELD(ANA_ANEVENTS, 13, 13), + [ANA_ANEVENTS_CLASSIFIED_COPY] = REG_FIELD(ANA_ANEVENTS, 12, 12), + [ANA_ANEVENTS_VLAN_DISCARD] = REG_FIELD(ANA_ANEVENTS, 11, 11), + [ANA_ANEVENTS_FWD_DISCARD] = REG_FIELD(ANA_ANEVENTS, 10, 10), + [ANA_ANEVENTS_MULTICAST_FLOOD] = REG_FIELD(ANA_ANEVENTS, 9, 9), + [ANA_ANEVENTS_UNICAST_FLOOD] = REG_FIELD(ANA_ANEVENTS, 8, 8), + [ANA_ANEVENTS_DEST_KNOWN] = REG_FIELD(ANA_ANEVENTS, 7, 7), + [ANA_ANEVENTS_BUCKET3_MATCH] = REG_FIELD(ANA_ANEVENTS, 6, 6), + [ANA_ANEVENTS_BUCKET2_MATCH] = REG_FIELD(ANA_ANEVENTS, 5, 5), + [ANA_ANEVENTS_BUCKET1_MATCH] = REG_FIELD(ANA_ANEVENTS, 4, 4), + [ANA_ANEVENTS_BUCKET0_MATCH] = REG_FIELD(ANA_ANEVENTS, 3, 3), + [ANA_ANEVENTS_CPU_OPERATION] = REG_FIELD(ANA_ANEVENTS, 2, 2), + [ANA_ANEVENTS_DMAC_LOOKUP] = REG_FIELD(ANA_ANEVENTS, 1, 1), + [ANA_ANEVENTS_SMAC_LOOKUP] = REG_FIELD(ANA_ANEVENTS, 0, 0), + [ANA_TABLES_MACACCESS_B_DOM] = REG_FIELD(ANA_TABLES_MACACCESS, 18, 18), + [ANA_TABLES_MACTINDX_BUCKET] = REG_FIELD(ANA_TABLES_MACTINDX, 10, 11), + [ANA_TABLES_MACTINDX_M_INDEX] = REG_FIELD(ANA_TABLES_MACTINDX, 0, 9), + [GCB_SOFT_RST_SWC_RST] = REG_FIELD(GCB_SOFT_RST, 1, 1), + [GCB_SOFT_RST_CHIP_RST] = REG_FIELD(GCB_SOFT_RST, 0, 0), + [QSYS_TIMED_FRAME_ENTRY_TFRM_VLD] = REG_FIELD(QSYS_TIMED_FRAME_ENTRY, 20, 20), + [QSYS_TIMED_FRAME_ENTRY_TFRM_FP] = REG_FIELD(QSYS_TIMED_FRAME_ENTRY, 8, 19), + [QSYS_TIMED_FRAME_ENTRY_TFRM_PORTNO] = REG_FIELD(QSYS_TIMED_FRAME_ENTRY, 4, 7), + [QSYS_TIMED_FRAME_ENTRY_TFRM_TM_SEL] = REG_FIELD(QSYS_TIMED_FRAME_ENTRY, 1, 3), + [QSYS_TIMED_FRAME_ENTRY_TFRM_TM_T] = REG_FIELD(QSYS_TIMED_FRAME_ENTRY, 0, 0), + [SYS_RESET_CFG_CORE_ENA] = REG_FIELD(SYS_RESET_CFG, 2, 2), + [SYS_RESET_CFG_MEM_ENA] = REG_FIELD(SYS_RESET_CFG, 1, 1), + [SYS_RESET_CFG_MEM_INIT] = REG_FIELD(SYS_RESET_CFG, 0, 0), + /* Replicated per number of ports (12), register size 4 per port */ + [QSYS_SWITCH_PORT_MODE_PORT_ENA] = REG_FIELD_ID(QSYS_SWITCH_PORT_MODE, 14, 14, 12, 4), + [QSYS_SWITCH_PORT_MODE_SCH_NEXT_CFG] = REG_FIELD_ID(QSYS_SWITCH_PORT_MODE, 11, 13, 12, 4), + [QSYS_SWITCH_PORT_MODE_YEL_RSRVD] = REG_FIELD_ID(QSYS_SWITCH_PORT_MODE, 10, 10, 12, 4), + [QSYS_SWITCH_PORT_MODE_INGRESS_DROP_MODE] = REG_FIELD_ID(QSYS_SWITCH_PORT_MODE, 9, 9, 12, 4), + [QSYS_SWITCH_PORT_MODE_TX_PFC_ENA] = REG_FIELD_ID(QSYS_SWITCH_PORT_MODE, 1, 8, 12, 4), + [QSYS_SWITCH_PORT_MODE_TX_PFC_MODE] = REG_FIELD_ID(QSYS_SWITCH_PORT_MODE, 0, 0, 12, 4), + [SYS_PORT_MODE_DATA_WO_TS] = REG_FIELD_ID(SYS_PORT_MODE, 5, 6, 12, 4), + [SYS_PORT_MODE_INCL_INJ_HDR] = REG_FIELD_ID(SYS_PORT_MODE, 3, 4, 12, 4), + [SYS_PORT_MODE_INCL_XTR_HDR] = REG_FIELD_ID(SYS_PORT_MODE, 1, 2, 12, 4), + [SYS_PORT_MODE_INCL_HDR_ERR] = REG_FIELD_ID(SYS_PORT_MODE, 0, 0, 12, 4), + [SYS_PAUSE_CFG_PAUSE_START] = REG_FIELD_ID(SYS_PAUSE_CFG, 10, 18, 12, 4), + [SYS_PAUSE_CFG_PAUSE_STOP] = REG_FIELD_ID(SYS_PAUSE_CFG, 1, 9, 12, 4), + [SYS_PAUSE_CFG_PAUSE_ENA] = REG_FIELD_ID(SYS_PAUSE_CFG, 0, 1, 12, 4), + [GCB_MIIM_MII_STATUS_PENDING] = REG_FIELD(GCB_MIIM_MII_STATUS, 2, 2), + [GCB_MIIM_MII_STATUS_BUSY] = REG_FIELD(GCB_MIIM_MII_STATUS, 3, 3), +}; + +static const struct ocelot_stat_layout vsc7512_stats_layout[] = { + { .offset = 0x00, .name = "rx_octets", }, + { .offset = 0x01, .name = "rx_unicast", }, + { .offset = 0x02, .name = "rx_multicast", }, + { .offset = 0x03, .name = "rx_broadcast", }, + { .offset = 0x04, .name = "rx_shorts", }, + { .offset = 0x05, .name = "rx_fragments", }, + { .offset = 0x06, .name = "rx_jabbers", }, + { .offset = 0x07, .name = "rx_crc_align_errs", }, + { .offset = 0x08, .name = "rx_sym_errs", }, + { .offset = 0x09, .name = "rx_frames_below_65_octets", }, + { .offset = 0x0A, .name = "rx_frames_65_to_127_octets", }, + { .offset = 0x0B, .name = "rx_frames_128_to_255_octets", }, + { .offset = 0x0C, .name = "rx_frames_256_to_511_octets", }, + { .offset = 0x0D, .name = "rx_frames_512_to_1023_octets", }, + { .offset = 0x0E, .name = "rx_frames_1024_to_1526_octets", }, + { .offset = 0x0F, .name = "rx_frames_over_1526_octets", }, + { .offset = 0x10, .name = "rx_pause", }, + { .offset = 0x11, .name = "rx_control", }, + { .offset = 0x12, .name = "rx_longs", }, + { .offset = 0x13, .name = "rx_classified_drops", }, + { .offset = 0x14, .name = "rx_red_prio_0", }, + { .offset = 0x15, .name = "rx_red_prio_1", }, + { .offset = 0x16, .name = "rx_red_prio_2", }, + { .offset = 0x17, .name = "rx_red_prio_3", }, + { .offset = 0x18, .name = "rx_red_prio_4", }, + { .offset = 0x19, .name = "rx_red_prio_5", }, + { .offset = 0x1A, .name = "rx_red_prio_6", }, + { .offset = 0x1B, .name = "rx_red_prio_7", }, + { .offset = 0x1C, .name = "rx_yellow_prio_0", }, + { .offset = 0x1D, .name = "rx_yellow_prio_1", }, + { .offset = 0x1E, .name = "rx_yellow_prio_2", }, + { .offset = 0x1F, .name = "rx_yellow_prio_3", }, + { .offset = 0x20, .name = "rx_yellow_prio_4", }, + { .offset = 0x21, .name = "rx_yellow_prio_5", }, + { .offset = 0x22, .name = "rx_yellow_prio_6", }, + { .offset = 0x23, .name = "rx_yellow_prio_7", }, + { .offset = 0x24, .name = "rx_green_prio_0", }, + { .offset = 0x25, .name = "rx_green_prio_1", }, + { .offset = 0x26, .name = "rx_green_prio_2", }, + { .offset = 0x27, .name = "rx_green_prio_3", }, + { .offset = 0x28, .name = "rx_green_prio_4", }, + { .offset = 0x29, .name = "rx_green_prio_5", }, + { .offset = 0x2A, .name = "rx_green_prio_6", }, + { .offset = 0x2B, .name = "rx_green_prio_7", }, + { .offset = 0x40, .name = "tx_octets", }, + { .offset = 0x41, .name = "tx_unicast", }, + { .offset = 0x42, .name = "tx_multicast", }, + { .offset = 0x43, .name = "tx_broadcast", }, + { .offset = 0x44, .name = "tx_collision", }, + { .offset = 0x45, .name = "tx_drops", }, + { .offset = 0x46, .name = "tx_pause", }, + { .offset = 0x47, .name = "tx_frames_below_65_octets", }, + { .offset = 0x48, .name = "tx_frames_65_to_127_octets", }, + { .offset = 0x49, .name = "tx_frames_128_255_octets", }, + { .offset = 0x4A, .name = "tx_frames_256_511_octets", }, + { .offset = 0x4B, .name = "tx_frames_512_1023_octets", }, + { .offset = 0x4C, .name = "tx_frames_1024_1526_octets", }, + { .offset = 0x4D, .name = "tx_frames_over_1526_octets", }, + { .offset = 0x4E, .name = "tx_yellow_prio_0", }, + { .offset = 0x4F, .name = "tx_yellow_prio_1", }, + { .offset = 0x50, .name = "tx_yellow_prio_2", }, + { .offset = 0x51, .name = "tx_yellow_prio_3", }, + { .offset = 0x52, .name = "tx_yellow_prio_4", }, + { .offset = 0x53, .name = "tx_yellow_prio_5", }, + { .offset = 0x54, .name = "tx_yellow_prio_6", }, + { .offset = 0x55, .name = "tx_yellow_prio_7", }, + { .offset = 0x56, .name = "tx_green_prio_0", }, + { .offset = 0x57, .name = "tx_green_prio_1", }, + { .offset = 0x58, .name = "tx_green_prio_2", }, + { .offset = 0x59, .name = "tx_green_prio_3", }, + { .offset = 0x5A, .name = "tx_green_prio_4", }, + { .offset = 0x5B, .name = "tx_green_prio_5", }, + { .offset = 0x5C, .name = "tx_green_prio_6", }, + { .offset = 0x5D, .name = "tx_green_prio_7", }, + { .offset = 0x5E, .name = "tx_aged", }, + { .offset = 0x80, .name = "drop_local", }, + { .offset = 0x81, .name = "drop_tail", }, + { .offset = 0x82, .name = "drop_yellow_prio_0", }, + { .offset = 0x83, .name = "drop_yellow_prio_1", }, + { .offset = 0x84, .name = "drop_yellow_prio_2", }, + { .offset = 0x85, .name = "drop_yellow_prio_3", }, + { .offset = 0x86, .name = "drop_yellow_prio_4", }, + { .offset = 0x87, .name = "drop_yellow_prio_5", }, + { .offset = 0x88, .name = "drop_yellow_prio_6", }, + { .offset = 0x89, .name = "drop_yellow_prio_7", }, + { .offset = 0x8A, .name = "drop_green_prio_0", }, + { .offset = 0x8B, .name = "drop_green_prio_1", }, + { .offset = 0x8C, .name = "drop_green_prio_2", }, + { .offset = 0x8D, .name = "drop_green_prio_3", }, + { .offset = 0x8E, .name = "drop_green_prio_4", }, + { .offset = 0x8F, .name = "drop_green_prio_5", }, + { .offset = 0x90, .name = "drop_green_prio_6", }, + { .offset = 0x91, .name = "drop_green_prio_7", }, +}; + +static unsigned int ocelot_spi_translate_address(unsigned int reg) +{ + return cpu_to_be32((reg & 0xffffff) >> 2); +} + +struct ocelot_spi_regmap_context { + struct spi_device *spi; + u32 base; +}; + +static int ocelot_spi_reg_read(void *context, unsigned int reg, + unsigned int *val) +{ + struct ocelot_spi_regmap_context *regmap_context = context; + struct spi_transfer tx, padding, rx; + struct ocelot_spi_data *ocelot_spi; + struct spi_message msg; + struct spi_device *spi; + unsigned int addr; + u8 *tx_buf; + + BUG_ON(!val); + + spi = regmap_context->spi; + + ocelot_spi = spi_get_drvdata(spi); + + addr = ocelot_spi_translate_address(reg + regmap_context->base); + tx_buf = (u8 *)&addr; + + spi_message_init(&msg); + + memset(&tx, 0, sizeof(struct spi_transfer)); + + /* Ignore the first byte for the 24-bit address */ + tx.tx_buf = &tx_buf[1]; + tx.len = 3; + + spi_message_add_tail(&tx, &msg); + + if (ocelot_spi->spi_padding_bytes > 0) { + u8 dummy_buf[16] = {0}; + + memset(&padding, 0, sizeof(struct spi_transfer)); + + /* Just toggle the clock for padding bytes */ + padding.len = ocelot_spi->spi_padding_bytes; + padding.tx_buf = dummy_buf; + padding.dummy_data = 1; + + spi_message_add_tail(&padding, &msg); + } + + memset(&rx, 0, sizeof(struct spi_transfer)); + rx.rx_buf = val; + rx.len = 4; + + spi_message_add_tail(&rx, &msg); + + return spi_sync(spi, &msg); +} + +static int ocelot_spi_reg_write(void *context, unsigned int reg, + unsigned int val) +{ + struct ocelot_spi_regmap_context *regmap_context = context; + struct spi_transfer tx[2] = {0}; + struct spi_message msg; + struct spi_device *spi; + unsigned int addr; + u8 *tx_buf; + + spi = regmap_context->spi; + + addr = ocelot_spi_translate_address(reg + regmap_context->base); + tx_buf = (u8 *)&addr; + + spi_message_init(&msg); + + /* Ignore the first byte for the 24-bit address and set the write bit */ + tx_buf[1] |= BIT(7); + tx[0].tx_buf = &tx_buf[1]; + tx[0].len = 3; + + spi_message_add_tail(&tx[0], &msg); + + memset(&tx[1], 0, sizeof(struct spi_transfer)); + tx[1].tx_buf = &val; + tx[1].len = 4; + + spi_message_add_tail(&tx[1], &msg); + + return spi_sync(spi, &msg); +} + +static const struct regmap_config ocelot_spi_regmap_config = { + .reg_bits = 24, + .reg_stride = 4, + .val_bits = 32, + + .reg_read = ocelot_spi_reg_read, + .reg_write = ocelot_spi_reg_write, + + .max_register = 0xffffffff, + .use_single_write = true, + .use_single_read = true, + .can_multi_write = false, + + .reg_format_endian = REGMAP_ENDIAN_BIG, + .val_format_endian = REGMAP_ENDIAN_NATIVE, +}; + +static void vsc7512_phylink_validate(struct ocelot *ocelot, int port, + unsigned long *supported, + struct phylink_link_state *state) +{ + struct ocelot_port *ocelot_port = ocelot->ports[port]; + + __ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, }; + + if (state->interface != PHY_INTERFACE_MODE_NA && + state->interface != ocelot_port->phy_mode) { + bitmap_zero(supported, __ETHTOOL_LINK_MODE_MASK_NBITS); + return; + } + + phylink_set_port_modes(mask); + phylink_set(mask, Autoneg); + phylink_set(mask, Pause); + phylink_set(mask, Asym_Pause); + phylink_set(mask, 10baseT_Half); + phylink_set(mask, 10baseT_Full); + phylink_set(mask, 100baseT_Half); + phylink_set(mask, 100baseT_Full); + phylink_set(mask, 1000baseT_Half); + phylink_set(mask, 1000baseT_Full); + + bitmap_and(supported, supported, mask, __ETHTOOL_LINK_MODE_MASK_NBITS); + bitmap_and(state->advertising, state->advertising, mask, + __ETHTOOL_LINK_MODE_MASK_NBITS); +} + +static int vsc7512_prevalidate_phy_mode(struct ocelot *ocelot, int port, + phy_interface_t phy_mode) +{ + switch (phy_mode) { + case PHY_INTERFACE_MODE_INTERNAL: + if (port < 4) + return 0; + return -EOPNOTSUPP; + case PHY_INTERFACE_MODE_SGMII: + if (port < 8) + return 0; + return -EOPNOTSUPP; + case PHY_INTERFACE_MODE_QSGMII: + if (port == 7 || port == 8 || port == 10) + return 0; + return -EOPNOTSUPP; + default: + return -EOPNOTSUPP; + } +} + +static int vsc7512_port_setup_tc(struct dsa_switch *ds, int port, + enum tc_setup_type type, void *type_data) +{ + return -EOPNOTSUPP; +} + +static const struct vcap_field vsc7512_vcap_es0_keys[] = { + [VCAP_ES0_EGR_PORT] = { 0, 4 }, + [VCAP_ES0_IGR_PORT] = { 4, 4 }, + [VCAP_ES0_RSV] = { 8, 2 }, + [VCAP_ES0_L2_MC] = { 10, 1 }, + [VCAP_ES0_L2_BC] = { 11, 1 }, + [VCAP_ES0_VID] = { 12, 12 }, + [VCAP_ES0_DP] = { 24, 1 }, + [VCAP_ES0_PCP] = { 25, 3 }, +}; + +static const struct vcap_field vsc7512_vcap_es0_actions[] = { + [VCAP_ES0_ACT_PUSH_OUTER_TAG] = { 0, 2 }, + [VCAP_ES0_ACT_PUSH_INNER_TAG] = { 2, 1 }, + [VCAP_ES0_ACT_TAG_A_TPID_SEL] = { 3, 2 }, + [VCAP_ES0_ACT_TAG_A_VID_SEL] = { 5, 1 }, + [VCAP_ES0_ACT_TAG_A_PCP_SEL] = { 6, 2 }, + [VCAP_ES0_ACT_TAG_A_DEI_SEL] = { 8, 2 }, + [VCAP_ES0_ACT_TAG_B_TPID_SEL] = { 10, 2 }, + [VCAP_ES0_ACT_TAG_B_VID_SEL] = { 12, 1 }, + [VCAP_ES0_ACT_TAG_B_PCP_SEL] = { 13, 2 }, + [VCAP_ES0_ACT_TAG_B_DEI_SEL] = { 15, 2 }, + [VCAP_ES0_ACT_VID_A_VAL] = { 17, 12 }, + [VCAP_ES0_ACT_PCP_A_VAL] = { 29, 3 }, + [VCAP_ES0_ACT_DEI_A_VAL] = { 32, 1 }, + [VCAP_ES0_ACT_VID_B_VAL] = { 33, 12 }, + [VCAP_ES0_ACT_PCP_B_VAL] = { 45, 3 }, + [VCAP_ES0_ACT_DEI_B_VAL] = { 48, 1 }, + [VCAP_ES0_ACT_RSV] = { 49, 24 }, + [VCAP_ES0_ACT_HIT_STICKY] = { 73, 1 }, +}; + +static const struct vcap_field vsc7512_vcap_is1_keys[] = { + [VCAP_IS1_HK_TYPE] = { 0, 1 }, + [VCAP_IS1_HK_LOOKUP] = { 1, 2 }, + [VCAP_IS1_HK_IGR_PORT_MASK] = { 3, 12 }, + [VCAP_IS1_HK_RSV] = { 15, 9 }, + [VCAP_IS1_HK_OAM_Y1731] = { 24, 1 }, + [VCAP_IS1_HK_L2_MC] = { 25, 1 }, + [VCAP_IS1_HK_L2_BC] = { 26, 1 }, + [VCAP_IS1_HK_IP_MC] = { 27, 1 }, + [VCAP_IS1_HK_VLAN_TAGGED] = { 28, 1 }, + [VCAP_IS1_HK_VLAN_DBL_TAGGED] = { 29, 1 }, + [VCAP_IS1_HK_TPID] = { 30, 1 }, + [VCAP_IS1_HK_VID] = { 31, 12 }, + [VCAP_IS1_HK_DEI] = { 43, 1 }, + [VCAP_IS1_HK_PCP] = { 44, 3 }, + /* Specific Fields for IS1 Half Key S1_NORMAL */ + [VCAP_IS1_HK_L2_SMAC] = { 47, 48 }, + [VCAP_IS1_HK_ETYPE_LEN] = { 95, 1 }, + [VCAP_IS1_HK_ETYPE] = { 96, 16 }, + [VCAP_IS1_HK_IP_SNAP] = { 112, 1 }, + [VCAP_IS1_HK_IP4] = { 113, 1 }, + /* Layer-3 Information */ + [VCAP_IS1_HK_L3_FRAGMENT] = { 114, 1 }, + [VCAP_IS1_HK_L3_FRAG_OFS_GT0] = { 115, 1 }, + [VCAP_IS1_HK_L3_OPTIONS] = { 116, 1 }, + [VCAP_IS1_HK_L3_DSCP] = { 117, 6 }, + [VCAP_IS1_HK_L3_IP4_SIP] = { 123, 32 }, + /* Layer-4 Information */ + [VCAP_IS1_HK_TCP_UDP] = { 155, 1 }, + [VCAP_IS1_HK_TCP] = { 156, 1 }, + [VCAP_IS1_HK_L4_SPORT] = { 157, 16 }, + [VCAP_IS1_HK_L4_RNG] = { 173, 8 }, + /* Specific Fields for IS1 Half Key S1_5TUPLE_IP4 */ + [VCAP_IS1_HK_IP4_INNER_TPID] = { 47, 1 }, + [VCAP_IS1_HK_IP4_INNER_VID] = { 48, 12 }, + [VCAP_IS1_HK_IP4_INNER_DEI] = { 60, 1 }, + [VCAP_IS1_HK_IP4_INNER_PCP] = { 61, 3 }, + [VCAP_IS1_HK_IP4_IP4] = { 64, 1 }, + [VCAP_IS1_HK_IP4_L3_FRAGMENT] = { 65, 1 }, + [VCAP_IS1_HK_IP4_L3_FRAG_OFS_GT0] = { 66, 1 }, + [VCAP_IS1_HK_IP4_L3_OPTIONS] = { 67, 1 }, + [VCAP_IS1_HK_IP4_L3_DSCP] = { 68, 6 }, + [VCAP_IS1_HK_IP4_L3_IP4_DIP] = { 74, 32 }, + [VCAP_IS1_HK_IP4_L3_IP4_SIP] = { 106, 32 }, + [VCAP_IS1_HK_IP4_L3_PROTO] = { 138, 8 }, + [VCAP_IS1_HK_IP4_TCP_UDP] = { 146, 1 }, + [VCAP_IS1_HK_IP4_TCP] = { 147, 1 }, + [VCAP_IS1_HK_IP4_L4_RNG] = { 148, 8 }, + [VCAP_IS1_HK_IP4_IP_PAYLOAD_S1_5TUPLE] = { 156, 32 }, +}; + +static const struct vcap_field vsc7512_vcap_is1_actions[] = { + [VCAP_IS1_ACT_DSCP_ENA] = { 0, 1 }, + [VCAP_IS1_ACT_DSCP_VAL] = { 1, 6 }, + [VCAP_IS1_ACT_QOS_ENA] = { 7, 1 }, + [VCAP_IS1_ACT_QOS_VAL] = { 8, 3 }, + [VCAP_IS1_ACT_DP_ENA] = { 11, 1 }, + [VCAP_IS1_ACT_DP_VAL] = { 12, 1 }, + [VCAP_IS1_ACT_PAG_OVERRIDE_MASK] = { 13, 8 }, + [VCAP_IS1_ACT_PAG_VAL] = { 21, 8 }, + [VCAP_IS1_ACT_RSV] = { 29, 9 }, + /* The fields below are incorrectly shifted by 2 in the manual */ + [VCAP_IS1_ACT_VID_REPLACE_ENA] = { 38, 1 }, + [VCAP_IS1_ACT_VID_ADD_VAL] = { 39, 12 }, + [VCAP_IS1_ACT_FID_SEL] = { 51, 2 }, + [VCAP_IS1_ACT_FID_VAL] = { 53, 13 }, + [VCAP_IS1_ACT_PCP_DEI_ENA] = { 66, 1 }, + [VCAP_IS1_ACT_PCP_VAL] = { 67, 3 }, + [VCAP_IS1_ACT_DEI_VAL] = { 70, 1 }, + [VCAP_IS1_ACT_VLAN_POP_CNT_ENA] = { 71, 1 }, + [VCAP_IS1_ACT_VLAN_POP_CNT] = { 72, 2 }, + [VCAP_IS1_ACT_CUSTOM_ACE_TYPE_ENA] = { 74, 4 }, + [VCAP_IS1_ACT_HIT_STICKY] = { 78, 1 }, +}; + +static const struct vcap_field vsc7512_vcap_is2_keys[] = { + /* Common: 46 bits */ + [VCAP_IS2_TYPE] = { 0, 4 }, + [VCAP_IS2_HK_FIRST] = { 4, 1 }, + [VCAP_IS2_HK_PAG] = { 5, 8 }, + [VCAP_IS2_HK_IGR_PORT_MASK] = { 13, 12 }, + [VCAP_IS2_HK_RSV2] = { 25, 1 }, + [VCAP_IS2_HK_HOST_MATCH] = { 26, 1 }, + [VCAP_IS2_HK_L2_MC] = { 27, 1 }, + [VCAP_IS2_HK_L2_BC] = { 28, 1 }, + [VCAP_IS2_HK_VLAN_TAGGED] = { 29, 1 }, + [VCAP_IS2_HK_VID] = { 30, 12 }, + [VCAP_IS2_HK_DEI] = { 42, 1 }, + [VCAP_IS2_HK_PCP] = { 43, 3 }, + /* MAC_ETYPE / MAC_LLC / MAC_SNAP / OAM common */ + [VCAP_IS2_HK_L2_DMAC] = { 46, 48 }, + [VCAP_IS2_HK_L2_SMAC] = { 94, 48 }, + /* MAC_ETYPE (TYPE=000) */ + [VCAP_IS2_HK_MAC_ETYPE_ETYPE] = { 142, 16 }, + [VCAP_IS2_HK_MAC_ETYPE_L2_PAYLOAD0] = { 158, 16 }, + [VCAP_IS2_HK_MAC_ETYPE_L2_PAYLOAD1] = { 174, 8 }, + [VCAP_IS2_HK_MAC_ETYPE_L2_PAYLOAD2] = { 182, 3 }, + /* MAC_LLC (TYPE=001) */ + [VCAP_IS2_HK_MAC_LLC_L2_LLC] = { 142, 40 }, + /* MAC_SNAP (TYPE=010) */ + [VCAP_IS2_HK_MAC_SNAP_L2_SNAP] = { 142, 40 }, + /* MAC_ARP (TYPE=011) */ + [VCAP_IS2_HK_MAC_ARP_SMAC] = { 46, 48 }, + [VCAP_IS2_HK_MAC_ARP_ADDR_SPACE_OK] = { 94, 1 }, + [VCAP_IS2_HK_MAC_ARP_PROTO_SPACE_OK] = { 95, 1 }, + [VCAP_IS2_HK_MAC_ARP_LEN_OK] = { 96, 1 }, + [VCAP_IS2_HK_MAC_ARP_TARGET_MATCH] = { 97, 1 }, + [VCAP_IS2_HK_MAC_ARP_SENDER_MATCH] = { 98, 1 }, + [VCAP_IS2_HK_MAC_ARP_OPCODE_UNKNOWN] = { 99, 1 }, + [VCAP_IS2_HK_MAC_ARP_OPCODE] = { 100, 2 }, + [VCAP_IS2_HK_MAC_ARP_L3_IP4_DIP] = { 102, 32 }, + [VCAP_IS2_HK_MAC_ARP_L3_IP4_SIP] = { 134, 32 }, + [VCAP_IS2_HK_MAC_ARP_DIP_EQ_SIP] = { 166, 1 }, + /* IP4_TCP_UDP / IP4_OTHER common */ + [VCAP_IS2_HK_IP4] = { 46, 1 }, + [VCAP_IS2_HK_L3_FRAGMENT] = { 47, 1 }, + [VCAP_IS2_HK_L3_FRAG_OFS_GT0] = { 48, 1 }, + [VCAP_IS2_HK_L3_OPTIONS] = { 49, 1 }, + [VCAP_IS2_HK_IP4_L3_TTL_GT0] = { 50, 1 }, + [VCAP_IS2_HK_L3_TOS] = { 51, 8 }, + [VCAP_IS2_HK_L3_IP4_DIP] = { 59, 32 }, + [VCAP_IS2_HK_L3_IP4_SIP] = { 91, 32 }, + [VCAP_IS2_HK_DIP_EQ_SIP] = { 123, 1 }, + /* IP4_TCP_UDP (TYPE=100) */ + [VCAP_IS2_HK_TCP] = { 124, 1 }, + [VCAP_IS2_HK_L4_DPORT] = { 125, 16 }, + [VCAP_IS2_HK_L4_SPORT] = { 141, 16 }, + [VCAP_IS2_HK_L4_RNG] = { 157, 8 }, + [VCAP_IS2_HK_L4_SPORT_EQ_DPORT] = { 165, 1 }, + [VCAP_IS2_HK_L4_SEQUENCE_EQ0] = { 166, 1 }, + [VCAP_IS2_HK_L4_FIN] = { 167, 1 }, + [VCAP_IS2_HK_L4_SYN] = { 168, 1 }, + [VCAP_IS2_HK_L4_RST] = { 169, 1 }, + [VCAP_IS2_HK_L4_PSH] = { 170, 1 }, + [VCAP_IS2_HK_L4_ACK] = { 171, 1 }, + [VCAP_IS2_HK_L4_URG] = { 172, 1 }, + [VCAP_IS2_HK_L4_1588_DOM] = { 173, 8 }, + [VCAP_IS2_HK_L4_1588_VER] = { 181, 4 }, + /* IP4_OTHER (TYPE=101) */ + [VCAP_IS2_HK_IP4_L3_PROTO] = { 124, 8 }, + [VCAP_IS2_HK_L3_PAYLOAD] = { 132, 56 }, + /* IP6_STD (TYPE=110) */ + [VCAP_IS2_HK_IP6_L3_TTL_GT0] = { 46, 1 }, + [VCAP_IS2_HK_L3_IP6_SIP] = { 47, 128 }, + [VCAP_IS2_HK_IP6_L3_PROTO] = { 175, 8 }, + /* OAM (TYPE=111) */ + [VCAP_IS2_HK_OAM_MEL_FLAGS] = { 142, 7 }, + [VCAP_IS2_HK_OAM_VER] = { 149, 5 }, + [VCAP_IS2_HK_OAM_OPCODE] = { 154, 8 }, + [VCAP_IS2_HK_OAM_FLAGS] = { 162, 8 }, + [VCAP_IS2_HK_OAM_MEPID] = { 170, 16 }, + [VCAP_IS2_HK_OAM_CCM_CNTS_EQ0] = { 186, 1 }, + [VCAP_IS2_HK_OAM_IS_Y1731] = { 187, 1 }, +}; + +static const struct vcap_field vsc7512_vcap_is2_actions[] = { + [VCAP_IS2_ACT_HIT_ME_ONCE] = { 0, 1 }, + [VCAP_IS2_ACT_CPU_COPY_ENA] = { 1, 1 }, + [VCAP_IS2_ACT_CPU_QU_NUM] = { 2, 3 }, + [VCAP_IS2_ACT_MASK_MODE] = { 5, 2 }, + [VCAP_IS2_ACT_MIRROR_ENA] = { 7, 1 }, + [VCAP_IS2_ACT_LRN_DIS] = { 8, 1 }, + [VCAP_IS2_ACT_POLICE_ENA] = { 9, 1 }, + [VCAP_IS2_ACT_POLICE_IDX] = { 10, 9 }, + [VCAP_IS2_ACT_POLICE_VCAP_ONLY] = { 19, 1 }, + [VCAP_IS2_ACT_PORT_MASK] = { 20, 11 }, + [VCAP_IS2_ACT_REW_OP] = { 31, 9 }, + [VCAP_IS2_ACT_SMAC_REPLACE_ENA] = { 40, 1 }, + [VCAP_IS2_ACT_RSV] = { 41, 2 }, + [VCAP_IS2_ACT_ACL_ID] = { 43, 6 }, + [VCAP_IS2_ACT_HIT_CNT] = { 49, 32 }, +}; + +static struct vcap_props vsc7512_vcap_props[] = { + [VCAP_ES0] = { + .action_type_width = 0, + .action_table = { + [ES0_ACTION_TYPE_NORMAL] = { + .width = 73, + .count = 1, + }, + }, + .target = S0, + .keys = vsc7512_vcap_es0_keys, + .actions = vsc7512_vcap_es0_actions, + }, + [VCAP_IS1] = { + .action_type_width = 0, + .action_table = { + [IS1_ACTION_TYPE_NORMAL] = { + .width = 78, + .count = 4, + }, + }, + .target = S1, + .keys = vsc7512_vcap_is1_keys, + .actions = vsc7512_vcap_is1_actions, + }, + [VCAP_IS2] = { + .action_type_width = 1, + .action_table = { + [IS2_ACTION_TYPE_NORMAL] = { + .width = 49, + .count = 2, + }, + [IS2_ACTION_TYPE_SMAC_SIP] = { + .width = 6, + .count = 4, + }, + }, + .target = S2, + .keys = vsc7512_vcap_is2_keys, + .actions = vsc7512_vcap_is2_actions, + }, +}; + +static struct regmap *vsc7512_regmap_init(struct ocelot *ocelot, + struct resource *res) +{ + struct ocelot_spi_regmap_context *context; + struct regmap_config regmap_config; + struct ocelot_spi_data *ocelot_spi; + struct regmap *regmap; + struct device *dev; + char name[32]; + + ocelot_spi = ocelot_to_ocelot_spi(ocelot); + dev = &ocelot_spi->spi->dev; + + context = devm_kzalloc(dev, sizeof(struct ocelot_spi_regmap_context), + GFP_KERNEL); + + if (IS_ERR(context)) + return ERR_CAST(context); + + context->base = res->start; + context->spi = ocelot_spi->spi; + + memcpy(®map_config, &ocelot_spi_regmap_config, + sizeof(ocelot_spi_regmap_config)); + + /* A unique bus name is required for each regmap */ + if (res->name) + snprintf(name, sizeof(name) - 1, "ocelot_spi-%s", res->name); + else + snprintf(name, sizeof(name) - 1, "ocelot_spi@0x%08x", + res->start); + + regmap_config.name = name; + regmap_config.max_register = res->end - res->start; + + regmap = devm_regmap_init(dev, NULL, context, ®map_config); + + if (IS_ERR(regmap)) + return ERR_CAST(regmap); + + return regmap; +} + +static const struct felix_info ocelot_spi_info = { + .target_io_res = vsc7512_target_io_res, + .port_io_res = vsc7512_port_io_res, + .regfields = vsc7512_regfields, + .map = vsc7512_regmap, + .ops = &vsc7512_ops, + .stats_layout = vsc7512_stats_layout, + .num_stats = ARRAY_SIZE(vsc7512_stats_layout), + .vcap = vsc7512_vcap_props, + .num_mact_rows = 1024, + + /* The 7512 and 7514 both have support for up to 10 ports. The 7511 and + * 7513 have support for 4. Due to lack of hardware to test and + * validate external phys, this is currently limited to 4 ports. + * Expanding this to 10 for the 7512 and 7514 and defining the + * appropriate phy-handle values in the device tree should be possible. + */ + .num_ports = 4, + .num_tx_queues = OCELOT_NUM_TC, + .mdio_bus_alloc = felix_mdio_bus_alloc, + .mdio_bus_free = felix_mdio_bus_free, + .phylink_validate = vsc7512_phylink_validate, + .prevalidate_phy_mode = vsc7512_prevalidate_phy_mode, + .port_setup_tc = vsc7512_port_setup_tc, + .init_regmap = vsc7512_regmap_init, +}; + +static int ocelot_spi_probe(struct spi_device *spi) +{ + struct ocelot_spi_data *ocelot_spi; + struct dsa_switch *ds; + struct ocelot *ocelot; + struct felix *felix; + struct device *dev; + int err; + + dev = &spi->dev; + + ocelot_spi = devm_kzalloc(dev, sizeof(struct ocelot_spi_data), + GFP_KERNEL); + + if (!ocelot_spi) + return -ENOMEM; + + if (spi->max_speed_hz <= 500000) { + ocelot_spi->spi_padding_bytes = 0; + } else { + /* Calculation taken from the manual for IF_CFGSTAT:IF_CFG. Err + * on the side of more padding bytes, as having too few can be + * difficult to detect at runtime. + */ + ocelot_spi->spi_padding_bytes = 1 + + (spi->max_speed_hz / 1000000 + 2) / 8; + } + + dev_set_drvdata(dev, ocelot_spi); + ocelot_spi->spi = spi; + + spi->bits_per_word = 8; + + err = spi_setup(spi); + if (err < 0) { + dev_err(&spi->dev, "Error %d initializing SPI\n", err); + return err; + } + + felix = &ocelot_spi->felix; + + ocelot = &felix->ocelot; + ocelot->dev = dev; + + /* Not sure about this */ + ocelot->num_flooding_pgids = 1; + + felix->info = &ocelot_spi_info; + + ds = kzalloc(sizeof(*ds), GFP_KERNEL); + if (!ds) { + err = -ENOMEM; + dev_err(dev, "Failed to allocate DSA switch\n"); + return err; + } + + ds->dev = &spi->dev; + ds->num_ports = felix->info->num_ports; + ds->num_tx_queues = felix->info->num_tx_queues; + ds->ops = &felix_switch_ops; + ds->priv = ocelot; + felix->ds = ds; + + err = dsa_register_switch(ds); + if (err) { + dev_err(dev, "Failed to register DSA switch: %d\n", err); + goto err_register_ds; + } + + return 0; + +err_register_ds: + kfree(ds); + return err; +} + +static int ocelot_spi_remove(struct spi_device *spi) +{ + struct ocelot_spi_data *ocelot_spi; + struct felix *felix; + + ocelot_spi = spi_get_drvdata(spi); + felix = &ocelot_spi->felix; + + dsa_unregister_switch(felix->ds); + + kfree(felix->ds); + + devm_kfree(&spi->dev, ocelot_spi); + + return 0; +} + +const struct of_device_id vsc7512_of_match[] = { + { .compatible = "mscc,vsc7514" }, + { .compatible = "mscc,vsc7513" }, + { .compatible = "mscc,vsc7512" }, + { .compatible = "mscc,vsc7511" }, + { }, +}; +MODULE_DEVICE_TABLE(of, vsc7512_of_match); + +static struct spi_driver ocelot_vsc7512_spi_driver = { + .driver = { + .name = "vsc7512", + .of_match_table = of_match_ptr(vsc7512_of_match), + }, + .probe = ocelot_spi_probe, + .remove = ocelot_spi_remove, +}; +module_spi_driver(ocelot_vsc7512_spi_driver); + +MODULE_DESCRIPTION("Ocelot Switch SPI driver"); +MODULE_LICENSE("GPL v2"); diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c index adfb9781799e..10937dc59fce 100644 --- a/drivers/net/ethernet/mscc/ocelot.c +++ b/drivers/net/ethernet/mscc/ocelot.c @@ -2016,6 +2016,14 @@ int ocelot_init(struct ocelot *ocelot) int i, ret; u32 port; + if (ocelot->ops->bus_init) { + ret = ocelot->ops->bus_init(ocelot); + if (ret) { + dev_err(ocelot->dev, "Bus init failed\n"); + return ret; + } + } + if (ocelot->ops->reset) { ret = ocelot->ops->reset(ocelot); if (ret) { diff --git a/include/soc/mscc/ocelot.h b/include/soc/mscc/ocelot.h index ff6e65a266d6..f5383804e724 100644 --- a/include/soc/mscc/ocelot.h +++ b/include/soc/mscc/ocelot.h @@ -129,6 +129,7 @@ enum ocelot_target { PTP, GCB, DEV_GMII, + DEV_CPUORG, TARGET_MAX, }; @@ -407,6 +408,8 @@ enum ocelot_reg { GCB_MIIM_MII_STATUS, GCB_MIIM_MII_CMD, GCB_MIIM_MII_DATA, + GCB_PHY_PHY_CFG, + GCB_PHY_PHY_STAT, DEV_CLOCK_CFG = DEV_GMII << TARGET_OFFSET, DEV_PORT_MISC, DEV_EVENTS, @@ -446,6 +449,20 @@ enum ocelot_reg { PCS1G_TSTPAT_STATUS, DEV_PCS_FX100_CFG, DEV_PCS_FX100_STATUS, + DEV_CPUORG_IF_CTRL = DEV_CPUORG << TARGET_OFFSET, + DEV_CPUORG_IF_CFGSTAT, + DEV_CPUORG_ORG_CFG, + DEV_CPUORG_ERR_CNTS, + DEV_CPUORG_TIMEOUT_CFG, + DEV_CPUORG_GPR, + DEV_CPUORG_MAILBOX_SET, + DEV_CPUORG_MAILBOX_CLR, + DEV_CPUORG_MAILBOX, + DEV_CPUORG_SEMA_CFG, + DEV_CPUORG_SEMA0, + DEV_CPUORG_SEMA0_OWNER, + DEV_CPUORG_SEMA1, + DEV_CPUORG_SEMA1_OWNER, }; enum ocelot_regfield { @@ -504,6 +521,7 @@ enum ocelot_regfield { SYS_RESET_CFG_MEM_ENA, SYS_RESET_CFG_MEM_INIT, GCB_SOFT_RST_SWC_RST, + GCB_SOFT_RST_CHIP_RST, GCB_MIIM_MII_STATUS_PENDING, GCB_MIIM_MII_STATUS_BUSY, SYS_PAUSE_CFG_PAUSE_START, @@ -560,6 +578,7 @@ struct ocelot; struct ocelot_ops { struct net_device *(*port_to_netdev)(struct ocelot *ocelot, int port); int (*netdev_to_port)(struct net_device *dev); + int (*bus_init)(struct ocelot *ocelot); int (*reset)(struct ocelot *ocelot); u16 (*wm_enc)(u16 value); u16 (*wm_dec)(u16 value); From patchwork Sat Jul 10 19:26:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Foster X-Patchwork-Id: 472812 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B7483C07E9C for ; Sat, 10 Jul 2021 19:26:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A19796135E for ; Sat, 10 Jul 2021 19:26:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231938AbhGJT3b (ORCPT ); Sat, 10 Jul 2021 15:29:31 -0400 Received: from mail-bn7nam10on2107.outbound.protection.outlook.com ([40.107.92.107]:9249 "EHLO NAM10-BN7-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231270AbhGJT3O (ORCPT ); Sat, 10 Jul 2021 15:29:14 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=S5tD1Snm7ETc3gj8xdTtVNQS1eK0gTVCLGJb80lLyNenifv75/tgoN+7D9Qx90/2tMqOKU0UWw1zvlYMD2CLIG0L5KvRwptf/gGtaxW1T8lMtlfNNxkqJQPTvxVeQIeNzLLvQhKlJjVia1eMYgyhYTTpCJxtseKoUWTEeLMoA++Hs0+aVT/E8FuYCIJEyUGXw2KoHdGKPHvr2kmYXG0tj0ypiAGQ29Q5JiFeEVLky1Kn2/KPnM+4WQhbFBTTNutBSmO/e5m4/xd8QSsfjw1QC++L3bsqsiDQEmMHXj5bEMKzzbKKRi7BslkTnPAOzYfww/Rg2QLc7X+UDY6iXUxblQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5kzVX/APDWZFMXE/nte6ZHwoytOQ0NphKRfHF81nBWA=; b=Xa5sg1yhcqe9yoY7uTvyu4Pm5uvQ1ULT3e74khdhWCRtjyN1acnaNRJTB/pmEGu/lUjT5OznS1y5wnUnZCyfMBAYjr8JIYDpCV6hDidcpjeTbqfMDIemYUAUrl5A1aHCwmMhtJ2rNkLEhJ6YfhGxO/FobqQZwI9YrA1c+8mMecWWuFtkU8S7h3eW4zLnBJZLLEjdiWAQRThuLFJGgPG30c2P0bIt5WGNTEkGiIXxc/6LlNtUr8YDrvKvzp2/37P5qaxh3RrVJLAyZBq/nBpOWvnyy4kTl2PIRJ9D4eoCJYqtgf3uOrut1e7J3CT9aXIHmI1yiT+J7oVPrOIzfc59Pw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=in-advantage.com; dmarc=pass action=none header.from=in-advantage.com; dkim=pass header.d=in-advantage.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inadvantage.onmicrosoft.com; s=selector2-inadvantage-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5kzVX/APDWZFMXE/nte6ZHwoytOQ0NphKRfHF81nBWA=; b=lO1Y8T84kjmz4KScoz1lbDo2Gvgj1rl/0B0qmYkuqGwmwMPW4HgxGKCAhzFI0X/nv5R1ER+zYOPCBDHcoCqrZueFtVmYxeZ1d+p/62S5UR3qImwXBgWwfvCXVHPk0+RFzwrMsKFgX4TqZhCVWrUr2WBEYq7ji9qF2137IOFNJtY= Authentication-Results: lunn.ch; dkim=none (message not signed) header.d=none; lunn.ch; dmarc=none action=none header.from=in-advantage.com; Received: from MWHPR1001MB2351.namprd10.prod.outlook.com (2603:10b6:301:35::37) by MWHPR10MB1709.namprd10.prod.outlook.com (2603:10b6:301:7::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.22; Sat, 10 Jul 2021 19:26:21 +0000 Received: from MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::e81f:cf8e:6ad6:d24d]) by MWHPR1001MB2351.namprd10.prod.outlook.com ([fe80::e81f:cf8e:6ad6:d24d%3]) with mapi id 15.20.4287.033; Sat, 10 Jul 2021 19:26:21 +0000 From: Colin Foster To: andrew@lunn.ch, vivien.didelot@gmail.com, f.fainelli@gmail.com, olteanv@gmail.com, davem@davemloft.net, kuba@kernel.org, robh+dt@kernel.org, claudiu.manoil@nxp.com, alexandre.belloni@bootlin.com, UNGLinuxDriver@microchip.com, linux@armlinux.org.uk Cc: netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH v2 net-next 8/8] Update documentation for the VSC7512 SPI device Date: Sat, 10 Jul 2021 12:26:02 -0700 Message-Id: <20210710192602.2186370-9-colin.foster@in-advantage.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210710192602.2186370-1-colin.foster@in-advantage.com> References: <20210710192602.2186370-1-colin.foster@in-advantage.com> X-ClientProxiedBy: MWHPR12CA0042.namprd12.prod.outlook.com (2603:10b6:301:2::28) To MWHPR1001MB2351.namprd10.prod.outlook.com (2603:10b6:301:35::37) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (67.185.175.147) by MWHPR12CA0042.namprd12.prod.outlook.com (2603:10b6:301:2::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.19 via Frontend Transport; Sat, 10 Jul 2021 19:26:21 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 71e6c8e6-c2bb-4316-ac7a-08d943d89939 X-MS-TrafficTypeDiagnostic: MWHPR10MB1709: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7691; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Y/uIBlY14Cy9bBFBISrJbNhuPXlnGsWSixrkAemDMxCsKqqfgT8WUpAU5c45cvNUwiRx+QG8/4TxI1ZQk1qxu64uQkCw81OCJCLJuvfuuAPcRXhzWq5kMIXA0UFhtgWjW2VvKTEsQwVmJBKp6xAzGB2c9SKQKSJq5MUmCYab0HT2opKncOFKJsyoaO25xCaye/ZrA8BAj/pcpuHUpwPWUWcIRIoyS48KtHHqIYeE7ndbOwM2GJlwkBdN4sBH4IwA4zN2QoN1b6aCmqYqTL2tlJsQDjdonJsy8js+BeaNBEq+mWHpMBxlAjUvpIOgQiXLoTeNpkTAYpTMqL+0+En7J/7fx3ampU1+z91yUjoOG4xrcfYat+dwnqeHWVuDreaDkXfu4apj8Y6D/jWX3PV2WzveSKS53XVSwk4ZsEPnW622illtjULEIDlq4rJIVvaYK1sj2lFOpJoyef34sNk4VGBXxbastuBMNuqKM6r1XU3fnkEnrcTHJpuYMKP3dOjIfgm+b+TR7DACjZlYBNL81DewV1PD+ZOV5LZgxi6fX5loNSURhsID42C6ISQUhF+1gUw+NINybdMb2VwwHCEEcpa4BR/ix2ISc1QypCWsDI1hL6frmd0rEpUolIm8M4suI0M4jpBNam9yRlvTrelQcm4j7Ze+O5REcTF230ONtc3FN3egtMHWztcOX8gBbDL6JLCyg8LyK634gRcYp31voCkg3f8ni0jVYWspPGJ9/54= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MWHPR1001MB2351.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(346002)(396003)(376002)(39830400003)(136003)(366004)(8936002)(7416002)(6506007)(5660300002)(2906002)(66556008)(26005)(2616005)(8676002)(44832011)(6486002)(6512007)(66476007)(6666004)(38100700002)(38350700002)(52116002)(66946007)(921005)(4326008)(956004)(1076003)(316002)(36756003)(86362001)(186003)(478600001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Yz6dumXtxiJ8Q3dIgvbg1qCKX5fY1RoiFOrqRCmGnEbnX2yCYDRJryTg804Q3WMewUsaA/rOa1k2iKNv5WYfbQUhS7LhXipJwfcFlsQQ04Vl4PYTKrpSugKaZKEZttyP3b14epEHlMpkaQKouIkegBP2KUvJ7WCG2s2b7GI6vRMxdqTZeoEc5DKDct4KL7KEO9ET13IVhQEho/hIXGgP3/J6pYgIMhXjwgwIlnirSbI0Ql7S/21kTwUmlTm8SwcAipJn5WCmRGI5e8Iqupx/7ZUJGKCLINV3AnuMTgUnkvEjV8Yb+Yi++JKzfPj1BtwdjRmpmwW/LGYGqoydKIgzsGYN3GgDUrDu6VwQKSudtO8z8D4tVQERyrdoV7bNlh8JMvfJ/EXvBlS4vcvoC/u6Depp6u4aQPFm8HIxHQ7fG7xdkX3TgkBW3JP09k4NOYPYHJdVt+a9MXgpCh8euqtEq3kUPdkp0p2cUVu71FCVAnk4nxJ7Uzp2CbV5VJbymazFmTR0aEEvVvTej8E2Ef9S3LEhHK44J+Mx3TacxwONah32ah3XMWLOew0wXgjFqQbuZEptF0NMVdZNHBTJyQ8C0N37Hu5kHgX5O+bp5vK0CNqfJeJZ2gGi65MCgD8cXK+m4qFmIWoei5mX6IkiJdD7vmeUnDSkrR5FMod4PD79Z5zmMss64r5+t2Mo0Xyn3P4APe4ZqgTkYx+BFmiSy7xgXdfalqOATydGViOhtVFNqCzZwsNGO0KqTHxCM7ROiOf0MgnF2fsbTEd3l+b8xjgBmGQS5SzFEkAK5ai+hHF0VzkPypg6Akv2PqsGEkK/nk7A2pkQO/hZTFq0rUXqQ03tvBtXHeUHYmp4C7+h/CXG0F2yi0oxQP1f5GBTvMnxs3EQKwk7rUNaW89V7LHa/XoelEv2vsb+NmDVc7ztjZTRL7hMG9VYLvhsn54CHaSlBGbObJcVIqPu5/F0JJf4d2COrLMBqhqJdI92z1DXg43zy0FUi7Bvqo5sW91W5IX2BDSktosWmZKXn88TvciSGHFon0FkMKa/Y8ndzUScSCjZRzeaRKZ4q0ZJ0Xo/T6O9wEu4iR5Qdv0qT7toL7Rsasvsm7zAmKOdHLaMzKW3RAvI617gfEYF6KFEiqLRlCZAZVi3+N24k/pzj9NO146rV1GdHhtP0fZRN6qpEyrWZmeWQqU/iMJ5cJUHVf6GUX7W3AbsjJjqlrv0SCZGKCP0ZGz2DkZgItKpiUIDMgesqe9nwifVCRlQix+zS8l5nZ6BM3lM45oXKaOrg1/Rwef3jI0h9rY4dtZq0bjhqGdej2G08ARFHbdjbx5MlDap2w2Wo716 X-OriginatorOrg: in-advantage.com X-MS-Exchange-CrossTenant-Network-Message-Id: 71e6c8e6-c2bb-4316-ac7a-08d943d89939 X-MS-Exchange-CrossTenant-AuthSource: MWHPR1001MB2351.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jul 2021 19:26:21.4465 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 48e842ca-fbd8-4633-a79d-0c955a7d3aae X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: iOvBPnsGMPwBn77zhUaZZeLXQZ4Tb1corlMuXM16WxZpYM+1+z93yWWCU1pnl8xEcFWILi2mDvs85bQGyOjzAWeEXHokKlQ3nr5RMeLi4kM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR10MB1709 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Signed-off-by: Colin Foster --- .../devicetree/bindings/net/dsa/ocelot.txt | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/Documentation/devicetree/bindings/net/dsa/ocelot.txt b/Documentation/devicetree/bindings/net/dsa/ocelot.txt index 7a271d070b72..f5d05bf8b093 100644 --- a/Documentation/devicetree/bindings/net/dsa/ocelot.txt +++ b/Documentation/devicetree/bindings/net/dsa/ocelot.txt @@ -8,6 +8,7 @@ Currently the switches supported by the felix driver are: - VSC9959 (Felix) - VSC9953 (Seville) +- VSC7511, VSC7512, VSC7513, VSC7514 via SPI The VSC9959 switch is found in the NXP LS1028A. It is a PCI device, part of the larger ENETC root complex. As a result, the ethernet-switch node is a sub-node @@ -211,3 +212,70 @@ Example: }; }; }; + +The VSC7513 and VSC7514 switches can be controlled internally via the MIPS +processor. The VSC7511 and VSC7512 don't have this internal processor, but all +four chips can be controlled externally through SPI with the following required +properties: + +- compatible: + Can be "mscc,vsc7511", "mscc,vsc7512", "mscc,vsc7513", or + "mscc,vsc7514". + +Supported phy modes for all chips are: + +* phy_mode = "internal": on ports 0, 1, 2, 3 + +Additionally, the VSC7512 and VSC7514 support SGMII and QSGMII on various ports, +though that is currently untested. + +Example for control from a BeagleBone Black + +&spi0 { + #address-cells = <1>; + #size-cells = <0>; + status = "okay"; + + vsc7512: vsc7512@0 { + compatible = "mscc,vsc7512"; + spi-max-frequency = <250000>; + reg = <0>; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + ethernet = <&mac>; + phy-mode = "internal"; + + fixed-link { + speed = <100>; + full-duplex; + }; + }; + + port@1 { + reg = <1>; + label = "swp1"; + status = "okay"; + phy-mode = "internal"; + }; + + port@2 { + reg = <2>; + label = "swp2"; + status = "okay"; + phy-mode = "internal"; + }; + + port@3 { + reg = <3>; + label = "swp3"; + status = "okay"; + phy-mode = "internal"; + }; + }; + }; +};