coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
gspi.c File Reference
#include <device/mmio.h>
#include <assert.h>
#include <bootstate.h>
#include <console/console.h>
#include <delay.h>
#include <device/device.h>
#include <device/pci_def.h>
#include <device/pci_ops.h>
#include <intelblocks/cfg.h>
#include <intelblocks/gspi.h>
#include <intelblocks/lpss.h>
#include <intelblocks/spi.h>
#include <soc/iomap.h>
#include <soc/pci_devs.h>
#include <string.h>
#include <timer.h>
Include dependency graph for gspi.c:

Go to the source code of this file.

Data Structures

struct  gspi_ctrlr_params
 

Macros

#define SSCR0   0x0 /* SSP Control Register 0 */
 
#define SSCR0_EDSS_0   (0 << 20)
 
#define SSCR0_EDSS_1   (1 << 20)
 
#define SSCR0_SCR_SHIFT   (8)
 
#define SSCR0_SCR_MASK   (0xFFF)
 
#define SSCR0_SSE_DISABLE   (0 << 7)
 
#define SSCR0_SSE_ENABLE   (1 << 7)
 
#define SSCR0_ECS_ON_CHIP   (0 << 6)
 
#define SSCR0_FRF_MOTOROLA   (0 << 4)
 
#define SSCR0_DSS_SHIFT   (0)
 
#define SSCR0_DSS_MASK   (0xF)
 
#define SSCR1   0x4 /* SSP Control Register 1 */
 
#define SSCR1_IFS_LOW   (0 << 16)
 
#define SSCR1_IFS_HIGH   (1 << 16)
 
#define SSCR1_SPH_FIRST   (0 << 4)
 
#define SSCR1_SPH_SECOND   (1 << 4)
 
#define SSCR1_SPO_LOW   (0 << 3)
 
#define SSCR1_SPO_HIGH   (1 << 3)
 
#define SSSR   0x8 /* SSP Status Register */
 
#define SSSR_TUR   (1 << 21) /* Tx FIFO underrun */
 
#define SSSR_TINT   (1 << 19) /* Rx Time-out interrupt */
 
#define SSSR_PINT
 
#define SSSR_ROR   (1 << 7) /* Rx FIFO Overrun */
 
#define SSSR_BSY   (1 << 4) /* SSP Busy */
 
#define SSSR_RNE   (1 << 3) /* Receive FIFO not empty */
 
#define SSSR_TNF   (1 << 2) /* Transmit FIFO not full */
 
#define SSDR   0x10 /* SSP Data Register */
 
#define SSTO   0x28 /* SSP Time out */
 
#define SITF   0x44 /* SPI Transmit FIFO */
 
#define SITF_LEVEL_SHIFT   (16)
 
#define SITF_LEVEL_MASK   (0x3f)
 
#define SITF_LWM_SHIFT   (8)
 
#define SITF_LWM_MASK   (0x3f)
 
#define SITF_LWM(x)   ((((x) - 1) & SITF_LWM_MASK) << SITF_LWM_SHIFT)
 
#define SITF_HWM_SHIFT   (0)
 
#define SITF_HWM_MASK   (0x3f)
 
#define SITF_HWM(x)   ((((x) - 1) & SITF_HWM_MASK) << SITF_HWM_SHIFT)
 
#define SIRF   0x48 /* SPI Receive FIFO */
 
#define SIRF_LEVEL_SHIFT   (8)
 
#define SIRF_LEVEL_MASK   (0x3f)
 
#define SIRF_WM_SHIFT   (0)
 
#define SIRF_WM_MASK   (0x3f)
 
#define SIRF_WM(x)   ((((x) - 1) & SIRF_WM_MASK) << SIRF_WM_SHIFT)
 
#define CLOCKS   0x200 /* Clocks */
 
#define CLOCKS_UPDATE   (1 << 31)
 
#define CLOCKS_N_SHIFT   (16)
 
#define CLOCKS_N_MASK   (0x7fff)
 
#define CLOCKS_M_SHIFT   (1)
 
#define CLOCKS_M_MASK   (0x7fff)
 
#define CLOCKS_DISABLE   (0 << 0)
 
#define CLOCKS_ENABLE   (1 << 0)
 
#define RESETS   0x204 /* Resets */
 
#define DMA_RESET   (0 << 2)
 
#define DMA_ACTIVE   (1 << 2)
 
#define CTRLR_RESET   (0 << 0)
 
