Commit 13c1eff1 authored by Olof Johansson's avatar Olof Johansson

Merge tag 'hisi-drivers-for-5.5' of git://github.com/hisilicon/linux-hisi into arm/drivers

ARM64: hisi: SoC driver updates for 5.5

- check the LOGIC_PIO_INDIRECT region ops at registration instead of
  in the IO port accessors to optimise the lib/ligic_pio.c

- add the hisi LPC driver to the build test for the other architectures
  except ALPHA, C6X, HEXAGON and PARISC as they do not define {read,write}sb
  by updating the hisi LPC Kconfig and adding a dummy PIO_INDIRECT_SIZE

- clean the sparse complains of the hisi LPC driver

- build logic_pio into a lib to avoid including in the vmlinux when not
  referenced

* tag 'hisi-drivers-for-5.5' of git://github.com/hisilicon/linux-hisi:
  logic_pio: Build into a library
  bus: hisi_lpc: Expand build test coverage
  bus: hisi_lpc: Clean some types
  logic_pio: Define PIO_INDIRECT_SIZE for !CONFIG_INDIRECT_PIO
  lib: logic_pio: Enforce LOGIC_PIO_INDIRECT region ops are set at registration

Link: https://lore.kernel.org/r/5DC959B9.80301@hisilicon.comSigned-off-by: default avatarOlof Johansson <olof@lixom.net>
parents 01d1a860 f361c863
...@@ -41,8 +41,9 @@ config MOXTET ...@@ -41,8 +41,9 @@ config MOXTET
config HISILICON_LPC config HISILICON_LPC
bool "Support for ISA I/O space on HiSilicon Hip06/7" bool "Support for ISA I/O space on HiSilicon Hip06/7"
depends on ARM64 && (ARCH_HISI || COMPILE_TEST) depends on (ARM64 && ARCH_HISI) || (COMPILE_TEST && !ALPHA && !HEXAGON && !PARISC && !C6X)
select INDIRECT_PIO depends on HAS_IOMEM
select INDIRECT_PIO if ARM64
help help
Driver to enable I/O access to devices attached to the Low Pin Driver to enable I/O access to devices attached to the Low Pin
Count bus on the HiSilicon Hip06/7 SoC. Count bus on the HiSilicon Hip06/7 SoC.
......
...@@ -74,7 +74,7 @@ struct hisi_lpc_dev { ...@@ -74,7 +74,7 @@ struct hisi_lpc_dev {
/* About 10us. This is specific for single IO operations, such as inb */ /* About 10us. This is specific for single IO operations, such as inb */
#define LPC_PEROP_WAITCNT 100 #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; u32 status;
...@@ -209,7 +209,7 @@ static u32 hisi_lpc_comm_in(void *hostdata, unsigned long pio, size_t dwidth) ...@@ -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 hisi_lpc_dev *lpcdev = hostdata;
struct lpc_cycle_para iopara; struct lpc_cycle_para iopara;
unsigned long addr; unsigned long addr;
u32 rd_data = 0; __le32 rd_data = 0;
int ret; int ret;
if (!lpcdev || !dwidth || dwidth > LPC_MAX_DWIDTH) if (!lpcdev || !dwidth || dwidth > LPC_MAX_DWIDTH)
...@@ -244,13 +244,12 @@ static void hisi_lpc_comm_out(void *hostdata, unsigned long pio, ...@@ -244,13 +244,12 @@ static void hisi_lpc_comm_out(void *hostdata, unsigned long pio,
struct lpc_cycle_para iopara; struct lpc_cycle_para iopara;
const unsigned char *buf; const unsigned char *buf;
unsigned long addr; unsigned long addr;
__le32 _val = cpu_to_le32(val);
if (!lpcdev || !dwidth || dwidth > LPC_MAX_DWIDTH) if (!lpcdev || !dwidth || dwidth > LPC_MAX_DWIDTH)
return; return;
val = cpu_to_le32(val); buf = (const unsigned char *)&_val;
buf = (const unsigned char *)&val;
addr = hisi_lpc_pio_to_addr(lpcdev, pio); addr = hisi_lpc_pio_to_addr(lpcdev, pio);
iopara.opflags = FG_INCRADDR_LPC; iopara.opflags = FG_INCRADDR_LPC;
......
...@@ -108,10 +108,10 @@ void logic_outsl(unsigned long addr, const void *buffer, unsigned int count); ...@@ -108,10 +108,10 @@ void logic_outsl(unsigned long addr, const void *buffer, unsigned int count);
* area by redefining the macro below. * area by redefining the macro below.
*/ */
#define PIO_INDIRECT_SIZE 0x4000 #define PIO_INDIRECT_SIZE 0x4000
#define MMIO_UPPER_LIMIT (IO_SPACE_LIMIT - PIO_INDIRECT_SIZE)
#else #else
#define MMIO_UPPER_LIMIT IO_SPACE_LIMIT #define PIO_INDIRECT_SIZE 0
#endif /* CONFIG_INDIRECT_PIO */ #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); struct logic_pio_hwaddr *find_io_range_by_fwnode(struct fwnode_handle *fwnode);
unsigned long logic_pio_trans_hwaddr(struct fwnode_handle *fwnode, unsigned long logic_pio_trans_hwaddr(struct fwnode_handle *fwnode,
......
...@@ -108,7 +108,7 @@ obj-$(CONFIG_HAS_IOMEM) += iomap_copy.o devres.o ...@@ -108,7 +108,7 @@ obj-$(CONFIG_HAS_IOMEM) += iomap_copy.o devres.o
obj-$(CONFIG_CHECK_SIGNATURE) += check_signature.o obj-$(CONFIG_CHECK_SIGNATURE) += check_signature.o
obj-$(CONFIG_DEBUG_LOCKING_API_SELFTESTS) += locking-selftest.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 obj-$(CONFIG_GENERIC_HWEIGHT) += hweight.o
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
* Copyright (C) 2017 HiSilicon Limited, All Rights Reserved. * Copyright (C) 2017 HiSilicon Limited, All Rights Reserved.
* Author: Gabriele Paoloni <gabriele.paoloni@huawei.com> * Author: Gabriele Paoloni <gabriele.paoloni@huawei.com>
* Author: Zhichang Yuan <yuanzhichang@hisilicon.com> * Author: Zhichang Yuan <yuanzhichang@hisilicon.com>
* Author: John Garry <john.garry@huawei.com>
*/ */
#define pr_fmt(fmt) "LOGIC PIO: " fmt #define pr_fmt(fmt) "LOGIC PIO: " fmt
...@@ -39,7 +40,8 @@ int logic_pio_register_range(struct logic_pio_hwaddr *new_range) ...@@ -39,7 +40,8 @@ int logic_pio_register_range(struct logic_pio_hwaddr *new_range)
resource_size_t iio_sz = MMIO_UPPER_LIMIT; resource_size_t iio_sz = MMIO_UPPER_LIMIT;
int ret = 0; 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; return -EINVAL;
start = new_range->hw_start; start = new_range->hw_start;
...@@ -237,7 +239,7 @@ type logic_in##bw(unsigned long addr) \ ...@@ -237,7 +239,7 @@ type logic_in##bw(unsigned long addr) \
} else if (addr >= MMIO_UPPER_LIMIT && addr < IO_SPACE_LIMIT) { \ } else if (addr >= MMIO_UPPER_LIMIT && addr < IO_SPACE_LIMIT) { \
struct logic_pio_hwaddr *entry = find_io_range(addr); \ struct logic_pio_hwaddr *entry = find_io_range(addr); \
\ \
if (entry && entry->ops) \ if (entry) \
ret = entry->ops->in(entry->hostdata, \ ret = entry->ops->in(entry->hostdata, \
addr, sizeof(type)); \ addr, sizeof(type)); \
else \ else \
...@@ -253,7 +255,7 @@ void logic_out##bw(type value, unsigned long addr) \ ...@@ -253,7 +255,7 @@ void logic_out##bw(type value, unsigned long addr) \
} else if (addr >= MMIO_UPPER_LIMIT && addr < IO_SPACE_LIMIT) { \ } else if (addr >= MMIO_UPPER_LIMIT && addr < IO_SPACE_LIMIT) { \
struct logic_pio_hwaddr *entry = find_io_range(addr); \ struct logic_pio_hwaddr *entry = find_io_range(addr); \
\ \
if (entry && entry->ops) \ if (entry) \
entry->ops->out(entry->hostdata, \ entry->ops->out(entry->hostdata, \
addr, value, sizeof(type)); \ addr, value, sizeof(type)); \
else \ else \
...@@ -261,7 +263,7 @@ void logic_out##bw(type value, unsigned long addr) \ ...@@ -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) \ unsigned int count) \
{ \ { \
if (addr < MMIO_UPPER_LIMIT) { \ if (addr < MMIO_UPPER_LIMIT) { \
...@@ -269,7 +271,7 @@ void logic_ins##bw(unsigned long addr, void *buffer, \ ...@@ -269,7 +271,7 @@ void logic_ins##bw(unsigned long addr, void *buffer, \
} else if (addr >= MMIO_UPPER_LIMIT && addr < IO_SPACE_LIMIT) { \ } else if (addr >= MMIO_UPPER_LIMIT && addr < IO_SPACE_LIMIT) { \
struct logic_pio_hwaddr *entry = find_io_range(addr); \ struct logic_pio_hwaddr *entry = find_io_range(addr); \
\ \
if (entry && entry->ops) \ if (entry) \
entry->ops->ins(entry->hostdata, \ entry->ops->ins(entry->hostdata, \
addr, buffer, sizeof(type), count); \ addr, buffer, sizeof(type), count); \
else \ else \
...@@ -286,7 +288,7 @@ void logic_outs##bw(unsigned long addr, const void *buffer, \ ...@@ -286,7 +288,7 @@ void logic_outs##bw(unsigned long addr, const void *buffer, \
} else if (addr >= MMIO_UPPER_LIMIT && addr < IO_SPACE_LIMIT) { \ } else if (addr >= MMIO_UPPER_LIMIT && addr < IO_SPACE_LIMIT) { \
struct logic_pio_hwaddr *entry = find_io_range(addr); \ struct logic_pio_hwaddr *entry = find_io_range(addr); \
\ \
if (entry && entry->ops) \ if (entry) \
entry->ops->outs(entry->hostdata, \ entry->ops->outs(entry->hostdata, \
addr, buffer, sizeof(type), count); \ addr, buffer, sizeof(type), count); \
else \ else \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment