Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933438AbbFJPXi (ORCPT ); Wed, 10 Jun 2015 11:23:38 -0400 Received: from mail-bn1on0145.outbound.protection.outlook.com ([157.56.110.145]:20800 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932859AbbFJPXW (ORCPT ); Wed, 10 Jun 2015 11:23:22 -0400 X-Greylist: delayed 27045 seconds by postgrey-1.27 at vger.kernel.org; Wed, 10 Jun 2015 11:23:15 EDT Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=freescale.com; freescale.mail.onmicrosoft.com; dkim=none (message not signed) header.d=none; From: Madalin Bucur To: , , CC: , Igal Liberman Subject: [PATCH 07/12] fsl/fman: Add FMan MURAM support Date: Wed, 10 Jun 2015 18:21:41 +0300 Message-ID: <1433949712-5648-2-git-send-email-madalin.bucur@freescale.com> X-Mailer: git-send-email 1.5.6.5 In-Reply-To: <1433949712-5648-1-git-send-email-madalin.bucur@freescale.com> References: <1433949712-5648-1-git-send-email-madalin.bucur@freescale.com> Reply-To: X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1;BY2FFO11FD053;1:to1HXyMqYWTxhkFCvGk6UXwXqUKw9EX2SnvMnXO4UAt3+KP0NChYWAHXq6yGFQmhLXdRKjGp03yBFfU+6jUpZ4bzkicVVBkuvREHVmcjsVEy9VOeR2r4AbpKp7/FQ8A6+G9iObnEQcjegHVpsWlUkyDHnnjicIc2EoAqG0lsj8PQwdaBc9VdrJSU3WSUgVF2U+SqRqTVphTgp0QrOAo6RlWgg0ArW90Z9uzi1ExWT7EjuPZ8WZzlsbFQY3yMIsCFbGLBkf5UJtojZd59IadE5dfWjUKu9F03pcnZcgsZ5AQmho482L7rJOJDhFAaybwZRAjZVNKAq/RJwh17bSkWaA== X-Forefront-Antispam-Report: CIP:192.88.168.50;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10019020)(6009001)(339900001)(189002)(199003)(107886002)(77096005)(5001960100002)(50986999)(6806004)(47776003)(2201001)(87936001)(46102003)(189998001)(76176999)(43066003)(104016003)(575784001)(49486002)(86362001)(33646002)(36756003)(5001770100001)(229853001)(19580395003)(77156002)(50226001)(19580405001)(53806999)(2950100001)(85426001)(48376002)(105606002)(62966003)(2004002)(2101003)(4001430100001);DIR:OUT;SFP:1102;SCL:1;SRVR:BL2PR03MB369;H:tx30smr01.am.freescale.net;FPR:;SPF:Fail;MLV:sfv;MX:1;A:1;LANG:en; MIME-Version: 1.0 Content-Type: text/plain X-Microsoft-Exchange-Diagnostics: 1;BL2PR03MB369;2:owlMCvnRHrKZ7G8UFQa6WW2sPoRJhU+vqYk+1cC7ZUcLXIaTkqu8rzOUV6J11WpZ;2:YiEuNqxe6iBLH6ln/VLW5k5n7Eajj90ZGjC60jFu8N77F5Pk161/0U8FE3Z/JzC6VxjzzaiZ53wjl6UnCxUOXHm3Ylzi2mfkbNgPCV8/GDAR2+Sd0xCPOikS3sizXYXDlvD6e/iyv4txhjiKcMO+s3M0xHEC1ZbKfJ9RFCK/ldjneQGLUb5xrIqCXkj2tPn2CCGhPAd0ptQj6q/kZn0JLfR6+3Q4dHAos3RI+EfCeyo=;6:/Ex1KanhdVoepzQPAk+z9qej7CfTX2LbqiraZyJEAkvL8PlaFaXH08YRQ+O25PSHklIsnLyHi2ZN0sugSlyncPxFoU8f4TI3DvCG9NOmrjKxsPno6vrYt8NYMwmZiVEwMplvE0qVrb8yJX8zPRVU454t3Qpwm54M1EuiBo0bdjJU8Dp1K8jsl65kVh8XR00WWOmN8X/mzkdevmqGVt7gQ4V1onl7aCKXeWSCgl+WIhoKSBKbLDA1G572wG1hPSVMVE1xrlI8UpeybCZ9OPBT2JGl6Jhgcfg+6ydo/PgPQckACSa0HVmHlOc7AIyOq12+ruAZwKAAAKq6KfV8Z6wSiQ==;3:TPToWEWd6WjLQZkQlzHUJCxZa8kXiRK//GLrXbeL3IB9XyyWEgzN4DqbPpVjq2fX2fpQUCwyvPOSd67kDl7/LVOutsjtdB3O72Y20doaIcSZnJLmSR3KV7ui3xOeF/pXKUGlhB0ijMzH+AfnKqdDEs0josoTCfb737fZo+j+kpUK7B9oIwFGxhStsW1Fy6fEsDBmkbP6C1vK+VovDW7PQ/eGG5wb1yh3SjZeMmnOzLqLh6uRB9xNuC5/Td899CtKN8N9MHiaGHCmOHps0Otu0RxQUo3PPeabO/qJuw9BlquYdEzkRVo36d7BFAdoMdE2 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BL2PR03MB369; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(5005006)(520003)(3002001);SRVR:BL2PR03MB369;BCL:0;PCL:0;RULEID:;SRVR:BL2PR03MB369; X-Forefront-PRVS: 06036BD506 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BL2PR03MB369;9:TB785GTKLV5uedL8CYhdGnXhcK24sjBntoLopWNDroV?= =?us-ascii?Q?vuwTgaFc93U2qysicwH2+dR7pjNmqtnAWAdDI5gs/ZHKgplmc8mWQwsKSasR?= =?us-ascii?Q?nh766mmZBP2SQ3BivKJvqm4i/He5mg7NWn8G7U4lZIhhV7N6ejCKZ/f3ouP8?= =?us-ascii?Q?JQ3perz0F8iMabgNY0U6c4x10FqF8iVmSNZ0BCblsq9zHJPEdOgSGW9ECkmN?= =?us-ascii?Q?DgQwLQVc8ILgwWTLjbJdSuecUx3FGB3N5ke0UojU8fAj2uiWntJnnMpnQ0dV?= =?us-ascii?Q?EndGsVWOQPkeyvXpMfODplsQzGOmkwNgRivJcCVYS44rtq0cjhtG7EmtPgIE?= =?us-ascii?Q?rK0UIs9LrEDow9FDZDycWFMDu2JJpuX8ngrC6gicHjEofI1cvtvt3vdM2qUX?= =?us-ascii?Q?jQw1KsL8QbqSG/M46ytiKyvqErTaTmWWUzFg6eRN4g5F37WmoBd9LYsfrnyp?= =?us-ascii?Q?OEAn9gS8ojURD/OLCo4UHZKE4+5YYrin5Hwn6M13qddo/s06j3K9ajawiBGl?= =?us-ascii?Q?DHxlFBl+fO5cLvk3myGRMPrjC2LuJlqoJgmQlDZH216VZGNGcnQMqqR89cFl?= =?us-ascii?Q?yi/tRrLfoGp84jkMbCoTJC/dqZWE6BPCMdafy19hPLoN1Uh7pOX+8GAbrmpQ?= =?us-ascii?Q?rVv813Di8b3Bzi/fyG7pAU8wUFTOQnnRiQtwu8AjH/1THjAAeBK24Lod77n4?= =?us-ascii?Q?zXRwnau/AN82b70TwxKcM26PlnbLPdcaS4Q3/wCviNgvxJGiILlf/spYfv1n?= =?us-ascii?Q?oftv+QPIO3D6owHbXSbkn1sJmb3/Pvxm16HheoxHnmNpp+O3Fe3anIdeW5aK?= =?us-ascii?Q?HQ2pB3G3v4tNexfQaOJ330Du867RaxQUvJ7HHbFCJezSJthA0Y5cMM7ea1t1?= =?us-ascii?Q?8GB+aoxLx1zlLJHLeN8RFgLGPvQ8qRCGELo443c4jXc0eeZ1OQLindln17x6?= =?us-ascii?Q?g3YOuir17bOQO6AhRwXr3w3r8VVuGB5liLqwrjQ=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1;BL2PR03MB369;3:bu30a6mHrKZ50NMGmpBxnx9Dj/rP97RlkO2pO2PxGN53f//2FfnpTZ68IT2yh+vQnFw9rutMpoI86KQKBte4kGH13jl1Wdbg6/JmM5OZ+7ojOBFQmfwp7MWSkFgTKrnXH/og7HIQ9bNNUJ1YxMagXQ==;10:Vg7qkyXsOyS8c1NoK9E8/n1i5psxkTKMKd+iqXBB47LIn2OTuV/PV/jklIMok300haBPsrvnWyKHJ0WljvWlObNdw9w0/iQPdrZtvyZ7bIg=;6:BTz9BEVQ72f+BzbRp3e2POJmGthX/2wGDTTsQ0J0S98OtMTuChnpf1fpFGtXoNRR X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jun 2015 15:23:09.0057 (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.168.50];Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL2PR03MB369 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 10899 Lines: 293 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 | 127 +++++++++++++++++++++ .../net/ethernet/freescale/fman/inc/fm_muram_ext.h | 103 +++++++++++++++++ 4 files changed, 235 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 af42c3a..825a0d5 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..f62042a --- /dev/null +++ b/drivers/net/ethernet/freescale/fman/fm_muram.c @@ -0,0 +1,127 @@ +/* + * 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. + */ + +/* FM MURAM ... */ +#include "fm_muram_ext.h" + +#include +#include +#include +#include + +struct muram_info { + struct gen_pool *pool; + void __iomem *vbase; + uint64_t size; + phys_addr_t pbase; +}; + +struct muram_info *fm_muram_init(phys_addr_t base, uint64_t size) +{ + struct muram_info *p_muram; + void __iomem *vaddr; + int ret; + + p_muram = kzalloc(sizeof(*p_muram), GFP_KERNEL); + if (!p_muram) + return NULL; + + p_muram->pool = gen_pool_create(ilog2(64), -1); + if (!p_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(p_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); + + p_muram->vbase = vaddr; + p_muram->pbase = base; + return p_muram; +} + +void fm_muram_free(struct muram_info *p_muram) +{ + /* Destroy pool */ + gen_pool_destroy(p_muram->pool); + /* Unmap memory */ + iounmap(p_muram->vbase); + /* Free pointer */ + kfree(p_muram); +} + +unsigned long fm_muram_vbase_to_offset(struct muram_info *p_muram, + unsigned long vaddr) +{ + return vaddr - (unsigned long)p_muram->vbase; +} + +unsigned long fm_muram_offset_to_vbase(struct muram_info *p_muram, + unsigned long offset) +{ + return offset + (unsigned long)p_muram->vbase; +} + +int fm_muram_alloc(struct muram_info *p_muram, uint32_t size) +{ + unsigned long vaddr; + + vaddr = gen_pool_alloc(p_muram->pool, size); + if (!vaddr) + return -ENOMEM; + + memset_io((void __iomem *)vaddr, 0, (int)size); + + return fm_muram_vbase_to_offset(p_muram, vaddr); +} + +void fm_muram_free_mem(struct muram_info *p_muram, uint32_t offset, + uint32_t size) +{ + unsigned long addr = fm_muram_offset_to_vbase(p_muram, offset); + + gen_pool_free(p_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..bc25764 --- /dev/null +++ b/drivers/net/ethernet/freescale/fman/inc/fm_muram_ext.h @@ -0,0 +1,103 @@ +/* + * 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. + */ + +/* File fm_muram_ext.h + * Description FM MURAM Application Programming Interface. + */ +#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 initialization API functions, definitions and enums */ + +/* Function fm_muram_init + * Description Creates partition in the MURAM. + * The routine returns a pointer to the MURAM partition. + * This pointer must be passed as first parameter to all other + * FM-MURAM function calls. + * No actual initialization or configuration of FM_MURAM hardware + * is done by this routine. + * Param[in] base - Pointer to base of memory mapped FM-MURAM. + * Param[in] size - Size of the FM-MURAM partition. + * Return pointer to FM-MURAM object, or NULL for Failure. + */ +struct muram_info *fm_muram_init(phys_addr_t base, uint64_t size); + +/* Function fm_muram_free + * Description Frees all resources that were assigned to FM-MURAM module. + * Calling this routine invalidates the pointer. + * Param[in] p_muram - FM-MURAM module pointer. + */ +void fm_muram_free(struct muram_info *p_muram); + +/* Function fm_muram_vbase_to_offset + * Description gives the offset of the memory region in the MURAM + * Param[in] p_muram - FM-MURAM module pointer. + * Param[in] vaddr - the virtual address of the memoru block + * Return the offset of the memory block + */ +unsigned long fm_muram_vbase_to_offset(struct muram_info *p_muram, + unsigned long vaddr); + +/* Function fm_muram_vbase_to_offset + * Description gives the address of the memory region from specific oddset + * Param[in] p_muram - FM-MURAM module pointer. + * Param[in] offset - the offset of the memory block + * Return the address of the memory blocl + */ +unsigned long fm_muram_offset_to_vbase(struct muram_info *p_muram, + unsigned long offset); + +/* Function fm_muram_alloc + * Description Allocate some memory from FM-MURAM partition. + * Param[in] p_muram - FM-MURAM module pointer. + * Param[in] size - size of the memory to be allocated. + * Return address of the allocated memory; NULL otherwise. + */ +int fm_muram_alloc(struct muram_info *p_muram, uint32_t size); + +/* Function fm_muram_free_mem + * Description Free an allocated memory from FM-MURAM partition. + * Param[in] p_muram - FM-MURAM module pointer. + * Param[in] offset - offset of the memory region to be freed. + * Param[in] size - size of the memory to be freed. + */ +void fm_muram_free_mem(struct muram_info *p_muram, uint32_t offset, + uint32_t size); + +#endif /* __FM_MURAM_EXT */ -- 1.7.11.7 -- 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/