From: Marcin Wojtas <mw@semihalf.com>
To: linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org
Cc: thomas.petazzoni@free-electrons.com, andrew@lunn.ch,
linux@arm.linux.org.uk, jason@lakedaemon.net, myair@marvell.com,
jaz@semihalf.com, simon.guinot@sequanux.org, xswang@marvell.com,
nadavh@marvell.com, alior@marvell.com, tn@semihalf.com,
gregory.clement@free-electrons.com, nitroshift@yahoo.com,
mw@semihalf.com, davem@davemloft.net,
sebastian.hesselbarth@gmail.com
Subject: [PATCH 07/13] bus: mvebu-mbus: provide api for obtaining IO and DRAM window information
Date: Sun, 22 Nov 2015 08:53:53 +0100 [thread overview]
Message-ID: <1448178839-3541-8-git-send-email-mw@semihalf.com> (raw)
In-Reply-To: <1448178839-3541-1-git-send-email-mw@semihalf.com>
This commit enables finding appropriate mbus window and obtaining its
target id and attribute for given physical address in two separate
routines, both for IO and DRAM windows. This functionality
is needed for Armada XP/38x Network Controller's Buffer Manager and
PnC configuration.
Signed-off-by: Marcin Wojtas <mw@semihalf.com>
[DRAM window information reference in LKv3.10]
Signed-off-by: Evan Wang <xswang@marvell.com>
---
drivers/bus/mvebu-mbus.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++++
include/linux/mbus.h | 3 +++
2 files changed, 54 insertions(+)
diff --git a/drivers/bus/mvebu-mbus.c b/drivers/bus/mvebu-mbus.c
index c43c3d2..3d1c0c3 100644
--- a/drivers/bus/mvebu-mbus.c
+++ b/drivers/bus/mvebu-mbus.c
@@ -948,6 +948,57 @@ void mvebu_mbus_get_pcie_io_aperture(struct resource *res)
*res = mbus_state.pcie_io_aperture;
}
+int mvebu_mbus_get_dram_win_info(phys_addr_t phyaddr, u8 *target, u8 *attr)
+{
+ const struct mbus_dram_target_info *dram;
+ int i;
+
+ /* Get dram info */
+ dram = mv_mbus_dram_info();
+ if (!dram) {
+ pr_err("missing DRAM information\n");
+ return -ENODEV;
+ }
+
+ /* Try to find matching DRAM window for phyaddr */
+ for (i = 0; i < dram->num_cs; i++) {
+ const struct mbus_dram_window *cs = dram->cs + i;
+
+ if (cs->base <= phyaddr && phyaddr <= (cs->base + cs->size)) {
+ *target = dram->mbus_dram_target_id;
+ *attr = cs->mbus_attr;
+ return 0;
+ }
+ }
+
+ pr_err("invalid dram address 0x%x\n", phyaddr);
+ return -EINVAL;
+}
+EXPORT_SYMBOL_GPL(mvebu_mbus_get_dram_win_info);
+
+int mvebu_mbus_get_io_win_info(phys_addr_t phyaddr, u32 *size, u8 *target,
+ u8 *attr)
+{
+ int win;
+
+ for (win = 0; win < mbus_state.soc->num_wins; win++) {
+ u64 wbase;
+ int enabled;
+
+ mvebu_mbus_read_window(&mbus_state, win, &enabled, &wbase,
+ size, target, attr, NULL);
+
+ if (!enabled)
+ continue;
+
+ if (wbase <= phyaddr && phyaddr <= wbase + *size)
+ return win;
+ }
+
+ return -EINVAL;
+}
+EXPORT_SYMBOL_GPL(mvebu_mbus_get_io_win_info);
+
static __init int mvebu_mbus_debugfs_init(void)
{
struct mvebu_mbus_state *s = &mbus_state;
diff --git a/include/linux/mbus.h b/include/linux/mbus.h
index 1f7bc63..ea34a86 100644
--- a/include/linux/mbus.h
+++ b/include/linux/mbus.h
@@ -69,6 +69,9 @@ static inline const struct mbus_dram_target_info *mv_mbus_dram_info_nooverlap(vo
int mvebu_mbus_save_cpu_target(u32 *store_addr);
void mvebu_mbus_get_pcie_mem_aperture(struct resource *res);
void mvebu_mbus_get_pcie_io_aperture(struct resource *res);
+int mvebu_mbus_get_dram_win_info(phys_addr_t phyaddr, u8 *target, u8 *attr);
+int mvebu_mbus_get_io_win_info(phys_addr_t phyaddr, u32 *size, u8 *target,
+ u8 *attr);
int mvebu_mbus_add_window_remap_by_id(unsigned int target,
unsigned int attribute,
phys_addr_t base, size_t size,
--
1.8.3.1
next prev parent reply other threads:[~2015-11-22 7:53 UTC|newest]
Thread overview: 52+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-22 7:53 [PATCH 00/13] mvneta Buffer Management and enhancements Marcin Wojtas
2015-11-22 7:53 ` [PATCH 01/13] net: mvneta: add configuration for MBUS windows access protection Marcin Wojtas
2015-11-25 18:19 ` Gregory CLEMENT
2015-11-22 7:53 ` [PATCH 02/13] net: mvneta: enable IP checksum with jumbo frames for Armada 38x on Port0 Marcin Wojtas
2015-11-22 20:00 ` Arnd Bergmann
2015-11-22 21:04 ` Marcin Wojtas
2015-11-22 21:32 ` Arnd Bergmann
2015-11-22 21:55 ` Marcin Wojtas
2015-11-22 7:53 ` [PATCH 03/13] net: mvneta: fix bit assignment in MVNETA_RXQ_CONFIG_REG Marcin Wojtas
2015-11-25 18:25 ` Gregory CLEMENT
2015-11-22 7:53 ` [PATCH 04/13] net: mvneta: enable suspend/resume support Marcin Wojtas
2015-11-25 18:35 ` Gregory CLEMENT
2015-11-26 17:39 ` Marcin Wojtas
2015-11-22 7:53 ` [PATCH 05/13] net: mvneta: add xmit_more support Marcin Wojtas
2015-11-22 7:53 ` [PATCH 06/13] net: mvneta: enable mixed egress processing using HR timer Marcin Wojtas
2015-11-26 16:45 ` Simon Guinot
2015-11-30 15:57 ` Marcin Wojtas
2015-12-02 10:03 ` Marcin Wojtas
2015-11-22 7:53 ` Marcin Wojtas [this message]
2015-11-22 20:02 ` [PATCH 07/13] bus: mvebu-mbus: provide api for obtaining IO and DRAM window information Arnd Bergmann
2015-11-22 21:24 ` Marcin Wojtas
2015-11-23 16:58 ` Arnd Bergmann
2015-11-22 7:53 ` [PATCH 08/13] ARM: mvebu: enable SRAM support in mvebu_v7_defconfig Marcin Wojtas
2016-02-16 10:51 ` Gregory CLEMENT
2015-11-22 7:53 ` [PATCH 09/13] net: mvneta: bm: add support for hardware buffer management Marcin Wojtas
2015-11-22 7:53 ` [PATCH 10/13] ARM: mvebu: add buffer manager nodes to armada-38x.dtsi Marcin Wojtas
2015-11-22 9:41 ` Sergei Shtylyov
2015-11-22 7:53 ` [PATCH 11/13] ARM: mvebu: enable buffer manager support on Armada 38x boards Marcin Wojtas
2015-11-22 7:53 ` [PATCH 12/13] ARM: mvebu: add buffer manager nodes to armada-xp.dtsi Marcin Wojtas
2015-11-22 7:53 ` [PATCH 13/13] ARM: mvebu: enable buffer manager support on Armada XP boards Marcin Wojtas
2015-11-22 20:06 ` [PATCH 00/13] mvneta Buffer Management and enhancements Arnd Bergmann
2015-11-22 21:37 ` Marcin Wojtas
2015-11-24 16:22 ` David Miller
2015-11-24 16:47 ` Marcin Wojtas
2015-11-25 18:34 ` Florian Fainelli
2015-11-29 13:21 ` Marcin Wojtas
2015-11-30 2:02 ` David Miller
2015-11-30 14:13 ` Marcin Wojtas
2015-11-30 16:25 ` David Miller
2015-12-02 8:26 ` Marcin Wojtas
2015-12-04 20:15 ` Florian Fainelli
2015-12-08 10:56 ` Marcin Wojtas
2015-12-08 16:57 ` David Miller
2015-11-30 17:16 ` Gregory CLEMENT
2015-11-30 19:53 ` Marcin Wojtas
2015-12-01 13:12 ` Gregory CLEMENT
2015-12-01 21:40 ` Marcin Wojtas
2015-12-01 23:34 ` Marcin Wojtas
2015-12-02 10:40 ` Gregory CLEMENT
2015-12-02 16:21 ` Gregory CLEMENT
2015-12-02 22:15 ` Marcin Wojtas
2015-12-02 22:56 ` Gregory CLEMENT
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1448178839-3541-8-git-send-email-mw@semihalf.com \
--to=mw@semihalf.com \
--cc=alior@marvell.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=gregory.clement@free-electrons.com \
--cc=jason@lakedaemon.net \
--cc=jaz@semihalf.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@arm.linux.org.uk \
--cc=myair@marvell.com \
--cc=nadavh@marvell.com \
--cc=netdev@vger.kernel.org \
--cc=nitroshift@yahoo.com \
--cc=sebastian.hesselbarth@gmail.com \
--cc=simon.guinot@sequanux.org \
--cc=thomas.petazzoni@free-electrons.com \
--cc=tn@semihalf.com \
--cc=xswang@marvell.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).