#define CTRLR_ACTIVE   (3 << 0)
 
#define ACTIVELTR_VALUE   0x210 /* Active LTR */
 
#define IDLELTR_VALUE   0x214 /* Idle LTR Value */
 
#define TX_BIT_COUNT   0x218 /* Tx Bit Count */
 
#define RX_BIT_COUNT   0x21c /* Rx Bit Count */
 
#define SSP_REG   0x220 /* SSP Reg */
 
#define DMA_FINISH_DISABLE   (1 << 0)
 
#define SPI_CS_CONTROL   0x224 /* SPI CS Control */
 
#define CS_0_POL_SHIFT   (12)
 
#define CS_0_POL_MASK   (1 << CS_0_POL_SHIFT)
 
#define CS_POL_LOW   (0)
 
#define CS_POL_HIGH   (1)
 
#define CS_0   (0 << 8)
 
#define CS_STATE_SHIFT   (1)
 
#define CS_STATE_MASK   (1 << CS_STATE_SHIFT)
 
#define CS_V1_STATE_LOW   (0)
 
#define CS_V1_STATE_HIGH   (1)
 
#define CS_MODE_HW   (0 << 0)
 
#define CS_MODE_SW   (1 << 0)
 
#define GSPI_DATA_BIT_LENGTH   (8)
 
#define GSPI_BUS_BASE(bar, bus)   ((bar) + (bus) * 4 * KiB)
 

Enumerations

enum  cs_assert { CS_ASSERT , CS_DEASSERT }
 

Functions

static uintptr_t gspi_get_early_base (void)
 
static const struct gspi_cfggspi_get_cfg (void)
 
static uintptr_t gspi_get_base_addr (int devfn, struct device *dev)
 
static void gspi_set_base_addr (int devfn, struct device *dev, uintptr_t base)
 
static int gspi_read_bus_range (unsigned int *start, unsigned int *end)
 
static int gspi_spi_to_gspi_bus (unsigned int spi_bus, unsigned int *gspi_bus)
 
static uintptr_t gspi_calc_base_addr (unsigned int gspi_bus)
 
static uint32_t gspi_get_bus_clk_mhz (unsigned int gspi_bus)
 
static uintptr_t gspi_get_bus_base_addr (unsigned int gspi_bus)
 
static void gspi_clear_cached_base (void *unused)
 
 BOOT_STATE_INIT_ENTRY (BS_DEV_RESOURCES, BS_ON_EXIT, gspi_clear_cached_base, NULL)
 
static uint32_t gspi_read_mmio_reg (const struct gspi_ctrlr_params *p, uint32_t offset)
 
static void gspi_write_mmio_reg (const struct gspi_ctrlr_params *p, uint32_t offset, uint32_t value)
 
static int gspi_ctrlr_params_init (struct gspi_ctrlr_params *p, unsigned int spi_bus)
 
static uint32_t gspi_csctrl_state_v2 (uint32_t pol, enum cs_assert cs_assert)
 
static uint32_t gspi_csctrl_state_v1 (uint32_t pol, enum cs_assert cs_assert)
 
static uint32_t gspi_csctrl_state (uint32_t pol, enum cs_assert cs_assert)
 
static uint32_t gspi_csctrl_polarity_v2 (enum spi_polarity active_pol)
 
static uint32_t gspi_csctrl_polarity_v1 (enum spi_polarity active_pol)
 
static uint32_t gspi_csctrl_polarity (enum spi_polarity active_pol)
 
static void __gspi_cs_change (const struct gspi_ctrlr_params *p, enum cs_assert cs_assert)
 
static int gspi_cs_change (const struct spi_slave *dev, enum cs_assert cs_assert)
 
int __weak gspi_get_soc_spi_cfg (unsigned int gspi_bus, struct spi_cfg *cfg)
 
static int gspi_cs_assert (const struct spi_slave *dev)
 
static void gspi_cs_deassert (const struct spi_slave *dev)
 
static uint32_t gspi_get_clk_div (unsigned int gspi_bus)
 
static int gspi_ctrlr_setup (const struct spi_slave *dev)
 
static uint32_t gspi_read_status (const struct gspi_ctrlr_params *p)
 
static void gspi_clear_status (const struct gspi_ctrlr_params *p)
 
static bool gspi_rx_fifo_empty (const struct gspi_ctrlr_params *p)
 
static bool gspi_tx_fifo_full (const struct gspi_ctrlr_params *p)
 
