1 /*
2  * Copyright (c) 2019 Western Digital Corporation or its affiliates
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #include "spi_context.h"
8 
9 #define SPI_OC_SIMPLE_DATA(dev) \
10 	((struct spi_oc_simple_data *) ((dev)->data))
11 
12 #define SPI_OC_SIMPLE_REG(info, offset) \
13 	((mem_addr_t) (info->base + \
14 		       (offset * CONFIG_SPI_OC_SIMPLE_BUS_WIDTH / 8)))
15 
16 #define SPI_OC_SIMPLE_SPCR(dev) SPI_OC_SIMPLE_REG(dev, 0x0)
17 #define SPI_OC_SIMPLE_SPSR(dev) SPI_OC_SIMPLE_REG(dev, 0x1)
18 #define SPI_OC_SIMPLE_SPDR(dev) SPI_OC_SIMPLE_REG(dev, 0x2)
19 #define SPI_OC_SIMPLE_SPER(dev) SPI_OC_SIMPLE_REG(dev, 0x3)
20 #define SPI_OC_SIMPLE_SPSS(dev) SPI_OC_SIMPLE_REG(dev, 0x4)
21 
22 #define SPI_OC_SIMPLE_SPCR_SPE  BIT(6)
23 #define SPI_OC_SIMPLE_SPCR_CPOL BIT(3)
24 #define SPI_OC_SIMPLE_SPCR_CPHA BIT(2)
25 
26 struct spi_oc_simple_cfg {
27 	uint32_t base;
28 	uint32_t f_sys;
29 };
30 
31 struct spi_oc_simple_data {
32 	struct spi_context ctx;
33 };
34