All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/5] hisi_lpc: Improve build test coverage
@ 2019-10-28 12:10 John Garry
  2019-10-28 12:10 ` [PATCH v2 1/5] lib: logic_pio: Enforce LOGIC_PIO_INDIRECT region ops are set at registration John Garry
                   ` (5 more replies)
  0 siblings, 6 replies; 8+ messages in thread
From: John Garry @ 2019-10-28 12:10 UTC (permalink / raw)
  To: xuwei5; +Cc: linuxarm, linux-kernel, olof, bhelgaas, arnd, John Garry

This series aims to improve the build test cover of the driver by
supporting building under COMPILE_TEST.

I also included "lib: logic_pio: Enforce LOGIC_PIO_INDIRECT region ops
are set at registration" as it was never picked up for 5.4.

Two new patches are also included since v1:
- clean issues detected by sparse
- build logic_pio.o into /lib library

John Garry (5):
  lib: logic_pio: Enforce LOGIC_PIO_INDIRECT region ops are set at
    registration
  logic_pio: Define PIO_INDIRECT_SIZE for !CONFIG_INDIRECT_PIO
  bus: hisi_lpc: Clean some types
  bus: hisi_lpc: Expand build test coverage
  logic_pio: Build into a library

 drivers/bus/Kconfig       |  4 ++--
 drivers/bus/hisi_lpc.c    |  9 ++++-----
 include/linux/logic_pio.h |  4 ++--
 lib/Makefile              |  2 +-
 lib/logic_pio.c           | 14 ++++++++------
 5 files changed, 17 insertions(+), 16 deletions(-)

-- 
2.17.1


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v2 1/5] lib: logic_pio: Enforce LOGIC_PIO_INDIRECT region ops are set at registration
  2019-10-28 12:10 [PATCH v2 0/5] hisi_lpc: Improve build test coverage John Garry
@ 2019-10-28 12:10 ` John Garry
  2019-10-28 12:10 ` [PATCH v2 2/5] logic_pio: Define PIO_INDIRECT_SIZE for !CONFIG_INDIRECT_PIO John Garry
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: John Garry @ 2019-10-28 12:10 UTC (permalink / raw)
  To: xuwei5; +Cc: linuxarm, linux-kernel, olof, bhelgaas, arnd, John Garry

Since the only LOGIC_PIO_INDIRECT host (hisi-lpc) now sets the ops prior
to registration, enforce this check for accessors ops at registration
instead of in the IO port accessors to simplify and marginally optimise
the code.

A slight misalignment is also tidied.

Also add myself as an author.

Suggested-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: John Garry <john.garry@huawei.com>
---
 lib/logic_pio.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/lib/logic_pio.c b/lib/logic_pio.c
index 905027574e5d..f511a99bb389 100644
--- a/lib/logic_pio.c
+++ b/lib/logic_pio.c
@@ -3,6 +3,7 @@
  * Copyright (C) 2017 HiSilicon Limited, All Rights Reserved.
  * Author: Gabriele Paoloni <gabriele.paoloni@huawei.com>
  * Author: Zhichang Yuan <yuanzhichang@hisilicon.com>
+ * Author: John Garry <john.garry@huawei.com>
  */
 
 #define pr_fmt(fmt)	"LOGIC PIO: " fmt
@@ -39,7 +40,8 @@ int logic_pio_register_range(struct logic_pio_hwaddr *new_range)
 	resource_size_t iio_sz = MMIO_UPPER_LIMIT;
 	int ret = 0;
 
-	if (!new_range || !new_range->fwnode || !new_range->size)
+	if (!new_range || !new_range->fwnode || !new_range->size ||
+	    (new_range->flags == LOGIC_PIO_INDIRECT && !new_range->ops))
 		return -EINVAL;
 
 	start = new_range->hw_start;
