Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752142AbcLESWS (ORCPT ); Mon, 5 Dec 2016 13:22:18 -0500 Received: from mail-sn1nam01on0076.outbound.protection.outlook.com ([104.47.32.76]:51857 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751443AbcLESWO (ORCPT ); Mon, 5 Dec 2016 13:22:14 -0500 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=fail action=none header.from=nxp.com; X-IncomingTopHeaderMarker: OriginalChecksum:;UpperCasedChecksum:;SizeAsReceived:512;Count:7 From: Ioana Radulescu To: Subject: [RESEND PATCH] bus: fsl-mc: add DPCON object APIs Date: Mon, 5 Dec 2016 10:48:39 -0600 Message-ID: <20161205164839.8623-1-ruxandra.radulescu@nxp.com> X-Mailer: git-send-email 2.11.0 X-IncomingHeaderCount: 7 X-EOPAttributedMessage: 0 X-Matching-Connectors: 131254301210007264;(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)(1110001)(1109001)(339900001)(336004)(199003)(189002)(8676002)(85426001)(38730400001)(1076002)(626004)(48376002)(92566002)(189998001)(50466002)(68736007)(36756003)(77096006)(575784001)(86362001)(2906002)(450100001)(305945005)(8936002)(105606002)(356003)(110136003)(106466001)(6916009)(97736004)(107886002)(47776003)(81166006)(81156014)(7846002)(2351001)(50226002)(5003940100001)(5660300001)(33646002)(50986999)(104016004)(2004002);DIR:OUT;SFP:1101;SCL:1;SRVR:BY2PR0301MB0742;H:tx30smr01.am.freescale.net;FPR:;SPF:Fail;PTR:InfoDomainNonexistent;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BN1BFFO11FD045;1:XFVFLDFtwy5IHrkTdrN3QhpBuC5xhkZR8M02J+iedCBq+dpM9P7o1xHZY/O5wEOpcGIc5hiui2Jf+iLDRixGI1Ga3bQLoGqDXQ8R6cfBZO5qYJFCU3FuVJoSVRGIdPjN3xE1HIcyr1KDYVQ60z+WniSvFh2X0O8Ky4DHLku7TPOTE9NwmQingQiQbWyq6KVOhQM+0da4gJleue0EK0XuLd5jy/iSEcVRPq0ds6FNPPtROSrDnNLxoYPsMyVt/TIoqj1Vf0uh4lMCKsKa97gVRQZwyi7USIisOxvJSeLzBeeazL3iv/z2WXs9HrnEZAjbulhGhQlLvPR4P2l/nZs9hr3U9wfe17l+oSkNfOk2JuRYa9p2gqcXS9ZfB/+7U9eOn0QKcWvLa7dptlL9ROZY/bPBfpAfsiPa52pRm9DfIX2SGp2i577ClqUEiDS3+OwH29fye+p9WevVbyVlDHcIdU9lXsHo8KJW9hVNKptHbfMoGtu9CvMyhScgM4f7pHHrYVXcWHcjgCIWMQOos200BESc9lceyLeYVrOqnGQM7BpkJlElOYWZhCMdLI9+EwGUvlADaHFdP2RtKKeMY079C2niGjKpM8A1Belb1PDhgZk= MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 7a900f0b-f784-462f-f581-08d41d2e9151 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:BY2PR0301MB0742; X-Microsoft-Exchange-Diagnostics: 1;BY2PR0301MB0742;3:LFP9NHJrCt4tTYImg9KbNQc6IDCodfsE6UJuuGoZkUyU/fQmTrQk9UQYdqrQxCId8gJmRZfnFIibR8aYOVILr+gO5UsOddZNiuoAB+GeXpBvx9nG8l4HuTUEtfIWm0TEqHlWK8oc0jKgSHp3iazq5swyw3CQ3tUOQT/Cy6D6XcJ+XEcBcqs0/cvf/j6798Gx/q7u2jJNpxMyIICpCXPUVIitaDtqLrxN2h/Jo1PGhxyubANvJJRrXg545z43lslNtnKM6DnXJKjBycZSIEH0B9d3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ange-Diagnostics: 1;BY2PR0301MB0742;31:Rei5qmmQ5Y9ITezr0UoT4lqNym77I5+CzFcdmyQiYeYaqjxCMANyUYuE3daAwXyfDkIplH7R8k2dURU2vsLU79AlYdjX8r23GktGzTvU1vg14BqKPFB/o98xB4+r9QF7ZDDAwuiwACr6n1PcjxU56kGGEsruOpwxU0EoU0MTUKIA/j0Q7GRDzH76+if+ls6ZIYNI5OSMaBi0L1H/E+PEfhdNeCzGGPlqlZzCnN7IRdQUy4jdySknpOiIry1dvynmU8NgXpdlLoFFS8Rp0X0vZsh8LrfV0wvVCy4atgK+XQc= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(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:BY2PR0301MB0742;BCL:0;PCL:0;RULEID:(400006);SRVR:BY2PR0301MB0742; X-Microsoft-Exchange-Diagnostics: 1;BY2PR0301MB0742;4:NwieYXVISYAMkY8uimkCkHziJK0e1ghsKr57fLGfwKcFwQH25F9pezavAs5K9C0aZR4aUmr7h3dQYvzY9Jp5xCcChAQsC8oGQCTYBJqa/4a2kcJUgmm+kigum80fMuvBk99RqTmDdvisJv1TnYFAyz9sAEfixKdBdf9GK//cSrObt1CXvANSrU8V+KvW1IFkdSfejYhUDYudD6v+5SzLJ4J3/IwapiOjrEgiLAWj6pvb1pKkrbfWkPSGcC90Sfhd+5/1u0f6X5oeJxABimaUzYe7QKxa2rxV5+lX30FJWvawXyah4WxVBeSLgklyi8FQo72vCxh/t1baiZ963iEq6AKAIyhCoW69SQ7NXkxB0tFXDQf7PoKQezOd382zaj+4ucc5W659d0Lnc6sADzYJ5M1WrG/qwFC/+mz3AXvFQGQYMixsXKWPQNYBWMAo64BQLBdTQ43m70j54N/Rj8KAoR8BOb/mBGRftMFzgm1LP2Qzl0TTb65Ujt7sJXYH9CwslYQad6BtPEZc+Q0kgfAtvDSK2aA8rqz70/fUgPOEvYyosSe2fcIPQLvXqEj/1Vmu/IOh3xs7x2UzQBNUPwYe4B5VlS3uTHRdN7tu++9UU6UbI5DjuDt34Jz/r+SaMLVBMjJVpst/Uyos3zV318f+jexNDPqGaWgd+rxd3/i/OFAv6mpZ9ood+EUCcgHqSMBJbLeTCf94A920ghCzu0llxTOg+pGAbIDD4AgGYtJiG7g6yYOlxfB5eA2FdNr099+Nng1rdRm8+FRyuVQpfWPAow== X-Forefront-PRVS: 0147E151B5 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BY2PR0301MB0742;23:GjkvlgTmo0mkrwIefNvJlcMohPAYKfnNKbq6SeO?= =?us-ascii?Q?O2io/l2woKc6182RdmygFmQidDIZiQy+b2m68imKx4ez77KRMHwLSrobTppb?= =?us-ascii?Q?djev/tHIWmSFXK4kqZOPZGkQ4Kgx4qQ07n/ogFeIWJWuydiB0t2NweorttNu?= =?us-ascii?Q?DUcWLzryZcZ7r3eom+LDdcwfuPBT9uUGj3QJjtTP1pDZvyXgXCzFxcARiNn5?= =?us-ascii?Q?AxUPi/+GlIprUHHUVTqwnA0FT/9XM+/NXSHPuJBYzMt2ZpQWvnO6202mDP8G?= =?us-ascii?Q?xQS6vjT2dvaCqw/RZFZ4DWBDGpwzOJ5hnD8zwhtx2frtpT+krLfJz+qYSxl4?= =?us-ascii?Q?PQFAiG5YaovdQAzzuUQyiFm2qRwdZgRO5noyz49V996LKWybKv5hYmII/Cll?= =?us-ascii?Q?0lGCZTGzMebjwEFhJMr7O3EB+yIZd0wOuUzv2DLVzawfAp00fNRk/89iU+kg?= =?us-ascii?Q?DIfojDLN04jepKng4Nul0hMdW571XzdMkY4mAUhNmo05/OJaSQxemRn6VCxf?= =?us-ascii?Q?Up2kqUVswt55MO+h3WfgExRxJ0B3m/512veIoTobGLLoYevM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DPslqYVMx5O18Z4TFKBPueCrmiSwY2SLvkEvowExdffBM1wN6j3CJf6Oa3qod7jk48C5Bs0tBJImbpI4S1peafMGdlH;5:DJ3+DBvGYBqq91wIaHyzrKcZoidApmlCEp8kGa2AgtyzUAIxKoSqSKSLbwkp6CGyQnyDbn946FQ5q49htlH1b4lNMud1ZjkGY3MQhVPsbG4Yr+vb1yjlDck+ZHOIQWmNaAnkxKltCDNDHzlkr2n9Y2drG2GAC0MwsWrfQx8UUZyoPqzS7xzONnJHkxCC9RMg;24:ScCfaNa2Um0HJZAw7bbaaemSx1hmUtL+Lj9qTakg2QSlrMTxdStGyqnbcVcsq2PYyf2pQxbHh4/NTbxMnyLMnXxTBs2rDEH4KKfebfhvLgE= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;BY2PR0301MB0742;7:SOxaOimb/VZsj192z+b9Zgp7ex3clC0B7hgInkGsaP5BZFkQOrKHk5/Ex2+du47MjKWGQS26XZblGhPBdDxozuZ0Tv0Jyr+XnthH9/2dAqtdBjJp1I/y5tL1xZbl8Y+wOU3aKsl2goGA0OeC9IoqWzVQxzObhNzWRj7+o2ib81gJabGIalKSu+XshdvZWjrroUAg0vl3I3Z05UUsru2FckbtutLAgnETTVDUT0zVi7uK9/KFVDrPrkS85J0Vsx8pzYgbhQ6mWznxcV0dWn6ULlk+/1ez/AY3RTfGD5XIkjfL4Aafvimgz/NdJTWZu1D4QtKl+JdEQUUwNm1V80R4cAmZpPtyOHgW3EeXWl8g4Q5RtPqfGwSfcNCYmO8ZIxP7LIWQ8rB/X9k58X/lmpA1nbuP54BkSsXr7ZLeY6JjkBybcEKXxqNEPw0RrDEAJEgnsxhnK9U2fIFwzVJ/b0kP6A== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Dec 2016 16:48:40.7979 (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: BY2PR0301MB0742 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 17290 Lines: 563 From: Ioana Radulescu This patch adds the command building/parsing wrapper functions for the DPCON object. The binary interface version is v3.2. Signed-off-by: Ioana Radulescu Signed-off-by: Ioana Ciornei Signed-off-by: Stuart Yoder --- This patch depends on the following patch series: [PATCH v3 0/9] staging: fsl-mc: move bus driver out of staging, add dpio https://www.spinics.net/lists/kernel/msg2396338.html drivers/bus/fsl-mc/Makefile | 3 +- drivers/bus/fsl-mc/dpcon-cmd.h | 70 ++++++--- drivers/bus/fsl-mc/dpcon.c | 317 ++++++++++++++++++++++++++++++++++++++++ include/linux/fsl/dpcon.h | 115 +++++++++++++++ 4 files changed, 481 insertions(+), 24 deletions(-) create mode 100644 drivers/bus/fsl-mc/dpcon.c create mode 100644 include/linux/fsl/dpcon.h diff --git a/drivers/bus/fsl-mc/Makefile b/drivers/bus/fsl-mc/Makefile index d18df72..8ad0e9a 100644 --- a/drivers/bus/fsl-mc/Makefile +++ b/drivers/bus/fsl-mc/Makefile @@ -16,7 +16,8 @@ mc-bus-driver-objs := fsl-mc-bus.o \ fsl-mc-allocator.o \ fsl-mc-msi.o \ dpmcp.o \ - dpbp.o + dpbp.o \ + dpcon.o # MC DPIO driver obj-$(CONFIG_FSL_MC_DPIO) += dpio/ diff --git a/drivers/bus/fsl-mc/dpcon-cmd.h b/drivers/bus/fsl-mc/dpcon-cmd.h index d0a5e19..d1c4668 100644 --- a/drivers/bus/fsl-mc/dpcon-cmd.h +++ b/drivers/bus/fsl-mc/dpcon-cmd.h @@ -33,30 +33,54 @@ #define _FSL_DPCON_CMD_H /* DPCON Version */ -#define DPCON_VER_MAJOR 2 -#define DPCON_VER_MINOR 1 +#define DPCON_VER_MAJOR 3 +#define DPCON_VER_MINOR 2 + + +/* Command versioning */ +#define DPCON_CMD_BASE_VERSION 1 +#define DPCON_CMD_ID_OFFSET 4 + +#define DPCON_CMD(id) (((id) << DPCON_CMD_ID_OFFSET) | DPCON_CMD_BASE_VERSION) /* Command IDs */ -#define DPCON_CMDID_CLOSE 0x800 -#define DPCON_CMDID_OPEN 0x808 -#define DPCON_CMDID_CREATE 0x908 -#define DPCON_CMDID_DESTROY 0x900 - -#define DPCON_CMDID_ENABLE 0x002 -#define DPCON_CMDID_DISABLE 0x003 -#define DPCON_CMDID_GET_ATTR 0x004 -#define DPCON_CMDID_RESET 0x005 -#define DPCON_CMDID_IS_ENABLED 0x006 - -#define DPCON_CMDID_SET_IRQ 0x010 -#define DPCON_CMDID_GET_IRQ 0x011 -#define DPCON_CMDID_SET_IRQ_ENABLE 0x012 -#define DPCON_CMDID_GET_IRQ_ENABLE 0x013 -#define DPCON_CMDID_SET_IRQ_MASK 0x014 -#define DPCON_CMDID_GET_IRQ_MASK 0x015 -#define DPCON_CMDID_GET_IRQ_STATUS 0x016 -#define DPCON_CMDID_CLEAR_IRQ_STATUS 0x017 - -#define DPCON_CMDID_SET_NOTIFICATION 0x100 +#define DPCON_CMDID_CLOSE DPCON_CMD(0x800) +#define DPCON_CMDID_OPEN DPCON_CMD(0x808) +#define DPCON_CMDID_GET_API_VERSION DPCON_CMD(0xa08) + +#define DPCON_CMDID_ENABLE DPCON_CMD(0x002) +#define DPCON_CMDID_DISABLE DPCON_CMD(0x003) +#define DPCON_CMDID_GET_ATTR DPCON_CMD(0x004) +#define DPCON_CMDID_RESET DPCON_CMD(0x005) +#define DPCON_CMDID_IS_ENABLED DPCON_CMD(0x006) + +#define DPCON_CMDID_SET_NOTIFICATION DPCON_CMD(0x100) + +struct dpcon_cmd_open { + __le32 dpcon_id; +}; + +#define DPCON_ENABLE 1 + +struct dpcon_rsp_is_enabled { + u8 enabled; +}; + +struct dpcon_rsp_get_attr { + /* response word 0 */ + __le32 id; + __le16 qbman_ch_id; + u8 num_priorities; + u8 pad; +}; + +struct dpcon_cmd_set_notification { + /* cmd word 0 */ + __le32 dpio_id; + u8 priority; + u8 pad[3]; + /* cmd word 1 */ + __le64 user_ctx; +}; #endif /* _FSL_DPCON_CMD_H */ diff --git a/drivers/bus/fsl-mc/dpcon.c b/drivers/bus/fsl-mc/dpcon.c new file mode 100644 index 0000000..f1b33b3 --- /dev/null +++ b/drivers/bus/fsl-mc/dpcon.c @@ -0,0 +1,317 @@ +/* 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 + +#include "dpcon-cmd.h" + +/** + * dpcon_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_' + * @dpcon_id: DPCON 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 dpcon_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 dpcon_open(struct fsl_mc_io *mc_io, + u32 cmd_flags, + int dpcon_id, + u16 *token) +{ + struct mc_command cmd = { 0 }; + struct dpcon_cmd_open *dpcon_cmd; + int err; + + /* prepare command */ + cmd.header = mc_encode_cmd_header(DPCON_CMDID_OPEN, + cmd_flags, + 0); + dpcon_cmd = (struct dpcon_cmd_open *)cmd.params; + dpcon_cmd->dpcon_id = cpu_to_le32(dpcon_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; +} +EXPORT_SYMBOL(dpcon_open); + +/** + * dpcon_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 DPCON object + * + * After this function is called, no further operations are + * allowed on the object without opening a new control session. + * + * Return: '0' on Success; Error code otherwise. + */ +int dpcon_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(DPCON_CMDID_CLOSE, + cmd_flags, + token); + + /* send command to mc*/ + return mc_send_command(mc_io, &cmd); +} +EXPORT_SYMBOL(dpcon_close); + +/** + * dpcon_enable() - Enable the DPCON + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPCON object + * + * Return: '0' on Success; Error code otherwise + */ +int dpcon_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(DPCON_CMDID_ENABLE, + cmd_flags, + token); + + /* send command to mc*/ + return mc_send_command(mc_io, &cmd); +} +EXPORT_SYMBOL(dpcon_enable); + +/** + * dpcon_disable() - Disable the DPCON + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPCON object + * + * Return: '0' on Success; Error code otherwise + */ +int dpcon_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(DPCON_CMDID_DISABLE, + cmd_flags, + token); + + /* send command to mc*/ + return mc_send_command(mc_io, &cmd); +} +EXPORT_SYMBOL(dpcon_disable); + +/** + * dpcon_is_enabled() - Check if the DPCON is enabled. + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPCON object + * @en: Returns '1' if object is enabled; '0' otherwise + * + * Return: '0' on Success; Error code otherwise. + */ +int dpcon_is_enabled(struct fsl_mc_io *mc_io, + u32 cmd_flags, + u16 token, + int *en) +{ + struct mc_command cmd = { 0 }; + struct dpcon_rsp_is_enabled *dpcon_rsp; + int err; + + /* prepare command */ + cmd.header = mc_encode_cmd_header(DPCON_CMDID_IS_ENABLED, + cmd_flags, + token); + + /* send command to mc*/ + err = mc_send_command(mc_io, &cmd); + if (err) + return err; + + /* retrieve response parameters */ + dpcon_rsp = (struct dpcon_rsp_is_enabled *)cmd.params; + *en = dpcon_rsp->enabled & DPCON_ENABLE; + + return 0; +} +EXPORT_SYMBOL(dpcon_is_enabled); + +/** + * dpcon_reset() - Reset the DPCON, returns the object to initial state. + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPCON object + * + * Return: '0' on Success; Error code otherwise. + */ +int dpcon_reset(struct fsl_mc_io *mc_io, + u32 cmd_flags, + u16 token) +{ + struct mc_command cmd = { 0 }; + + /* prepare command */ + cmd.header = mc_encode_cmd_header(DPCON_CMDID_RESET, + cmd_flags, token); + + /* send command to mc*/ + return mc_send_command(mc_io, &cmd); +} +EXPORT_SYMBOL(dpcon_reset); + +/** + * dpcon_get_attributes() - Retrieve DPCON 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 DPCON object + * @attr: Object's attributes + * + * Return: '0' on Success; Error code otherwise. + */ +int dpcon_get_attributes(struct fsl_mc_io *mc_io, + u32 cmd_flags, + u16 token, + struct dpcon_attr *attr) +{ + struct mc_command cmd = { 0 }; + struct dpcon_rsp_get_attr *dpcon_rsp; + int err; + + /* prepare command */ + cmd.header = mc_encode_cmd_header(DPCON_CMDID_GET_ATTR, + cmd_flags, + token); + + /* send command to mc*/ + err = mc_send_command(mc_io, &cmd); + if (err) + return err; + + /* retrieve response parameters */ + dpcon_rsp = (struct dpcon_rsp_get_attr *)cmd.params; + attr->id = le32_to_cpu(dpcon_rsp->id); + attr->qbman_ch_id = le16_to_cpu(dpcon_rsp->qbman_ch_id); + attr->num_priorities = dpcon_rsp->num_priorities; + + return 0; +} +EXPORT_SYMBOL(dpcon_get_attributes); + +/** + * dpcon_set_notification() - Set DPCON notification destination + * @mc_io: Pointer to MC portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @token: Token of DPCON object + * @cfg: Notification parameters + * + * Return: '0' on Success; Error code otherwise + */ +int dpcon_set_notification(struct fsl_mc_io *mc_io, + u32 cmd_flags, + u16 token, + struct dpcon_notification_cfg *cfg) +{ + struct mc_command cmd = { 0 }; + struct dpcon_cmd_set_notification *dpcon_cmd; + + /* prepare command */ + cmd.header = mc_encode_cmd_header(DPCON_CMDID_SET_NOTIFICATION, + cmd_flags, + token); + dpcon_cmd = (struct dpcon_cmd_set_notification *)cmd.params; + dpcon_cmd->dpio_id = cpu_to_le32(cfg->dpio_id); + dpcon_cmd->priority = cfg->priority; + dpcon_cmd->user_ctx = cpu_to_le64(cfg->user_ctx); + + /* send command to mc*/ + return mc_send_command(mc_io, &cmd); +} +EXPORT_SYMBOL(dpcon_set_notification); + +/** + * dpcon_get_api_version - Get Data Path Concentrator API version + * @mc_io: Pointer to MC portal's DPCON object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @major_ver: Major version of DPCON API + * @minor_ver: Minor version of DPCON API + * + * Return: '0' on Success; Error code otherwise + */ +int dpcon_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(DPCON_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; +} +EXPORT_SYMBOL(dpcon_get_api_version); diff --git a/include/linux/fsl/dpcon.h b/include/linux/fsl/dpcon.h new file mode 100644 index 0000000..efa2390 --- /dev/null +++ b/include/linux/fsl/dpcon.h @@ -0,0 +1,115 @@ +/* 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_DPCON_H +#define __FSL_DPCON_H + +/* Data Path Concentrator API + * Contains initialization APIs and runtime control APIs for DPCON + */ + +struct fsl_mc_io; + +/** General DPCON macros */ + +/** + * Use it to disable notifications; see dpcon_set_notification() + */ +#define DPCON_INVALID_DPIO_ID (int)(-1) + +int dpcon_open(struct fsl_mc_io *mc_io, + u32 cmd_flags, + int dpcon_id, + u16 *token); + +int dpcon_close(struct fsl_mc_io *mc_io, + u32 cmd_flags, + u16 token); + +int dpcon_enable(struct fsl_mc_io *mc_io, + u32 cmd_flags, + u16 token); + +int dpcon_disable(struct fsl_mc_io *mc_io, + u32 cmd_flags, + u16 token); + +int dpcon_is_enabled(struct fsl_mc_io *mc_io, + u32 cmd_flags, + u16 token, + int *en); + +int dpcon_reset(struct fsl_mc_io *mc_io, + u32 cmd_flags, + u16 token); + +/** + * struct dpcon_attr - Structure representing DPCON attributes + * @id: DPCON object ID + * @qbman_ch_id: Channel ID to be used by dequeue operation + * @num_priorities: Number of priorities for the DPCON channel (1-8) + */ +struct dpcon_attr { + int id; + u16 qbman_ch_id; + u8 num_priorities; +}; + +int dpcon_get_attributes(struct fsl_mc_io *mc_io, + u32 cmd_flags, + u16 token, + struct dpcon_attr *attr); + +/** + * struct dpcon_notification_cfg - Structure representing notification params + * @dpio_id: DPIO object ID; must be configured with a notification channel; + * to disable notifications set it to 'DPCON_INVALID_DPIO_ID'; + * @priority: Priority selection within the DPIO channel; valid values + * are 0-7, depending on the number of priorities in that channel + * @user_ctx: User context value provided with each CDAN message + */ +struct dpcon_notification_cfg { + int dpio_id; + u8 priority; + u64 user_ctx; +}; + +int dpcon_set_notification(struct fsl_mc_io *mc_io, + u32 cmd_flags, + u16 token, + struct dpcon_notification_cfg *cfg); + +int dpcon_get_api_version(struct fsl_mc_io *mc_io, + u32 cmd_flags, + u16 *major_ver, + u16 *minor_ver); + +#endif /* __FSL_DPCON_H */ -- 1.7.3.4