2016-01-14 21:48:12 +08:00
|
|
|
/* spi_intel.h - Intel's SPI driver private definitions */
|
2015-08-21 18:01:08 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 2015 Intel Corporation.
|
|
|
|
*
|
2015-10-07 00:00:37 +08:00
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
2015-08-21 18:01:08 +08:00
|
|
|
*
|
2015-10-07 00:00:37 +08:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2015-08-21 18:01:08 +08:00
|
|
|
*
|
2015-10-07 00:00:37 +08:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
2015-08-21 18:01:08 +08:00
|
|
|
*/
|
|
|
|
|
2016-01-14 21:48:12 +08:00
|
|
|
#ifndef __SPI_INTEL_PRIV_H__
|
|
|
|
#define __SPI_INTEL_PRIV_H__
|
2015-08-21 18:01:08 +08:00
|
|
|
|
2015-10-08 18:24:27 +08:00
|
|
|
#ifdef CONFIG_PCI
|
|
|
|
#include <pci/pci.h>
|
|
|
|
#include <pci/pci_mgr.h>
|
|
|
|
#endif /* CONFIG_PCI */
|
2016-01-23 01:38:49 +08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
2015-10-08 18:24:27 +08:00
|
|
|
|
2016-01-08 16:46:14 +08:00
|
|
|
typedef void (*spi_intel_config_t)(void);
|
2015-10-08 18:24:27 +08:00
|
|
|
|
|
|
|
struct spi_intel_config {
|
|
|
|
uint32_t regs;
|
|
|
|
uint32_t irq;
|
|
|
|
#ifdef CONFIG_PCI
|
|
|
|
struct pci_dev_info pci_dev;
|
|
|
|
#endif /* CONFIG_PCI */
|
|
|
|
spi_intel_config_t config_func;
|
|
|
|
#ifdef CONFIG_SPI_INTEL_CS_GPIO
|
|
|
|
char *cs_gpio_name;
|
|
|
|
uint32_t cs_gpio_pin;
|
|
|
|
#endif /* CONFIG_SPI_INTEL_CS_GPIO */
|
|
|
|
};
|
|
|
|
|
|
|
|
struct spi_intel_data {
|
2015-12-08 20:30:41 +08:00
|
|
|
device_sync_call_t sync;
|
|
|
|
uint8_t error;
|
2015-10-08 18:24:27 +08:00
|
|
|
#ifdef CONFIG_SPI_INTEL_CS_GPIO
|
|
|
|
struct device *cs_gpio_port;
|
|
|
|
#endif /* CONFIG_SPI_INTEL_CS_GPIO */
|
|
|
|
uint32_t sscr0;
|
|
|
|
uint32_t sscr1;
|
|
|
|
uint8_t *tx_buf;
|
2015-11-04 01:28:36 +08:00
|
|
|
uint8_t *tx_buf_end;
|
2015-10-08 18:24:27 +08:00
|
|
|
uint8_t *rx_buf;
|
2015-11-04 01:28:36 +08:00
|
|
|
uint8_t *rx_buf_end;
|
|
|
|
uint32_t r_buf_len;
|
2015-10-08 18:24:27 +08:00
|
|
|
uint32_t t_len;
|
|
|
|
};
|
|
|
|
|
2015-08-21 18:01:08 +08:00
|
|
|
/* Registers */
|
|
|
|
#define INTEL_SPI_REG_SSCR0 (0x00)
|
2015-10-16 23:02:26 +08:00
|
|
|
#define INTEL_SPI_REG_SSCR1 (0x04)
|
2015-08-21 18:01:08 +08:00
|
|
|
#define INTEL_SPI_REG_SSSR (0x08)
|
|
|
|
#define INTEL_SPI_REG_SSDR (0x10)
|
|
|
|
#define INTEL_SPI_REG_DDS_RATE (0x28)
|
|
|
|
|
|
|
|
#define INTEL_SPI_CLK_DIV_MASK (0x000000ff)
|
|
|
|
#define INTEL_SPI_DDS_RATE_MASK (0xffffff00)
|
|
|
|
|
|
|
|
/* SSCR0 settings */
|
|
|
|
#define INTEL_SPI_SSCR0_DSS(__bpw) ((__bpw) - 1)
|
|
|
|
#define INTEL_SPI_SSCR0_SSE (0x1 << 7)
|
|
|
|
#define INTEL_SPI_SSCR0_SSE_BIT (7)
|
|
|
|
#define INTEL_SPI_SSCR0_SCR(__msf) \
|
2015-10-23 20:04:02 +08:00
|
|
|
((__msf & INTEL_SPI_CLK_DIV_MASK) << 8)
|
2015-08-21 18:01:08 +08:00
|
|
|
|
|
|
|
/* SSCR1 settings */
|
2015-09-11 19:23:21 +08:00
|
|
|
#define INTEL_SPI_SSCR1_TIE_BIT (1)
|
|
|
|
|
2015-08-21 18:01:08 +08:00
|
|
|
#define INTEL_SPI_SSCR1_RIE (0x1)
|
|
|
|
#define INTEL_SPI_SSCR1_TIE (0x1 << 1)
|
|
|
|
#define INTEL_SPI_SSCR1_LBM (0x1 << 2)
|
|
|
|
#define INTEL_SPI_SSCR1_SPO (0x1 << 3)
|
|
|
|
#define INTEL_SPI_SSCR1_SPH (0x1 << 4)
|
2015-11-04 01:28:36 +08:00
|
|
|
#define INTEL_SPI_SSCR1_TFT_MASK (0x1f << 6)
|
2015-08-21 18:01:08 +08:00
|
|
|
#define INTEL_SPI_SSCR1_TFT(__tft) \
|
|
|
|
(((__tft) - 1) << 6)
|
2015-11-04 01:28:36 +08:00
|
|
|
#define INTEL_SPI_SSCR1_RFT_MASK (0x1f << 11)
|
2015-08-21 18:01:08 +08:00
|
|
|
#define INTEL_SPI_SSCR1_RFT(__rft) \
|
|
|
|
(((__rft) - 1) << 11)
|
|
|
|
#define INTEL_SPI_SSCR1_EFWR (0x1 << 16)
|
2015-10-15 04:34:31 +08:00
|
|
|
#define INTEL_SPI_SSCR1_STRF (0x1 << 17)
|
2015-08-21 18:01:08 +08:00
|
|
|
|
|
|
|
#define INTEL_SPI_SSCR1_TFT_DFLT (8)
|
2015-11-04 01:28:36 +08:00
|
|
|
#define INTEL_SPI_SSCR1_RFT_DFLT (1)
|
2015-08-21 18:01:08 +08:00
|
|
|
|
|
|
|
/* SSSR settings */
|
|
|
|
#define INTEL_SPI_SSSR_TNF (0x4)
|
|
|
|
#define INTEL_SPI_SSSR_RNE (0x8)
|
|
|
|
#define INTEL_SPI_SSSR_TFS (0x20)
|
|
|
|
#define INTEL_SPI_SSSR_RFS (0x40)
|
|
|
|
#define INTEL_SPI_SSSR_ROR (0x80)
|
|
|
|
#define INTEL_SPI_SSSR_TFL_MASK (0x1f << 8)
|
|
|
|
#define INTEL_SPI_SSSR_TFL_EMPTY (0x00)
|
|
|
|
#define INTEL_SPI_SSSR_RFL_MASK (0x1f << 13)
|
|
|
|
#define INTEL_SPI_SSSR_RFL_EMPTY (0x1f)
|
|
|
|
|
|
|
|
#define INTEL_SPI_SSSR_TFL(__status) \
|
|
|
|
((__status & INTEL_SPI_SSSR_TFL_MASK) >> 8)
|
|
|
|
#define INTEL_SPI_SSSR_RFL(__status) \
|
|
|
|
((__status & INTEL_SPI_SSSR_RFL_MASK) >> 13)
|
|
|
|
|
|
|
|
#define INTEL_SPI_SSSR_BSY_BIT (4)
|
2015-11-04 01:28:36 +08:00
|
|
|
#define INTEL_SPI_SSSR_ROR_BIT (7)
|
2015-08-21 18:01:08 +08:00
|
|
|
|
|
|
|
/* DSS_RATE settings */
|
|
|
|
#define INTEL_SPI_DSS_RATE(__msf) \
|
2015-10-09 22:14:58 +08:00
|
|
|
((__msf & (INTEL_SPI_DDS_RATE_MASK)) >> 8)
|
2016-01-23 01:38:49 +08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
2015-08-21 18:01:08 +08:00
|
|
|
|
2016-01-14 21:48:12 +08:00
|
|
|
#endif /* __SPI_INTEL_PRIV_H__ */
|