@@ -237,7 +239,7 @@ type logic_in##bw(unsigned long addr)					\
 	} else if (addr >= MMIO_UPPER_LIMIT && addr < IO_SPACE_LIMIT) { \
 		struct logic_pio_hwaddr *entry = find_io_range(addr);	\
 									\
-		if (entry && entry->ops)				\
+		if (entry)						\
 			ret = entry->ops->in(entry->hostdata,		\
 					addr, sizeof(type));		\
 		else							\
@@ -253,7 +255,7 @@ void logic_out##bw(type value, unsigned long addr)			\
 	} else if (addr >= MMIO_UPPER_LIMIT && addr < IO_SPACE_LIMIT) {	\
 		struct logic_pio_hwaddr *entry = find_io_range(addr);	\
 									\
-		if (entry && entry->ops)				\
+		if (entry)						\
 			entry->ops->out(entry->hostdata,		\
 					addr, value, sizeof(type));	\
 		else							\
@@ -261,7 +263,7 @@ void logic_out##bw(type value, unsigned long addr)			\
 	}								\
 }									\
 									\
-void logic_ins##bw(unsigned long addr, void *buffer,		\
+void logic_ins##bw(unsigned long addr, void *buffer,			\
 		   unsigned int count)					\
 {									\
 	if (addr < MMIO_UPPER_LIMIT) {					\
@@ -269,7 +271,7 @@ void logic_ins##bw(unsigned long addr, void *buffer,		\
 	} else if (addr >= MMIO_UPPER_LIMIT && addr < IO_SPACE_LIMIT) {	\
 		struct logic_pio_hwaddr *entry = find_io_range(addr);	\
 									\
-		if (entry && entry->ops)				\
+		if (entry)						\
 			entry->ops->ins(entry->hostdata,		\
 				addr, buffer, sizeof(type), count);	\
 		else							\
@@ -286,7 +288,7 @@ void logic_outs##bw(unsigned long addr, const void *buffer,		\
 	} else if (addr >= MMIO_UPPER_LIMIT && addr < IO_SPACE_LIMIT) {	\
 		struct logic_pio_hwaddr *entry = find_io_range(addr);	\
 									\
-		if (entry && entry->ops)				\
+		if (entry)						\
 			entry->ops->outs(entry->hostdata,		\
 				addr, buffer, sizeof(type), count);	\
 		else							\
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v2 2/5] logic_pio: Define PIO_INDIRECT_SIZE for !CONFIG_INDIRECT_PIO
  2019-10-28 12:10 [PATCH v2 0/5] hisi_lpc: Improve build test coverage John Garry
  2019-10-28 12:10 ` [PATCH v2 1/5] lib: logic_pio: Enforce LOGIC_PIO_INDIRECT region ops are set at registration John Garry
@ 2019-10-28 12:10 ` John Garry
  2019-10-28 12:10 ` [PATCH v2 3/5] bus: hisi_lpc: Clean some types John Garry
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: John Garry @ 2019-10-28 12:10 UTC (permalink / raw)
  To: xuwei5; +Cc: linuxarm, linux-kernel, olof, bhelgaas, arnd, John Garry

With the goal of expanding the test coverage of the HiSi LPC driver to
!ARM64, define a dummy PIO_INDIRECT_SIZE for !CONFIG_INDIRECT_PIO, which
is required by the named driver.

Signed-off-by: John Garry <john.garry@huawei.com>
---
 include/linux/logic_pio.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/logic_pio.h b/include/linux/logic_pio.h
index 88e1e6304a71..54945aa824b4 100644
--- a/include/linux/logic_pio.h
+++ b/include/linux/logic_pio.h
@@ -108,10 +108,10 @@ void logic_outsl(unsigned long addr, const void *buffer, unsigned int count);
  * area by redefining the macro below.
  */
 #define PIO_INDIRECT_SIZE 0x4000
-#define MMIO_UPPER_LIMIT (IO_SPACE_LIMIT - PIO_INDIRECT_SIZE)
 #else
-#define MMIO_UPPER_LIMIT IO_SPACE_LIMIT
+#define PIO_INDIRECT_SIZE 0
 #endif /* CONFIG_INDIRECT_PIO */
+#define MMIO_UPPER_LIMIT (IO_SPACE_LIMIT - PIO_INDIRECT_SIZE)
 
 struct logic_pio_hwaddr *find_io_range_by_fwnode(struct fwnode_handle *fwnode);
 unsigned long logic_pio_trans_hwaddr(struct fwnode_handle *fwnode,
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v2 3/5] bus: hisi_lpc: Clean some types
  2019-10-28 12:10 [PATCH v2 0/5] hisi_lpc: Improve build test coverage John Garry
  2019-10-28 12:10 ` [PATCH v2 1/5] lib: logic_pio: Enforce LOGIC_PIO_INDIRECT region ops are set at registration John Garry
  2019-10-28 12:10 ` [PATCH v2 2/5] logic_pio: Define PIO_INDIRECT_SIZE for !CONFIG_INDIRECT_PIO John Garry
@ 2019-10-28 12:10 ` John Garry
  2019-10-28 12:10 ` [PATCH v2 4/5] bus: hisi_lpc: Expand build test coverage John Garry
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: John Garry @ 2019-10-28 12:10 UTC (permalink / raw)
  To: xuwei5; +Cc: linuxarm, linux-kernel, olof, bhelgaas, arnd, John Garry

Sparse complains of these:
drivers/bus/hisi_lpc.c:82:38: warning: incorrect type in argument 1 (different address spaces)
drivers/bus/hisi_lpc.c:82:38:    expected void const volatile [noderef] <asn:2>*addr
drivers/bus/hisi_lpc.c:82:38:    got unsigned char *
drivers/bus/hisi_lpc.c:131:35: warning: incorrect type in argument 1 (different address spaces)
drivers/bus/hisi_lpc.c:131:35:    expected unsigned char *mbase
drivers/bus/hisi_lpc.c:131:35:    got void [noderef] <asn:2>*membase
drivers/bus/hisi_lpc.c:186:35: warning: incorrect type in argument 1 (different address spaces)
drivers/bus/hisi_lpc.c:186:35:    expected unsigned char *mbase
drivers/bus/hisi_lpc.c:186:35:    got void [noderef] <asn:2>*membase
drivers/bus/hisi_lpc.c:228:16: warning: cast to restricted __le32
drivers/bus/hisi_lpc.c:251:13: warning: incorrect type in assignment (different base types)
drivers/bus/hisi_lpc.c:251:13:    expected unsigned int [unsigned] [usertype] val
drivers/bus/hisi_lpc.c:251:13:    got restricted __le32 [usertype] <noident>

Clean them up.

Signed-off-by: John Garry <john.garry@huawei.com>
---
 drivers/bus/hisi_lpc.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/bus/hisi_lpc.c b/drivers/bus/hisi_lpc.c
index 20c957185af2..8101df901830 100644
--- a/drivers/bus/hisi_lpc.c
+++ b/drivers/bus/hisi_lpc.c
@@ -74,7 +74,7 @@ struct hisi_lpc_dev {
 /* About 10us. This is specific for single IO operations, such as inb */
 #define LPC_PEROP_WAITCNT	100
 
-static int wait_lpc_idle(unsigned char *mbase, unsigned int waitcnt)
+static int wait_lpc_idle(void __iomem *mbase, unsigned int waitcnt)
 {
 	u32 status;
 
@@ -209,7 +209,7 @@ static u32 hisi_lpc_comm_in(void *hostdata, unsigned long pio, size_t dwidth)
 	struct hisi_lpc_dev *lpcdev = hostdata;
 	struct lpc_cycle_para iopara;
 	unsigned long addr;
-	u32 rd_data = 0;
+	__le32 rd_data = 0;
 	int ret;
 
 	if (!lpcdev || !dwidth || dwidth > LPC_MAX_DWIDTH)
@@ -244,13 +244,12 @@ static void hisi_lpc_comm_out(void *hostdata, unsigned long pio,
 	struct lpc_cycle_para iopara;
 	const unsigned char *buf;
 	unsigned long addr;
+	__le32 _val = cpu_to_le32(val);
 
 	if (!lpcdev || !dwidth || dwidth > LPC_MAX_DWIDTH)
 		return;
 
-	val = cpu_to_le32(val);
-
-	buf = (const unsigned char *)&val;
+	buf = (const unsigned char *)&_val;
 	addr = hisi_lpc_pio_to_addr(lpcdev, pio);
 
 	iopara.opflags = FG_INCRADDR_LPC;
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v2 4/5] bus: hisi_lpc: Expand build test coverage
  2019-10-28 12:10 [PATCH v2 0/5] hisi_lpc: Improve build test coverage John Garry
                   ` (2 preceding siblings ...)
  2019-10-28 12:10 ` [PATCH v2 3/5] bus: hisi_lpc: Clean some types John Garry
@ 2019-10-28 12:10 ` John Garry
  2019-11-01  3:19   ` kbuild test robot
  2019-10-28 12:10 ` [PATCH v2 5/5] logic_pio: Build into a library John Garry
  2019-10-30  9:19 ` [PATCH v2 0/5] hisi_lpc: Improve build test coverage Wei Xu
  5 siblings, 1 reply; 8+ messages in thread
From: John Garry @ 2019-10-28 12:10 UTC (permalink / raw)
  To: xuwei5; +Cc: linuxarm, linux-kernel, olof, bhelgaas, arnd, John Garry

Currently the driver will only ever be built for ARM64 because it selects
CONFIG_INDIRECT_PIO, which itself depends on ARM64.

Expand build test coverage for the driver to other architectures by only
selecting CONFIG_INDIRECT_PIO for ARM64, when we really want it.

Signed-off-by: John Garry <john.garry@huawei.com>
---
 drivers/bus/Kconfig | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/bus/Kconfig b/drivers/bus/Kconfig
index 6b331061d34b..44cb4b6bea18 100644
--- a/drivers/bus/Kconfig
+++ b/drivers/bus/Kconfig
@@ -41,8 +41,8 @@ config MOXTET
 
 config HISILICON_LPC
 	bool "Support for ISA I/O space on HiSilicon Hip06/7"
-	depends on ARM64 && (ARCH_HISI || COMPILE_TEST)
-	select INDIRECT_PIO
+	depends on (ARM64 && ARCH_HISI) || COMPILE_TEST
+	select INDIRECT_PIO if ARM64
 	help
 	  Driver to enable I/O access to devices attached to the Low Pin
 	  Count bus on the HiSilicon Hip06/7 SoC.
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v2 5/5] logic_pio: Build into a library
  2019-10-28 12:10 [PATCH v2 0/5] hisi_lpc: Improve build test coverage John Garry
                   ` (3 preceding siblings ...)
  2019-10-28 12:10 ` [PATCH v2 4/5] bus: hisi_lpc: Expand build test coverage John Garry
@ 2019-10-28 12:10 ` John Garry
  2019-10-30  9:19 ` [PATCH v2 0/5] hisi_lpc: Improve build test coverage Wei Xu
  5 siblings, 0 replies; 8+ messages in thread
From: John Garry @ 2019-10-28 12:10 UTC (permalink / raw)
  To: xuwei5; +Cc: linuxarm, linux-kernel, olof, bhelgaas, arnd, John Garry

Object file logic_pio.o is always built.

Ideally the object file should only be built when required. This is
tricky, as that would be for archs which define PCI_IOBASE, but no common
config option exists for that.

For now, continue to always build but at least ensure the symbols are not
included in the vmlinux when not referenced.

Suggested-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: John Garry <john.garry@huawei.com>
---
 lib/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/Makefile b/lib/Makefile
index c5892807e06f..27645143d8bb 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -108,7 +108,7 @@ obj-$(CONFIG_HAS_IOMEM) += iomap_copy.o devres.o
 obj-$(CONFIG_CHECK_SIGNATURE) += check_signature.o
 obj-$(CONFIG_DEBUG_LOCKING_API_SELFTESTS) += locking-selftest.o
 
-obj-y += logic_pio.o
+lib-y += logic_pio.o
 
 obj-$(CONFIG_GENERIC_HWEIGHT) += hweight.o
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 0/5] hisi_lpc: Improve build test coverage
  2019-10-28 12:10 [PATCH v2 0/5] hisi_lpc: Improve build test coverage John Garry
                   ` (4 preceding siblings ...)
  2019-10-28 12:10 ` [PATCH v2 5/5] logic_pio: Build into a library John Garry
@ 2019-10-30  9:19 ` Wei Xu
  5 siblings, 0 replies; 8+ messages in thread
From: Wei Xu @ 2019-10-30  9:19 UTC (permalink / raw)
  To: John Garry, xuwei5; +Cc: linuxarm, linux-kernel, olof, bhelgaas, arnd



On 2019/10/28 20:10, John Garry wrote:
> This series aims to improve the build test cover of the driver by
> supporting building under COMPILE_TEST.
>
> I also included "lib: logic_pio: Enforce LOGIC_PIO_INDIRECT region ops
> are set at registration" as it was never picked up for 5.4.
>
> Two new patches are also included since v1:
> - clean issues detected by sparse
> - build logic_pio.o into /lib library
>
> John Garry (5):
>    lib: logic_pio: Enforce LOGIC_PIO_INDIRECT region ops are set at
>      registration
>    logic_pio: Define PIO_INDIRECT_SIZE for !CONFIG_INDIRECT_PIO
>    bus: hisi_lpc: Clean some types
>    bus: hisi_lpc: Expand build test coverage
>    logic_pio: Build into a library
>
>   drivers/bus/Kconfig       |  4 ++--
>   drivers/bus/hisi_lpc.c    |  9 ++++-----
>   include/linux/logic_pio.h |  4 ++--
>   lib/Makefile              |  2 +-
>   lib/logic_pio.c           | 14 ++++++++------
>   5 files changed, 17 insertions(+), 16 deletions(-)
>

Thanks!
Series applied to the hisilicon driver tree.

Best Regards,
Wei


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 4/5] bus: hisi_lpc: Expand build test coverage
  2019-10-28 12:10 ` [PATCH v2 4/5] bus: hisi_lpc: Expand build test coverage John Garry
@ 2019-11-01  3:19   ` kbuild test robot
  0 siblings, 0 replies; 8+ messages in thread
