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