Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756015AbcJQTGD (ORCPT ); Mon, 17 Oct 2016 15:06:03 -0400 Received: from mail-co1nam03on0085.outbound.protection.outlook.com ([104.47.40.85]:24426 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S936358AbcJQTEb (ORCPT ); Mon, 17 Oct 2016 15:04:31 -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 Ciornei , Stuart Yoder Subject: [PATCH 14/14] staging: fsl-mc: uprev binary interface to match MC v10.x Date: Mon, 17 Oct 2016 13:43:58 -0500 Message-ID: <1476729838-10336-1-git-send-email-stuart.yoder@nxp.com> X-Mailer: git-send-email 1.9.0 X-EOPAttributedMessage: 0 X-Matching-Connectors: 131212037831158500;(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)(1110001)(1109001)(339900001)(199003)(189002)(50986999)(229853001)(50226002)(69596002)(85426001)(575784001)(2351001)(81166006)(81156014)(36756003)(5003940100001)(105606002)(8676002)(106466001)(92566002)(4326007)(2906002)(77096005)(19580405001)(47776003)(104016004)(11100500001)(19580395003)(110136003)(5660300001)(8936002)(33646002)(48376002)(50466002)(626004)(6666003)(7846002)(356003)(586003)(6916009)(86362001)(305945005)(97736004)(87936001)(68736007)(189998001)(8666005)(7059030);DIR:OUT;SFP:1101;SCL:1;SRVR:BN3PR03MB1416;H:az84smr01.freescale.net;FPR:;SPF:Fail;PTR:InfoDomainNonexistent;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BN1AFFO11FD053;1:a/8AoA4GzdIDV+783X6Pvqr69f6p344o4x8hUVQmCaukOMK1IGigwG2WnG7QAEgsp4Ma8IEGPoS02pApFDaiWFRwYgCu7/FYqpO7BE8lVaAldlFTWJEZ1dDBhpXMbRcOhoAV0B4NIKs5i8OiMp0G7uXryUjPMdLgypGSXMNJpzLNRtMkw5VcGEnfFPbmYNXK9nemaIsEvLm3IntQIMPQqQMTVxXWbOs4lhzKWJe+GzQvCcoTXMAAM547U329/rN/nypbIpvrs8qqi+7eZFqp5GpTSGvW7g9dbUqOb4VrIsS9nOFJkUhZXVPgnEzPFfJLG8c+Y0PVhyEjeAzDL9yw132FKUL5zYiw40BX6wqi6BsapvxP3nEyXCJ+IG7BaRrXpien1H71akx+vneFfWoF/Ma+rt8yVvUimSQczSI6ABvWR4Zds5PAs05XNZc553/XcS/L5VA0HcMYjdBEP5NiiMPGchzn3nznBKHR3oo0zBOasoCP08JlPKb/XQhjVH1M3tPEaGI6jEXCwT31d2MMU24hw/7zfY+rNYLstQMxBZZfv6zMVTt/Sj9sEB8vzwgZ3NNFdpFgLPBLu2VIluGVjFKi95gA/1yPlJTPgloFMcfdtjbkaCk9h6cPf1pcn5lZtROBJ2lah2Sk4yHk1jvjfvXyjZvzgCUWjNyw+SVaKcxKorIbEyE7Y1bYNMH/1HxIcJA5dez5hVSdZbyIt+M45+o5f7m3jJtLf7jSnTe+zvA= MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 88315ff5-883e-488a-0987-08d3f6be5ba3 X-Microsoft-Exchange-Diagnostics: 1;BN3PR03MB1416;2:OdSL6aWGmMIgOmoZAAJJdIeQ9txH9IBszj5KaRnZeT47RFR+Awr0QyiUVTNuflmkugvpKFQORiXI6JOqFr/IvAtygYgmIAmQT0iMy3kHLzxpJJlTPyGsrPjtzxFucAQ+o9ORnF7nksK2jC0SNXcc7K0F82WiGhv8yO4wgfWD4LtdLh4Gs4MD72ygFze8D2kcHbXkMWL2jXoS/74J2slouQ==;3:4wPS10SfsApKbyrD7pSlkoH3gao4trtKBZucto6pi168+zIkNJWGRVeYacNHKillJoBA4jVtMi/HGiYyZV/R9SbDX5TtYJpB+OZT7zMrt1nBAzM63T2ZWjLmE8OLK1ZzfB+TYeIeqtMq++wIq34/i6oiSNHezxbbAjXfjW1oCWWNOEPIng8tq4VxJq772whyA+NdlmxXg1CVAWd4iNcgZnWQLBO+2elalMditalQSsQy5lXQWIU3QMcP1BH9a0dL;25:QbTMiWaS8Bif+yiS7x6rPqA3oT7YBgdQyzRkxMuLSZBOW6ZCBkBM5o5sV6nOix73EaQ2fzVxY7ZwM+TB39mFv0KceObgQOpqW770RC/JpEEOPky3yXj3vni/7rFa3oNWq/Q860K3JDIG5Qp3rcl/2oRI9ovymFB7enXNaqxT5jLJipUVrmBvscPHEXLdL+lPL9x3yxoQooG8OVJMHVexKDyab1mESkRQk8cVaTA0mOW75vKT2sRix6bnilb5P6ZYA58+ZEs/9L5S+tgcMohKl6aqUeK+fsXqK4ff/R9WpC/QngQSZ2b/eVbV1C+jiOFRsJ6mR64Sy5hF1YOSma6nL/Wmw/nTQqW3S1CcwvEY6MvH3NH11IymuNfwQMZluXZ8RITEvla5eJ8umHPgRLFBeMg47JRS30xadZQ0o8wBF1QpRgtokfSrhmqUVcPq0BkEfjS79utQPDJWsZY7iirdCg== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BN3PR03MB1416; X-Microsoft-Exchange-Diagnostics: 1;BN3PR03MB1416;31:0zmgbGvYWeIw2dSF28olHX1/kp3ejC39488dOSaVOrgvPS2H5GeIYI3q30b5kcZXzrGcaJg2Dg+vbmm0Cxc1GnLi5D0pNBSznfjCiGC7jcUSjQhKZpidFs59VcJxjJygXW0KGUr08JzJROPEG8ArneiQkJntYhutUwPILk9XtZalLvovy186Hn+UDsjI+bzRVIbdY9h74FRZZP+4XRJAonmDF5WYmp5qGTyMKOBH17K60TZEyBPlCRFLLG+VOVSuCUPazGPuGryIGOzj6u7aO9hPDWx8OsYK0Q3TEHgvufE=;4:j2/hzcqhGGuRzS6fWLhh7DrNzl2Fjk9PpgrQ4JIfydpEkLvgMZUvjVyyk82Atbse8eXgp2RhrddcrWvz7OQGmxyXvPddBJcrwJEAtERVnzgXGt7DE8iGfT83g3e9UoP4XaPimZEEKp0/oC1F796hL0AoO8jUWM3OHR87z7NQe2BxtmWEl+QMY3OHyEOX6iXTvYcGjaqPRXR7ukLMcxtiQAZX/DBk7glTNmBlKz10pxMuclTuLOOR/mLmIeWTuqxbXT8caYe8W31EE2y7Yb5QRHxyWkGfyOp6HehFd0RIJ5AZm0J+Jxv7I2syaUwRNm+jyb64bsG2iZC/64Owd4PpknQADxy2YoYReNPMT6Ne0aCBDrtoBdjVzFLpD/kEaQp6NpkSrP5VOlrc9EFCeSlynkluyhi6IHU4dLh8CH6WciYY+jN9h1yLAwTXe98oYglNO6ign02QF/fp4t+y/UHXFlAHMeN3RAy2GdgxkwG2m3wvNlrGmz0l7fz/lpgxzEPJqzaUldrV62q7SjVRdBtusgKdgJczaQkjLIF2KNEyM7AQ44XWlHKZIdEt+iBsYMSci3Q5LQgLS4CjFoBxaZ2JvA== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197)(275809806118684); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040176)(601004)(2401047)(13023025)(13015025)(13017025)(13018025)(13024025)(8121501046)(5005006)(3002001)(10201501046)(6055026);SRVR:BN3PR03MB1416;BCL:0;PCL:0;RULEID:(400006);SRVR:BN3PR03MB1416; X-Forefront-PRVS: 0098BA6C6C X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BN3PR03MB1416;23:Ji3mFmo06G7acLKjhT5fKted+LfOTiILGkV9nX3FN?= =?us-ascii?Q?gheOokyXGG7PiJ9ERbhxFRS1QVwV0vtDOKUHyUhHJKAujIMJgupWmlC5mXsx?= =?us-ascii?Q?Y41eD/jHVp4YpoaPMQL6OovI7h8V5av+rk62/0j+YTFGBE8VfyagPGUY0ekW?= =?us-ascii?Q?GWGWupF1jD/fKfVbe8pQruLQAzSKKYJ2zIu3EN3eON+IiUjqdTflkJTbQuyG?= =?us-ascii?Q?xQo/DFUgUrMmUWwiN17/CqAzJzuOI5jCluHDCJR/L0IqfJHKpyDlzg/OPIv7?= =?us-ascii?Q?tUkmKmBhMkCbSMeCatq2DXAjBzofaWGOalYFT2R+FljoZmvWJtD47tg717MN?= =?us-ascii?Q?MK8wVYbYPaGIBrb3SVJUB5EjU/EtdYs7cvbf45zbsyiQ7dluhyCEdCOh7A21?= =?us-ascii?Q?noXxqghvA5VjtKJ2kCz31IqFkxGK6JpbR13RGHqlxiFuyQBHqcIK8vZmtHru?= =?us-ascii?Q?44ungh575z+57BbDyCx51v4MOgBR9vlL98JpheGG4e3+QgWckGm1M+z4iWFy?= =?us-ascii?Q?S993Stq0IF7EW467QQxwGrqkblq64Nn0Wiik8WDDRPAY8QLMa6VHqA4A3iXv?= =?us-ascii?Q?YbPPDxXfUn/Wi1z2iyruzsTjBqVVaEScSkYXRyYrwwTxMB4pORmZ7r10l10a?= =?us-ascii?Q?KPvTDklhPE/YawZuOXZahm6qPKgsG0pFIvABB0+7Aug9Fq8nItnLkGnDNecB?= =?us-ascii?Q?QfhHxquX9lwNncSS6ipPM5zbgbP1CVaC++Y89MI4jr1+0c6siXsYqUMzFj4f?= =?us-ascii?Q?6WXsDEUB9iY0040SBRANCxThiJOzyXIcDywq43rw4DM1S2wbs1rH3dsQ3Fo0?= =?us-ascii?Q?GlOEMb3kvLxBQTdmfZIV7+iInDWD8rEKrqa7xk0fcwrbNBHVKheZeTwSqeDv?= =?us-ascii?Q?MjxUe5OXx+M107HQsFAQfPvQiW3Hd3loSLenS5q8j20Fi8sxoBGNOZVByxVu?= =?us-ascii?Q?u6ZecYjkNFysAjt1DDW2xz+js8faJ7k/JhzkFfCx6ZfHj1Ar6JRaukwywX7Q?= =?us-ascii?Q?EN9ochxCyJCpFkX73blGFDcxSHJGAd6Lecu2G13cZnSMTIF2u3UCx8AblGqq?= =?us-ascii?Q?v76sRLuAIGKc98sVykoapE5aWNHgfoQ3EuhQ3atP3yPpx8obehuu6L+hdpdf?= =?us-ascii?Q?WlPhbtVwh+TKTMrec0E8AW0g3abOJpAzZei0kVgqewQKippsnC6EOovxeV6/?= =?us-ascii?Q?KHOPd72EmvVOT3toD1fs1nFixlZBMy/ucEe?= X-Microsoft-Exchange-Diagnostics: 1;BN3PR03MB1416;6:lewmFr9txPaaWJiOY736FDbuinUxysr5zt47QLxJkUi0FTYgrsS5gZu1YpKH8HsMxKIjX4fji30iMOrPkxireB4xgiTlpVnDGmCXPlYXE8X2KjpZrja/HGuhsu0kTPPHffSeXR10zW4tqeq7FRmCtPm7QsU7hZSbkBDWgPUpEh5x7X30id9TnKnu29cXsVrt2yRpb/h3d4yZ5qIb9RJz9FEAqW3YCFHI1FxtJH3y70kEJJ5JfwrIrwilbMcz4LjtC59tY49mlkmIgYTWwda5FSC4nHEypSQF5mTUPha4uqHOumWYhO3ZhUXpFEefPKWY;5:BkDXuR8cwXfMKonGmu1lRcCPIC19NXyqY9M2FriDYH15bCbhzWv4HhTAcimp8m3S31Jveg5zOf0JymZA/9piBDrHwwVkcVe4dyxE9y5bUdz9h54ZsfwH9qzWqPjnRu3GHflnDOhJVGTHU3C4nfNStY3XIjI9kwaDVA0oaM+VHkoh5N91ib3Czo5zwT34/KoY;24:BVc3ZxEiD/p2JLJlBvKOWqirFTLU3VPOi/aBBqjFCS8chl+S3JOf5gIDkUz+NNOG1DDukWWX6A5JUNwSQKi+MABJS03X6l3L1ZWAv23RSpQ= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;BN3PR03MB1416;7:IL5Of0Gpx6RjHsr4cZKEhmv4GdInwY2tKqdfL82ue+H736zX/06zyzVqdTqf49Xpg+JzPfEY7FIFfHDJUU5MTdnHO1SZXlS9Jo/i4uclp2f2khmLr+d/o1QND4WwjPXH/ihgmF68JCnVSYdsOwm/cBNMJ2GsGzBkS7LLMZaHYyrDqK8M0QPdBUz0isylt/Z1Jx0o+ICFwDoZJwejDgAReG6rWd7aK+fqTPpMePMoGIh5hLGy04rfILiepcvIFM9zyh8EJP7utX0d4ffVQuZ1dLRPquImDdMJlty9uuguoJYuR9wGzvBgxGAND0I3/rrVmwN9cjdyk5C/c/N3rFJYPdwFEUWFtgP9rsD+ZvVHgOI= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Oct 2016 18:49:42.8662 (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: BN3PR03MB1416 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 34302 Lines: 1035 From: Ioana Ciornei DPAA2 will not support MC firmware versions prior to MC v10.x. Update the MC interface code and drivers to reflect this. -update the object .h files and code that builds commands to include the new command version in the command header -object versions are no longer available in the object attributes, so remove references to them and instead get the version from the new get_api_version() command -create/destroy commands for all objects have new arguments -dpmng_get_container_id() is replaced by dprc_get_container_id() All MC firmware versions >= 10 will be supported going forward. Signed-off-by: Ioana Ciornei Signed-off-by: Stuart Yoder --- drivers/staging/fsl-mc/bus/dpbp-cmd.h | 57 +++++++++++--------- drivers/staging/fsl-mc/bus/dpbp.c | 67 ++++++++++++++++++------ drivers/staging/fsl-mc/bus/dpmcp-cmd.h | 45 ++++++++++------ drivers/staging/fsl-mc/bus/dpmcp.c | 66 +++++++++++++++++------ drivers/staging/fsl-mc/bus/dpmcp.h | 16 ++---- drivers/staging/fsl-mc/bus/dpmng-cmd.h | 13 ++--- drivers/staging/fsl-mc/bus/dpmng.c | 33 ------------ drivers/staging/fsl-mc/bus/dprc-cmd.h | 89 +++++++++++++++++--------------- drivers/staging/fsl-mc/bus/dprc-driver.c | 19 +++++-- drivers/staging/fsl-mc/bus/dprc.c | 65 ++++++++++++++++++++++- drivers/staging/fsl-mc/bus/fsl-mc-bus.c | 22 ++------ drivers/staging/fsl-mc/bus/mc-sys.c | 8 +-- drivers/staging/fsl-mc/include/dpbp.h | 21 ++++---- drivers/staging/fsl-mc/include/dprc.h | 19 ++++--- drivers/staging/fsl-mc/include/mc-cmd.h | 41 +++++++++++---- 15 files changed, 355 insertions(+), 226 deletions(-) diff --git a/drivers/staging/fsl-mc/bus/dpbp-cmd.h b/drivers/staging/fsl-mc/bus/dpbp-cmd.h index 4cc2918..7d86539 100644 --- a/drivers/staging/fsl-mc/bus/dpbp-cmd.h +++ b/drivers/staging/fsl-mc/bus/dpbp-cmd.h @@ -33,37 +33,48 @@ #define _FSL_DPBP_CMD_H /* DPBP Version */ -#define DPBP_VER_MAJOR 2 +#define DPBP_VER_MAJOR 3 #define DPBP_VER_MINOR 2 +/* Command versioning */ +#define DPBP_CMD_BASE_VERSION 1 +#define DPBP_CMD_ID_OFFSET 4 + +#define DPBP_CMD(id) ((id << DPBP_CMD_ID_OFFSET) | DPBP_CMD_BASE_VERSION) + /* Command IDs */ -#define DPBP_CMDID_CLOSE 0x800 -#define DPBP_CMDID_OPEN 0x804 -#define DPBP_CMDID_CREATE 0x904 -#define DPBP_CMDID_DESTROY 0x900 - -#define DPBP_CMDID_ENABLE 0x002 -#define DPBP_CMDID_DISABLE 0x003 -#define DPBP_CMDID_GET_ATTR 0x004 -#define DPBP_CMDID_RESET 0x005 -#define DPBP_CMDID_IS_ENABLED 0x006 - -#define DPBP_CMDID_SET_IRQ 0x010 -#define DPBP_CMDID_GET_IRQ 0x011 -#define DPBP_CMDID_SET_IRQ_ENABLE 0x012 -#define DPBP_CMDID_GET_IRQ_ENABLE 0x013 -#define DPBP_CMDID_SET_IRQ_MASK 0x014 -#define DPBP_CMDID_GET_IRQ_MASK 0x015 -#define DPBP_CMDID_GET_IRQ_STATUS 0x016 -#define DPBP_CMDID_CLEAR_IRQ_STATUS 0x017 - -#define DPBP_CMDID_SET_NOTIFICATIONS 0x01b0 -#define DPBP_CMDID_GET_NOTIFICATIONS 0x01b1 +#define DPBP_CMDID_CLOSE DPBP_CMD(0x800) +#define DPBP_CMDID_OPEN DPBP_CMD(0x804) +#define DPBP_CMDID_CREATE DPBP_CMD(0x904) +#define DPBP_CMDID_DESTROY DPBP_CMD(0x984) +#define DPBP_CMDID_GET_API_VERSION DPBP_CMD(0xa04) + +#define DPBP_CMDID_ENABLE DPBP_CMD(0x002) +#define DPBP_CMDID_DISABLE DPBP_CMD(0x003) +#define DPBP_CMDID_GET_ATTR DPBP_CMD(0x004) +#define DPBP_CMDID_RESET DPBP_CMD(0x005) +#define DPBP_CMDID_IS_ENABLED DPBP_CMD(0x006) + +#define DPBP_CMDID_SET_IRQ DPBP_CMD(0x010) +#define DPBP_CMDID_GET_IRQ DPBP_CMD(0x011) +#define DPBP_CMDID_SET_IRQ_ENABLE DPBP_CMD(0x012) +#define DPBP_CMDID_GET_IRQ_ENABLE DPBP_CMD(0x013) +#define DPBP_CMDID_SET_IRQ_MASK DPBP_CMD(0x014) +#define DPBP_CMDID_GET_IRQ_MASK DPBP_CMD(0x015) +#define DPBP_CMDID_GET_IRQ_STATUS DPBP_CMD(0x016) +#define DPBP_CMDID_CLEAR_IRQ_STATUS DPBP_CMD(0x017) + +#define DPBP_CMDID_SET_NOTIFICATIONS DPBP_CMD(0x01b0) +#define DPBP_CMDID_GET_NOTIFICATIONS DPBP_CMD(0x01b1) struct dpbp_cmd_open { __le32 dpbp_id; }; +struct dpbp_cmd_destroy { + __le32 object_id; +}; + #define DPBP_ENABLE 0x1 struct dpbp_rsp_is_enabled { diff --git a/drivers/staging/fsl-mc/bus/dpbp.c b/drivers/staging/fsl-mc/bus/dpbp.c index 122c40d..cf4782f 100644 --- a/drivers/staging/fsl-mc/bus/dpbp.c +++ b/drivers/staging/fsl-mc/bus/dpbp.c @@ -108,28 +108,26 @@ int dpbp_close(struct fsl_mc_io *mc_io, /** * dpbp_create() - Create the DPBP object. * @mc_io: Pointer to MC portal's I/O object + * @dprc_token: Parent container token; '0' for default container * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' * @cfg: Configuration structure - * @token: Returned token; use in subsequent API calls + * @obj_id: Returned object id; use in subsequent API calls * * Create the DPBP object, allocate required resources and * perform required initialization. * - * The object can be created either by declaring it in the - * DPL file, or by calling this 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 calls to - * this specific object. For objects that are created using the - * DPL file, call dpbp_open function to get an authentication - * token first. + * This function accepts an authentication token of a parent + * container that this object should be assigned to and returns + * an object id. This object_id will be used in all subsequent calls to + * this specific object. * * Return: '0' on Success; Error code otherwise. */ int dpbp_create(struct fsl_mc_io *mc_io, + u16 dprc_token, u32 cmd_flags, const struct dpbp_cfg *cfg, - u16 *token) + u32 *obj_id) { struct mc_command cmd = { 0 }; int err; @@ -138,7 +136,7 @@ int dpbp_create(struct fsl_mc_io *mc_io, /* prepare command */ cmd.header = mc_encode_cmd_header(DPBP_CMDID_CREATE, - cmd_flags, 0); + cmd_flags, dprc_token); /* send command to mc*/ err = mc_send_command(mc_io, &cmd); @@ -146,7 +144,7 @@ int dpbp_create(struct fsl_mc_io *mc_io, return err; /* retrieve response parameters */ - *token = mc_cmd_hdr_read_token(&cmd); + *obj_id = mc_cmd_read_object_id(&cmd); return 0; } @@ -154,20 +152,25 @@ int dpbp_create(struct fsl_mc_io *mc_io, /** * dpbp_destroy() - Destroy the DPBP object and release all its resources. * @mc_io: Pointer to MC portal's I/O object + * @dprc_token: Parent container token; '0' for default container * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPBP object + * @obj_id: ID of DPBP object * * Return: '0' on Success; error code otherwise. */ int dpbp_destroy(struct fsl_mc_io *mc_io, + u16 dprc_token, u32 cmd_flags, - u16 token) + u32 obj_id) { + struct dpbp_cmd_destroy *cmd_params; struct mc_command cmd = { 0 }; /* prepare command */ cmd.header = mc_encode_cmd_header(DPBP_CMDID_DESTROY, - cmd_flags, token); + cmd_flags, dprc_token); + cmd_params = (struct dpbp_cmd_destroy *)cmd.params; + cmd_params->object_id = cpu_to_le32(obj_id); /* send command to mc*/ return mc_send_command(mc_io, &cmd); @@ -610,8 +613,6 @@ int dpbp_get_attributes(struct fsl_mc_io *mc_io, rsp_params = (struct dpbp_rsp_get_attributes *)cmd.params; attr->bpid = le16_to_cpu(rsp_params->bpid); attr->id = le32_to_cpu(rsp_params->id); - attr->version.major = le16_to_cpu(rsp_params->version_major); - attr->version.minor = le16_to_cpu(rsp_params->version_minor); return 0; } @@ -690,3 +691,35 @@ int dpbp_get_notifications(struct fsl_mc_io *mc_io, return 0; } + +/** + * dpbp_get_api_version - Get Data Path Buffer Pool API version + * @mc_io: Pointer to Mc portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @major_ver: Major version of Buffer Pool API + * @minor_ver: Minor version of Buffer Pool API + * + * Return: '0' on Success; Error code otherwise. + */ +int dpbp_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(DPBP_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/staging/fsl-mc/bus/dpmcp-cmd.h b/drivers/staging/fsl-mc/bus/dpmcp-cmd.h index 1073ca2..7cb5149 100644 --- a/drivers/staging/fsl-mc/bus/dpmcp-cmd.h +++ b/drivers/staging/fsl-mc/bus/dpmcp-cmd.h @@ -33,25 +33,32 @@ #define _FSL_DPMCP_CMD_H /* Minimal supported DPMCP Version */ -#define DPMCP_MIN_VER_MAJOR 3 -#define DPMCP_MIN_VER_MINOR 0 +#define DPMCP_MIN_VER_MAJOR 3 +#define DPMCP_MIN_VER_MINOR 0 + +/* Command versioning */ +#define DPMCP_CMD_BASE_VERSION 1 +#define DPMCP_CMD_ID_OFFSET 4 + +#define DPMCP_CMD(id) ((id << DPMCP_CMD_ID_OFFSET) | DPMCP_CMD_BASE_VERSION) /* Command IDs */ -#define DPMCP_CMDID_CLOSE 0x800 -#define DPMCP_CMDID_OPEN 0x80b -#define DPMCP_CMDID_CREATE 0x90b -#define DPMCP_CMDID_DESTROY 0x900 - -#define DPMCP_CMDID_GET_ATTR 0x004 -#define DPMCP_CMDID_RESET 0x005 - -#define DPMCP_CMDID_SET_IRQ 0x010 -#define DPMCP_CMDID_GET_IRQ 0x011 -#define DPMCP_CMDID_SET_IRQ_ENABLE 0x012 -#define DPMCP_CMDID_GET_IRQ_ENABLE 0x013 -#define DPMCP_CMDID_SET_IRQ_MASK 0x014 -#define DPMCP_CMDID_GET_IRQ_MASK 0x015 -#define DPMCP_CMDID_GET_IRQ_STATUS 0x016 +#define DPMCP_CMDID_CLOSE DPMCP_CMD(0x800) +#define DPMCP_CMDID_OPEN DPMCP_CMD(0x80b) +#define DPMCP_CMDID_CREATE DPMCP_CMD(0x90b) +#define DPMCP_CMDID_DESTROY DPMCP_CMD(0x98b) +#define DPMCP_CMDID_GET_API_VERSION DPMCP_CMD(0xa0b) + +#define DPMCP_CMDID_GET_ATTR DPMCP_CMD(0x004) +#define DPMCP_CMDID_RESET DPMCP_CMD(0x005) + +#define DPMCP_CMDID_SET_IRQ DPMCP_CMD(0x010) +#define DPMCP_CMDID_GET_IRQ DPMCP_CMD(0x011) +#define DPMCP_CMDID_SET_IRQ_ENABLE DPMCP_CMD(0x012) +#define DPMCP_CMDID_GET_IRQ_ENABLE DPMCP_CMD(0x013) +#define DPMCP_CMDID_SET_IRQ_MASK DPMCP_CMD(0x014) +#define DPMCP_CMDID_GET_IRQ_MASK DPMCP_CMD(0x015) +#define DPMCP_CMDID_GET_IRQ_STATUS DPMCP_CMD(0x016) struct dpmcp_cmd_open { __le32 dpmcp_id; @@ -61,6 +68,10 @@ struct dpmcp_cmd_create { __le32 portal_id; }; +struct dpmcp_cmd_destroy { + __le32 object_id; +}; + struct dpmcp_cmd_set_irq { /* cmd word 0 */ u8 irq_index; diff --git a/drivers/staging/fsl-mc/bus/dpmcp.c b/drivers/staging/fsl-mc/bus/dpmcp.c index faade1e..e4d1651 100644 --- a/drivers/staging/fsl-mc/bus/dpmcp.c +++ b/drivers/staging/fsl-mc/bus/dpmcp.c @@ -106,28 +106,29 @@ int dpmcp_close(struct fsl_mc_io *mc_io, /** * dpmcp_create() - Create the DPMCP object. * @mc_io: Pointer to MC portal's I/O object + * @dprc_token: Parent container token; '0' for default container * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' * @cfg: Configuration structure - * @token: Returned token; use in subsequent API calls + * @obj_id: Returned object id; use in subsequent API calls * * Create the DPMCP object, allocate required resources and * perform required initialization. * * The object can be created either by declaring it in the * DPL file, or by calling this 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 calls to - * this specific object. For objects that are created using the - * DPL file, call dpmcp_open function to get an authentication - * token first. + + * This function accepts an authentication token of a parent + * container that this object should be assigned to and returns + * an object id. This object_id will be used in all subsequent calls to + * this specific object. * * Return: '0' on Success; Error code otherwise. */ int dpmcp_create(struct fsl_mc_io *mc_io, + u16 dprc_token, u32 cmd_flags, const struct dpmcp_cfg *cfg, - u16 *token) + u32 *obj_id) { struct mc_command cmd = { 0 }; struct dpmcp_cmd_create *cmd_params; @@ -136,7 +137,7 @@ int dpmcp_create(struct fsl_mc_io *mc_io, /* prepare command */ cmd.header = mc_encode_cmd_header(DPMCP_CMDID_CREATE, - cmd_flags, 0); + cmd_flags, dprc_token); cmd_params = (struct dpmcp_cmd_create *)cmd.params; cmd_params->portal_id = cpu_to_le32(cfg->portal_id); @@ -146,7 +147,7 @@ int dpmcp_create(struct fsl_mc_io *mc_io, return err; /* retrieve response parameters */ - *token = mc_cmd_hdr_read_token(&cmd); + *obj_id = mc_cmd_read_object_id(&cmd); return 0; } @@ -154,20 +155,25 @@ int dpmcp_create(struct fsl_mc_io *mc_io, /** * dpmcp_destroy() - Destroy the DPMCP object and release all its resources. * @mc_io: Pointer to MC portal's I/O object + * @dprc_token: Parent container token; '0' for default container * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @token: Token of DPMCP object + * @obj_id: ID of DPMCP object * * Return: '0' on Success; error code otherwise. */ int dpmcp_destroy(struct fsl_mc_io *mc_io, + u16 dprc_token, u32 cmd_flags, - u16 token) + u32 obj_id) { struct mc_command cmd = { 0 }; + struct dpmcp_cmd_destroy *cmd_params; /* prepare command */ cmd.header = mc_encode_cmd_header(DPMCP_CMDID_DESTROY, - cmd_flags, token); + cmd_flags, dprc_token); + cmd_params = (struct dpmcp_cmd_destroy *)cmd.params; + cmd_params->object_id = cpu_to_le32(obj_id); /* send command to mc*/ return mc_send_command(mc_io, &cmd); @@ -497,8 +503,38 @@ int dpmcp_get_attributes(struct fsl_mc_io *mc_io, /* retrieve response parameters */ rsp_params = (struct dpmcp_rsp_get_attributes *)cmd.params; attr->id = le32_to_cpu(rsp_params->id); - attr->version.major = le16_to_cpu(rsp_params->version_major); - attr->version.minor = le16_to_cpu(rsp_params->version_minor); + + return 0; +} + +/** + * dpmcp_get_api_version - Get Data Path Management Command Portal API version + * @mc_io: Pointer to Mc portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @major_ver: Major version of Data Path Management Command Portal API + * @minor_ver: Minor version of Data Path Management Command Portal API + * + * Return: '0' on Success; Error code otherwise. + */ +int dpmcp_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(DPMCP_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/staging/fsl-mc/bus/dpmcp.h b/drivers/staging/fsl-mc/bus/dpmcp.h index 902cddf..98a100d 100644 --- a/drivers/staging/fsl-mc/bus/dpmcp.h +++ b/drivers/staging/fsl-mc/bus/dpmcp.h @@ -61,13 +61,15 @@ struct dpmcp_cfg { }; int dpmcp_create(struct fsl_mc_io *mc_io, + u16 dprc_token, u32 cmd_flags, const struct dpmcp_cfg *cfg, - u16 *token); + u32 *obj_id); int dpmcp_destroy(struct fsl_mc_io *mc_io, + u16 dprc_token, u32 cmd_flags, - u16 token); + u32 obj_id); int dpmcp_reset(struct fsl_mc_io *mc_io, u32 cmd_flags, @@ -137,19 +139,9 @@ int dpmcp_get_irq_status(struct fsl_mc_io *mc_io, /** * struct dpmcp_attr - Structure representing DPMCP attributes * @id: DPMCP object ID - * @version: DPMCP version */ struct dpmcp_attr { int id; - /** - * struct version - Structure representing DPMCP version - * @major: DPMCP major version - * @minor: DPMCP minor version - */ - struct { - u16 major; - u16 minor; - } version; }; int dpmcp_get_attributes(struct fsl_mc_io *mc_io, diff --git a/drivers/staging/fsl-mc/bus/dpmng-cmd.h b/drivers/staging/fsl-mc/bus/dpmng-cmd.h index d42d977..cdddfb8 100644 --- a/drivers/staging/fsl-mc/bus/dpmng-cmd.h +++ b/drivers/staging/fsl-mc/bus/dpmng-cmd.h @@ -40,13 +40,14 @@ #ifndef __FSL_DPMNG_CMD_H #define __FSL_DPMNG_CMD_H -/* Command IDs */ -#define DPMNG_CMDID_GET_CONT_ID 0x830 -#define DPMNG_CMDID_GET_VERSION 0x831 +/* Command versioning */ +#define DPMNG_CMD_BASE_VERSION 1 +#define DPMNG_CMD_ID_OFFSET 4 -struct dpmng_rsp_get_container_id { - __le32 container_id; -}; +#define DPMNG_CMD(id) ((id << DPMNG_CMD_ID_OFFSET) | DPMNG_CMD_BASE_VERSION) + +/* Command IDs */ +#define DPMNG_CMDID_GET_VERSION DPMNG_CMD(0x831) struct dpmng_rsp_get_version { __le32 revision; diff --git a/drivers/staging/fsl-mc/bus/dpmng.c b/drivers/staging/fsl-mc/bus/dpmng.c index 831c6ed..ad5d5bb 100644 --- a/drivers/staging/fsl-mc/bus/dpmng.c +++ b/drivers/staging/fsl-mc/bus/dpmng.c @@ -72,36 +72,3 @@ int mc_get_version(struct fsl_mc_io *mc_io, } EXPORT_SYMBOL(mc_get_version); -/** - * dpmng_get_container_id() - Get container ID associated with a given portal. - * @mc_io: Pointer to MC portal's I/O object - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' - * @container_id: Requested container ID - * - * Return: '0' on Success; Error code otherwise. - */ -int dpmng_get_container_id(struct fsl_mc_io *mc_io, - u32 cmd_flags, - int *container_id) -{ - struct mc_command cmd = { 0 }; - struct dpmng_rsp_get_container_id *rsp_params; - int err; - - /* prepare command */ - cmd.header = mc_encode_cmd_header(DPMNG_CMDID_GET_CONT_ID, - cmd_flags, - 0); - - /* send command to mc*/ - err = mc_send_command(mc_io, &cmd); - if (err) - return err; - - /* retrieve response parameters */ - rsp_params = (struct dpmng_rsp_get_container_id *)cmd.params; - *container_id = le32_to_cpu(rsp_params->container_id); - - return 0; -} - diff --git a/drivers/staging/fsl-mc/bus/dprc-cmd.h b/drivers/staging/fsl-mc/bus/dprc-cmd.h index 154ce2f..588b8ca 100644 --- a/drivers/staging/fsl-mc/bus/dprc-cmd.h +++ b/drivers/staging/fsl-mc/bus/dprc-cmd.h @@ -41,48 +41,56 @@ #define _FSL_DPRC_CMD_H /* Minimal supported DPRC Version */ -#define DPRC_MIN_VER_MAJOR 5 +#define DPRC_MIN_VER_MAJOR 6 #define DPRC_MIN_VER_MINOR 0 +/* Command versioning */ +#define DPRC_CMD_BASE_VERSION 1 +#define DPRC_CMD_ID_OFFSET 4 + +#define DPRC_CMD(id) ((id << DPRC_CMD_ID_OFFSET) | DPRC_CMD_BASE_VERSION) + /* Command IDs */ -#define DPRC_CMDID_CLOSE 0x800 -#define DPRC_CMDID_OPEN 0x805 -#define DPRC_CMDID_CREATE 0x905 - -#define DPRC_CMDID_GET_ATTR 0x004 -#define DPRC_CMDID_RESET_CONT 0x005 - -#define DPRC_CMDID_SET_IRQ 0x010 -#define DPRC_CMDID_GET_IRQ 0x011 -#define DPRC_CMDID_SET_IRQ_ENABLE 0x012 -#define DPRC_CMDID_GET_IRQ_ENABLE 0x013 -#define DPRC_CMDID_SET_IRQ_MASK 0x014 -#define DPRC_CMDID_GET_IRQ_MASK 0x015 -#define DPRC_CMDID_GET_IRQ_STATUS 0x016 -#define DPRC_CMDID_CLEAR_IRQ_STATUS 0x017 - -#define DPRC_CMDID_CREATE_CONT 0x151 -#define DPRC_CMDID_DESTROY_CONT 0x152 -#define DPRC_CMDID_SET_RES_QUOTA 0x155 -#define DPRC_CMDID_GET_RES_QUOTA 0x156 -#define DPRC_CMDID_ASSIGN 0x157 -#define DPRC_CMDID_UNASSIGN 0x158 -#define DPRC_CMDID_GET_OBJ_COUNT 0x159 -#define DPRC_CMDID_GET_OBJ 0x15A -#define DPRC_CMDID_GET_RES_COUNT 0x15B -#define DPRC_CMDID_GET_RES_IDS 0x15C -#define DPRC_CMDID_GET_OBJ_REG 0x15E -#define DPRC_CMDID_SET_OBJ_IRQ 0x15F -#define DPRC_CMDID_GET_OBJ_IRQ 0x160 -#define DPRC_CMDID_SET_OBJ_LABEL 0x161 -#define DPRC_CMDID_GET_OBJ_DESC 0x162 - -#define DPRC_CMDID_CONNECT 0x167 -#define DPRC_CMDID_DISCONNECT 0x168 -#define DPRC_CMDID_GET_POOL 0x169 -#define DPRC_CMDID_GET_POOL_COUNT 0x16A - -#define DPRC_CMDID_GET_CONNECTION 0x16C +#define DPRC_CMDID_CLOSE DPRC_CMD(0x800) +#define DPRC_CMDID_OPEN DPRC_CMD(0x805) +#define DPRC_CMDID_CREATE DPRC_CMD(0x905) +#define DPRC_CMDID_GET_API_VERSION DPRC_CMD(0xa05) + +#define DPRC_CMDID_GET_ATTR DPRC_CMD(0x004) +#define DPRC_CMDID_RESET_CONT DPRC_CMD(0x005) + +#define DPRC_CMDID_SET_IRQ DPRC_CMD(0x010) +#define DPRC_CMDID_GET_IRQ DPRC_CMD(0x011) +#define DPRC_CMDID_SET_IRQ_ENABLE DPRC_CMD(0x012) +#define DPRC_CMDID_GET_IRQ_ENABLE DPRC_CMD(0x013) +#define DPRC_CMDID_SET_IRQ_MASK DPRC_CMD(0x014) +#define DPRC_CMDID_GET_IRQ_MASK DPRC_CMD(0x015) +#define DPRC_CMDID_GET_IRQ_STATUS DPRC_CMD(0x016) +#define DPRC_CMDID_CLEAR_IRQ_STATUS DPRC_CMD(0x017) + +#define DPRC_CMDID_CREATE_CONT DPRC_CMD(0x151) +#define DPRC_CMDID_DESTROY_CONT DPRC_CMD(0x152) +#define DPRC_CMDID_GET_CONT_ID DPRC_CMD(0x830) +#define DPRC_CMDID_SET_RES_QUOTA DPRC_CMD(0x155) +#define DPRC_CMDID_GET_RES_QUOTA DPRC_CMD(0x156) +#define DPRC_CMDID_ASSIGN DPRC_CMD(0x157) +#define DPRC_CMDID_UNASSIGN DPRC_CMD(0x158) +#define DPRC_CMDID_GET_OBJ_COUNT DPRC_CMD(0x159) +#define DPRC_CMDID_GET_OBJ DPRC_CMD(0x15A) +#define DPRC_CMDID_GET_RES_COUNT DPRC_CMD(0x15B) +#define DPRC_CMDID_GET_RES_IDS DPRC_CMD(0x15C) +#define DPRC_CMDID_GET_OBJ_REG DPRC_CMD(0x15E) +#define DPRC_CMDID_SET_OBJ_IRQ DPRC_CMD(0x15F) +#define DPRC_CMDID_GET_OBJ_IRQ DPRC_CMD(0x160) +#define DPRC_CMDID_SET_OBJ_LABEL DPRC_CMD(0x161) +#define DPRC_CMDID_GET_OBJ_DESC DPRC_CMD(0x162) + +#define DPRC_CMDID_CONNECT DPRC_CMD(0x167) +#define DPRC_CMDID_DISCONNECT DPRC_CMD(0x168) +#define DPRC_CMDID_GET_POOL DPRC_CMD(0x169) +#define DPRC_CMDID_GET_POOL_COUNT DPRC_CMD(0x16A) + +#define DPRC_CMDID_GET_CONNECTION DPRC_CMD(0x16C) struct dprc_cmd_open { __le32 container_id; @@ -198,9 +206,6 @@ struct dprc_rsp_get_attributes { /* response word 1 */ __le32 options; __le32 portal_id; - /* response word 2 */ - __le16 version_major; - __le16 version_minor; }; struct dprc_cmd_set_res_quota { diff --git a/drivers/staging/fsl-mc/bus/dprc-driver.c b/drivers/staging/fsl-mc/bus/dprc-driver.c index b4e46fb..4e416d8 100644 --- a/drivers/staging/fsl-mc/bus/dprc-driver.c +++ b/drivers/staging/fsl-mc/bus/dprc-driver.c @@ -597,6 +597,7 @@ static int dprc_probe(struct fsl_mc_device *mc_dev) struct fsl_mc_bus *mc_bus = to_fsl_mc_bus(mc_dev); bool mc_io_created = false; bool msi_domain_set = false; + u16 major_ver, minor_ver; if (WARN_ON(strcmp(mc_dev->obj_desc.type, "dprc") != 0)) return -EINVAL; @@ -669,13 +670,21 @@ static int dprc_probe(struct fsl_mc_device *mc_dev) goto error_cleanup_open; } - if (mc_bus->dprc_attr.version.major < DPRC_MIN_VER_MAJOR || - (mc_bus->dprc_attr.version.major == DPRC_MIN_VER_MAJOR && - mc_bus->dprc_attr.version.minor < DPRC_MIN_VER_MINOR)) { + error = dprc_get_api_version(mc_dev->mc_io, 0, + &major_ver, + &minor_ver); + if (error < 0) { + dev_err(&mc_dev->dev, "dprc_get_api_version() failed: %d\n", + error); + goto error_cleanup_open; + } + + if (major_ver < DPRC_MIN_VER_MAJOR || + (major_ver == DPRC_MIN_VER_MAJOR && + minor_ver < DPRC_MIN_VER_MINOR)) { dev_err(&mc_dev->dev, "ERROR: DPRC version %d.%d not supported\n", - mc_bus->dprc_attr.version.major, - mc_bus->dprc_attr.version.minor); + major_ver, minor_ver); error = -ENOTSUPP; goto error_cleanup_open; } diff --git a/drivers/staging/fsl-mc/bus/dprc.c b/drivers/staging/fsl-mc/bus/dprc.c index ace3441..572edd4 100644 --- a/drivers/staging/fsl-mc/bus/dprc.c +++ b/drivers/staging/fsl-mc/bus/dprc.c @@ -565,8 +565,6 @@ int dprc_get_attributes(struct fsl_mc_io *mc_io, attr->icid = le16_to_cpu(rsp_params->icid); attr->options = le32_to_cpu(rsp_params->options); attr->portal_id = le32_to_cpu(rsp_params->portal_id); - attr->version.major = le16_to_cpu(rsp_params->version_major); - attr->version.minor = le16_to_cpu(rsp_params->version_minor); return 0; } @@ -1386,3 +1384,66 @@ int dprc_get_connection(struct fsl_mc_io *mc_io, return 0; } + +/** + * dprc_get_api_version - Get Data Path Resource Container API version + * @mc_io: Pointer to Mc portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @major_ver: Major version of Data Path Resource Container API + * @minor_ver: Minor version of Data Path Resource Container API + * + * Return: '0' on Success; Error code otherwise. + */ +int dprc_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(DPRC_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; +} + +/** + * dprc_get_container_id - Get container ID associated with a given portal. + * @mc_io: Pointer to Mc portal's I/O object + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' + * @container_id: Requested container id + * + * Return: '0' on Success; Error code otherwise. + */ +int dprc_get_container_id(struct fsl_mc_io *mc_io, + u32 cmd_flags, + int *container_id) +{ + struct mc_command cmd = { 0 }; + int err; + + /* prepare command */ + cmd.header = mc_encode_cmd_header(DPRC_CMDID_GET_CONT_ID, + cmd_flags, + 0); + + /* send command to mc*/ + err = mc_send_command(mc_io, &cmd); + if (err) + return err; + + /* retrieve response parameters */ + *container_id = (int)mc_cmd_read_object_id(&cmd); + + return 0; +} diff --git a/drivers/staging/fsl-mc/bus/fsl-mc-bus.c b/drivers/staging/fsl-mc/bus/fsl-mc-bus.c index 19a1935..4e92437 100644 --- a/drivers/staging/fsl-mc/bus/fsl-mc-bus.c +++ b/drivers/staging/fsl-mc/bus/fsl-mc-bus.c @@ -311,21 +311,6 @@ static int get_dprc_icid(struct fsl_mc_io *mc_io, return error; } -static int get_dprc_version(struct fsl_mc_io *mc_io, - int container_id, u16 *major, u16 *minor) -{ - struct dprc_attributes attr; - int error; - - error = get_dprc_attr(mc_io, container_id, &attr); - if (error == 0) { - *major = attr.version.major; - *minor = attr.version.minor; - } - - return error; -} - static int translate_mc_addr(struct fsl_mc_device *mc_dev, enum dprc_region_type mc_region_type, u64 mc_offset, phys_addr_t *phys_addr) @@ -787,7 +772,7 @@ static int fsl_mc_bus_probe(struct platform_device *pdev) if (error < 0) goto error_cleanup_mc_io; - error = dpmng_get_container_id(mc_io, 0, &container_id); + error = dprc_get_container_id(mc_io, 0, &container_id); if (error < 0) { dev_err(&pdev->dev, "dpmng_get_container_id() failed: %d\n", error); @@ -795,8 +780,9 @@ static int fsl_mc_bus_probe(struct platform_device *pdev) } memset(&obj_desc, 0, sizeof(struct dprc_obj_desc)); - error = get_dprc_version(mc_io, container_id, - &obj_desc.ver_major, &obj_desc.ver_minor); + error = dprc_get_api_version(mc_io, 0, + &obj_desc.ver_major, + &obj_desc.ver_minor); if (error < 0) goto error_cleanup_mc_io; diff --git a/drivers/staging/fsl-mc/bus/mc-sys.c b/drivers/staging/fsl-mc/bus/mc-sys.c index e47bd23..4d82802 100644 --- a/drivers/staging/fsl-mc/bus/mc-sys.c +++ b/drivers/staging/fsl-mc/bus/mc-sys.c @@ -67,7 +67,7 @@ static u16 mc_cmd_hdr_read_cmdid(struct mc_command *cmd) struct mc_cmd_header *hdr = (struct mc_cmd_header *)&cmd->header; u16 cmd_id = le16_to_cpu(hdr->cmd_id); - return (cmd_id & MC_CMD_HDR_CMDID_MASK) >> MC_CMD_HDR_CMDID_SHIFT; + return cmd_id; } static int mc_status_to_error(enum mc_cmd_status status) @@ -200,7 +200,7 @@ static int mc_polling_wait_preemptible(struct fsl_mc_io *mc_io, if (time_after_eq(jiffies, jiffies_until_timeout)) { dev_dbg(mc_io->dev, - "MC command timed out (portal: %#llx, obj handle: %#x, command: %#x)\n", + "MC command timed out (portal: %#llx, dprc handle: %#x, command: %#x)\n", mc_io->portal_phys_addr, (unsigned int)mc_cmd_hdr_read_token(cmd), (unsigned int)mc_cmd_hdr_read_cmdid(cmd)); @@ -240,7 +240,7 @@ static int mc_polling_wait_atomic(struct fsl_mc_io *mc_io, timeout_usecs -= MC_CMD_COMPLETION_POLLING_MAX_SLEEP_USECS; if (timeout_usecs == 0) { dev_dbg(mc_io->dev, - "MC command timed out (portal: %#llx, obj handle: %#x, command: %#x)\n", + "MC command timed out (portal: %#llx, dprc handle: %#x, command: %#x)\n", mc_io->portal_phys_addr, (unsigned int)mc_cmd_hdr_read_token(cmd), (unsigned int)mc_cmd_hdr_read_cmdid(cmd)); @@ -294,7 +294,7 @@ int mc_send_command(struct fsl_mc_io *mc_io, struct mc_command *cmd) if (status != MC_CMD_STATUS_OK) { dev_dbg(mc_io->dev, - "MC command failed: portal: %#llx, obj handle: %#x, command: %#x, status: %s (%#x)\n", + "MC command failed: portal: %#llx, dprc handle: %#x, command: %#x, status: %s (%#x)\n", mc_io->portal_phys_addr, (unsigned int)mc_cmd_hdr_read_token(cmd), (unsigned int)mc_cmd_hdr_read_cmdid(cmd), diff --git a/drivers/staging/fsl-mc/include/dpbp.h b/drivers/staging/fsl-mc/include/dpbp.h index 51cc12a..9e83d61 100644 --- a/drivers/staging/fsl-mc/include/dpbp.h +++ b/drivers/staging/fsl-mc/include/dpbp.h @@ -58,13 +58,15 @@ struct dpbp_cfg { }; int dpbp_create(struct fsl_mc_io *mc_io, + u16 dprc_token, u32 cmd_flags, const struct dpbp_cfg *cfg, - u16 *token); + u32 *obj_id); int dpbp_destroy(struct fsl_mc_io *mc_io, + u16 dprc_token, u32 cmd_flags, - u16 token); + u32 obj_id); int dpbp_enable(struct fsl_mc_io *mc_io, u32 cmd_flags, @@ -147,21 +149,11 @@ int dpbp_clear_irq_status(struct fsl_mc_io *mc_io, /** * struct dpbp_attr - Structure representing DPBP attributes * @id: DPBP object ID - * @version: DPBP version * @bpid: Hardware buffer pool ID; should be used as an argument in * acquire/release operations on buffers */ struct dpbp_attr { int id; - /** - * struct version - Structure representing DPBP version - * @major: DPBP major version - * @minor: DPBP minor version - */ - struct { - u16 major; - u16 minor; - } version; u16 bpid; }; @@ -217,6 +209,11 @@ int dpbp_get_notifications(struct fsl_mc_io *mc_io, u16 token, struct dpbp_notification_cfg *cfg); +int dpbp_get_api_version(struct fsl_mc_io *mc_io, + u32 cmd_flags, + u16 *major_ver, + u16 *minor_ver); + /** @} */ #endif /* __FSL_DPBP_H */ diff --git a/drivers/staging/fsl-mc/include/dprc.h b/drivers/staging/fsl-mc/include/dprc.h index 0d8042b..5d9ebe6 100644 --- a/drivers/staging/fsl-mc/include/dprc.h +++ b/drivers/staging/fsl-mc/include/dprc.h @@ -239,22 +239,12 @@ int dprc_clear_irq_status(struct fsl_mc_io *mc_io, * @icid: Container's ICID * @portal_id: Container's portal ID * @options: Container's options as set at container's creation - * @version: DPRC version */ struct dprc_attributes { int container_id; u16 icid; int portal_id; u64 options; - /** - * struct version - DPRC version - * @major: DPRC major version - * @minor: DPRC minor version - */ - struct { - u16 major; - u16 minor; - } version; }; int dprc_get_attributes(struct fsl_mc_io *mc_io, @@ -551,5 +541,14 @@ int dprc_get_connection(struct fsl_mc_io *mc_io, struct dprc_endpoint *endpoint2, int *state); +int dprc_get_api_version(struct fsl_mc_io *mc_io, + u32 cmd_flags, + u16 *major_ver, + u16 *minor_ver); + +int dprc_get_container_id(struct fsl_mc_io *mc_io, + u32 cmd_flags, + int *container_id); + #endif /* _FSL_DPRC_H */ diff --git a/drivers/staging/fsl-mc/include/mc-cmd.h b/drivers/staging/fsl-mc/include/mc-cmd.h index f33ad17..2e08aa3 100644 --- a/drivers/staging/fsl-mc/include/mc-cmd.h +++ b/drivers/staging/fsl-mc/include/mc-cmd.h @@ -49,6 +49,15 @@ struct mc_command { u64 params[MC_CMD_NUM_OF_PARAMS]; }; +struct mc_rsp_create { + __le32 object_id; +}; + +struct mc_rsp_api_ver { + __le16 major_ver; + __le16 minor_ver; +}; + enum mc_cmd_status { MC_CMD_STATUS_OK = 0x0, /* Completed successfully */ MC_CMD_STATUS_READY = 0x1, /* Ready to be processed */ @@ -73,11 +82,6 @@ enum mc_cmd_status { /* Command completion flag */ #define MC_CMD_FLAG_INTR_DIS 0x01 -#define MC_CMD_HDR_CMDID_MASK 0xFFF0 -#define MC_CMD_HDR_CMDID_SHIFT 4 -#define MC_CMD_HDR_TOKEN_MASK 0xFFC0 -#define MC_CMD_HDR_TOKEN_SHIFT 6 - static inline u64 mc_encode_cmd_header(u16 cmd_id, u32 cmd_flags, u16 token) @@ -85,10 +89,8 @@ static inline u64 mc_encode_cmd_header(u16 cmd_id, u64 header = 0; struct mc_cmd_header *hdr = (struct mc_cmd_header *)&header; - hdr->cmd_id = cpu_to_le16((cmd_id << MC_CMD_HDR_CMDID_SHIFT) & - MC_CMD_HDR_CMDID_MASK); - hdr->token = cpu_to_le16((token << MC_CMD_HDR_TOKEN_SHIFT) & - MC_CMD_HDR_TOKEN_MASK); + hdr->cmd_id = cpu_to_le16(cmd_id); + hdr->token = cpu_to_le16(token); hdr->status = MC_CMD_STATUS_READY; if (cmd_flags & MC_CMD_FLAG_PRI) hdr->flags_hw = MC_CMD_FLAG_PRI; @@ -103,7 +105,26 @@ static inline u16 mc_cmd_hdr_read_token(struct mc_command *cmd) struct mc_cmd_header *hdr = (struct mc_cmd_header *)&cmd->header; u16 token = le16_to_cpu(hdr->token); - return (token & MC_CMD_HDR_TOKEN_MASK) >> MC_CMD_HDR_TOKEN_SHIFT; + return token; +} + +static inline u32 mc_cmd_read_object_id(struct mc_command *cmd) +{ + struct mc_rsp_create *rsp_params; + + rsp_params = (struct mc_rsp_create *)cmd->params; + return le32_to_cpu(rsp_params->object_id); +} + +static inline void mc_cmd_read_api_version(struct mc_command *cmd, + u16 *major_ver, + u16 *minor_ver) +{ + struct mc_rsp_api_ver *rsp_params; + + rsp_params = (struct mc_rsp_api_ver *)cmd->params; + *major_ver = le16_to_cpu(rsp_params->major_ver); + *minor_ver = le16_to_cpu(rsp_params->minor_ver); } #endif /* __FSL_MC_CMD_H */ -- 1.9.0