From: kbuild test robot @ 2019-11-01  3:19 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 10085 bytes --]

Hi John,

I love your patch! Yet something to improve:

[auto build test ERROR on linus/master]
[cannot apply to v5.4-rc5 next-20191031]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/John-Garry/lib-logic_pio-Enforce-LOGIC_PIO_INDIRECT-region-ops-are-set-at-registration/20191030-081925
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 23fdb198ae81f47a574296dab5167c5e136a02ba
config: parisc-allmodconfig (attached as .config)
compiler: hppa-linux-gcc (GCC) 7.4.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        GCC_VERSION=7.4.0 make.cross ARCH=parisc 

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   drivers//bus/hisi_lpc.c: In function 'hisi_lpc_target_in':
>> drivers//bus/hisi_lpc.c:137:2: error: implicit declaration of function 'readsb'; did you mean 'readb'? [-Werror=implicit-function-declaration]
     readsb(lpcdev->membase + LPC_REG_RDATA, buf, opcnt);
     ^~~~~~
     readb
   drivers//bus/hisi_lpc.c: In function 'hisi_lpc_target_out':
>> drivers//bus/hisi_lpc.c:180:2: error: implicit declaration of function 'writesb'; did you mean 'writeb'? [-Werror=implicit-function-declaration]
     writesb(lpcdev->membase + LPC_REG_WDATA, buf, opcnt);
     ^~~~~~~
     writeb
   cc1: some warnings being treated as errors