static bool gspi_rx_fifo_overrun (const struct gspi_ctrlr_params *p)
 
static uint8_t gspi_read_byte (const struct gspi_ctrlr_params *p)
 
static void gspi_write_byte (const struct gspi_ctrlr_params *p, uint8_t data)
 
static void gspi_read_data (struct gspi_ctrlr_params *p)
 
static void gspi_write_data (struct gspi_ctrlr_params *p)
 
static void gspi_read_dummy (struct gspi_ctrlr_params *p)
 
static void gspi_write_dummy (struct gspi_ctrlr_params *p)
 
static int gspi_ctrlr_flush (const struct gspi_ctrlr_params *p)
 
static int __gspi_xfer (struct gspi_ctrlr_params *p)
 
static int gspi_ctrlr_xfer (const struct spi_slave *dev, const void *dout, size_t bytesout, void *din, size_t bytesin)
 

Variables

static uintptr_t gspi_base [CONFIG_SOC_INTEL_COMMON_BLOCK_GSPI_MAX]
 
const struct spi_ctrlr gspi_ctrlr
 

Macro Definition Documentation

◆ ACTIVELTR_VALUE

#define ACTIVELTR_VALUE   0x210 /* Active LTR */

Definition at line 79 of file gspi.c.

◆ CLOCKS

#define CLOCKS   0x200 /* Clocks */

Definition at line 66 of file gspi.c.

◆ CLOCKS_DISABLE

#define CLOCKS_DISABLE   (0 << 0)

Definition at line 72 of file gspi.c.

◆ CLOCKS_ENABLE

#define CLOCKS_ENABLE   (1 << 0)

Definition at line 73 of file gspi.c.

◆ CLOCKS_M_MASK

#define CLOCKS_M_MASK   (0x7fff)

Definition at line 71 of file gspi.c.

◆ CLOCKS_M_SHIFT

#define CLOCKS_M_SHIFT   (1)

Definition at line 70 of file gspi.c.

◆ CLOCKS_N_MASK

#define CLOCKS_N_MASK   (0x7fff)

Definition at line 69 of file gspi.c.

◆ CLOCKS_N_SHIFT

#define CLOCKS_N_SHIFT   (16)

Definition at line 68 of file gspi.c.

◆ CLOCKS_UPDATE

#define CLOCKS_UPDATE   (1 << 31)

Definition at line 67 of file gspi.c.

◆ CS_0

#define CS_0   (0 << 8)

Definition at line 90 of file gspi.c.

◆ CS_0_POL_MASK

#define CS_0_POL_MASK   (1 << CS_0_POL_SHIFT)

Definition at line 87 of file gspi.c.

◆ CS_0_POL_SHIFT

#define CS_0_POL_SHIFT   (12)

Definition at line 86 of file gspi.c.

◆ CS_MODE_HW

#define CS_MODE_HW   (0 << 0)

Definition at line 95 of file gspi.c.

◆ CS_MODE_SW

#define CS_MODE_SW   (1 << 0)

Definition at line 96 of file gspi.c.

◆ CS_POL_HIGH

#define CS_POL_HIGH   (1)

Definition at line 89 of file gspi.c.

◆ CS_POL_LOW

#define CS_POL_LOW   (0)

Definition at line 88 of file gspi.c.

◆ CS_STATE_MASK

#define CS_STATE_MASK   (1 << CS_STATE_SHIFT)

Definition at line 92 of file gspi.c.

◆ CS_STATE_SHIFT

#define CS_STATE_SHIFT   (1)

Definition at line 91 of file gspi.c.

◆ CS_V1_STATE_HIGH

#define CS_V1_STATE_HIGH   (1)

Definition at line 94 of file gspi.c.

◆ CS_V1_STATE_LOW

#define CS_V1_STATE_LOW   (0)

Definition at line 93 of file gspi.c.

◆ CTRLR_ACTIVE

#define CTRLR_ACTIVE   (3 << 0)

Definition at line 78 of file gspi.c.

◆ CTRLR_RESET

#define CTRLR_RESET   (0 << 0)

Definition at line 77 of file gspi.c.

◆ DMA_ACTIVE

#define DMA_ACTIVE   (1 << 2)

Definition at line 76 of file gspi.c.

◆ DMA_FINISH_DISABLE

#define DMA_FINISH_DISABLE   (1 << 0)

Definition at line 84 of file gspi.c.

