Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1422705AbcKPUSA (ORCPT ); Wed, 16 Nov 2016 15:18:00 -0500 Received: from mail-dm3nam03on0061.outbound.protection.outlook.com ([104.47.41.61]:27805 "EHLO NAM03-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S934444AbcKPUQw (ORCPT ); Wed, 16 Nov 2016 15:16:52 -0500 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; nxp.com; dkim=none (message not signed) header.d=none;nxp.com; dmarc=fail action=none header.from=nxp.com;nxp.com; dkim=none (message not signed) header.d=none; X-IncomingTopHeaderMarker: OriginalChecksum:;UpperCasedChecksum:;SizeAsReceived:1009;Count:10 From: Stuart Yoder To: CC: , , , , , , , , Ioana Radulescu , Roy Pledge , Stuart Yoder , Laurentiu Tudor Subject: [PATCH v2 3/9] bus: fsl-mc: dpio: add APIs for DPIO objects Date: Wed, 16 Nov 2016 14:09:53 -0600 Message-ID: <1479326999-29340-4-git-send-email-stuart.yoder@nxp.com> X-Mailer: git-send-email 1.9.0 In-Reply-To: <1479326999-29340-1-git-send-email-stuart.yoder@nxp.com> References: <1479326999-29340-1-git-send-email-stuart.yoder@nxp.com> X-IncomingHeaderCount: 10 X-EOPAttributedMessage: 0 X-Matching-Connectors: 131238010092313513;(91ab9b29-cfa4-454e-5278-08d120cd25b8);() X-Forefront-Antispam-Report: CIP:192.88.168.50;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(6009001)(7916002)(2980300002)(1109001)(1110001)(336004)(339900001)(189002)(199003)(2351001)(106466001)(105606002)(97736004)(33646002)(8676002)(48376002)(50466002)(50226002)(68736007)(305945005)(2906002)(8666005)(8936002)(7846002)(86362001)(356003)(47776003)(36756003)(7416002)(81156014)(5660300001)(110136003)(189998001)(4326007)(81166006)(6916009)(2950100002)(87936001)(85426001)(50986999)(6666003)(76176999)(77096005)(104016004)(5003940100001)(626004)(92566002)(7059030)(2004002);DIR:OUT;SFP:1101;SCL:1;SRVR:DM2PR0301MB0749;H:tx30smr01.am.freescale.net;FPR:;SPF:Fail;PTR:InfoDomainNonexistent;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BL2FFO11FD014;1:KibZ+lBy4GzMoUeorBx+oaRcKn670W2ufO+8dSo1+hPhFKfFOxN8AmStW//s8zdfcpMSgrrMguPqFPuJ5H9USiBBUOWFei3VEmel8+ZR6W+b1fL7XuNm4OsQAy98/Q5YFzMyqbbSpHcu6zjPgZMWM8hgrGGIBsRwC/CdmVukS20lV3YNAPvOpuJ1M4RrsW99Rekpu8GOfegFyko2ciPVabidhgLUqKNfPTfanKDKN457nmWLjX5FFZPWJIBWI9FnkZkWxndyF5g14Y6a2E2qGB/xueLyG6V2kP7Xn1fr8XkM1p0yclK83MW5t63trt40u3mqE2arA7hd6JFG4/841tc5CGh2C+qY4e4AAHrnTLnprnnFspRUSKTMoSOWFz+ZNOIpAmL2fUJapT5NBbBLSWo4+dVRJpt/1aKoHxnR1dPgpTM831yJwl4Q5IpDa0nrPUI9O+mQnjME06PlpmQHJJ0wQc+XQK/dctMTB6HK+kpydDXIy6x2E7Z1hLJu+WDu/X2qLbM06+fAtz05KWQVZnsSl/+nRzFRSrpeGagWtQddkFtz6sdZOAU6yO3ys3E3gnSLNoIzGQiet4bDbPib/TpmhO8/uAlkWYoebexGp66BaoTDXU49h3aHtN+IZ1+1PGMJg9/IjmIBI+6uLWnHzfDR1q9gT38rRXykA29saUDLzgNEef6u71ghU0yK6La3bb6OTm8makmIA/Rj4KHO38PVv0aatBgdLnq8Mayxa1s= MIME-Version: 1.0 Content-Type: text/plain X-Microsoft-Exchange-Diagnostics: 1;DM2PR0301MB0749;2:kJKSwspb23URzCe/+LLn07k/Mj5lzaimucTJ0aH54kbL+jCTKgzFHVcyqmDWlnqNW7huWoM3rBOBbB7DY9BTkazhWqOdiPayRQKa2UFnXHvvC9N41okt8s2Ik+vr617hslwvxTg836UoE4ric2wK1+vAr0xXO3apQY4kn2OKYqY=;3:xvSal+hTrBkqKWdgVa+9MYFqNHq20m3bh7qJ44EE1WfhCjIhAMKYxvqypyOyZn+eGCqFKVw6gJ/PWDodixvSxusF7nQ+ofnMi9d1x0j3Z/llIBIZuGO5gfaZIQ7/6XoJJBgYpgo+EgH3r0h3QkTw1+1LuntNssGYHuBluq8KuW1URzOyHtck4/ITwJXBOIx5S9oWfhevH1ru9awZqXwn2fDBCWAznCgRy1CrTx/kYcrq1fhhZXabFi0sNJgRq2xgw/wkTftuCXAHW44rz+ROkw==;25:1bvDJZ5SGt34zuZvEJrAiMqSG5QuhNQpjIK2jJU46CrxvRM3pyphoRkhcThGYVbz1uUJUn8Hs78APc3iem5I9XgSMBAKRxVPcVCPQlkNOfPmB99RlWpj5NsdN9OjzKvyMq2oJl2PLDK4lghQu+XjS/n5d1kSKFAgRHP6HTJaKhuTiTW0SjYDZucyvfEBZSh/7JP+D1SRqdBTKWyDVdeH33mEw4QbJ5yk0PJY4Ieq7MrQfjtjPf4Esip7oZRD4tLhcJM/yAfA66P9zuvfBriEtQtCKZVlBeC6hr3B8DF+wNffF3wy5LMPaSGaX1QEaiHI1owtmwGUNCJhJ14Tn12IU6Hh7BE9MrsHL4MuzHyGXRFg7HfglQvGpSOjLDyKoDPGlQiI9BanD/vm+Hfvon3Aak0oP4XnIfaphaPyV/naYfiEYNvSV/CV889Pzqa08eNO+umVRxk/JAe4py22D7mhcA== X-MS-Office365-Filtering-Correlation-Id: 45a0377f-5959-4370-dba9-08d40e5d7f0b X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:DM2PR0301MB0749; X-Microsoft-Exchange-Diagnostics: 1;DM2PR0301MB0749;31:VAtvT6ggMBRL2NA9mfsAEiEB52IE1o6w9S6sLIpap25pZNrQ/KEaiRK/mDnZ7/9vJgkPxYugUvmS3bpzM407KJaxJhVL9wXK9bmB81iHw3xOJP+7UEIojmHPp3ozLnXiOOFgQZcmyReIk//4nesx6FCRU31KsNaKutDnXZx5HieUX0jrGI6nzYxM4hEWJw9TN81VEQtdWTLVS6vsSsea7hjT/JNFc4UWmYIQg+WPGTu9hNzT/fOgSxXhI52fk6dD8FOXVtG0HovNNrMO9yQXgsdXhnnwZyDhiiHhmlxQnm8= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(35073007944872)(185117386973197)(275809806118684); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6095035)(601004)(2401047)(13024025)(8121501046)(5005006)(13023025)(13015025)(13017025)(13018025)(10201501046)(3002001)(6055026)(6096035);SRVR:DM2PR0301MB0749;BCL:0;PCL:0;RULEID:(400006);SRVR:DM2PR0301MB0749; X-Microsoft-Exchange-Diagnostics: 1;DM2PR0301MB0749;4:5Zkca2QtNYHC2y7uzHrv/ZlagrSs0z7RkuleirFvQ18RWBHiCFO3Q7m+wDv56yHaBepvS9XgbXK3vj+Xb6ox/6nWMcSoEdjqzPzqA9tjsVTvJyGa3ww0M9K4lrk7QQEexMd1am0eHT/6UoLQBHeqxnV8kEeXMe3Ik6JKCvEn9hvAaeXbtff9hIHQlSVOV0ge+8RFEU5BAIeJsq9U9mr0JfgSrxEyO6KQ/B/brC5x22yR4eycQ3bdjtZg7AdbOkly8XyGWr1N8YJmzCnnekvE1dm91lOawMuQZAVVawwoOQL4WWayyEPz0W5pr8CvfepEAwW3hhw86dZpMe4C4BTK79uXUFVUxspzLfsshXpL5xpuXpvQKZilIXx1Si2sXjhSNrgouNPH8WQk7caNDqbYzhmQTCV84PVc/I0aVsF6L4u8kFYKmOEEc13p87KVH3UCLC0qrEU2STSl8UjkMhCfRT7EJT4SQ1Qwye8KPEDbS3ePWw1qh3VnaPnqHiTk7PWgEH1Q6MyhDYMaNPD129SdgYH0Nm90n1aizdwVOUCi7O2Wfbu/KiqQYu6QXS/gU8cvPjZ8sV6VAiOoaq0lqDWnBD4v+W6HieYXZ/r9q6IyUIdlRhcqBPbha53ItWEgtPg7rPIolFco9p54n+2d4yEYzw== X-Forefront-PRVS: 01283822F8 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;DM2PR0301MB0749;23:IJA6dXvjccrgvVuI/pBrwgeyCOdw8FVEER5JTlb?= =?us-ascii?Q?Q5ZBt85MzZYlwpNtagHK/d+2OZFxWFlaVhnj1camtK2cg9aMB2EipIWLZB7C?= =?us-ascii?Q?6mVQyqTaf2eGIzfszWd5l93qRNevPMOEEI/DIgWxo2e9/w6Dq8D9w8BmuMv5?= =?us-ascii?Q?Y3TopM/qe5TsgyGe6zth9egdO82jhoZdjKhN2Ru92jHOY1exhaxrr85lrja2?= =?us-ascii?Q?8qmPIN/N9cuoZL6gsM33ljuI6nPtJcps4M0LLN9Gvq/UwRkIWvTHwCRcq+og?= =?us-ascii?Q?9Tg7Bbdr0gAP7APsrjMti3nZxJrTRrk/jaReCFlt6/65LMCIuoNJEJBA5X6x?= =?us-ascii?Q?DPwFC+dDH6Po6nkz1vZIKiJDE0Ayuem00pEgg1A5+/1WsYdIz4tfiVSXec89?= =?us-ascii?Q?HVaz4XvhoihsW93YGy/CS0VqjDN1NQ2mJsFrKh9UsCyun+kJY5TdcvoesE9N?= =?us-ascii?Q?kGrPC7tqPMvMZdUihrxRDnSEy4OW6sGxAu1NDZNzohEvnvleqWf9jBuhCOlx?= =?us-ascii?Q?Uqb8M2UMD0sAl7B6EpV5yeYwgb8XIYhzq3RNPthBXkZVXbmyr57fbiDTvZph?= =?us-ascii?Q?8BAec5S0ig7cy7zneChW5JWZsWcdef9waVB29uw6NXUTZOmmxKYisOLRgSbE?= =?us-ascii?Q?IMiLC4ckTY8DCwEtWRjsvjBhrS8yQ80Q+/jSoj10Ei7y3mV9JeSZh9Jy2sxp?= =?us-ascii?Q?EYXGuUE1+teO4GezxrOJ7mRY99TFgJsnoMO6MgN3NqrTvJ5/jqdj/On2m3HG?= =?us-ascii?Q?qfoda9MU5807z5ewTYSnIIoj8nkToa/m63v53TIO1H+sJ5R5WmQtKC28zT3L?= =?us-ascii?Q?egww51U3q2tiW767RHPSMyjGVtwOqT7VqEhFBNNpU6QYDUNYWgRv1ImUkWKh?= =?us-ascii?Q?/IylYG/5l67eyJxHjdCmsPE6w93umBJ7B6XIEapO2g37D9A8hQLQlZ1TrDb+?= =?us-ascii?Q?qRFvPa7EZmq20wLwQ71cI3ADmAMDr/4GwS9SWODoGhRSElQemX7lNbH1sfMr?= =?us-ascii?Q?1er+3qwENM0NpCy074kWGTGNuUK2zzQBQhX1khtqYCzCVZkDZRDorr8xDOo+?= =?us-ascii?Q?/CgB6pxXrciRn9YHu6I0Jam2H9Mdl89dMxioVsRh2fKQp4Yg2izak67PoNiA?= =?us-ascii?Q?HhaUxXwZyLfZDcwq0SgoGdCArVl1tHNCY?= X-Microsoft-Exchange-Diagnostics: 1;DM2PR0301MB0749;6:4aDJ/Pd3qAmiJeSqsK0sdOuY7zNTSrfCriiOFsq66qSv649f4nvtuqJEYJqh2V7J2moex8O52aSmgy8c1kvpzKMRGUDbqJA8DS+buTGwmIqMAC6ECN4X5Vyx1AroDaXzA5z2F3ADGU4EKMqyRGhRy6DUnhNDC2k4fjArrslJtHtnh/MfPY3SAfqEARUknKnuZHTVWrs9ftKXc//1ykzN4x3/5jzyLIpDzk/05sUprynjDJ2ZTSZePzwTc61xhFwCb2p2X3fICYG7QnQ4Dg+S7lMnJpj3xGms4KNsTFrSBUARpGTGlqu//Si/bWHoNelAWAF7cnBZdo0rHMTfI2vkSA==;5:d+ya92yb6w2cFURHSyQ1gJhsaKi4C0Eg1DRQ9hH6XaP2zzZCWWebb4fM1AXHMAy4EVk2CYjSJCjipqW01PwlttzqXwwnsyG94hrl22aWiirL/nJiIwI9oHoq4/qSNQ7MV7HwEkYdO/Nh2larftHfWTqHgkMRHwRiGFpkzBm8RpjiLOz9sXcxJIVKlMaLKkXi;24:g+fgbG/Ik36lVrN2lKGQ0dfTyKML4Qs4B2sNOViHBqwWA5MNutTEJNtc0hJmnqHaMtpqE9J6hTFF8PMGCERF7JTpmLlANiMMQh4p8s0A3iA= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;DM2PR0301MB0749;7:aRsr8x7jBTf9kQpyxd/Vr4Fn97F9FI9/QjjX8Jdy0GcHvyI3mPh3uY8CcNuxCTdqGyWxCOXR0+GYV+UdJcecpZOAzi781pF4kIVSWS4hENJSMJxNfB3YENUb+QEsNlceAi0kbOQX4o80rttWLs0UJMLtt4QNk2LECtppHI+gUbouPbU0wUsS/rxnuAdU+RvYlc1IrtqlklK2p5ITBsHSdsSWgtHFSA6F0AGxQrkPON+KrqPW1I1kLaB7O7sxEezggpOrMlf835p+d+pikB/2BXzI7d9rlcwRp3y2Yw9oFH1NCs2CvPfcBK86jT/Kb81Rl5VWDOq5Z+2UsLF105o1MTZQzAX//DHH1DbqcleC2aw= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Nov 2016 20:16:49.0597 (UTC) X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e;Ip=[192.88.168.50];Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR0301MB0749 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 16967 Lines: 501 From: Ioana Radulescu Add the command build/parse APIs for operating on DPIO objects through the DPAA2 Management Complex. Signed-off-by: Ioana Radulescu Signed-off-by: Roy Pledge Signed-off-by: Stuart Yoder Cc: Laurentiu Tudor --- -v2 -removed unused structs and defines as suggested by Ioana Radulescu drivers/bus/fsl-mc/Kconfig | 10 ++ drivers/bus/fsl-mc/Makefile | 3 + drivers/bus/fsl-mc/dpio/Makefile | 9 ++ drivers/bus/fsl-mc/dpio/dpio-cmd.h | 75 ++++++++++++ drivers/bus/fsl-mc/dpio/dpio.c | 229 +++++++++++++++++++++++++++++++++++++ drivers/bus/fsl-mc/dpio/dpio.h | 108 +++++++++++++++++ 6 files changed, 434 insertions(+) create mode 100644 drivers/bus/fsl-mc/dpio/Makefile create mode 100644 drivers/bus/fsl-mc/dpio/dpio-cmd.h create mode 100644 drivers/bus/fsl-mc/dpio/dpio.c create mode 100644 drivers/bus/fsl-mc/dpio/dpio.h diff --git a/drivers/bus/fsl-mc/Kconfig b/drivers/bus/fsl-mc/Kconfig index 5c009ab..a10aaf0 100644 --- a/drivers/bus/fsl-mc/Kconfig +++ b/drivers/bus/fsl-mc/Kconfig @@ -15,3 +15,13 @@ config FSL_MC_BUS architecture. The fsl-mc bus driver handles discovery of DPAA2 objects (which are represented as Linux devices) and binding objects to drivers. + +config FSL_MC_DPIO + tristate "QorIQ DPAA2 DPIO driver" + depends on FSL_MC_BUS + help + Driver for the DPAA2 DPIO object. A DPIO provides queue and + buffer management facilities for software to interact with + other DPAA2 objects. This driver does not expose the DPIO + objects individually, but groups them under a service layer + API. diff --git a/drivers/bus/fsl-mc/Makefile b/drivers/bus/fsl-mc/Makefile index d56afee..d18df72 100644 --- a/drivers/bus/fsl-mc/Makefile +++ b/drivers/bus/fsl-mc/Makefile @@ -17,3 +17,6 @@ mc-bus-driver-objs := fsl-mc-bus.o \ fsl-mc-msi.o \ dpmcp.o \ dpbp.o + +# MC DPIO driver +obj-$(CONFIG_FSL_MC_DPIO) += dpio/ diff --git a/drivers/bus/fsl-mc/dpio/Makefile b/drivers/bus/fsl-mc/dpio/Makefile new file mode 100644 index 0000000..128befc --- /dev/null +++ b/drivers/bus/fsl-mc/dpio/Makefile @@ -0,0 +1,9 @@ +# +# QorIQ DPAA2 DPIO driver +# + +subdir-ccflags-y := -Werror + +obj-$(CONFIG_FSL_MC_DPIO) += fsl-mc-dpio.o + +fsl-mc-dpio-objs := dpio.o diff --git a/drivers/bus/fsl-mc/dpio/dpio-cmd.h b/drivers/bus/fsl-mc/dpio/dpio-cmd.h new file mode 100644 index 0000000..3464ed9 --- /dev/null +++ b/drivers/bus/fsl-mc/dpio/dpio-cmd.h @@ -0,0 +1,75 @@ +/* + * Copyright 2013-2016 Freescale Semiconductor Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the above-listed copyright holders nor the + * names of any contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * ALTERNATIVELY, this software may be distributed under the terms of the + * GNU General Public License ("GPL") as published by the Free Software + * Foundation, either version 2 of that License or (at your option) any + * later version. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef _FSL_DPIO_CMD_H +#define _FSL_DPIO_CMD_H + +/* DPIO Version */ +#define DPIO_VER_MAJOR 4 +#define DPIO_VER_MINOR 2 + +/* Command Versioning */ + +#define DPIO_CMD_ID_OFFSET 4 +#define DPIO_CMD_BASE_VERSION 1 + +#define DPIO_CMD(id) ((id << DPIO_CMD_ID_OFFSET) | DPIO_CMD_BASE_VERSION) + +/* Command IDs */ +#define DPIO_CMDID_CLOSE DPIO_CMD(0x800) +#define DPIO_CMDID_OPEN DPIO_CMD(0x803) +#define DPIO_CMDID_GET_API_VERSION DPIO_CMD(0xa03) +#define DPIO_CMDID_ENABLE DPIO_CMD(0x002) +#define DPIO_CMDID_DISABLE DPIO_CMD(0x003) +#define DPIO_CMDID_GET_ATTR DPIO_CMD(0x004) + +struct dpio_cmd_open { + __le32 dpio_id; +}; + +#define DPIO_CHANNEL_MODE_MASK 0x3 + +struct dpio_rsp_get_attr { + /* cmd word 0 */ + __le32 id; + __le16 qbman_portal_id; + u8 num_priorities; + u8 channel_mode; + /* cmd word 1 */ + __le64 qbman_portal_ce_addr; + /* cmd word 2 */ + __le64 qbman_portal_ci_addr; + /* cmd word 3 */ + __le32 pad; + __le32 qbman_version; +}; + +#endif /* _FSL_DPIO_CMD_H */ diff --git a/drivers/bus/fsl-mc/dpio/dpio.c b/drivers/bus/fsl-mc/dpio/dpio.c new file mode 100644 index 0000000..5f1ee19 --- /dev/null +++ b/drivers/bus/fsl-mc/dpio/dpio.c @@ -0,0 +1,229 @@ +/* + * Copyright 2013-2016 Freescale Semiconductor Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the above-listed copyright holders nor the + * names of any contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * ALTERNATIVELY, this software may be distributed under the terms of the + * GNU General Public License ("GPL") as published by the Free Software + * Foundation, either version 2 of that License or (at your option) any + * later version. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +#include +#include + +#include "dpio.h" +#include "dpio-cmd.h" + +/* + * Data Path I/O Portal API + * Contains initialization APIs and runtime control APIs for DPIO + */ + +/** + * dpio_open() - Open a control session for the specified object + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @dpio_id: DPIO unique ID + * @token: Returned token; use in subsequent API calls + * + * This function can be used to open a control session for an + * already created object; an object may have been declared in + * the DPL or by calling the dpio_create() function. + * This function returns a unique authentication token, + * associated with the specific object ID and the specific MC + * portal; this token must be used in all subsequent commands for + * this specific object. + * + * Return: '0' on Success; Error code otherwise. + */ +int dpio_open(struct fsl_mc_io *mc_io, + u32 cmd_flags, + int dpio_id, + u16 *token) +{ + struct mc_command cmd = { 0 }; + struct dpio_cmd_open *dpio_cmd; + int err; + + /* prepare command */ + cmd.header = mc_encode_cmd_header(DPIO_CMDID_OPEN, + cmd_flags, + 0); + dpio_cmd = (struct dpio_cmd_open *)cmd.params; + dpio_cmd->dpio_id = cpu_to_le32(dpio_id); + + /* send command to mc*/ + err = mc_send_command(mc_io, &cmd); + if (err) + return err; + + /* retrieve response parameters */ + *token = mc_cmd_hdr_read_token(&cmd); + + return 0; +} + +/** + * dpio_close() - Close the control session of the object + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPIO object + * + * Return: '0' on Success; Error code otherwise. + */ +int dpio_close(struct fsl_mc_io *mc_io, + u32 cmd_flags, + u16 token) +{ + struct mc_command cmd = { 0 }; + + /* prepare command */ + cmd.header = mc_encode_cmd_header(DPIO_CMDID_CLOSE, + cmd_flags, + token); + + /* send command to mc*/ + return mc_send_command(mc_io, &cmd); +} + +/** + * dpio_enable() - Enable the DPIO, allow I/O portal operations. + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPIO object + * + * Return: '0' on Success; Error code otherwise + */ +int dpio_enable(struct fsl_mc_io *mc_io, + u32 cmd_flags, + u16 token) +{ + struct mc_command cmd = { 0 }; + + /* prepare command */ + cmd.header = mc_encode_cmd_header(DPIO_CMDID_ENABLE, + cmd_flags, + token); + + /* send command to mc*/ + return mc_send_command(mc_io, &cmd); +} + +/** + * dpio_disable() - Disable the DPIO, stop any I/O portal operation. + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPIO object + * + * Return: '0' on Success; Error code otherwise + */ +int dpio_disable(struct fsl_mc_io *mc_io, + u32 cmd_flags, + u16 token) +{ + struct mc_command cmd = { 0 }; + + /* prepare command */ + cmd.header = mc_encode_cmd_header(DPIO_CMDID_DISABLE, + cmd_flags, + token); + + /* send command to mc*/ + return mc_send_command(mc_io, &cmd); +} + +/** + * dpio_get_attributes() - Retrieve DPIO attributes + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPIO object + * @attr: Returned object's attributes + * + * Return: '0' on Success; Error code otherwise + */ +int dpio_get_attributes(struct fsl_mc_io *mc_io, + u32 cmd_flags, + u16 token, + struct dpio_attr *attr) +{ + struct mc_command cmd = { 0 }; + struct dpio_rsp_get_attr *dpio_rsp; + int err; + + /* prepare command */ + cmd.header = mc_encode_cmd_header(DPIO_CMDID_GET_ATTR, + cmd_flags, + token); + + /* send command to mc*/ + err = mc_send_command(mc_io, &cmd); + if (err) + return err; + + /* retrieve response parameters */ + dpio_rsp = (struct dpio_rsp_get_attr *)cmd.params; + attr->id = le32_to_cpu(dpio_rsp->id); + attr->qbman_portal_id = le16_to_cpu(dpio_rsp->qbman_portal_id); + attr->num_priorities = dpio_rsp->num_priorities; + attr->channel_mode = dpio_rsp->channel_mode & DPIO_CHANNEL_MODE_MASK; + attr->qbman_portal_ce_offset = + le64_to_cpu(dpio_rsp->qbman_portal_ce_addr); + attr->qbman_portal_ci_offset = + le64_to_cpu(dpio_rsp->qbman_portal_ci_addr); + attr->qbman_version = le32_to_cpu(dpio_rsp->qbman_version); + + return 0; +} + +/** + * dpio_get_api_version - Get Data Path I/O API version + * @mc_io: Pointer to MC portal's DPIO object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @major_ver: Major version of DPIO API + * @minor_ver: Minor version of DPIO API + * + * Return: '0' on Success; Error code otherwise + */ +int dpio_get_api_version(struct fsl_mc_io *mc_io, + u32 cmd_flags, + u16 *major_ver, + u16 *minor_ver) +{ + struct mc_command cmd = { 0 }; + int err; + + /* prepare command */ + cmd.header = mc_encode_cmd_header(DPIO_CMDID_GET_API_VERSION, + cmd_flags, 0); + + /* send command to mc */ + err = mc_send_command(mc_io, &cmd); + if (err) + return err; + + /* retrieve response parameters */ + mc_cmd_read_api_version(&cmd, major_ver, minor_ver); + + return 0; +} diff --git a/drivers/bus/fsl-mc/dpio/dpio.h b/drivers/bus/fsl-mc/dpio/dpio.h new file mode 100644 index 0000000..743ceca --- /dev/null +++ b/drivers/bus/fsl-mc/dpio/dpio.h @@ -0,0 +1,108 @@ +/* + * Copyright 2013-2016 Freescale Semiconductor Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the above-listed copyright holders nor the + * names of any contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * ALTERNATIVELY, this software may be distributed under the terms of the + * GNU General Public License ("GPL") as published by the Free Software + * Foundation, either version 2 of that License or (at your option) any + * later version. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef __FSL_DPIO_H +#define __FSL_DPIO_H + +struct fsl_mc_io; + +int dpio_open(struct fsl_mc_io *mc_io, + u32 cmd_flags, + int dpio_id, + u16 *token); + +int dpio_close(struct fsl_mc_io *mc_io, + u32 cmd_flags, + u16 token); + +/** + * enum dpio_channel_mode - DPIO notification channel mode + * @DPIO_NO_CHANNEL: No support for notification channel + * @DPIO_LOCAL_CHANNEL: Notifications on data availability can be received by a + * dedicated channel in the DPIO; user should point the queue's + * destination in the relevant interface to this DPIO + */ +enum dpio_channel_mode { + DPIO_NO_CHANNEL = 0, + DPIO_LOCAL_CHANNEL = 1, +}; + +/** + * struct dpio_cfg - Structure representing DPIO configuration + * @channel_mode: Notification channel mode + * @num_priorities: Number of priorities for the notification channel (1-8); + * relevant only if 'channel_mode = DPIO_LOCAL_CHANNEL' + */ +struct dpio_cfg { + enum dpio_channel_mode channel_mode; + u8 num_priorities; +}; + +int dpio_enable(struct fsl_mc_io *mc_io, + u32 cmd_flags, + u16 token); + +int dpio_disable(struct fsl_mc_io *mc_io, + u32 cmd_flags, + u16 token); + +/** + * struct dpio_attr - Structure representing DPIO attributes + * @id: DPIO object ID + * @qbman_portal_ce_offset: offset of the software portal cache-enabled area + * @qbman_portal_ci_offset: offset of the software portal cache-inhibited area + * @qbman_portal_id: Software portal ID + * @channel_mode: Notification channel mode + * @num_priorities: Number of priorities for the notification channel (1-8); + * relevant only if 'channel_mode = DPIO_LOCAL_CHANNEL' + * @qbman_version: QBMAN version + */ +struct dpio_attr { + int id; + u64 qbman_portal_ce_offset; + u64 qbman_portal_ci_offset; + u16 qbman_portal_id; + enum dpio_channel_mode channel_mode; + u8 num_priorities; + u32 qbman_version; +}; + +int dpio_get_attributes(struct fsl_mc_io *mc_io, + u32 cmd_flags, + u16 token, + struct dpio_attr *attr); + +int dpio_get_api_version(struct fsl_mc_io *mc_io, + u32 cmd_flags, + u16 *major_ver, + u16 *minor_ver); + +#endif /* __FSL_DPIO_H */ -- 1.9.0