vim +137 drivers//bus/hisi_lpc.c

adf38bb0b5956a Zhichang Yuan 2018-03-21   90  
adf38bb0b5956a Zhichang Yuan 2018-03-21   91  /*
adf38bb0b5956a Zhichang Yuan 2018-03-21   92   * hisi_lpc_target_in - trigger a series of LPC cycles for read operation
adf38bb0b5956a Zhichang Yuan 2018-03-21   93   * @lpcdev: pointer to hisi lpc device
adf38bb0b5956a Zhichang Yuan 2018-03-21   94   * @para: some parameters used to control the lpc I/O operations
adf38bb0b5956a Zhichang Yuan 2018-03-21   95   * @addr: the lpc I/O target port address
adf38bb0b5956a Zhichang Yuan 2018-03-21   96   * @buf: where the read back data is stored
adf38bb0b5956a Zhichang Yuan 2018-03-21   97   * @opcnt: how many I/O operations required, i.e. data width
adf38bb0b5956a Zhichang Yuan 2018-03-21   98   *
adf38bb0b5956a Zhichang Yuan 2018-03-21   99   * Returns 0 on success, non-zero on fail.
adf38bb0b5956a Zhichang Yuan 2018-03-21  100   */
adf38bb0b5956a Zhichang Yuan 2018-03-21  101  static int hisi_lpc_target_in(struct hisi_lpc_dev *lpcdev,
adf38bb0b5956a Zhichang Yuan 2018-03-21  102  			      struct lpc_cycle_para *para, unsigned long addr,
adf38bb0b5956a Zhichang Yuan 2018-03-21  103  			      unsigned char *buf, unsigned long opcnt)
adf38bb0b5956a Zhichang Yuan 2018-03-21  104  {
adf38bb0b5956a Zhichang Yuan 2018-03-21  105  	unsigned int cmd_word;
adf38bb0b5956a Zhichang Yuan 2018-03-21  106  	unsigned int waitcnt;
adf38bb0b5956a Zhichang Yuan 2018-03-21  107  	unsigned long flags;
adf38bb0b5956a Zhichang Yuan 2018-03-21  108  	int ret;
adf38bb0b5956a Zhichang Yuan 2018-03-21  109  
adf38bb0b5956a Zhichang Yuan 2018-03-21  110  	if (!buf || !opcnt || !para || !para->csize || !lpcdev)
adf38bb0b5956a Zhichang Yuan 2018-03-21  111  		return -EINVAL;
adf38bb0b5956a Zhichang Yuan 2018-03-21  112  
adf38bb0b5956a Zhichang Yuan 2018-03-21  113  	cmd_word = 0; /* IO mode, Read */
adf38bb0b5956a Zhichang Yuan 2018-03-21  114  	waitcnt = LPC_PEROP_WAITCNT;
adf38bb0b5956a Zhichang Yuan 2018-03-21  115  	if (!(para->opflags & FG_INCRADDR_LPC)) {
adf38bb0b5956a Zhichang Yuan 2018-03-21  116  		cmd_word |= LPC_REG_CMD_SAMEADDR;
adf38bb0b5956a Zhichang Yuan 2018-03-21  117  		waitcnt = LPC_MAX_WAITCNT;
adf38bb0b5956a Zhichang Yuan 2018-03-21  118  	}
adf38bb0b5956a Zhichang Yuan 2018-03-21  119  
adf38bb0b5956a Zhichang Yuan 2018-03-21  120  	/* whole operation must be atomic */
adf38bb0b5956a Zhichang Yuan 2018-03-21  121  	spin_lock_irqsave(&lpcdev->cycle_lock, flags);
adf38bb0b5956a Zhichang Yuan 2018-03-21  122  
adf38bb0b5956a Zhichang Yuan 2018-03-21  123  	writel_relaxed(opcnt, lpcdev->membase + LPC_REG_OP_LEN);
adf38bb0b5956a Zhichang Yuan 2018-03-21  124  	writel_relaxed(cmd_word, lpcdev->membase + LPC_REG_CMD);
adf38bb0b5956a Zhichang Yuan 2018-03-21  125  	writel_relaxed(addr, lpcdev->membase + LPC_REG_ADDR);
adf38bb0b5956a Zhichang Yuan 2018-03-21  126  
adf38bb0b5956a Zhichang Yuan 2018-03-21  127  	writel(LPC_REG_STARTUP_SIGNAL_START,
adf38bb0b5956a Zhichang Yuan 2018-03-21  128  	       lpcdev->membase + LPC_REG_STARTUP_SIGNAL);
adf38bb0b5956a Zhichang Yuan 2018-03-21  129  
adf38bb0b5956a Zhichang Yuan 2018-03-21  130  	/* whether the operation is finished */
adf38bb0b5956a Zhichang Yuan 2018-03-21  131  	ret = wait_lpc_idle(lpcdev->membase, waitcnt);
adf38bb0b5956a Zhichang Yuan 2018-03-21  132  	if (ret) {
adf38bb0b5956a Zhichang Yuan 2018-03-21  133  		spin_unlock_irqrestore(&lpcdev->cycle_lock, flags);
adf38bb0b5956a Zhichang Yuan 2018-03-21  134  		return ret;
adf38bb0b5956a Zhichang Yuan 2018-03-21  135  	}
adf38bb0b5956a Zhichang Yuan 2018-03-21  136  
adf38bb0b5956a Zhichang Yuan 2018-03-21 @137  	readsb(lpcdev->membase + LPC_REG_RDATA, buf, opcnt);
adf38bb0b5956a Zhichang Yuan 2018-03-21  138  
adf38bb0b5956a Zhichang Yuan 2018-03-21  139  	spin_unlock_irqrestore(&lpcdev->cycle_lock, flags);
adf38bb0b5956a Zhichang Yuan 2018-03-21  140  
adf38bb0b5956a Zhichang Yuan 2018-03-21  141  	return 0;
adf38bb0b5956a Zhichang Yuan 2018-03-21  142  }
adf38bb0b5956a Zhichang Yuan 2018-03-21  143  
adf38bb0b5956a Zhichang Yuan 2018-03-21  144  /*
adf38bb0b5956a Zhichang Yuan 2018-03-21  145   * hisi_lpc_target_out - trigger a series of LPC cycles for write operation
adf38bb0b5956a Zhichang Yuan 2018-03-21  146   * @lpcdev: pointer to hisi lpc device
adf38bb0b5956a Zhichang Yuan 2018-03-21  147   * @para: some parameters used to control the lpc I/O operations
adf38bb0b5956a Zhichang Yuan 2018-03-21  148   * @addr: the lpc I/O target port address
adf38bb0b5956a Zhichang Yuan 2018-03-21  149   * @buf: where the data to be written is stored
adf38bb0b5956a Zhichang Yuan 2018-03-21  150   * @opcnt: how many I/O operations required, i.e. data width
adf38bb0b5956a Zhichang Yuan 2018-03-21  151   *
adf38bb0b5956a Zhichang Yuan 2018-03-21  152   * Returns 0 on success, non-zero on fail.
adf38bb0b5956a Zhichang Yuan 2018-03-21  153   */
adf38bb0b5956a Zhichang Yuan 2018-03-21  154  static int hisi_lpc_target_out(struct hisi_lpc_dev *lpcdev,
adf38bb0b5956a Zhichang Yuan 2018-03-21  155  			       struct lpc_cycle_para *para, unsigned long addr,
adf38bb0b5956a Zhichang Yuan 2018-03-21  156  			       const unsigned char *buf, unsigned long opcnt)
adf38bb0b5956a Zhichang Yuan 2018-03-21  157  {
adf38bb0b5956a Zhichang Yuan 2018-03-21  158  	unsigned int waitcnt;
adf38bb0b5956a Zhichang Yuan 2018-03-21  159  	unsigned long flags;
adf38bb0b5956a Zhichang Yuan 2018-03-21  160  	u32 cmd_word;
adf38bb0b5956a Zhichang Yuan 2018-03-21  161  	int ret;
adf38bb0b5956a Zhichang Yuan 2018-03-21  162  
adf38bb0b5956a Zhichang Yuan 2018-03-21  163  	if (!buf || !opcnt || !para || !lpcdev)
adf38bb0b5956a Zhichang Yuan 2018-03-21  164  		return -EINVAL;
adf38bb0b5956a Zhichang Yuan 2018-03-21  165  
adf38bb0b5956a Zhichang Yuan 2018-03-21  166  	/* default is increasing address */
adf38bb0b5956a Zhichang Yuan 2018-03-21  167  	cmd_word = LPC_REG_CMD_OP; /* IO mode, write */
adf38bb0b5956a Zhichang Yuan 2018-03-21  168  	waitcnt = LPC_PEROP_WAITCNT;
adf38bb0b5956a Zhichang Yuan 2018-03-21  169  	if (!(para->opflags & FG_INCRADDR_LPC)) {
adf38bb0b5956a Zhichang Yuan 2018-03-21  170  		cmd_word |= LPC_REG_CMD_SAMEADDR;
adf38bb0b5956a Zhichang Yuan 2018-03-21  171  		waitcnt = LPC_MAX_WAITCNT;
adf38bb0b5956a Zhichang Yuan 2018-03-21  172  	}
adf38bb0b5956a Zhichang Yuan 2018-03-21  173  
adf38bb0b5956a Zhichang Yuan 2018-03-21  174  	spin_lock_irqsave(&lpcdev->cycle_lock, flags);
adf38bb0b5956a Zhichang Yuan 2018-03-21  175  
adf38bb0b5956a Zhichang Yuan 2018-03-21  176  	writel_relaxed(opcnt, lpcdev->membase + LPC_REG_OP_LEN);
adf38bb0b5956a Zhichang Yuan 2018-03-21  177  	writel_relaxed(cmd_word, lpcdev->membase + LPC_REG_CMD);
adf38bb0b5956a Zhichang Yuan 2018-03-21  178  	writel_relaxed(addr, lpcdev->membase + LPC_REG_ADDR);
adf38bb0b5956a Zhichang Yuan 2018-03-21  179  
adf38bb0b5956a Zhichang Yuan 2018-03-21 @180  	writesb(lpcdev->membase + LPC_REG_WDATA, buf, opcnt);
adf38bb0b5956a Zhichang Yuan 2018-03-21  181  
adf38bb0b5956a Zhichang Yuan 2018-03-21  182  	writel(LPC_REG_STARTUP_SIGNAL_START,
adf38bb0b5956a Zhichang Yuan 2018-03-21  183  	       lpcdev->membase + LPC_REG_STARTUP_SIGNAL);
adf38bb0b5956a Zhichang Yuan 2018-03-21  184  
adf38bb0b5956a Zhichang Yuan 2018-03-21  185  	/* whether the operation is finished */
adf38bb0b5956a Zhichang Yuan 2018-03-21  186  	ret = wait_lpc_idle(lpcdev->membase, waitcnt);
adf38bb0b5956a Zhichang Yuan 2018-03-21  187  
adf38bb0b5956a Zhichang Yuan 2018-03-21  188  	spin_unlock_irqrestore(&lpcdev->cycle_lock, flags);
adf38bb0b5956a Zhichang Yuan 2018-03-21  189  
adf38bb0b5956a Zhichang Yuan 2018-03-21  190  	return ret;
adf38bb0b5956a Zhichang Yuan 2018-03-21  191  }
adf38bb0b5956a Zhichang Yuan 2018-03-21  192  