◆ DMA_RESET

#define DMA_RESET   (0 << 2)

Definition at line 75 of file gspi.c.

◆ GSPI_BUS_BASE

#define GSPI_BUS_BASE (   bar,
  bus 
)    ((bar) + (bus) * 4 * KiB)

Definition at line 99 of file gspi.c.

◆ GSPI_DATA_BIT_LENGTH

#define GSPI_DATA_BIT_LENGTH   (8)

Definition at line 98 of file gspi.c.

◆ IDLELTR_VALUE

#define IDLELTR_VALUE   0x214 /* Idle LTR Value */

Definition at line 80 of file gspi.c.

◆ RESETS

#define RESETS   0x204 /* Resets */

Definition at line 74 of file gspi.c.

◆ RX_BIT_COUNT

#define RX_BIT_COUNT   0x21c /* Rx Bit Count */

Definition at line 82 of file gspi.c.

◆ SIRF

#define SIRF   0x48 /* SPI Receive FIFO */

Definition at line 58 of file gspi.c.

◆ SIRF_LEVEL_MASK

#define SIRF_LEVEL_MASK   (0x3f)

Definition at line 60 of file gspi.c.

◆ SIRF_LEVEL_SHIFT

#define SIRF_LEVEL_SHIFT   (8)

Definition at line 59 of file gspi.c.

◆ SIRF_WM

#define SIRF_WM (   x)    ((((x) - 1) & SIRF_WM_MASK) << SIRF_WM_SHIFT)

Definition at line 63 of file gspi.c.

◆ SIRF_WM_MASK

#define SIRF_WM_MASK   (0x3f)

Definition at line 62 of file gspi.c.

◆ SIRF_WM_SHIFT

#define SIRF_WM_SHIFT   (0)

Definition at line 61 of file gspi.c.

◆ SITF

#define SITF   0x44 /* SPI Transmit FIFO */

Definition at line 49 of file gspi.c.

◆ SITF_HWM

#define SITF_HWM (   x)    ((((x) - 1) & SITF_HWM_MASK) << SITF_HWM_SHIFT)

Definition at line 57 of file gspi.c.

◆ SITF_HWM_MASK

#define SITF_HWM_MASK   (0x3f)

Definition at line 56 of file gspi.c.

◆ SITF_HWM_SHIFT

#define SITF_HWM_SHIFT   (0)

Definition at line 55 of file gspi.c.

◆ SITF_LEVEL_MASK

#define SITF_LEVEL_MASK   (0x3f)

Definition at line 51 of file gspi.c.

◆ SITF_LEVEL_SHIFT

#define SITF_LEVEL_SHIFT   (16)

Definition at line 50 of file gspi.c.

◆ SITF_LWM

#define SITF_LWM (   x)    ((((x) - 1) & SITF_LWM_MASK) << SITF_LWM_SHIFT)

Definition at line 54 of file gspi.c.

◆ SITF_LWM_MASK

#define SITF_LWM_MASK   (0x3f)

Definition at line 53 of file gspi.c.

◆ SITF_LWM_SHIFT

#define SITF_LWM_SHIFT   (8)

Definition at line 52 of file gspi.c.

◆ SPI_CS_CONTROL

#define SPI_CS_CONTROL   0x224 /* SPI CS Control */

Definition at line 85 of file gspi.c.

◆ SSCR0

#define SSCR0   0x0 /* SSP Control Register 0 */

Definition at line 21 of file gspi.c.

◆ SSCR0_DSS_MASK

#define SSCR0_DSS_MASK   (0xF)

Definition at line 31 of file gspi.c.

◆ SSCR0_DSS_SHIFT

#define SSCR0_DSS_SHIFT   (0)

Definition at line 30 of file gspi.c.

◆ SSCR0_ECS_ON_CHIP

#define SSCR0_ECS_ON_CHIP   (0 << 6)

Definition at line 28 of file gspi.c.

◆ SSCR0_EDSS_0

#define SSCR0_EDSS_0   (0 << 20)

Definition at line 22 of file gspi.c.

◆ SSCR0_EDSS_1

#define SSCR0_EDSS_1   (1 << 20)

Definition at line 23 of file gspi.c.

◆ SSCR0_FRF_MOTOROLA

#define SSCR0_FRF_MOTOROLA   (0 << 4)

Definition at line 29 of file gspi.c.

◆ SSCR0_SCR_MASK

#define SSCR0_SCR_MASK   (0xFFF)

