1*f3e89362SColin Foster /* SPDX-License-Identifier: GPL-2.0 OR MIT */ 2*f3e89362SColin Foster /* Copyright 2021, 2022 Innovative Advantage Inc. */ 3*f3e89362SColin Foster 4*f3e89362SColin Foster #ifndef _MFD_OCELOT_H 5*f3e89362SColin Foster #define _MFD_OCELOT_H 6*f3e89362SColin Foster 7*f3e89362SColin Foster #include <linux/kconfig.h> 8*f3e89362SColin Foster 9*f3e89362SColin Foster struct device; 10*f3e89362SColin Foster struct regmap; 11*f3e89362SColin Foster struct resource; 12*f3e89362SColin Foster 13*f3e89362SColin Foster /** 14*f3e89362SColin Foster * struct ocelot_ddata - Private data for an external Ocelot chip 15*f3e89362SColin Foster * @gcb_regmap: General Configuration Block regmap. Used for 16*f3e89362SColin Foster * operations like chip reset. 17*f3e89362SColin Foster * @cpuorg_regmap: CPU Device Origin Block regmap. Used for operations 18*f3e89362SColin Foster * like SPI bus configuration. 19*f3e89362SColin Foster * @spi_padding_bytes: Number of padding bytes that must be thrown out before 20*f3e89362SColin Foster * read data gets returned. This is calculated during 21*f3e89362SColin Foster * initialization based on bus speed. 22*f3e89362SColin Foster * @dummy_buf: Zero-filled buffer of spi_padding_bytes size. The dummy 23*f3e89362SColin Foster * bytes that will be sent out between the address and 24*f3e89362SColin Foster * data of a SPI read operation. 25*f3e89362SColin Foster */ 26*f3e89362SColin Foster struct ocelot_ddata { 27*f3e89362SColin Foster struct regmap *gcb_regmap; 28*f3e89362SColin Foster struct regmap *cpuorg_regmap; 29*f3e89362SColin Foster int spi_padding_bytes; 30*f3e89362SColin Foster void *dummy_buf; 31*f3e89362SColin Foster }; 32*f3e89362SColin Foster 33*f3e89362SColin Foster int ocelot_chip_reset(struct device *dev); 34*f3e89362SColin Foster int ocelot_core_init(struct device *dev); 35*f3e89362SColin Foster 36*f3e89362SColin Foster /* SPI-specific routines that won't be necessary for other interfaces */ 37*f3e89362SColin Foster struct regmap *ocelot_spi_init_regmap(struct device *dev, 38*f3e89362SColin Foster const struct resource *res); 39*f3e89362SColin Foster 40*f3e89362SColin Foster #define OCELOT_SPI_BYTE_ORDER_LE 0x00000000 41*f3e89362SColin Foster #define OCELOT_SPI_BYTE_ORDER_BE 0x81818181 42*f3e89362SColin Foster 43*f3e89362SColin Foster #ifdef __LITTLE_ENDIAN 44*f3e89362SColin Foster #define OCELOT_SPI_BYTE_ORDER OCELOT_SPI_BYTE_ORDER_LE 45*f3e89362SColin Foster #else 46*f3e89362SColin Foster #define OCELOT_SPI_BYTE_ORDER OCELOT_SPI_BYTE_ORDER_BE 47*f3e89362SColin Foster #endif 48*f3e89362SColin Foster 49*f3e89362SColin Foster #endif 50