From patchwork Fri Jul 5 21:39:13 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ezequiel Garcia X-Patchwork-Id: 2824361 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id CA13E9F3C3 for ; Fri, 5 Jul 2013 21:42:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D35DE20108 for ; Fri, 5 Jul 2013 21:42:17 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9C012200F8 for ; Fri, 5 Jul 2013 21:42:16 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UvDkR-0001zx-FT; Fri, 05 Jul 2013 21:41:00 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UvDk8-00074t-3x; Fri, 05 Jul 2013 21:40:40 +0000 Received: from mail.free-electrons.com ([94.23.35.102]) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UvDji-00070v-Rf for linux-arm-kernel@lists.infradead.org; Fri, 05 Jul 2013 21:40:16 +0000 Received: by mail.free-electrons.com (Postfix, from userid 106) id D68F7814; Fri, 5 Jul 2013 23:39:56 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from localhost.localdomain (unknown [190.2.109.25]) by mail.free-electrons.com (Postfix) with ESMTPA id 772437C2; Fri, 5 Jul 2013 23:39:52 +0200 (CEST) From: Ezequiel Garcia To: , Subject: [PATCH v6 02/21] bus: mvebu-mbus: Add new API for window creation Date: Fri, 5 Jul 2013 18:39:13 -0300 Message-Id: <1373060372-32357-3-git-send-email-ezequiel.garcia@free-electrons.com> X-Mailer: git-send-email 1.8.1.5 In-Reply-To: <1373060372-32357-1-git-send-email-ezequiel.garcia@free-electrons.com> References: <1373060372-32357-1-git-send-email-ezequiel.garcia@free-electrons.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130705_174015_121399_20AEEC81 X-CRM114-Status: GOOD ( 11.06 ) X-Spam-Score: -2.1 (--) Cc: Thomas Petazzoni , Andrew Lunn , Jason Cooper , Arnd Bergmann , Grant Likely , Jason Gunthorpe , Maen Suleiman , Lior Amsalem , Gregory Clement , Sebastian Hesselbarth X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Thomas Petazzoni We add an API to create MBus address decoding windows from the target ID and attribute. This function will be used later and deprecate the current name based scheme. Signed-off-by: Thomas Petazzoni --- drivers/bus/mvebu-mbus.c | 33 +++++++++++++++++++++++++-------- include/linux/mbus.h | 6 ++++++ 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/drivers/bus/mvebu-mbus.c b/drivers/bus/mvebu-mbus.c index 33c6947..827468a 100644 --- a/drivers/bus/mvebu-mbus.c +++ b/drivers/bus/mvebu-mbus.c @@ -748,6 +748,22 @@ static const struct of_device_id of_mvebu_mbus_ids[] = { /* * Public API of the driver */ +int mvebu_mbus_add_window_remap_by_id(unsigned int target, + unsigned int attribute, + phys_addr_t base, size_t size, + phys_addr_t remap) +{ + struct mvebu_mbus_state *s = &mbus_state; + + if (!mvebu_mbus_window_conflicts(s, base, size, target, attribute)) { + pr_err("cannot add window '%x:%x', conflicts with another window\n", + target, attribute); + return -EINVAL; + } + + return mvebu_mbus_alloc_window(s, base, size, remap, target, attribute); +} + int mvebu_mbus_add_window_remap_flags(const char *devname, phys_addr_t base, size_t size, phys_addr_t remap, unsigned int flags) @@ -776,14 +792,8 @@ int mvebu_mbus_add_window_remap_flags(const char *devname, phys_addr_t base, else if (flags == MVEBU_MBUS_PCI_WA) attr |= 0x28; - if (!mvebu_mbus_window_conflicts(s, base, size, target, attr)) { - pr_err("cannot add window '%s', conflicts with another window\n", - devname); - return -EINVAL; - } - - return mvebu_mbus_alloc_window(s, base, size, remap, target, attr); - + return mvebu_mbus_add_window_remap_by_id(target, attr, base, + size, remap); } int mvebu_mbus_add_window(const char *devname, phys_addr_t base, size_t size) @@ -792,6 +802,13 @@ int mvebu_mbus_add_window(const char *devname, phys_addr_t base, size_t size) MVEBU_MBUS_NO_REMAP, 0); } +int mvebu_mbus_add_window_by_id(unsigned int target, unsigned int attribute, + phys_addr_t base, size_t size) +{ + return mvebu_mbus_add_window_remap_by_id(target, attribute, base, + size, MVEBU_MBUS_NO_REMAP); +} + int mvebu_mbus_del_window(phys_addr_t base, size_t size) { int win; diff --git a/include/linux/mbus.h b/include/linux/mbus.h index dba482e..9245b66 100644 --- a/include/linux/mbus.h +++ b/include/linux/mbus.h @@ -62,8 +62,14 @@ static inline const struct mbus_dram_target_info *mv_mbus_dram_info(void) int mvebu_mbus_add_window_remap_flags(const char *devname, phys_addr_t base, size_t size, phys_addr_t remap, unsigned int flags); +int mvebu_mbus_add_window_remap_by_id(unsigned int target, + unsigned int attribute, + phys_addr_t base, size_t size, + phys_addr_t remap); int mvebu_mbus_add_window(const char *devname, phys_addr_t base, size_t size); +int mvebu_mbus_add_window_by_id(unsigned int target, unsigned int attribute, + phys_addr_t base, size_t size); int mvebu_mbus_del_window(phys_addr_t base, size_t size); int mvebu_mbus_init(const char *soc, phys_addr_t mbus_phys_base, size_t mbus_size, phys_addr_t sdram_phys_base,