Definition at line 25 of file gspi.c.

◆ SSCR0_SCR_SHIFT

#define SSCR0_SCR_SHIFT   (8)

Definition at line 24 of file gspi.c.

◆ SSCR0_SSE_DISABLE

#define SSCR0_SSE_DISABLE   (0 << 7)

Definition at line 26 of file gspi.c.

◆ SSCR0_SSE_ENABLE

#define SSCR0_SSE_ENABLE   (1 << 7)

Definition at line 27 of file gspi.c.

◆ SSCR1

#define SSCR1   0x4 /* SSP Control Register 1 */

Definition at line 32 of file gspi.c.

◆ SSCR1_IFS_HIGH

#define SSCR1_IFS_HIGH   (1 << 16)

Definition at line 34 of file gspi.c.

◆ SSCR1_IFS_LOW

#define SSCR1_IFS_LOW   (0 << 16)

Definition at line 33 of file gspi.c.

◆ SSCR1_SPH_FIRST

#define SSCR1_SPH_FIRST   (0 << 4)

Definition at line 35 of file gspi.c.

◆ SSCR1_SPH_SECOND

#define SSCR1_SPH_SECOND   (1 << 4)

Definition at line 36 of file gspi.c.

◆ SSCR1_SPO_HIGH

#define SSCR1_SPO_HIGH   (1 << 3)

Definition at line 38 of file gspi.c.

◆ SSCR1_SPO_LOW

#define SSCR1_SPO_LOW   (0 << 3)

Definition at line 37 of file gspi.c.

◆ SSDR

#define SSDR   0x10 /* SSP Data Register */

Definition at line 47 of file gspi.c.

◆ SSP_REG

#define SSP_REG   0x220 /* SSP Reg */

Definition at line 83 of file gspi.c.

◆ SSSR

#define SSSR   0x8 /* SSP Status Register */

Definition at line 39 of file gspi.c.

◆ SSSR_BSY

#define SSSR_BSY   (1 << 4) /* SSP Busy */

Definition at line 44 of file gspi.c.

◆ SSSR_PINT

#define SSSR_PINT
Value:
(1 << 18) /* Peripheral trailing byte
interrupt */

Definition at line 42 of file gspi.c.

◆ SSSR_RNE

#define SSSR_RNE   (1 << 3) /* Receive FIFO not empty */

Definition at line 45 of file gspi.c.

◆ SSSR_ROR

#define SSSR_ROR   (1 << 7) /* Rx FIFO Overrun */

Definition at line 43 of file gspi.c.

◆ SSSR_TINT

#define SSSR_TINT   (1 << 19) /* Rx Time-out interrupt */

Definition at line 41 of file gspi.c.

◆ SSSR_TNF

#define SSSR_TNF   (1 << 2) /* Transmit FIFO not full */

Definition at line 46 of file gspi.c.

◆ SSSR_TUR

#define SSSR_TUR   (1 << 21) /* Tx FIFO underrun */

Definition at line 40 of file gspi.c.

◆ SSTO

#define SSTO   0x28 /* SSP Time out */

Definition at line 48 of file gspi.c.

◆ TX_BIT_COUNT

#define TX_BIT_COUNT   0x218 /* Tx Bit Count */

Definition at line 81 of file gspi.c.

Enumeration Type Documentation

◆ cs_assert

enum cs_assert
Enumerator
CS_ASSERT 
CS_DEASSERT 

Definition at line 316 of file gspi.c.

Function Documentation

◆ __gspi_cs_change()

static void __gspi_cs_change ( const struct gspi_ctrlr_params p,
enum cs_assert  cs_assert 
)
static

Definition at line 383 of file gspi.c.

References CS_0_POL_MASK, CS_STATE_MASK, CS_STATE_SHIFT, gspi_csctrl_state(), gspi_read_mmio_reg(), gspi_write_mmio_reg(), and SPI_CS_CONTROL.

Referenced by gspi_cs_change().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ __gspi_xfer()

static int __gspi_xfer ( struct gspi_ctrlr_params p)
static

◆ BOOT_STATE_INIT_ENTRY()

BOOT_STATE_INIT_ENTRY ( BS_DEV_RESOURCES  ,
BS_ON_EXIT  ,
gspi_clear_cached_base  ,
NULL   
)

◆ gspi_calc_base_addr()

static uintptr_t gspi_calc_base_addr ( unsigned int  gspi_bus)
static

