Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934143AbcJUOJ0 (ORCPT ); Fri, 21 Oct 2016 10:09:26 -0400 Received: from mail-sn1nam01on0042.outbound.protection.outlook.com ([104.47.32.42]:46322 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S933408AbcJUOIM (ORCPT ); Fri, 21 Oct 2016 10:08:12 -0400 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;nxp.com; dkim=none (message not signed) header.d=none; From: Stuart Yoder To: CC: , , , , , , Ioana Radulescu , Roy Pledge , Stuart Yoder Subject: [PATCH 3/9] bus: fsl-mc: dpio: add APIs for DPIO objects Date: Fri, 21 Oct 2016 09:01:43 -0500 Message-ID: <1477058509-12547-4-git-send-email-stuart.yoder@nxp.com> X-Mailer: git-send-email 1.9.0 In-Reply-To: <1477058509-12547-1-git-send-email-stuart.yoder@nxp.com> References: <1477058509-12547-1-git-send-email-stuart.yoder@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131215324820556132;(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)(7916002)(2980300002)(1109001)(1110001)(339900001)(189002)(199003)(97736004)(69596002)(48376002)(36756003)(305945005)(4326007)(86362001)(50466002)(68736007)(81166006)(50986999)(19580405001)(7846002)(2351001)(105606002)(189998001)(586003)(229853001)(104016004)(77096005)(8666005)(8936002)(50226002)(356003)(92566002)(6666003)(87936001)(33646002)(6916009)(85426001)(5660300001)(47776003)(5003940100001)(7416002)(110136003)(2950100002)(81156014)(19580395003)(76176999)(8676002)(11100500001)(106466001)(626004)(2906002)(7059030)(2004002);DIR:OUT;SFP:1101;SCL:1;SRVR:SN1PR0301MB1629;H:az84smr01.freescale.net;FPR:;SPF:Fail;PTR:InfoDomainNonexistent;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BN1BFFO11FD027;1:NTxw12HLtlPl7/JUjwG1q3zuBheGtSvoMTDpRqNpWWfwF8AzMicBaJ41cHhcjSiOySq12fC+XxXvnKeRPfYFlkENE/s5VvPfXSq5I7iq5LuUbyJbMpi9vV4tNPYn25qci3M1cfFUhFIBQdGCXnGSfLHLHhj4T50jdRO0oGg4/aOL2YUxZmyucf60/92rMutw2AxYSQP+kVWPCjkXi4xdqDh7gijgSM1qRmq30PdCjnTtAgTCZbnmyvfaRKDGeCwhrqRLH9tI3BqOwQHB/ZDiBOf9E8GQdfU0AqzEHW16a0G6iotseRrDUA0rDVNCXmxdWDpjA1OT4WYueo2QKq+8PfRBSFgJae7yVWDRFdSXfaNoyGFlfP0O0DUNqcxksf8zVa3GcPTcX7MRu0I/VPKvdWRFKJqs+X58cnbmdCzqf122KKvuFb5rRyQQqwScHiERq3NgeT07nV7znZSo8B0EK9qS7rnVHjWTIr/GLWy5mWt7oGU1B2Sv4AlJCGCx4F3GWRw2IpbvjtLdDby75aWC++D2JJkB5WBD4Z+puSmRfjjhW8IU/bWhPdQjppLntezXueA1HlJzsEaxoQ+e1fpBYQonhTiOt5m/9Dy7+BtLU78UxkdS0/uOp3OjJdyRNKI8tufLxmmRWqWNoUYIOf5M1LxhtMHi9kmuTpYbfc8/w7L8Xf3vGEQDVeCvKWojrJdqnW2Z0fJdvYyhnwW8vvI45i2AM+YpDM7g61KP8cWHlt8= MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 0099b91c-6c9a-41c6-e802-08d3f9bbab78 X-Microsoft-Exchange-Diagnostics: 1;SN1PR0301MB1629;2:GEL1q0jXrbXDlHJqWuYVcHt9BhIz+l+zWv9qqWzREAZ5e8BPf1YKMvw6d+ZxGbiWEWmlslqomQsUtObAWZkAIiFCqBEBAcwBuXSxcr/LfmpspL2cgGDUafslspoAaaaNPfrCvTUgzlx+WZTlLRTVgCQyK/PbDRC7BkP+X1B+u3t96AEpFqTkVS7cNoQjvmswv0y7LEkSAZAxjhOuShQYPw==;3:dvUWWBzZugnNMacuwFC2PNvjgR82Zkf6PLxbzuNltdTxey5qFBfNDpy+6ZRchxUIMqJWupk+UdvvtsRsUn0hpAS895YkkwzvTQfRQE3BneIDs2KATxE4FzWVf/2krZgX570UHFF1wQNdqEqmqNDKrN3AQrhXjycm1EE5p6H+qu3DsbVhrr0UemaSD6xBd0i/3QVGRX26hInAmsIIwDTdmTetASufYNgOFSrX+O6Ak+scYe0ChceqKIkylnFC7y5/;25:T5WI+/RsppYT3GrTvLLNO2zUSywuhmZ6MDY+QxXjq7QtUBHFZznspOeCe6Wlo238PlUyaqQQRS8UZVWzIbS4XSSZgfkzj/UQJTqlpqKegCXIB3Rdki0RgcQvEGNlQrK/2YE+UjqKgqNHFt7RwP0gSsVihndwRUK2aTofsm++p/xeibE57xzYimBuLS+za/6ZpVGAG39QKQYBlFhZIIv54Er8SucrHmGaSHNw+BKzRFI7OY4BFLdxZzJF0fy39ttUsdaTP2DFCbLFhjkZn+xY6MqwPY6JTRY52noqLDo/gLjIfbO9FAgoDFotkMOh6hxlQBTE8NzNPYJl09xP/b+JpjuWyzPo1rGZEHV9U9Nj9hki1h4S0vuldCLYOqqHHk21EzcRt6U4+qCT9EYcqgq6H/46E6upGWPu152Hnc0CocBwg+EEnPUr6TLLsdF2rVD0SgPuZX4R03QAmDjlJCKmHg== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:SN1PR0301MB1629; X-Microsoft-Exchange-Diagnostics: 1;SN1PR0301MB1629;31:5GBSMlPNCyRE2EPRf9eUw30ByDSekLIYrejFL8ih88PCwq+BWGOHDvfMfVaC8VcChupdDTWyKprsr939IT7+jrUhKGyL4G0Qt2CY73cL4S0ChiYLOkTDJZP3jvvIeIiPugfqyHPzw+zh0cLKG6WpL2CgBM/7wxC0g2qRiJUPQIlnnVad2LYxezhW/TPdQ7Uu0Q4epnPOF8gzVQNWtI22tImnk+TfVG+nHTPZgWitvXPUEviz0CkJgWGlIz/R+H4CJS+vWGfRvYCuhVDXbpjrO1r+031wII9TxX9CNK/iaOA=;4:H1r6Ta9riEAEcgvVlN9iB9bkHwxKX8EzdLRPa0tb+5K+PpF4BB3hsgyEU+1POobP7gf8YRP3tSBFgBpAImbueCwgghJmVBbdDrTHUI1QAAotZQ8fPyO4ruFmOigxORPvDCbgSPqjzcN1Wf9ApMaSlKqQf1GNRrc47qBWUeCLQP8TDZz6++wtUQBx+hhFJpK/jzzO8PUPqxar4W0CDdwEGcVzdyGKgopOKCH5x5i8v9hpZLtUwn6tMff37f0yXoD+DH69fr5AAr9g+CSw4xRwGU3W/M9QZraVC3M/cvTeWwiAKY6MRRwBftkLNF5xSmuCdpqdshoQdgixBoD+0ovRiJdaXsv2f2FfVtq6ottrfPwmTuudgNdMzQdrCnyVZ49qwOofEQSbO+eNJE6acZjBS8lq13Xp2/u+R5OCXpomUzv4RBHJPBrlzYEWtT/LAR4juLsuldUXyI0oyVjoMX6sEZnYnWeDXzfSsgvRnXPQjZvDUSrvm4JSpO87cyr7AckXFLNGKnQoA3Zi6fyCAj60s9u778QnWIoDc7Cx+EaixpilyeMQrr48u6kUA0DbeVSIDz6u3bRO58l0R2NAAW7ThwRa/Oue5GqXrTNHIjPpYsT6qbfkMzoYqXdJB0Le0XVJ X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(35073007944872)(185117386973197)(275809806118684); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040176)(601004)(2401047)(5005006)(8121501046)(13023025)(13024025)(13018025)(13017025)(13015025)(10201501046)(3002001)(6055026);SRVR:SN1PR0301MB1629;BCL:0;PCL:0;RULEID:(400006);SRVR:SN1PR0301MB1629; X-Forefront-PRVS: 01026E1310 X-Microsoft-Exchange-Diagnostics: =?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zyJIQ1U6DhIjqr5p;24:AO5Siw24mBlaLqbGxYB/5gJbHvQStjx+9gzQtVSJ/n2JNeb1RXRquiOENBwNiaPX4HeeD794q9q2os2BxRzWHu+bGSG+od37980QtYfdCJc= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;SN1PR0301MB1629;7:uuht895auMjQwN4NI0WQ0u8qVLi27Z+OjRWfa4ym0nkYxq2YtWuvsoJ9wYBl/dxoOQcM1oioAkPtP8pCeGHEA/6D7kSKgEZimBJZZqDp4+NVhJAvUi5gYPPUUA5yIuEix0tmefJEtIe+rrOaTaoEjLBWD7Un65QuwV2LdKZtETK/urQTsu+3Dhm3nWUE5L75TevBVPQY/a0H0VFTG/1D5ELN4hgm9kdiOQha5psxpvrJWg7YLqw1RQe+98TSqQbv81Pyf8wbTNx676LF5g4X00X8lcr56cFKaWWXziem911zOIlEBL5fTDiiUAAJt0elNEHJlIz0GfW4RIn+BCECLGaUBsCsuorKL43G14AfV2I= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2016 14:08:01.8060 (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: SN1PR0301MB1629 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 19246 Lines: 620 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/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 | 198 ++++++++++++++++++++++++++++++++ drivers/bus/fsl-mc/dpio/dpio.c | 229 +++++++++++++++++++++++++++++++++++++ drivers/bus/fsl-mc/dpio/dpio.h | 108 +++++++++++++++++ 6 files changed, 557 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..b25a4cc --- /dev/null +++ b/drivers/bus/fsl-mc/dpio/dpio-cmd.h @@ -0,0 +1,198 @@ +/* + * 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_CREATE DPIO_CMD(0x903) +#define DPIO_CMDID_DESTROY DPIO_CMD(0x983) +#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) +#define DPIO_CMDID_RESET DPIO_CMD(0x005) +#define DPIO_CMDID_IS_ENABLED DPIO_CMD(0x006) + +#define DPIO_CMDID_SET_IRQ DPIO_CMD(0x010) +#define DPIO_CMDID_GET_IRQ DPIO_CMD(0x011) +#define DPIO_CMDID_SET_IRQ_ENABLE DPIO_CMD(0x012) +#define DPIO_CMDID_GET_IRQ_ENABLE DPIO_CMD(0x013) +#define DPIO_CMDID_SET_IRQ_MASK DPIO_CMD(0x014) +#define DPIO_CMDID_GET_IRQ_MASK DPIO_CMD(0x015) +#define DPIO_CMDID_GET_IRQ_STATUS DPIO_CMD(0x016) +#define DPIO_CMDID_CLEAR_IRQ_STATUS DPIO_CMD(0x017) + +#define DPIO_CMDID_SET_STASHING_DEST DPIO_CMD(0x120) +#define DPIO_CMDID_GET_STASHING_DEST DPIO_CMD(0x121) +#define DPIO_CMDID_ADD_STATIC_DEQUEUE_CHANNEL DPIO_CMD(0x122) +#define DPIO_CMDID_REMOVE_STATIC_DEQUEUE_CHANNEL DPIO_CMD(0x123) + +struct dpio_cmd_open { + __le32 dpio_id; +}; + +#define DPIO_CHANNEL_MODE_MASK 0x3 + +struct dpio_cmd_create { + __le16 pad0; + u8 channel_mode; + u8 pad1; + u8 num_priorities; + +}; + +#define DPIO_ENABLE 1 + +struct dpio_rsp_is_enabled { + u8 enabled; +}; + +struct dpio_cmd_set_irq { + /* cmd word 0 */ + u8 irq_index; + u8 pad[3]; + __le32 irq_val; + /* cmd word 1 */ + __le64 irq_addr; + /* cmd word 2 */ + __le32 irq_num; +}; + +struct dpio_cmd_get_irq { + __le32 pad; + u8 irq_index; +}; + +struct dpio_rsp_get_irq { + /* response word 0 */ + __le32 irq_val; + __le32 pad; + /* response word 1 */ + __le64 irq_addr; + /* response word 2 */ + __le32 irq_num; + __le32 type; +}; + +struct dpio_cmd_set_irq_enable { + u8 enable; + u8 pad[3]; + u8 irq_index; +}; + +struct dpio_cmd_get_irq_enable { + __le32 pad; + u8 irq_index; +}; + +struct dpio_rsp_get_irq_enable { + u8 enabled; +}; + +struct dpio_cmd_set_irq_mask { + __le32 mask; + u8 irq_index; +}; + +struct dpio_cmd_get_irq_mask { + __le32 pad; + u8 irq_index; +}; + +struct dpio_rsp_get_irq_mask { + __le32 mask; +}; + +struct dpio_cmd_get_irq_status { + __le32 status; + u8 irq_index; +}; + +struct dpio_rsp_get_irq_status { + __le32 status; +}; + +struct dpio_cmd_clear_irq_status { + __le32 status; + u8 irq_index; +}; + +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; +}; + +struct dpio_cmd_set_stashing_dest { + u8 sdest; +}; + +struct dpio_rsp_get_stashing_dest { + u8 sdest; +}; + +struct dpio_cmd_add_static_dequeue_channel { + __le32 dpcon_id; +}; + +struct dpio_rsp_add_static_dequeue_channel { + u8 channel_index; +}; + +struct dpio_cmd_remove_static_dequeue_channel { + __le32 dpcon_id; +}; + +#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