:::::: The code at line 137 was first introduced by commit
:::::: adf38bb0b5956ab5469acb1ca981a9287c7ad1d8 HISI LPC: Support the LPC host on Hip06/Hip07 with DT bindings

:::::: TO: Zhichang Yuan <yuanzhichang@hisilicon.com>
:::::: CC: Bjorn Helgaas <helgaas@kernel.org>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 58452 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2019-11-01  3:19 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-28 12:10 [PATCH v2 0/5] hisi_lpc: Improve build test coverage John Garry
2019-10-28 12:10 ` [PATCH v2 1/5] lib: logic_pio: Enforce LOGIC_PIO_INDIRECT region ops are set at registration John Garry
2019-10-28 12:10 ` [PATCH v2 2/5] logic_pio: Define PIO_INDIRECT_SIZE for !CONFIG_INDIRECT_PIO John Garry
2019-10-28 12:10 ` [PATCH v2 3/5] bus: hisi_lpc: Clean some types John Garry
2019-10-28 12:10 ` [PATCH v2 4/5] bus: hisi_lpc: Expand build test coverage John Garry
2019-11-01  3:19   ` kbuild test robot
2019-10-28 12:10 ` [PATCH v2 5/5] logic_pio: Build into a library John Garry
2019-10-30  9:19 ` [PATCH v2 0/5] hisi_lpc: Improve build test coverage Wei Xu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.