Definition at line 216 of file gspi.c.

References DEVTREE_CONST, device::enabled, GSPI_BUS_BASE, gspi_get_base_addr(), gspi_get_early_base(), gspi_set_base_addr(), gspi_soc_bus_to_devfn(), and pcidev_path_on_root().

Referenced by gspi_get_bus_base_addr().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gspi_clear_cached_base()

static void gspi_clear_cached_base ( void unused)
static

Definition at line 265 of file gspi.c.

References gspi_base, and memset().

Here is the call graph for this function:

◆ gspi_clear_status()

static void gspi_clear_status ( const struct gspi_ctrlr_params p)
static

Definition at line 552 of file gspi.c.

References gspi_write_mmio_reg(), SSSR, SSSR_PINT, SSSR_ROR, SSSR_TINT, and SSSR_TUR.

Here is the call graph for this function:

◆ gspi_cs_assert()

static int gspi_cs_assert ( const struct spi_slave dev)
static

Definition at line 421 of file gspi.c.

References CS_ASSERT, and gspi_cs_change().

Here is the call graph for this function:

◆ gspi_cs_change()

static int gspi_cs_change ( const struct spi_slave dev,
enum cs_assert  cs_assert 
)
static

Definition at line 397 of file gspi.c.

References __gspi_cs_change(), spi_slave::bus, gspi_ctrlr_params_init(), and params.

Referenced by gspi_cs_assert(), and gspi_cs_deassert().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gspi_cs_deassert()

static void gspi_cs_deassert ( const struct spi_slave dev)
static

Definition at line 426 of file gspi.c.

References CS_DEASSERT, and gspi_cs_change().

Here is the call graph for this function:

◆ gspi_csctrl_polarity()

static uint32_t gspi_csctrl_polarity ( enum spi_polarity  active_pol)
static

Definition at line 375 of file gspi.c.

References CONFIG, gspi_csctrl_polarity_v1(), and gspi_csctrl_polarity_v2().

Referenced by gspi_ctrlr_setup().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gspi_csctrl_polarity_v1()

static uint32_t gspi_csctrl_polarity_v1 ( enum spi_polarity  active_pol)
static

Definition at line 367 of file gspi.c.

References CS_POL_HIGH, CS_POL_LOW, and SPI_POLARITY_LOW.

Referenced by gspi_csctrl_polarity().

Here is the caller graph for this function:

◆ gspi_csctrl_polarity_v2()

static uint32_t gspi_csctrl_polarity_v2 ( enum spi_polarity  active_pol)
static

Definition at line 359 of file gspi.c.

References CS_POL_HIGH, CS_POL_LOW, and SPI_POLARITY_LOW.

Referenced by gspi_csctrl_polarity().

Here is the caller graph for this function:

◆ gspi_csctrl_state()

static uint32_t gspi_csctrl_state ( uint32_t  pol,
enum cs_assert  cs_assert 
)
static

Definition at line 351 of file gspi.c.

References CONFIG, gspi_csctrl_state_v1(), and gspi_csctrl_state_v2().

Referenced by __gspi_cs_change(), and gspi_ctrlr_setup().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gspi_csctrl_state_v1()

static uint32_t gspi_csctrl_state_v1 ( uint32_t  pol,
enum cs_assert  cs_assert 
)
static

Definition at line 337 of file gspi.c.

References CS_ASSERT, CS_POL_HIGH, CS_V1_STATE_HIGH, and CS_V1_STATE_LOW.

Referenced by gspi_csctrl_state().

Here is the caller graph for this function:

◆ gspi_csctrl_state_v2()

static uint32_t gspi_csctrl_state_v2 ( uint32_t  pol,
enum cs_assert  cs_assert 
)
static

Definition at line 332 of file gspi.c.

Referenced by gspi_csctrl_state().

Here is the caller graph for this function:

◆ gspi_ctrlr_flush()

static int gspi_ctrlr_flush ( const struct gspi_ctrlr_params p)
static

Definition at line 617 of file gspi.c.

References BIOS_ERR, gspi_ctrlr_params::gspi_bus, gspi_read_byte(), gspi_rx_fifo_empty(), printk, stopwatch_expired(), and stopwatch_init_msecs_expire().

Here is the call graph for this function:

◆ gspi_ctrlr_params_init()

static int gspi_ctrlr_params_init ( struct gspi_ctrlr_params p,
unsigned int  spi_bus 
)
static

