xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
To: xen-devel@lists.xensource.com
Cc: tim@xen.org, Ian.Campbell@citrix.com,
	Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Subject: [PATCH v4 6/7] xen/arm: introduce vexpress_syscfg
Date: Tue, 8 Jan 2013 20:03:26 +0000	[thread overview]
Message-ID: <1357675408-27949-6-git-send-email-stefano.stabellini@eu.citrix.com> (raw)
In-Reply-To: <alpine.DEB.2.02.1301081935090.4981@kaball.uk.xensource.com>

Introduce a Versatile Express specific function to read/write
motherboard settings.

Changes in v4:
- move the wait loop and the syscfg cfgctrl write into a separate
function;
- fix comments;
- define all registers in write;
- move platform_vexpress.c to platforms/vexpress.c;
- move platform_vexpress.h to arm-arm/platforms/vexpress.h.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
---
 xen/arch/arm/Makefile                    |    1 +
 xen/arch/arm/mode_switch.S               |    2 +-
 xen/arch/arm/platforms/vexpress.c        |  100 ++++++++++++++++++++++++++++++
 xen/include/asm-arm/platform_vexpress.h  |   17 -----
 xen/include/asm-arm/platforms/vexpress.h |   40 ++++++++++++
 5 files changed, 142 insertions(+), 18 deletions(-)
 create mode 100644 xen/arch/arm/platforms/vexpress.c
 delete mode 100644 xen/include/asm-arm/platform_vexpress.h
 create mode 100644 xen/include/asm-arm/platforms/vexpress.h

diff --git a/xen/arch/arm/Makefile b/xen/arch/arm/Makefile
index 4c61b04..781e022 100644
--- a/xen/arch/arm/Makefile
+++ b/xen/arch/arm/Makefile
@@ -1,4 +1,5 @@
 subdir-y += lib
+subdir-y += platforms
 
 obj-y += dummy.o
 obj-y += early_printk.o
diff --git a/xen/arch/arm/mode_switch.S b/xen/arch/arm/mode_switch.S
index 7c3b357..ba42898 100644
--- a/xen/arch/arm/mode_switch.S
+++ b/xen/arch/arm/mode_switch.S
@@ -19,7 +19,7 @@
 
 #include <asm/config.h>
 #include <asm/page.h>
-#include <asm/platform_vexpress.h>
+#include <asm/platforms/vexpress.h>
 #include <asm/asm_defns.h>
 #include "gic.h"
 
