[PATCH 1/2] goldfish: Add functions to simplify goldfish related MMIO
rkir at google.com
rkir at google.com
Wed Jun 27 21:47:55 UTC 2018
From: Roman Kiryanov <rkir at google.com>
Add functions
* to read and write u64 to be used in the goldfish sync driver.
* to write integer pointers to remove casting in tty/goldfish.c.
Signed-off-by: Roman Kiryanov <rkir at google.com>
---
include/linux/goldfish.h | 35 +++++++++++++++++++++++++++--------
1 file changed, 27 insertions(+), 8 deletions(-)
diff --git a/include/linux/goldfish.h b/include/linux/goldfish.h
index 2835c150c3ff..50af2f3d710a 100644
--- a/include/linux/goldfish.h
+++ b/include/linux/goldfish.h
@@ -4,24 +4,43 @@
/* Helpers for Goldfish virtual platform */
-static inline void gf_write_ptr(const void *ptr, void __iomem *portl,
- void __iomem *porth)
+static inline void gf_write_addr(unsigned long addr, void __iomem *portl,
+ void __iomem *porth)
{
- writel((u32)(unsigned long)ptr, portl);
+ writel((u32)addr, portl);
#ifdef CONFIG_64BIT
- writel((unsigned long)ptr >> 32, porth);
+ writel((u32)(addr >> 32), porth);
#endif
}
-static inline void gf_write_dma_addr(const dma_addr_t addr,
- void __iomem *portl,
+static inline void gf_write_ptr(const void *ptr, void __iomem *portl,
+ void __iomem *porth)
+{
+ gf_write_addr((unsigned long)ptr, portl, porth);
+}
+
+static inline void gf_write_u64(u64 value, void __iomem *portl,
+ void __iomem *porth)
+{
+ writel((u32)value, portl);
+ writel((u32)(value >> 32), porth);
+}
+
+static inline u64 gf_read_u64(void __iomem *portl, void __iomem *porth)
+{
+ u64 lo = readl(portl);
+ u64 hi = readl(porth);
+
+ return lo | (hi << 32);
+}
+
+static inline void gf_write_dma_addr(const dma_addr_t addr, void __iomem *portl,
void __iomem *porth)
{
writel((u32)addr, portl);
#ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT
- writel(addr >> 32, porth);
+ writel((u32)(addr >> 32), porth);
#endif
}
-
#endif /* __LINUX_GOLDFISH_H */
--
2.18.0.rc2.346.g013aa6912e-goog
More information about the devel
mailing list