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>
11 /* Chip dependent SPI access */
12 static int ksz_spi_read(struct ksz_device
*dev
, u32 reg
, u8
*data
,
14 static int ksz_spi_write(struct ksz_device
*dev
, u32 reg
, void *data
,
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);
27 *val
= be16_to_cpu(*val
);
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);
37 *val
= be32_to_cpu(*val
);
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
);