dt-bindings: mtd: ingenic: Use standard ecc-engine property
[linux/fpc-iii.git] / drivers / net / dsa / microchip / ksz_spi.h
blob427811bd60b380097a62b27c72daa60abe629ce4
1 /* SPDX-License-Identifier: GPL-2.0
2 * Microchip KSZ series SPI access common header
4 * Copyright (C) 2017-2018 Microchip Technology Inc.
5 * Tristram Ha <Tristram.Ha@microchip.com>
6 */
8 #ifndef __KSZ_SPI_H
9 #define __KSZ_SPI_H
11 /* Chip dependent SPI access */
12 static int ksz_spi_read(struct ksz_device *dev, u32 reg, u8 *data,
13 unsigned int len);
14 static int ksz_spi_write(struct ksz_device *dev, u32 reg, void *data,
15 unsigned int len);
17 static int ksz_spi_read8(struct ksz_device *dev, u32 reg, u8 *val)
19 return ksz_spi_read(dev, reg, val, 1);
22 static int ksz_spi_read16(struct ksz_device *dev, u32 reg, u16 *val)
24 int ret = ksz_spi_read(dev, reg, (u8 *)val, 2);
26 if (!ret)
27 *val = be16_to_cpu(*val);
29 return ret;
32 static int ksz_spi_read32(struct ksz_device *dev, u32 reg, u32 *val)
34 int ret = ksz_spi_read(dev, reg, (u8 *)val, 4);
36 if (!ret)
37 *val = be32_to_cpu(*val);
39 return ret;
42 static int ksz_spi_write8(struct ksz_device *dev, u32 reg, u8 value)
44 return ksz_spi_write(dev, reg, &value, 1);
47 static int ksz_spi_write16(struct ksz_device *dev, u32 reg, u16 value)
49 value = cpu_to_be16(value);
50 return ksz_spi_write(dev, reg, &value, 2);
53 static int ksz_spi_write32(struct ksz_device *dev, u32 reg, u32 value)
55 value = cpu_to_be32(value);
56 return ksz_spi_write(dev, reg, &value, 4);
59 static int ksz_spi_get(struct ksz_device *dev, u32 reg, void *data, size_t len)
61 return ksz_spi_read(dev, reg, data, len);
64 static int ksz_spi_set(struct ksz_device *dev, u32 reg, void *data, size_t len)
66 return ksz_spi_write(dev, reg, data, len);
69 #endif