Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934752AbbGVPlm (ORCPT ); Wed, 22 Jul 2015 11:41:42 -0400 Received: from mail-bn1bon0113.outbound.protection.outlook.com ([157.56.111.113]:56728 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S934715AbbGVPlh (ORCPT ); Wed, 22 Jul 2015 11:41:37 -0400 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: To: CC: , , , , , , , Igal Liberman Subject: [v3, 4/9] fsl/fman: Add FMan MURAM support Date: Wed, 22 Jul 2015 14:22:09 +0300 Message-ID: <1437564129-16558-1-git-send-email-igal.liberman@freescale.com> X-Mailer: git-send-email 1.7.9.5 Reply-To: X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1;BL2FFO11OLC011;1:jVdkyYgXVj7nuaB/gWclM6Eaj7HpKUerzPQN5L1MLbg4gDNKU2QZ5P0EQ46faUck0rgYp6RRAT04sDxTCsdOVQw9YoFQssZjFRpbwC2JBAUjpfkd8ONdvjqncGdYnhNDSBwD3vmpQeP5NnVkBDnefIcK5WC052bsTnT5wvVY0sY86xGDCX3Q6P86uRVz9Sk86Sl8zBmJm/qpNZKbL6ET8S7YbwoeeWCOsk/AIj7z1Cmc7CcD6S6uhIvq0zL8tsmm47N0CSgTwQq5xFr2s6ziya02HhPxzBK4n2wRYwporR6tT3xJu5V/Gqqzjz+EugoEzeaV03HQII9LJYguB0m/Gg== X-Forefront-Antispam-Report: CIP:192.88.168.50;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10019020)(6009001)(2980300002)(339900001)(199003)(189002)(53806999)(5001960100002)(106466001)(107886002)(50986999)(48376002)(189998001)(110136002)(575784001)(87936001)(86362001)(6806004)(85426001)(86152002)(43066003)(77096005)(19580405001)(50226001)(19580395003)(50466002)(105606002)(104016003)(5003940100001)(33646002)(47776003)(229853001)(2351001)(36756003)(46102003)(77156002)(62966003)(4001430100001);DIR:OUT;SFP:1102;SCL:1;SRVR:BY2PR03MB378;H:tx30smr01.am.freescale.net;FPR:;SPF:Fail;MLV:sfv;A:1;MX:1;LANG:en; MIME-Version: 1.0 Content-Type: text/plain X-Microsoft-Exchange-Diagnostics: 1;BY2PR03MB378;2:Hg6P3rj5iaGGDVjWXvD7ZMM5ONX9306DWiOeerDw6BvRcs5O4fgjB2lR8yCogeUJEHhszdvAS1JK2cCCSdkSLuR2WAnr1k5bLyb830pENRDu/kI6bgSmN9tzZzdqmGaSaj8gWzfq6xsSrCWHdXoEjkD2oE1KAWurUBx7/hnk/Xo=;3:YWXQZaFadJrXEtnZvJBvEVYdId6+BNVi/1k+lQvz+xzHcM4lLu3a4BQPgC7PjjsXthzoMzp207OJZ1qaMqfe0eDRTLrWQ+G8A3rKpwwMCtrwqpz7LLkOduiZV3zil8udIHDu3il9KQwlLYhXx0q7gRWxe9IXcZ6wZYbTo2mq46XzxTjdbKuquNGdMEnb7T1wa+254jHAsgHEaFmswIO9Y5fLq0IpJ8teckJrkWcY4Nc=;25:mKkqajugjqQos1sWTxKUOqfDs38X9ptMbR7clCc6kVw0e3VSqMCcAWjDKmBQeJgmD65X6r/Vgs3KWe69EO7wOTnfSW/jpxM/0UnuLbVMzPo9aLdG/5V4dhrJD3aW2FE5LQUI4lnJPjcaao2UjnB+qob7Q9cKRZYuwenfJ7wtLYT8P19oi3GYylzQZGbkm5bO0YZ0dbtkQP9s6p2QsHZVrPwUXrzlgfGHT5oueSbox99cHS/Wm7E2SSTfhDfdqP4cr9NQO3raezb0jITzWlclXw== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY2PR03MB378; X-Microsoft-Exchange-Diagnostics: 1;BY2PR03MB378;20:W5vKg7TIS0kcUEy6jFYbGhb38S+XZYIGdxn1pv8j8Dq1QMonDhWP5IsqBGKo5A6l1ajsxWgyoC1y/hCxNECLgrrwCEVW6TSRW9cl1hRUmbK8V3NHjML+QK+anj/p5JILroNkRydel/YYTC8TCVW+w/JncRFhcTlRDZu/RRbdzlEACL2aStTCmFrY7rjP0dcE88AFX4y43IRg7tyBiLTtFqjpxkLgvKdVOwDU0YLkmGUzbr95UiFG/Xg/r300uPtab9Ovo0ZhaHjloY7+jzF2zSOBBwMaZcFmtzteOxYvuGIyF3sYAMkX7w1Kn1kPKSzyJ8pEPgHWSnfCqT+QDkEUgLqU9xY/7KmuM6w9VfUKZ/0=;4:0lzQPJNBG+dEJYGvz9AnQ4SGf+a/U3WTFcdLedEizC5zjzH2q3e8iosOpBHwDlXcglp7KrEZ/U5HITHLOcs4mSoaJaaYS+gmTACTY/wGKgE9y4886i6sE7Qi0VAdHyx8vrn9xKo4qxD91fBGCSp+kwzyOjDrKhJ4smeKdjAMlurrJl4+1Ezbbs5ppTNsfpaWe2vIbt5K9d68AqB12dNgnbqa01AwopijpJU9v7IXqluC5ZoDtiWltvEUhSjdJz/IWGiHswOzJP7WM07qOIIEay034/zswA3dwuQV+VqQTaU= BY2PR03MB378: X-MS-Exchange-Organization-RulesExecuted 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:BY2PR03MB378;BCL:0;PCL:0;RULEID:;SRVR:BY2PR03MB378; X-Forefront-PRVS: 0645BEB7AA X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BY2PR03MB378;23:e0zDBspXrdzkx99dgj1+Pl+4bHQMq3WZzRqcirJSXE?= =?us-ascii?Q?9BNIHKg34Zxz4m5hSlO1ysCbXYJ5In9k7pwPn4u87mERLmwLUFFlhLdetJFT?= =?us-ascii?Q?O5CdV3zftbN+Y/L7e2uuc0Lg5q0/5eJePPxlrLu4cirhU+U2ek9oiro/oaY9?= =?us-ascii?Q?Gw3nyavnIrYt7C/HnBHpjDzJVn1vGosHiE96zoazO3HvqXn/JRYwLwP4BbxT?= =?us-ascii?Q?+kh88BAn/vD1BUXAaSD0NpdvYcOxEfS6tXsG7zK+5mEG/GJQAe30rtdH5fU7?= =?us-ascii?Q?wXly7fdepbHOS9fDnhnqYaImC/K0FhDOooNcu16Xha3/gzewSmva4B1oCo+x?= =?us-ascii?Q?yVQzy+p/qTxqr62OGAygLO7b32qX2HhnIRTcUHhCHKhhsC3ZAIJcv1IL/cf4?= =?us-ascii?Q?j/EleJhAC6IkAmupKUmqPhIdO2sGRydIVSqORG9p2SF21a7slGF0hrPrE6CM?= =?us-ascii?Q?27LUNy8+HBc8qpqL9kRittL4tzEMSdbfHbyMnxgwBFQPq49Qy39sEGXDcG1G?= =?us-ascii?Q?WBcnFQfxGQph2wmdsfJabbLuWe1SuzXVKBv0VZcxJ6ohFu4K614rwEC9lRNk?= =?us-ascii?Q?uYn836rZsIMIshc8QArjrOo1s6v0Og10gwxTzFb6m1BdH10flhczeMlnH1w4?= =?us-ascii?Q?cKtg/1ufpui2Xtr8nwKvW4VN8f8VWr1jgeZRVTyjCwof24sv9TWxnXT8aOe+?= =?us-ascii?Q?9MHETGbZkeQ9a54kR35+Ydt3YqyuogM0OoqFvO7EX8R3NZd4VjZd2WbOIbgk?= =?us-ascii?Q?ccnBTq+vwEP4dh1xkmFfV3igDhJYKYJaQKirMk5PFSgWyjG+r4dEcCY0SmKc?= =?us-ascii?Q?eQJaYOuPLQxjw9AGLz9Aw2mcPUJXm72Som5z9WmkYDaUVJc7Q5hgaDS/dvO4?= =?us-ascii?Q?pgGQ0qFUU68dPI4NWFPfe5y+bjAn2o0jPnTK02xYC2ag0EQtHoBarZGhksXO?= =?us-ascii?Q?xHmgYL9WD5gnoMJ+CoxynrF9QdPAzPcOxxJPJGQzRc7JyOcrNZIq/iR5PVoJ?= =?us-ascii?Q?A=3D?= X-Microsoft-Exchange-Diagnostics: 1;BY2PR03MB378;5:HEe91rXPNAj2OvASsWqT7MrtNYYH94bmEiFmrS2KvI70Hy0f/ksF3jFtPV3gqgyp0NL+8qDbDWMQEVDZETuV7NaGd1X0QeZNIBjl8hFV15Vy1pwXPvocgwhH1DlwnhfFSFHvsSXLqUayf6tZpMwULw==;24:cIoOVFDXpZebOsYCuv+r3savx7kFBDlJlnSpA/CAnrLtfzQ7/4eHkFt7XClFRAnIlje8Gl+/6WdjdfovDVigAt42Bq+SJUEdKJOHizdqQ7o=;20:iO/qnK/ov8V7pfpi7nPm/zlYnV+mxpMpI52zRGZJgVMX3fTfFmZRZNTOSu+w7Xc6O7mrQhrWWbd0edfUJ7WJPQ== X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jul 2015 15:26:48.2683 (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: BY2PR03MB378 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 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..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/