1 /* SPDX-License-Identifier: BSD-2-Clause */ 2 /* 3 * Copyright (c) 2016, Linaro Limited 4 * 5 */ 6 7 #ifndef __PL022_SPI_H__ 8 #define __PL022_SPI_H__ 9 10 #include <gpio.h> 11 #include <spi.h> 12 13 #define PL022_REG_SIZE 0x1000 14 15 enum pl022_cs_control { 16 PL022_CS_CTRL_AUTO_GPIO, 17 PL022_CS_CTRL_CB, 18 PL022_CS_CTRL_MANUAL 19 }; 20 21 struct pl022_cs_gpio_data { 22 struct gpio_chip *chip; 23 unsigned int pin_num; 24 }; 25 26 union pl022_cs_data { 27 struct pl022_cs_gpio_data gpio_data; 28 void (*cs_cb)(enum gpio_level value); 29 }; 30 31 struct pl022_data { 32 union pl022_cs_data cs_data; 33 struct spi_chip chip; 34 vaddr_t base; 35 enum spi_mode mode; 36 enum pl022_cs_control cs_control; 37 unsigned int clk_hz; 38 unsigned int speed_hz; 39 unsigned int data_size_bits; 40 bool loopback; 41 }; 42 43 void pl022_init(struct pl022_data *pd); 44 45 #endif /* __PL022_SPI_H__ */ 46 47