Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932094AbdCHV4d (ORCPT ); Wed, 8 Mar 2017 16:56:33 -0500 Received: from mail-co1nam03on0051.outbound.protection.outlook.com ([104.47.40.51]:45861 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752699AbdCHV4D (ORCPT ); Wed, 8 Mar 2017 16:56:03 -0500 Authentication-Results: spf=fail (sender IP is 192.88.158.2) smtp.mailfrom=nxp.com; nxp.com; dkim=none (message not signed) header.d=none;nxp.com; dmarc=fail action=none header.from=nxp.com; From: Roy Pledge To: CC: , , , , , , , , , , , Stuart Yoder Subject: [v6 2/8] bus: fsl-mc: dpio: add APIs for DPIO objects Date: Wed, 8 Mar 2017 16:54:44 -0500 Message-ID: <1489010090-18025-3-git-send-email-roy.pledge@nxp.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1489010090-18025-1-git-send-email-roy.pledge@nxp.com> References: <1489010090-18025-1-git-send-email-roy.pledge@nxp.com> Reply-To: X-EOPAttributedMessage: 0 X-Matching-Connectors: 131334837041229802;(91ab9b29-cfa4-454e-5278-08d120cd25b8);() X-Forefront-Antispam-Report: CIP:192.88.158.2;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(6009001)(336005)(39850400002)(39400400002)(39380400002)(39410400002)(39860400002)(39840400002)(39450400003)(2980300002)(1110001)(1109001)(339900001)(189002)(199003)(9170700003)(86362001)(356003)(5003940100001)(2906002)(104016004)(7416002)(110136004)(50466002)(48376002)(81166006)(8676002)(36756003)(5660300001)(97736004)(38730400002)(39060400002)(305945005)(3450700001)(43066003)(4326008)(189998001)(33646002)(53936002)(77096006)(2351001)(8656002)(106466001)(105606002)(50986999)(76176999)(54906002)(50226002)(85426001)(8936002)(2950100002)(4720700003)(47776003)(6916009)(6666003)(2004002);DIR:OUT;SFP:1101;SCL:1;SRVR:BN6PR03MB2946;H:az84smr01.freescale.net;FPR:;SPF:Fail;MLV:ovrnspm;MX:1;A:1;PTR:InfoDomainNonexistent;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BL2FFO11FD008;1:aTrG86Fe4yK8+WjDyVaN1LuGG79PoNmpjfS6q48/SvSQ3GLT/oVEekNahXQr0yIYiYuINwKUN48ISuWwQL+qeNUJhNqich/kYJUw0QUP5UcR11qcYLgnyMIVuq5oNXSJ6cUJ2srzLwSwRMej6Hw07+7j7nXlJZbseinczZvAIF/7i/JCiOWFCuMxFfdo/z+2wUV5yFkd0LEk7nZqcy918uQrwCFYFo0UIigTg4xwWY17Ew+xyMmeta6ImNNZEstJM9vvY0vFeANU2OyMzULKB35Om5+YUdSgaRwWhQXURlhO56+U4cSVAK2aeZZPkoiCRWU70sIPUJ3t+r2vVBEyseOwQjnhS2jFi8Q6zZGYM9xqeAav+ZYV3ctbS0dFssyefVlTcIie3xvch7mtk7HFAiWJ3vZMDth2enccr1zP6pOh+ZLOo1ahz7X9ahWtJr+0k/6lmX+aVrfOmfEUlhdGXt1Yl4x07CSdfWFSJ8c9y28LO/tcD1dGl6FVn1VaqEmkvNYLN1Nm6t/BQ1vDYs6u3QRKV0l9Uptuv5mhsTYfWiNA9GvknioUP7VAv2a6NIRhA0G/yb5HtkRGk1d1wWAKKkiiJtLe4Tp6dJeOTI859vW873AFneY7+ALBb9VV70PzRVs9pqOXZ6TJfjqK5DCj4vmgkB3yrYvFN4FtdlEE2m/MKwJiXqmkG24+L6cPirkrzOyMOEWlUFak3uLDp6OLAQ== MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: f43eab12-56aa-4110-2d2a-08d4666dc6ec X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:BN6PR03MB2946; X-Microsoft-Exchange-Diagnostics: 1;BN6PR03MB2946;3:9txEa/aJMmlTfgytUpaTxlbzsYyodwos7rxIvQ4Iz5PtiR32Vi2OgzBN96PSZLhqV8xy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RexoHw6SVlTyLwzDRN+g== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(35073007944872)(185117386973197)(275809806118684); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6095060)(601004)(2401047)(13024025)(13017025)(13018025)(13015025)(13023025)(5005006)(8121501046)(3002001)(10201501046)(6055026)(6096035)(20161123565025)(20161123559025)(20161123561025)(20161123563025)(20161123556025);SRVR:BN6PR03MB2946;BCL:0;PCL:0;RULEID:(400006);SRVR:BN6PR03MB2946; X-Microsoft-Exchange-Diagnostics: 1;BN6PR03MB2946;4:+j1jjfnkxKfmBUDrt4Ci6q0pASN7+VsncQirMZQzX9N75G+qLy4M6xzViI/4T2wJT+Gbp2FgOl4oSy3PSoRSbKBlZaYKAmKWOXI1aA1/ImJIRgmAwtMsOKv8RZ3P7uAMEehFigomG0lJAK+GldIS3YyHIGwBphYnq2MLMhkxAMoaI8QF+oN6t24lHC21F2sLyRroWUcYc+cbNDEHLCq3fVg2W0uQNSwOk/uwyYEotlcWhxj3wLYCpEO6HKiwMgPOr1NJ9fZtEr8/yJwqtAhOEh7ZEoRzjpF/eg8HhhF/BRQ4aHDRm3xsb2XxZTSMT/BUAQ9B0Pw1ehN2I9cxTsI7t7D+2PqyoVkuCZLgu2wl5x9zpNd0nTT8up86MoxqRP6jdmCJKXpQiUwYTs5oUsWzX2wmpHb/bCRbBYXLOAL/rXD+wFVK8RYuURW6G4VPSekBUClOITEqbCIaBFJNhHXexLn1NhoyiWPmtVSrw4bjCkFQ/JCFCyiLoeilVovfDwL4xAkNz9FcVfLdLTpqzM2nFHe6Q7CANBGneY74cxVi+JEuz/FqbhJBOhGBDbFBDAOIDAf4/9ypnj3Y/P0ZGeEDki5syRxFIXvrdwq27PDgZn1PXdeU3x/GDHuVL948J5K5jS6lJ6WoS1iVYJ0L+9Yz9bcaHN3ATtrPS3qjOs1yw+eXoAqMIEKSRfSKn3+J2m5WrBRB1mbb1/cFzgoN8hS2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fPFT36TOQsjFdhZe995y+/Y8U2/uH5ci+VX1YsokCBXcAIh/IoOs3n9Nvz7mMCvxodjZEpzqS3FVB1N42E8Vyyk9O8gN1DIteXg2q1sQH6exuiCxZzdCbm0/z2X08HVrpFkjd7o1C/svQFae6K+St70/WuagYKYC0R7PXESJ8YOvuk4KRusaMHJ4y0m33ldVEq4vCZxNdJ3Oh2wbCBZ9GiGHdw=;5:req3MNi7WiEZ1Z0laTkSFWbLG7ttI50XIWKZFaYt10I1MhOTftFB3zaBI7M1mgB1vzUVZLNDzfeERLe6YVkMLooMT+OPXfu58WaGNVtQ1Ju8O2FAn2aws6VRwRWV98dU3FMUTya28fy2ttjQMXsEXqE8802NB3Su1o70r+T2Gr150lodk7H7t1O74Pm2qAkj;24:SPq4luWhRNxdCpyA1A1AoDPxLgSXR+yfWjWDFKSHATR4Ro0810orNp2RMQ4L34aLyEM4Zmh7uGYMLcSJ5e71McBLp35Fyn8e8xcAiLV/+Wg= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;BN6PR03MB2946;7:da9RxWyNgSHDOzk+6JZBIxu1d011hioPw5igrBgZqo3m1gOsMLDHbe2LezEtCdILeH0byQoCpYc3NhbsJm8l5dx/sl2DTtr+ATvElOsqZqvBkkJQcx8xAYNPMXkPqfB2Qr4EFq6pgdC9icJCo0j7i1a7MVIU8K2VSfpUTBBhj8hvzRCxOkf9I84sEZOYTf+xD8WwVCpH9qWceM+T7Lq852vuD8gFVJflUI/6pEviacq86y1F93tZ5mzZ1JqYunvVRu4Qrc6nNo+Lee1u/5oKjwr/nAZUnYEsml9bE0tk3k1gpE/59Y2j/69wDs5iX5rtqp8YLLi++E9VwClGGYPDQg== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Mar 2017 21:55:03.8733 (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.158.2];Helo=[az84smr01.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR03MB2946 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 17003 Lines: 493 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 --- drivers/staging/fsl-mc/bus/Kconfig | 10 ++ drivers/staging/fsl-mc/bus/Makefile | 3 + drivers/staging/fsl-mc/bus/dpio/Makefile | 9 ++ drivers/staging/fsl-mc/bus/dpio/dpio-cmd.h | 75 ++++++++++ drivers/staging/fsl-mc/bus/dpio/dpio.c | 224 ++++++++++++++++++++++++++++ drivers/staging/fsl-mc/bus/dpio/dpio.h | 109 ++++++++++++++ 6 files changed, 430 insertions(+) create mode 100644 drivers/staging/fsl-mc/bus/dpio/Makefile create mode 100644 drivers/staging/fsl-mc/bus/dpio/dpio-cmd.h create mode 100644 drivers/staging/fsl-mc/bus/dpio/dpio.c create mode 100644 drivers/staging/fsl-mc/bus/dpio/dpio.h diff --git a/drivers/staging/fsl-mc/bus/Kconfig b/drivers/staging/fsl-mc/bus/Kconfig index 5c009ab..a10aaf0 100644 --- a/drivers/staging/fsl-mc/bus/Kconfig +++ b/drivers/staging/fsl-mc/bus/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/staging/fsl-mc/bus/Makefile b/drivers/staging/fsl-mc/bus/Makefile index 38716fd..577e9fa 100644 --- a/drivers/staging/fsl-mc/bus/Makefile +++ b/drivers/staging/fsl-mc/bus/Makefile @@ -18,3 +18,6 @@ mc-bus-driver-objs := fsl-mc-bus.o \ irq-gic-v3-its-fsl-mc-msi.o \ dpmcp.o \ dpbp.o + +# MC DPIO driver +obj-$(CONFIG_FSL_MC_DPIO) += dpio/ diff --git a/drivers/staging/fsl-mc/bus/dpio/Makefile b/drivers/staging/fsl-mc/bus/dpio/Makefile new file mode 100644 index 0000000..128befc --- /dev/null +++ b/drivers/staging/fsl-mc/bus/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/staging/fsl-mc/bus/dpio/dpio-cmd.h b/drivers/staging/fsl-mc/bus/dpio/dpio-cmd.h new file mode 100644 index 0000000..b2dc6e7 --- /dev/null +++ b/drivers/staging/fsl-mc/bus/dpio/dpio-cmd.h @@ -0,0 +1,75 @@ +/* + * Copyright 2013-2016 Freescale Semiconductor Inc. + * Copyright 2016 NXP + * + * 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 qbman_version; +}; + +#endif /* _FSL_DPIO_CMD_H */ diff --git a/drivers/staging/fsl-mc/bus/dpio/dpio.c b/drivers/staging/fsl-mc/bus/dpio/dpio.c new file mode 100644 index 0000000..d81e023 --- /dev/null +++ b/drivers/staging/fsl-mc/bus/dpio/dpio.c @@ -0,0 +1,224 @@ +/* + * Copyright 2013-2016 Freescale Semiconductor Inc. + * Copyright 2016 NXP + * + * 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/mc-sys.h" +#include "../../include/mc-cmd.h" + +#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); + + 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); + + 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); + + 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); + + 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); + + 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); + + 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/staging/fsl-mc/bus/dpio/dpio.h b/drivers/staging/fsl-mc/bus/dpio/dpio.h new file mode 100644 index 0000000..ced1103 --- /dev/null +++ b/drivers/staging/fsl-mc/bus/dpio/dpio.h @@ -0,0 +1,109 @@ +/* + * Copyright 2013-2016 Freescale Semiconductor Inc. + * Copyright 2016 NXP + * + * 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.7.9.5