Definition at line 295 of file gspi.c.

References BIOS_ERR, gspi_ctrlr_params::gspi_bus, gspi_get_bus_base_addr(), gspi_spi_to_gspi_bus(), memset(), gspi_ctrlr_params::mmio_base, printk, and spi_bus.

Referenced by gspi_cs_change(), and gspi_ctrlr_setup().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gspi_ctrlr_setup()

◆ gspi_ctrlr_xfer()

static int gspi_ctrlr_xfer ( const struct spi_slave dev,
const void dout,
size_t  bytesout,
void din,
size_t  bytesin 
)
static

Definition at line 678 of file gspi.c.

◆ gspi_get_base_addr()

static uintptr_t gspi_get_base_addr ( int  devfn,
struct device dev 
)
static

Definition at line 167 of file gspi.c.

References ALIGN_DOWN, PCI_BASE_ADDRESS_0, and pci_read_config32().

Referenced by gspi_calc_base_addr().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gspi_get_bus_base_addr()

static uintptr_t gspi_get_bus_base_addr ( unsigned int  gspi_bus)
static

Definition at line 252 of file gspi.c.

References gspi_base, and gspi_calc_base_addr().

Referenced by gspi_ctrlr_params_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gspi_get_bus_clk_mhz()

static uint32_t gspi_get_bus_clk_mhz ( unsigned int  gspi_bus)
static

Definition at line 243 of file gspi.c.

References gspi_get_cfg(), and gspi_cfg::speed_mhz.

Referenced by gspi_get_clk_div().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gspi_get_cfg()

static const struct gspi_cfg* gspi_get_cfg ( void  )
static

Definition at line 108 of file gspi.c.

References chip_get_common_soc_structure(), and soc_intel_common_config::gspi.

Referenced by gspi_get_bus_clk_mhz().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gspi_get_clk_div()

static uint32_t gspi_get_clk_div ( unsigned int  gspi_bus)
static

Definition at line 431 of file gspi.c.

References assert, DIV_ROUND_UP, gspi_ctrlr_params::gspi_bus, gspi_get_bus_clk_mhz(), and SSCR0_SCR_MASK.

Referenced by gspi_ctrlr_setup().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gspi_get_early_base()

static uintptr_t gspi_get_early_base ( void  )
static

Definition at line 102 of file gspi.c.

References EARLY_GSPI_BASE_ADDRESS.

Referenced by gspi_calc_base_addr().

Here is the caller graph for this function:

◆ gspi_get_soc_spi_cfg()

int __weak gspi_get_soc_spi_cfg ( unsigned int  gspi_bus,
struct spi_cfg cfg 
)

◆ gspi_read_bus_range()

static int gspi_read_bus_range ( unsigned int *  start,
unsigned int *  end 
)
static

Definition at line 181 of file gspi.c.

References spi_ctrlr_buses::bus_end, spi_ctrlr_buses::bus_start, spi_ctrlr_buses::ctrlr, gspi_ctrlr, spi_ctrlr_bus_map, and spi_ctrlr_bus_map_count.

Referenced by gspi_spi_to_gspi_bus().

Here is the caller graph for this function:

◆ gspi_read_byte()

static uint8_t gspi_read_byte ( const struct gspi_ctrlr_params p)
static

Definition at line 580 of file gspi.c.

References gspi_read_mmio_reg(), and SSDR.

Referenced by gspi_ctrlr_flush(), gspi_read_data(), and gspi_read_dummy().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gspi_read_data()

static void gspi_read_data ( struct gspi_ctrlr_params p)
static

Definition at line 591 of file gspi.c.

References gspi_ctrlr_params::bytesin, gspi_read_byte(), and gspi_ctrlr_params::in.

Referenced by __gspi_xfer().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gspi_read_dummy()

static void gspi_read_dummy ( struct gspi_ctrlr_params p)
static

Definition at line 605 of file gspi.c.

References gspi_ctrlr_params::bytesin, and gspi_read_byte().

Referenced by __gspi_xfer().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gspi_read_mmio_reg()

static uint32_t gspi_read_mmio_reg ( const struct gspi_ctrlr_params p,
uint32_t  offset 
)
static

Definition at line 281 of file gspi.c.

References assert, gspi_ctrlr_params::mmio_base, offset, and read32().

Referenced by __gspi_cs_change(), gspi_read_byte(), and gspi_read_status().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gspi_read_status()

