Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756713AbcLAWtd (ORCPT ); Thu, 1 Dec 2016 17:49:33 -0500 Received: from mail-by2nam03on0089.outbound.protection.outlook.com ([104.47.42.89]:57527 "EHLO NAM03-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752715AbcLAWt3 (ORCPT ); Thu, 1 Dec 2016 17:49:29 -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:937;Count:10 From: Stuart Yoder To: CC: , , , , , , , , , Roy Pledge , Stuart Yoder Subject: [PATCH v3 3/9] bus: fsl-mc: dpio: add APIs for DPIO objects Date: Thu, 1 Dec 2016 16:41:28 -0600 Message-ID: <1480632094-3621-4-git-send-email-stuart.yoder@nxp.com> X-Mailer: git-send-email 1.9.0 In-Reply-To: <1480632094-3621-1-git-send-email-stuart.yoder@nxp.com> References: <1480632094-3621-1-git-send-email-stuart.yoder@nxp.com> X-IncomingHeaderCount: 10 X-EOPAttributedMessage: 0 X-Matching-Connectors: 131251061352406113;(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)(339900001)(336004)(189002)(199003)(5003940100001)(189998001)(50226002)(8676002)(81156014)(81166006)(47776003)(8936002)(86362001)(38730400001)(77096006)(305945005)(39450400002)(50466002)(48376002)(85426001)(39410400001)(92566002)(36756003)(39380400001)(39400400001)(7846002)(356003)(2906002)(33646002)(4326007)(8666005)(626004)(104016004)(6916009)(50986999)(76176999)(68736007)(2351001)(6666003)(97736004)(106466001)(7416002)(110136003)(5660300001)(105606002)(2950100002)(7059030)(2004002);DIR:OUT;SFP:1101;SCL:1;SRVR:BY2PR0301MB0744;H:tx30smr01.am.freescale.net;FPR:;SPF:Fail;PTR:InfoDomainNonexistent;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BY2FFO11FD032;1:/1JMdzVo78HchgpGLLmbCn2jKeErRXFKT8TUreT6cyOXcWTQ1eGuGeMiZk0VHDGisZYWaEGkuQUulIQNO2lAlsREs7l2QJ/P7uLmOJpylgydEF0+GZbTZVyUh8c0zH8h3hfo9B94jU0qlTccDXv3Gvex6rM0XVwTlYbAKC3/rwLWsm54fCuA7FMRJYnIQXhtFWuU7uZEnohpagTY3R7X6lQIYJW/dfO+if8xef8iLIRsGRUP566MBoj2DrcXwOGco8BGXbEZBkIbqRs/yB7xReF9nzG7rq1sopU/Fum1ATqFWa5GmhL2Tt8I8Sc58mg01xEYFaq0eQbbJDHTxsEBipEBkyuLEeAr2aL49RJl9Cu0u6PQ5s7ovkFaJTp4jInHA/SOYEpTmuoXRq/K1imiKUmvx5zO2q3+cn0/IBAtkAhEM91hQrtp41Ey6xH+kxTzlNoRzKzfb2WIzS5b1AN1DXhMTi4kbHcjELgji5P+a8lDPgwR9CpdcTjV9ZaoS0mWnBeTZ8Hac9kqptqpLFxzbVb/blCTwqf3yvtFOrtnYRkRh7qNHLjU8+/0D8YFYJL/hOqoKNCiw+wJTxSR5xEQtPIoQIJA5BS2bs8fzS9Ykvwwv8HbjJUFLxRFoBjxTjF9jeBM+xvLLYdsCNKM3FnmzYzY9rn7iuP4GYI+Qpo6glgB1/GGvknY211VU2emxND8Y3k65RWyQHpy3o1Df3HCPKM4+Vyc/iN8fsTZgAtW1eA= MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 84360515-d5b3-453a-3b02-08d41a3c3ac2 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:BY2PR0301MB0744; X-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aZYjajDcNz+r5CwNGLmGHajnTvM3bAAGyklLSSUKUGd/Gj4RojploZekXc5/3cw4XWOGN6d7l9LbrcfooR/fJ6maZzit3LFwgzYJ7nXDzvpL7XIcBhpH1f0ST+RGq6Njd1X8kP+/kq2CQ6XtY6dLjria2a5OmlfaqySU9ufTMuL4PaBI0kAxRBuFXKlT6zusLNZs1I= X-Microsoft-Exchange-Diagnostics: 1;BY2PR0301MB0744;31:w6VbYltAJpMMgcUF2Vl2awtmQ8y4StI+TYtuI1tFV9tFhmgPCAvcUCV7bVnqbH/Xy+cDoZwgSUnSu9ipWMMfyyUwmYF8dpsxeoJwIq/tX1hbVKFpZve25/GdZ6eHXG8SW9HPUFyN3gLKMwBhDglV2pdLGw+X8yLtbBhsh15w+jTXXL8lFsRV8g9mkqfm8JnFpA6MiyemmB3cmG1V10Pm00H2GM9W6YXJKGyjuF2i33qOZPogOZGbxuDPcHIpSAWtmu7UuuhZRO0ZnhR7k5xIpg== 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)(13017025)(13023025)(13015025)(13024025)(13018025)(8121501046)(5005006)(10201501046)(3002001)(6055026)(6096035)(20161123565025)(20161123561025)(20161123559025)(20161123556025)(20161123563025);SRVR:BY2PR0301MB0744;BCL:0;PCL:0;RULEID:(400006);SRVR:BY2PR0301MB0744; X-Microsoft-Exchange-Diagnostics: 1;BY2PR0301MB0744;4:UIsbGs4mh+JwtioKx+Ct7EEktBmyr0/5JnibZS4jILRUAtMn0lQyH7FSSHFL9z9FrdiSxCUYsE88HUtBp4laGZxnsWQhCWmNXHeKQcJGhfN9U1DQxQ6CRQtC9qnjVly1p9kYjpwTXUYWDhzIAi+7rqy6BiwDIcaOQk32hTc1VqIhiPvbuMXXbHQ0y+2mWr18wp0kFyGDnrfJde2DYlz2ENYSfuNRD0WhUxHnKF3U0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r2j1G+e3k7lwV5W6BGuQErFaComGzwcQBXa3n+XZj5D+SoOycJkuEAhs48B+0brfOTFRu0TaGrnmAA7wUwCCU80eH5PdTY9Tc0nNeoJOHpAeqvC4gzx2ssbqixRnCwssppjvdy7ccZkvr6fMV0wOTfP+odLalLoB+mdKDBmZkj/rSJP11jwm769jh/DaCQMKsKMzthFAj24gbrwvGBseGTGM+HU9dP2y4vSKO+1ozn0EFYZ4+59EZS0p3X9cDLsfsxXNzctQyLz2+BN35AfQyDil3vgBC+masgAKK61KeDOzdC+ztBjDsV2YVgnCUQW3E5s3ZuI32AL4FfPZxOFWrkmvM31bA== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Dec 2016 22:48:55.0378 (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: BY2PR0301MB0744 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 16931 Lines: 504 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 --- Notes: -v3 -no changes -v2 -removed unused structs and defines 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