diff --git a/xen/arch/arm/platforms/vexpress.c b/xen/arch/arm/platforms/vexpress.c
new file mode 100644
index 0000000..b57b62e
--- /dev/null
+++ b/xen/arch/arm/platforms/vexpress.c
@@ -0,0 +1,100 @@
+/*
+ * xen/arch/arm/platform_vexpress.c
+ *
+ * Versatile Express specific settings
+ *
+ * Stefano Stabellini <stefano.stabellini@eu.citrix.com>
+ * Copyright (c) 2013 Citrix Systems.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include <asm/platforms/vexpress.h>
+#include <xen/mm.h>
+
+#define DCC_SHIFT      26
+#define FUNCTION_SHIFT 20
+#define SITE_SHIFT     16
+#define POSITION_SHIFT 12
+#define DEVICE_SHIFT   0
+
+static inline int vexpress_ctrl_start(uint32_t *syscfg, int write,
+                                      int function, int device)
+{
+    int dcc = 0; /* DCC to access */
+    int site = 0; /* motherboard */
+    int position = 0; /* daughterboard */
+    uint32_t stat;
+
+    /* set control register */
+    syscfg[V2M_SYS_CFGCTRL/4] = V2M_SYS_CFG_START |
+        (write ? V2M_SYS_CFG_WRITE : 0) |
+        (dcc << DCC_SHIFT) | (function << FUNCTION_SHIFT) |
+        (site << SITE_SHIFT) | (position << POSITION_SHIFT) |
+        (device << DEVICE_SHIFT);
+
+    /* wait for complete flag to be set */
+    do {
+        stat = syscfg[V2M_SYS_CFGSTAT/4];
+        dsb();
+    } while ( !(stat & V2M_SYS_CFG_COMPLETE) );
+
+    /* check error status and return error flag if set */
+    if ( stat & V2M_SYS_CFG_ERROR )
+    {
+        printk(KERN_ERR "V2M SYS_CFGSTAT reported a configuration error\n");
+        return -1;
+    }
+    return 0;
+}
+
+int vexpress_syscfg(int write, int function, int device, uint32_t *data)
+{
+    uint32_t *syscfg = (uint32_t *) FIXMAP_ADDR(FIXMAP_MISC);
+    int ret = -1;
+
+    set_fixmap(FIXMAP_MISC, V2M_SYS_MMIO_BASE >> PAGE_SHIFT, DEV_SHARED);
+
+    if ( syscfg[V2M_SYS_CFGCTRL/4] & V2M_SYS_CFG_START )
+        goto out;
+
+    /* clear the complete bit in the V2M_SYS_CFGSTAT status register */
+    syscfg[V2M_SYS_CFGSTAT/4] = 0;
+
+    if ( write )
+    {
+        /* write data */
+        syscfg[V2M_SYS_CFGDATA/4] = *data;
+
+        if ( vexpress_ctrl_start(syscfg, write, function, device) < 0 )
+            goto out;
+    } else {
+        if ( vexpress_ctrl_start(syscfg, write, function, device) < 0 )
+            goto out;
+        else
+            /* read data */
+            *data = syscfg[V2M_SYS_CFGDATA/4];
+    }
+
+    ret = 0;
+out:
+    clear_fixmap(FIXMAP_MISC);
+    return ret;
+}
+
+/*
+ * Local variables:
+ * mode: C
+ * c-set-style: "BSD"
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
diff --git a/xen/include/asm-arm/platform_vexpress.h b/xen/include/asm-arm/platform_vexpress.h
deleted file mode 100644
index 3556af3..0000000
--- a/xen/include/asm-arm/platform_vexpress.h
+++ /dev/null
@@ -1,17 +0,0 @@
-#ifndef __ASM_ARM_PLATFORM_H
-#define __ASM_ARM_PLATFORM_H
-
-/* V2M */
-#define V2M_SYS_MMIO_BASE     (0x1c010000)
-#define V2M_SYS_FLAGSSET      (0x30)
-#define V2M_SYS_FLAGSCLR      (0x34)
-
-#endif /* __ASM_ARM_PLATFORM_H */
-/*
- * Local variables:
- * mode: C
- * c-set-style: "BSD"
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- */
diff --git a/xen/include/asm-arm/platforms/vexpress.h b/xen/include/asm-arm/platforms/vexpress.h
new file mode 100644
index 0000000..e464913
--- /dev/null
+++ b/xen/include/asm-arm/platforms/vexpress.h
@@ -0,0 +1,40 @@
+#ifndef __ASM_ARM_PLATFORMS_VEXPRESS_H
+#define __ASM_ARM_PLATFORMS_VEXPRESS_H
+
+/* V2M */
+#define V2M_SYS_MMIO_BASE     (0x1c010000)
+#define V2M_SYS_FLAGSSET      (0x30)
+#define V2M_SYS_FLAGSCLR      (0x34)
+
+#define V2M_SYS_CFGDATA       (0x00A0)
+#define V2M_SYS_CFGCTRL       (0x00A4)
+#define V2M_SYS_CFGSTAT       (0x00A8)
+
+#define V2M_SYS_CFG_START     (1<<31)
+#define V2M_SYS_CFG_WRITE     (1<<30)
+#define V2M_SYS_CFG_ERROR     (1<<1)
+#define V2M_SYS_CFG_COMPLETE  (1<<0)
+
+#define V2M_SYS_CFG_OSC_FUNC  1
+#define V2M_SYS_CFG_OSC0      0
+#define V2M_SYS_CFG_OSC1      1
+#define V2M_SYS_CFG_OSC2      2
+#define V2M_SYS_CFG_OSC3      3
+#define V2M_SYS_CFG_OSC4      4
+#define V2M_SYS_CFG_OSC5      5
+
+#ifndef __ASSEMBLY__
+#include <xen/inttypes.h>
+
+int vexpress_syscfg(int write, int function, int device, uint32_t *data);
+#endif
+
+#endif /* __ASM_ARM_PLATFORMS_VEXPRESS_H */
+/*
+ * Local variables:
+ * mode: C
+ * c-set-style: "BSD"
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
-- 
1.7.2.5

  parent reply	other threads:[~2013-01-08 20:03 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-08 20:02 [PATCH v4 0/7] xen: ARM HDLCD video driver Stefano Stabellini
2013-01-08 20:03 ` [PATCH v4 1/7] xen/arm: introduce early_ioremap Stefano Stabellini
2013-01-10 15:48   ` Ian Campbell
2013-01-14 17:46     ` Stefano Stabellini
2013-01-08 20:03 ` [PATCH v4 2/7] xen: infrastructure to have cross-platform video drivers Stefano Stabellini
2013-01-10 15:49   ` Ian Campbell
2013-01-10 16:08     ` Jan Beulich
2013-01-10 16:16       ` Ian Campbell
2013-01-10 16:28       ` Keir Fraser
2013-01-21 11:38         ` Ian Campbell
2013-01-10 16:16   ` Ian Campbell
2013-01-08 20:03 ` [PATCH v4 3/7] xen: introduce a generic framebuffer driver Stefano Stabellini
2013-01-09 10:53   ` Jan Beulich
2013-01-09 14:05     ` Stefano Stabellini
2013-01-09 14:45       ` Mats Petersson
2013-01-09 14:51         ` Mats Petersson
2013-01-09 17:17           ` Stefano Stabellini
2013-01-08 20:03 ` [PATCH v4 4/7] xen/arm: move setup_mm right after setup_pagetables Stefano Stabellini
2013-01-10 15:55   ` Ian Campbell
2013-01-14 17:18     ` Stefano Stabellini
2013-01-15 10:29       ` Ian Campbell
2013-01-08 20:03 ` [PATCH v4 5/7] xen/device_tree: introduce find_compatible_node Stefano Stabellini
2013-01-08 20:03 ` Stefano Stabellini [this message]
2013-01-10 15:58   ` [PATCH v4 6/7] xen/arm: introduce vexpress_syscfg Ian Campbell
2013-01-14 17:11     ` Stefano Stabellini
2013-01-08 20:03 ` [PATCH v4 7/7] xen/arm: introduce a driver for the ARM HDLCD controller Stefano Stabellini

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=1357675408-27949-6-git-send-email-stefano.stabellini@eu.citrix.com \
    --to=stefano.stabellini@eu.citrix.com \
    --cc=Ian.Campbell@citrix.com \
    --cc=tim@xen.org \
    --cc=xen-devel@lists.xensource.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).