static uint32_t gspi_read_status ( const struct gspi_ctrlr_params p)
static

Definition at line 547 of file gspi.c.

References gspi_read_mmio_reg(), and SSSR.

Referenced by gspi_rx_fifo_empty(), gspi_rx_fifo_overrun(), and gspi_tx_fifo_full().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gspi_rx_fifo_empty()

static bool gspi_rx_fifo_empty ( const struct gspi_ctrlr_params p)
static

Definition at line 558 of file gspi.c.

References gspi_read_status(), and SSSR_RNE.

Referenced by __gspi_xfer(), and gspi_ctrlr_flush().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gspi_rx_fifo_overrun()

static bool gspi_rx_fifo_overrun ( const struct gspi_ctrlr_params p)
static

Definition at line 568 of file gspi.c.

References BIOS_ERR, gspi_ctrlr_params::gspi_bus, gspi_read_status(), printk, and SSSR_ROR.

Referenced by __gspi_xfer().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gspi_set_base_addr()

static void gspi_set_base_addr ( int  devfn,
struct device dev,
uintptr_t  base 
)
static

Definition at line 172 of file gspi.c.

References base, PCI_BASE_ADDRESS_0, PCI_COMMAND, PCI_COMMAND_MASTER, PCI_COMMAND_MEMORY, and pci_write_config32().

Referenced by gspi_calc_base_addr().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gspi_spi_to_gspi_bus()

static int gspi_spi_to_gspi_bus ( unsigned int  spi_bus,
unsigned int *  gspi_bus 
)
static

Definition at line 200 of file gspi.c.

References gspi_read_bus_range(), and spi_bus.

Referenced by gspi_ctrlr_params_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gspi_tx_fifo_full()

static bool gspi_tx_fifo_full ( const struct gspi_ctrlr_params p)
static

Definition at line 563 of file gspi.c.

References gspi_read_status(), and SSSR_TNF.

Referenced by __gspi_xfer().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gspi_write_byte()

static void gspi_write_byte ( const struct gspi_ctrlr_params p,
uint8_t  data 
)
static

Definition at line 586 of file gspi.c.

References gspi_write_mmio_reg(), and SSDR.

Referenced by gspi_write_data(), and gspi_write_dummy().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gspi_write_data()

static void gspi_write_data ( struct gspi_ctrlr_params p)
static

Definition at line 598 of file gspi.c.

References gspi_ctrlr_params::bytesout, gspi_write_byte(), and gspi_ctrlr_params::out.

Referenced by __gspi_xfer().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gspi_write_dummy()

static void gspi_write_dummy ( struct gspi_ctrlr_params p)
static

Definition at line 611 of file gspi.c.

References gspi_ctrlr_params::bytesout, and gspi_write_byte().

Referenced by __gspi_xfer().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gspi_write_mmio_reg()

static void gspi_write_mmio_reg ( const struct gspi_ctrlr_params p,
uint32_t  offset,
uint32_t  value 
)
static

Definition at line 288 of file gspi.c.

References assert, gspi_ctrlr_params::mmio_base, offset, value, and write32().

Referenced by __gspi_cs_change(), gspi_clear_status(), gspi_ctrlr_setup(), and gspi_write_byte().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ gspi_base

uintptr_t gspi_base[CONFIG_SOC_INTEL_COMMON_BLOCK_GSPI_MAX]
static

Definition at line 251 of file gspi.c.

Referenced by gspi_clear_cached_base(), and gspi_get_bus_base_addr().

◆ gspi_ctrlr

const struct spi_ctrlr gspi_ctrlr
Initial value:
= {
.claim_bus = gspi_cs_assert,
.release_bus = gspi_cs_deassert,
.setup = gspi_ctrlr_setup,
.xfer = gspi_ctrlr_xfer,
}
static int gspi_cs_assert(const struct spi_slave *dev)
Definition: gspi.c:421
static void gspi_cs_deassert(const struct spi_slave *dev)
Definition: gspi.c:426
static int gspi_ctrlr_xfer(const struct spi_slave *dev, const void *dout, size_t bytesout, void *din, size_t bytesin)
Definition: gspi.c:678
static int gspi_ctrlr_setup(const struct spi_slave *dev)
Definition: gspi.c:444
#define SPI_CTRLR_DEFAULT_MAX_XFER_SIZE
Definition: spi-generic.h:102

Definition at line 678 of file gspi.c.

Referenced by gspi_read_bus_range().