162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 OR MIT */ 262306a36Sopenharmony_ci/* Copyright 2021, 2022 Innovative Advantage Inc. */ 362306a36Sopenharmony_ci 462306a36Sopenharmony_ci#ifndef _MFD_OCELOT_H 562306a36Sopenharmony_ci#define _MFD_OCELOT_H 662306a36Sopenharmony_ci 762306a36Sopenharmony_ci#include <linux/kconfig.h> 862306a36Sopenharmony_ci 962306a36Sopenharmony_cistruct device; 1062306a36Sopenharmony_cistruct regmap; 1162306a36Sopenharmony_cistruct resource; 1262306a36Sopenharmony_ci 1362306a36Sopenharmony_ci/** 1462306a36Sopenharmony_ci * struct ocelot_ddata - Private data for an external Ocelot chip 1562306a36Sopenharmony_ci * @gcb_regmap: General Configuration Block regmap. Used for 1662306a36Sopenharmony_ci * operations like chip reset. 1762306a36Sopenharmony_ci * @cpuorg_regmap: CPU Device Origin Block regmap. Used for operations 1862306a36Sopenharmony_ci * like SPI bus configuration. 1962306a36Sopenharmony_ci * @spi_padding_bytes: Number of padding bytes that must be thrown out before 2062306a36Sopenharmony_ci * read data gets returned. This is calculated during 2162306a36Sopenharmony_ci * initialization based on bus speed. 2262306a36Sopenharmony_ci * @dummy_buf: Zero-filled buffer of spi_padding_bytes size. The dummy 2362306a36Sopenharmony_ci * bytes that will be sent out between the address and 2462306a36Sopenharmony_ci * data of a SPI read operation. 2562306a36Sopenharmony_ci */ 2662306a36Sopenharmony_cistruct ocelot_ddata { 2762306a36Sopenharmony_ci struct regmap *gcb_regmap; 2862306a36Sopenharmony_ci struct regmap *cpuorg_regmap; 2962306a36Sopenharmony_ci int spi_padding_bytes; 3062306a36Sopenharmony_ci void *dummy_buf; 3162306a36Sopenharmony_ci}; 3262306a36Sopenharmony_ci 3362306a36Sopenharmony_ciint ocelot_chip_reset(struct device *dev); 3462306a36Sopenharmony_ciint ocelot_core_init(struct device *dev); 3562306a36Sopenharmony_ci 3662306a36Sopenharmony_ci/* SPI-specific routines that won't be necessary for other interfaces */ 3762306a36Sopenharmony_cistruct regmap *ocelot_spi_init_regmap(struct device *dev, 3862306a36Sopenharmony_ci const struct resource *res); 3962306a36Sopenharmony_ci 4062306a36Sopenharmony_ci#define OCELOT_SPI_BYTE_ORDER_LE 0x00000000 4162306a36Sopenharmony_ci#define OCELOT_SPI_BYTE_ORDER_BE 0x81818181 4262306a36Sopenharmony_ci 4362306a36Sopenharmony_ci#ifdef __LITTLE_ENDIAN 4462306a36Sopenharmony_ci#define OCELOT_SPI_BYTE_ORDER OCELOT_SPI_BYTE_ORDER_LE 4562306a36Sopenharmony_ci#else 4662306a36Sopenharmony_ci#define OCELOT_SPI_BYTE_ORDER OCELOT_SPI_BYTE_ORDER_BE 4762306a36Sopenharmony_ci#endif 4862306a36Sopenharmony_ci 4962306a36Sopenharmony_ci#endif 50