Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161197AbcLPQjd (ORCPT ); Fri, 16 Dec 2016 11:39:33 -0500 Received: from mail-co1nam03on0087.outbound.protection.outlook.com ([104.47.40.87]:34720 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S935426AbcLPQi5 (ORCPT ); Fri, 16 Dec 2016 11:38:57 -0500 X-Greylist: delayed 59675 seconds by postgrey-1.27 at vger.kernel.org; Fri, 16 Dec 2016 11:38:57 EST 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:928;Count:10 From: Stuart Yoder To: CC: , , , , , , , , , , Stuart Yoder Subject: [PATCH v5 2/8] bus: fsl-mc: dpio: add APIs for DPIO objects Date: Fri, 16 Dec 2016 10:31:00 -0600 Message-ID: <1481905866-10816-3-git-send-email-stuart.yoder@nxp.com> X-Mailer: git-send-email 1.9.0 In-Reply-To: <1481905866-10816-1-git-send-email-stuart.yoder@nxp.com> References: <1481905866-10816-1-git-send-email-stuart.yoder@nxp.com> X-IncomingHeaderCount: 10 X-EOPAttributedMessage: 0 X-Matching-Connectors: 131263799345121661;(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)(336005)(7916002)(39450400003)(39400400002)(39850400002)(39380400002)(39840400002)(39860400002)(39410400002)(2980300002)(1109001)(1110001)(339900001)(199003)(189002)(50986999)(5003940100001)(50226002)(305945005)(68736007)(50466002)(4326007)(8666005)(47776003)(2906002)(356003)(6916009)(2950100002)(6666003)(110136003)(8676002)(8936002)(105606002)(38730400001)(81156014)(81166006)(33646002)(48376002)(77096006)(85426001)(5660300001)(97736004)(104016004)(2351001)(86362001)(189998001)(7416002)(76176999)(626004)(106466001)(92566002)(36756003)(7059030)(2004002);DIR:OUT;SFP:1101;SCL:1;SRVR:DM2PR0301MB0749;H:tx30smr01.am.freescale.net;FPR:;SPF:Fail;PTR:InfoDomainNonexistent;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BL2FFO11FD040;1:BEflF/jMv8A5Zf2BJojfGhkigRTVBx9KhN5zlID0qUwmYnefzAqsaF3YvU3Aj+I08zcZbG1YkPMqo3Ge31Bfg22BkqQhq/W58PQtw7pHDnMr+BDwsiBaHJK54Uo+RmQXOhT7LVnoaqENNJxE3KHfnQEOjZgo53HWxoyaBx1PBA3MuwM7ab1AFdI5OGiVESGVflCAT549ByWLKdJ3yEFTtRKUiEOyr0tFp4/kobupsXm43lRjWruOiv4RACwEzad4tjEwtkz+8pFKMnSkSyz/g/moW9lTek4IBW3Pk//IM/7XFXmykDyLq+5LHDquY9RCz/N4tfLrd/hKUxlj6W1rAY7Ul/opAmHWw7P9Fn00wSdfpIXck8F6jJzlaMyTP82t3L1dvI7ArGUqTx5TZz9A3wupbvMAol1c4UWFW+8CW4dYskyQ9PVWmlxHiFRIFIsyemSqBi21AqzhUic1GeMGufO+4v63RDzDEqwfVkHJ0g19xFEenKe1niXtOzhu9e9R0LvJHLkv6YYpFZ962nRpFeLjYrkkDUWp1uaeYPLFnKMZ4+rDCpbmKTx8cCjR+oRB8j6uETPcgXQr1+vECwyS8YNlmwB3XKq27OoaOvkJsPvWTdBYcymXf2j7oMzZfPKOM6Xg1eIcQcKB8r13Dj7JUo+3NGxDwMP5sQmBCcnno1fEXRSmBh4/MyuDHiJsPniaeYlD5RRApnSkkqLiR+7tkDntNnYDHeAySD8oPaRx3AI= MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: d4a31fe1-7bc0-4519-897d-08d425d2064c X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:DM2PR0301MB0749; X-Microsoft-Exchange-Diagnostics: 1;DM2PR0301MB0749;3:3OIji2aI6/wtTftkL0LZKNTgwURXL74Ui6/eomU/7Ud0s5U5R/cTYwbpeR+h5dqpWiYdmOPOqIw4GgEU+NCjpdg3J1hLzAzv3YSa2vlVkxZeEVbz0xx8d6PMpAXUk3gpaWIcK9FzMufwwHV/E2LoMROZLNdqiLFazX1DhvV7ET4u8lHxd5laNA2TowcZBf0yub+tfz/t/maiQBOM3AJouz+tBwLdJdv7y0sJCEP/u9+vvNChyaC7Y/wrjpU/L6DPJ+ldCi83JK2gT2C3QmWkFILfWvrhvJQD4yGwqY+4KTu6CDWw5zVIGrdfAHeTsO9lY1Sf1rO+k9+eFtYgOgy1qkVqUBsrbkIUGFrbCQFcvaGuRW2xURmyoMuhaGqTe7io X-Microsoft-Exchange-Diagnostics: 1;DM2PR0301MB0749;25:s2GS3ezl3awMppa+LnIGMjVD3zB+G9Bq9qtNwikS84QprCpZHjtworbryfSU6m+XoxI8SjyJ44rRnxOlbe+xdguQY4h+BKNIHrD07C/bW/VSKpjDp8qILw0/TxKly65tHCfyABnayGQ5xuJS2fyPxb7wb41966Lj4sCG7rAc3dvx/LH6eYmSDlhanYVDQsTFswd7Vkcg6VjcekW4MecdR+1psiSgczxv377dz0jzHPon3G2KE+VCbMJSHFjH9U8roqg+lfAA+yG72fVYwrIeMJdhuqn5eney/dOnuiDotkkuJIPKFtOQ78dprhbp5kyDibbSU/i5kashx4oQdp9IqDDKYMg/k6a4wSFTbbG6vfzrlJ+7SccguUiO6vKLrpJFT9YplBqv5pUNzdx3IlXgo9oPUYVsgmyJhllYQSzX/RCjb/6O8b2VYGML6eJNngBTZADRx7B7eQKFFlEJ+r2ecMXZ/hjQlBbQcAKl8vORfMqBqRSI/i0S2zOXeht4Mou/S4wZsOZpddClePAxnyBjRt1FHV21CGfZygb6NKgFB+gpr++4mXkJytApYhdjgUQvSiOIf4dNow2u5cpC0RCWRAg+XtKOm0qBIIde5mxlG6Eud/x6rvTswI5CLDmoC6RiqoWsOzoL2nrjN5jDlgTbJvbty1ZfWU1EyzhZXj1s8t8XABfhTIZ1rxBLBB7ejy6/5MZM7nd0SWdi65XvTFkQhQhLM/bREfWknj8hnHgsAsHjSIorIa6Nij2x2a7zZVejY8l291WFhwUhWINAf0dyASZv1r+sErucL49GUOQJn3Y= X-Microsoft-Exchange-Diagnostics: 1;DM2PR0301MB0749;31:9GLYm233qBZRuh5MNZapZSGgKRcFPXfHHdgM1RVJsY9pwWJ2VAijZ2F1lSCeyq0mrocksBKcNddcLCak6Ll04/nH4Y8c9UHz3kFwnIy654AYRzJPxornp4g9uYSv25SH13QmMJ+eVFYBc9QTZPoy2ppM8XsUsInpNwjYqvTCQnDFAu1MORp9wXwMPU1jDZ5jWTilMyXALSw5CEodi1U+NOukCNwR0Z5U4BGL2SExSaG8z5c/ncZGRDVV7nzbL95l1yQArF2HH8CIcUTSpzxDyW/FIWuSD/AhMMUrhQ5dZG4= 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)(13023025)(13017025)(5005006)(13015025)(8121501046)(13018025)(10201501046)(3002001)(6055026)(6096035)(20161123556025)(20161123565025)(20161123559025)(20161123563025)(20161123561025);SRVR:DM2PR0301MB0749;BCL:0;PCL:0;RULEID:(400006);SRVR:DM2PR0301MB0749; X-Microsoft-Exchange-Diagnostics: 1;DM2PR0301MB0749;4:7Dm7Mz9fxE82nkjhWgVxL1tDTxEW+68nyfGcXbYX6m0Ilk7i+57/cEBy2DIe8mD3hPC7H3hcIe5t57uajxrepECrazQ7q/tlsUfWpuNEPOlTfzXGFeAAKfU2QpQuK6hSrez81fdRXKBpqTMrSqEziR3jF+LYOx+lkGEQmlgfoFtqqOQOqScDBIgjuMd9ws0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4PhLcS?= =?us-ascii?Q?247VPnxNEfBUxpN9HU7AQjjlHDKRVW/v2pPs8+X/rH9n7K/AsCDotoxCld6u?= =?us-ascii?Q?TgOh+8ryUVsZNC+1Yyj1TEUjRp6hxAm1eInqUio/wSoinkMrTcvgiZ/Nd+Qj?= =?us-ascii?Q?qjsJMZR8QbccrFmIBAEpraq4=3D?= X-Microsoft-Exchange-Diagnostics: 1;DM2PR0301MB0749;6:McJ5+NF8aIVsNRYR6A/SNQsRvm4QkT7I8vqPhJMSims2M0XphjVJ8+JQFe0/66CXfFyBLkmb3TdC9slHXyTCyK4LEMLqGF2sT0+JvYm3ZjhArqiY2NK1WZVSokFE4hd2hgZvtcL/Kh3Y2sfwny6dxQBYWDlVNYKwXTjoqWj/Fg2Qs4snSoXk/dU1beqDiOPGIoEfjY7gP0HjOW6ZKhNEjpwZcHYQXIs+NUaDAYVpoziMFJtEjnDydYXNz3Q6FfyTJV8wYavz7eQiRExKada5g+hVhWQTatAOTPkRWk3SScBoWuwXIreZnpEFgkZNXPSvdyE94kuyKAPVoPCYj267wgTSo9K8SVkfdlY9H+QmkqXa7b56QoplrW0fHJja7Yl+2OgCS2gDpGZaJ1ccx9FTjpzK/1EnS2RCmJlKx5sQW/fb/uWWaW9s6auiCo2hzsyN;5:Eyw9LslJlI4nXskOHg097iGMGK8kMS++FPmOgmdgzWBiGy4JQcf9O70bg2mPbt5AKzLEnpDY7zkn/ydd2xjXfIvl6omFvCNqD1X+2x8JrLPZHFSev73QFk1klvJo6qjW/Wa3l60fzC3+HlynNOn5bnhYzGizeLTBBgBF8TbSv5QNZTORBpOkIc2F9DBirM32;24:xr89w3R6gzlJ5+iiXgX+FTY1ZEOkxvolQyTCxjI1gHAnmcH8lkADCDteRiaQVsS694ZpqHFB7wQGpcVnKMyY+s0RR637CG4fqBFjmEVFDdo= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;DM2PR0301MB0749;7:N81FeXK2Mf4yeqjd50iKgCewidjEwl/TvDiSGnsXAY0W6ei9A6nThKF0qLkew6G1B1yFrxp7nwLRvggg2lfxHYzlWGtie86CeEC53v7Sei/gN9W5h2rZB65EIN0T4mNryVhK5/3jLMRkkvlGyC0A4Svi4kLwxAAaThTtyyPYp71SC5hdT37Eabu+wHPVwu2t/QiU/kxlVmZi+HdOXttyjVcCb8PeThe/7JADqz45wcLfmNKW52UPEGq/9pHDwIyB941P9vA1R4UKDO3YwARG0HN0aeZ9xPMX0G9hKXbPnL6/fR8mDlylGiqWOyu3Agx4I0ovKs4DIf9lPJBvjiz4Eny7/tPrtu3vJ9+jHrt6ETGV+l7NCbp5Ao7zdfZoyPmzIdE1JntxP/opSe01rAS8GVchQbD0bQ+nWqscLznf7Bx1Y/o0aYFMNmJmpdHbXaORHb3ezws82IwnkfxsHSa0kQ== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Dec 2016 16:38:54.3405 (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: 17211 Lines: 505 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: -v4 -adjust file location to be in drivers/staging -remove unneeded comments -updated copyright -v3 -no changes -v2 -removed unused structs and defines 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 | 76 ++++++++++ drivers/staging/fsl-mc/bus/dpio/dpio.c | 224 +++++++++++++++++++++++++++++ drivers/staging/fsl-mc/bus/dpio/dpio.h | 109 ++++++++++++++ 6 files changed, 431 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..c237d5f --- /dev/null +++ b/drivers/staging/fsl-mc/bus/dpio/dpio-cmd.h @@ -0,0 +1,76 @@ +/* + * 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 pad; + __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.9.0