Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753601AbbHENpf (ORCPT ); Wed, 5 Aug 2015 09:45:35 -0400 Received: from mail-bl2on0122.outbound.protection.outlook.com ([65.55.169.122]:51385 "EHLO na01-bl2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753570AbbHENp3 (ORCPT ); Wed, 5 Aug 2015 09:45:29 -0400 Authentication-Results: spf=fail (sender IP is 192.88.158.2) smtp.mailfrom=freescale.com; freescale.mail.onmicrosoft.com; dkim=none (message not signed) header.d=none; From: To: CC: , , , , , , , , Igal Liberman Subject: [v4, 4/9] fsl/fman: Add FMan MURAM support Date: Wed, 5 Aug 2015 12:25:20 +0300 Message-ID: <1438766725-8053-5-git-send-email-igal.liberman@freescale.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1438766725-8053-1-git-send-email-igal.liberman@freescale.com> References: <1438766725-8053-1-git-send-email-igal.liberman@freescale.com> Reply-To: X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1;BL2FFO11FD019;1:GCAKOvk4RHrqjojlGxoqwkPqD/o+w7MYotfPkM/PzVbPt/oEhsMNMr3L8wYW06j3EdooFuNQyYGxe0ObSzQiqf2lU6SyQ89ROgkN1SUBez56fyHtGkJCjjmdBpQ2MJW2buXB52/OUNOQNMYjkzGZnb3UNtS7kqMwdCPmYWuFdi+9HPXISGlapeZE/prCe8j8zQ9sPXosgu31cQ3szD7w9+yhOyVUwDWaFFuEFGliTmdUsDpciTIR9l0K8YkV//GJk8DJ+OKtSyp0VvaGhKCuwKWuB5p9qKXLcDkiBUJlHUo90coFvK5xHjXGHmI5PB5zdHkImobstUj2xt8u4E3JCA== X-Forefront-Antispam-Report: CIP:192.88.158.2;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10019020)(6009001)(2980300002)(339900001)(199003)(189002)(68736005)(5001830100001)(189998001)(36756003)(77096005)(229853001)(48376002)(5001960100002)(106466001)(85426001)(43066003)(4001540100001)(46102003)(86152002)(19580395003)(97736004)(19580405001)(2950100001)(6806004)(77156002)(50986999)(76176999)(110136002)(87936001)(50226001)(5001860100001)(47776003)(86362001)(50466002)(2351001)(33646002)(53806999)(64706001)(105606002)(81156007)(104016003)(69596002)(107886002)(62966003)(5003940100001)(2004002)(4001430100001);DIR:OUT;SFP:1102;SCL:1;SRVR:BL2PR03MB547;H:az84smr01.freescale.net;FPR:;SPF:Fail;PTR:InfoDomainNonexistent;A:1;MX:1;LANG:en; MIME-Version: 1.0 Content-Type: text/plain X-Microsoft-Exchange-Diagnostics: 1;BL2PR03MB547;2:cev/0i/x/hjRhb8uXLtXaYw0ERL/HpfVdDIdxqXiXdUJ7O0Wgvgl2HISViXgF1XM73WVk40kv9bz/zD+kJNf1Bee9DZo8QXOOqf7IUiuTk11YYMZl4fNIthQu7iGfTaCasFdomef8NLaBcoUs+tOqPgMoTMyj36mJHJNuqBw7Pw=;3:axrgv6lETm0DL1rbDajqo8ywAVxnWzkE6G68XlyaMWPu/HVYUjqsCdcFGAxcbGVOv3TkDDaaKOlQE5REUSQwGe+lBzEv+Oz4BRKo6fWFqKVJJ5pLcEb4908SX1YoAHNuR1RB4r3xATd4sMi+W59pHpytfUqWIIusGPm07Z1txUhtPqcW4UDJplpKT6+plfd8QHGUyuz555v2sAsSSNDLmbuCcaKJrcG6/gsAyhvuy+0=;25:c58MGd5RbMsBMiF8zRYghdKTN6jSiSq3Tlj9IepykMl9pZPQcZmCu1FWRbD20eudswiOHhj6ZkC1Dk+wUiuRivkaT2wcvEt4nnKSmZZV7G5Rh6R/9venicGsGpnaJDbWOIiE0eQlmWUrgMFhDYUv6vWlOhrmZt4Bt7TrdRco4LnZWpW7jYnJDroPEKlzdMDt54A71M3yNretogGERl7LLpe0vnsDqYbRO3d6AJYJpeb8EnmEpWoLvHUzwuFqkvN/+1FdseScvHpu2SQmZ+McrA== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BL2PR03MB547; X-Microsoft-Exchange-Diagnostics: 1;BL2PR03MB547;20:heFtOJn9Y37MPY4A5RbKsyZIKkgRpnNN3iMCoVtgKYPPSfsIg7dA7UWyzeE0cMBc0CZkYKhkVptZN8zqeLBVOmo3zvmIBgpJlY5t/N54vXIYiWGMtEwztQcmxBke2RwwV1etlKDHzOt1LZjn0g6tjSdB5zp9Xlq2EfJQBLkE2+xqhx84o62pLgWTEsyuuNpZWzYrQJmJo6SO//jfK88DuEkT0T7yJumx2sNJDRYC3h/jjqfvIGNOUYPA3S3fp3S9+ceFzXdsaIWkKWmIi4XqK2aLzjrclIx+x24c+iLJ9ZCDQuYutYNqgWh7bbyx0spH+NJLF1pB0SpUPril8rOBlpx7RfbIJ1uJNtBGNSBqNZc=;4:3KUucxXPqRnMwLQoWXOKE9PrbfZckNzte0UTJqRpAJz7vW/+o530dbZfUOErgv3v8d3WS1rImi1o4mpzWuOzW5JpRbhVgDMucgWm5c4gBOYbeH/Uf5p+EroBHmtJzZ4tUiY+qeAdytOWJLD8n11LTyo+tnYWerpzGAheDgU8rmyYvcuK4pNcllnNtcrl2Y/8jB8LcKJdOvO0KLHVOuhLYHnYiZ2FtxlC6ARAyA07RIV25ght5mmEUVs0F+ptiT7yJz3NBBsFuGfM2FhIqdMU+Pm/PA3eo1YhpSJGxhqGzPk= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(5005006)(3002001);SRVR:BL2PR03MB547;BCL:0;PCL:0;RULEID:;SRVR:BL2PR03MB547; X-Forefront-PRVS: 06592CCE58 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BL2PR03MB547;23:cYUoHaevtaRfdEvG7fCoWiOEAiqWBiP/+uXlE5fL+W?= =?us-ascii?Q?E3Yi3nprfX0qNuORb0QJ4X0jGXkP/D5euWJ4KZ1coh6eSDMxb+fOc2KExqUT?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gdCUt3hjr8M2iCQOf6oMYA?= =?us-ascii?Q?FSCqjTX9hTIvq4CRm/PwgDuiDYSDRqcSVdJCUaieleuHqORX7+sH6pJVTcCk?= =?us-ascii?Q?Es28ZN0FR1so4BQXLBA7ed5G5kMXS9/nStzJIXuUhWd3x+x68Q74Okq3ALGV?= =?us-ascii?Q?/0xYUr3pydLu7S5pIyteWti9e50ckWwGqxh2rLuCLSvG/k8cq31tQK2bwwYr?= =?us-ascii?Q?mC7uKhx/WPWpSjtVbyB2B7ob+zQREiMunjSI3/ydrHCR7SKBej/HCKdQ=3D?= =?us-ascii?Q?=3D?= X-Microsoft-Exchange-Diagnostics: 1;BL2PR03MB547;5:Lnaqv8Mq5nnT3v8gSGHJDSO9kiFRO1zXPOF9TUJ9GkpPd+oC4ERGu5FNN4FFV4JUf124sKd2mpk2RATTL3PZMn3f7Ul3X3/oVPXOudTrfrOltMEGqlQJVMez97AbTb5F/XFF+aSknZ/yyG1RgnW4ug==;24:dFoCTjRuD0yO0Gt/LnPCJXncIVKo9OMaRsxLbAZuzEbInU3CC74qPnXdh6YuPDBRoaH7Nj+zNDsb4vek5//PghNMpqVVKsXzT9sNIPWpp4o=;20:V3TGIYJjHLV9fKid9Ru6owAUkpWp0DmB2/MWdlnTRjqv7NsZL94D01Q45C9hnOV5+yCwBrWt+3C1dkoVkyKbcw== X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Aug 2015 13:29:28.8836 (UTC) X-MS-Exchange-CrossTenant-Id: 710a03f5-10f6-4d38-9ff4-a80b81da590d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=710a03f5-10f6-4d38-9ff4-a80b81da590d;Ip=[192.88.158.2];Helo=[az84smr01.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL2PR03MB547 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 9952 Lines: 280 From: Igal Liberman Add Frame Manager Multi-User RAM support. Signed-off-by: Igal Liberman --- drivers/net/ethernet/freescale/fman/Kconfig | 1 + drivers/net/ethernet/freescale/fman/Makefile | 6 +- drivers/net/ethernet/freescale/fman/fm_muram.c | 115 ++++++++++++++++++++ .../net/ethernet/freescale/fman/inc/fm_muram_ext.h | 102 +++++++++++++++++ 4 files changed, 222 insertions(+), 2 deletions(-) create mode 100644 drivers/net/ethernet/freescale/fman/fm_muram.c create mode 100644 drivers/net/ethernet/freescale/fman/inc/fm_muram_ext.h diff --git a/drivers/net/ethernet/freescale/fman/Kconfig b/drivers/net/ethernet/freescale/fman/Kconfig index 8aeae29..66b7296 100644 --- a/drivers/net/ethernet/freescale/fman/Kconfig +++ b/drivers/net/ethernet/freescale/fman/Kconfig @@ -1,6 +1,7 @@ config FSL_FMAN bool "FMan support" depends on FSL_SOC || COMPILE_TEST + select GENERIC_ALLOCATOR default n help Freescale Data-Path Acceleration Architecture Frame Manager diff --git a/drivers/net/ethernet/freescale/fman/Makefile b/drivers/net/ethernet/freescale/fman/Makefile index 1841b03..55c91bd 100644 --- a/drivers/net/ethernet/freescale/fman/Makefile +++ b/drivers/net/ethernet/freescale/fman/Makefile @@ -1,8 +1,10 @@ -subdir-ccflags-y += -I$(srctree)/drivers/net/ethernet/freescale/fman/flib +subdir-ccflags-y += -I$(srctree)/drivers/net/ethernet/freescale/fman/flib \ + -I$(srctree)/drivers/net/ethernet/freescale/fman/inc \ + -I$(srctree)/drivers/net/ethernet/freescale/fman obj-y += fsl_fman.o -fsl_fman-objs := fman.o +fsl_fman-objs := fman.o fm_muram.o obj-y += port/ obj-y += mac/ diff --git a/drivers/net/ethernet/freescale/fman/fm_muram.c b/drivers/net/ethernet/freescale/fman/fm_muram.c new file mode 100644 index 0000000..9d74bd9 --- /dev/null +++ b/drivers/net/ethernet/freescale/fman/fm_muram.c @@ -0,0 +1,115 @@ +/* + * Copyright 2008-2015 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 Freescale Semiconductor nor the + * names of its 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 Freescale Semiconductor ``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 Freescale Semiconductor 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 "fm_muram_ext.h" + +#include +#include +#include +#include + +struct muram_info { + struct gen_pool *pool; + void __iomem *vbase; + size_t size; + phys_addr_t pbase; +}; + +struct muram_info *fm_muram_init(phys_addr_t base, size_t size) +{ + struct muram_info *muram; + void __iomem *vaddr; + int ret; + + muram = kzalloc(sizeof(*muram), GFP_KERNEL); + if (!muram) + return NULL; + + muram->pool = gen_pool_create(ilog2(64), -1); + if (!muram->pool) { + pr_err("%s(): MURAM pool create failed\n", __func__); + return NULL; + } + + vaddr = ioremap(base, size); + if (!vaddr) { + pr_err("%s(): MURAM ioremap failed\n", __func__); + return NULL; + } + + ret = gen_pool_add_virt(muram->pool, (unsigned long)vaddr, + base, size, -1); + if (ret < 0) { + pr_err("%s(): MURAM pool add failed\n", __func__); + iounmap(vaddr); + return NULL; + } + + memset_io(vaddr, 0, (int)size); + + muram->vbase = vaddr; + muram->pbase = base; + return muram; +} + +unsigned long fm_muram_vbase_to_offset(struct muram_info *muram, + unsigned long vaddr) +{ + return vaddr - (unsigned long)muram->vbase; +} + +unsigned long fm_muram_offset_to_vbase(struct muram_info *muram, + unsigned long offset) +{ + return offset + (unsigned long)muram->vbase; +} + +int fm_muram_alloc(struct muram_info *muram, size_t size) +{ + unsigned long vaddr; + + vaddr = gen_pool_alloc(muram->pool, size); + if (!vaddr) + return -ENOMEM; + + memset_io((void __iomem *)vaddr, 0, size); + + return fm_muram_vbase_to_offset(muram, vaddr); +} + +void fm_muram_free_mem(struct muram_info *muram, u32 offset, size_t size) +{ + unsigned long addr = fm_muram_offset_to_vbase(muram, offset); + + gen_pool_free(muram->pool, addr, size); +} + diff --git a/drivers/net/ethernet/freescale/fman/inc/fm_muram_ext.h b/drivers/net/ethernet/freescale/fman/inc/fm_muram_ext.h new file mode 100644 index 0000000..d027b16 --- /dev/null +++ b/drivers/net/ethernet/freescale/fman/inc/fm_muram_ext.h @@ -0,0 +1,102 @@ +/* + * Copyright 2008-2015 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 Freescale Semiconductor nor the + * names of its 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 Freescale Semiconductor ``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 Freescale Semiconductor 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 __FM_MURAM_EXT +#define __FM_MURAM_EXT + +#include "linux/types.h" + +#define FM_MURAM_INVALID_ALLOCATION -1 + +/* Structure for FM MURAM information */ +struct muram_info; + +/** + * fm_muram_init + * @base: Pointer to base of memory mapped FM-MURAM. + * @size: Size of the FM-MURAM partition. + * + * Creates partition in the MURAM. + * The routine returns a pointer to the MURAM partition. + * This pointer must be passed as to all other FM-MURAM function calls. + * No actual initialization or configuration of FM_MURAM hardware is done by + * this routine. + * + * Return: pointer to FM-MURAM object, or NULL for Failure. + */ +struct muram_info *fm_muram_init(phys_addr_t base, size_t size); + +/** + * fm_muram_vbase_to_offset + * @muram: FM-MURAM module pointer. + * @vaddr: The virtual address of the memory block + * + * Gives the offset of the memory region in the MURAM + * + * Return: The offset of the memory block + */ +unsigned long fm_muram_vbase_to_offset(struct muram_info *muram, + unsigned long vaddr); + +/** + * fm_muram_vbase_to_offset + * @muram: FM-MURAM module pointer. + * @offset: the offset of the memory block + * + * Gives the address of the memory region from specific oddset + * + * Return: The address of the memory blocl + */ +unsigned long fm_muram_offset_to_vbase(struct muram_info *muram, + unsigned long offset); + +/** + * fm_muram_alloc + * @muram: FM-MURAM module pointer. + * @size: Size of the memory to be allocated. + * + * Allocate some memory from FM-MURAM partition. + * + * Return: address of the allocated memory; NULL otherwise. + */ +int fm_muram_alloc(struct muram_info *muram, size_t size); + +/** + * fm_muram_free_mem + * muram: FM-MURAM module pointer. + * offset: offset of the memory region to be freed. + * size: size of the memory to be freed. + * + * Free an allocated memory from FM-MURAM partition. + */ +void fm_muram_free_mem(struct muram_info *muram, u32 offset, size_t size); + +#endif /* __FM_MURAM_EXT */ -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/