drivers/net/wireless/microchip/wilc1000/spi.c
Source file repositories/reference/linux-study-clean/drivers/net/wireless/microchip/wilc1000/spi.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/wireless/microchip/wilc1000/spi.c- Extension
.c- Size
- 32814 bytes
- Lines
- 1375
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/clk.hlinux/spi/spi.hlinux/crc7.hlinux/crc-itu-t.hlinux/gpio/consumer.hnetdev.hcfg80211.h
Detected Declarations
struct wilc_spistruct wilc_gpiosstruct wilc_spi_cmdstruct wilc_spi_read_rsp_datastruct wilc_spi_rsp_datastruct wilc_spi_special_cmd_rspfunction wilc_parse_gpiosfunction wilc_wlan_powerfunction wilc_bus_probefunction wilc_bus_removefunction wilc_spi_txfunction wilc_spi_rxfunction wilc_spi_tx_rxfunction spi_data_writefunction wilc_get_crc7function wilc_spi_single_readfunction wilc_spi_write_cmdfunction wilc_spi_dma_rwfunction wilc_spi_special_cmdfunction wilc_spi_reset_cmd_sequencefunction wilc_spi_read_regfunction wilc_spi_readfunction spi_internal_writefunction spi_internal_readfunction wilc_spi_write_regfunction spi_data_rspfunction wilc_spi_writefunction wilc_spi_resetfunction wilc_spi_is_initfunction wilc_spi_deinitfunction wilc_spi_initfunction wilc_spi_configure_bus_protocolfunction wilc_validate_chipidfunction wilc_spi_read_sizefunction wilc_spi_read_intfunction wilc_spi_clear_int_extfunction wilc_spi_sync_ext
Annotated Snippet
struct wilc_spi {
bool isinit; /* true if wilc_spi_init was successful */
bool probing_crc; /* true if we're probing chip's CRC config */
bool crc7_enabled; /* true if crc7 is currently enabled */
bool crc16_enabled; /* true if crc16 is currently enabled */
struct wilc_gpios {
struct gpio_desc *enable; /* ENABLE GPIO or NULL */
struct gpio_desc *reset; /* RESET GPIO or NULL */
} gpios;
};
static const struct wilc_hif_func wilc_hif_spi;
static int wilc_spi_reset(struct wilc *wilc);
static int wilc_spi_configure_bus_protocol(struct wilc *wilc);
static int wilc_validate_chipid(struct wilc *wilc);
/********************************************
*
* Spi protocol Function
*
********************************************/
#define CMD_DMA_WRITE 0xc1
#define CMD_DMA_READ 0xc2
#define CMD_INTERNAL_WRITE 0xc3
#define CMD_INTERNAL_READ 0xc4
#define CMD_TERMINATE 0xc5
#define CMD_REPEAT 0xc6
#define CMD_DMA_EXT_WRITE 0xc7
#define CMD_DMA_EXT_READ 0xc8
#define CMD_SINGLE_WRITE 0xc9
#define CMD_SINGLE_READ 0xca
#define CMD_RESET 0xcf
#define SPI_RETRY_MAX_LIMIT 10
#define SPI_ENABLE_VMM_RETRY_LIMIT 2
/* SPI response fields (section 11.1.2 in ATWILC1000 User Guide): */
#define RSP_START_FIELD GENMASK(7, 4)
#define RSP_TYPE_FIELD GENMASK(3, 0)
/* SPI response values for the response fields: */
#define RSP_START_TAG 0xc
#define RSP_TYPE_FIRST_PACKET 0x1
#define RSP_TYPE_INNER_PACKET 0x2
#define RSP_TYPE_LAST_PACKET 0x3
#define RSP_STATE_NO_ERROR 0x00
#define PROTOCOL_REG_PKT_SZ_MASK GENMASK(6, 4)
#define PROTOCOL_REG_CRC16_MASK GENMASK(3, 3)
#define PROTOCOL_REG_CRC7_MASK GENMASK(2, 2)
/*
* The SPI data packet size may be any integer power of two in the
* range from 256 to 8192 bytes.
*/
#define DATA_PKT_LOG_SZ_MIN 8 /* 256 B */
#define DATA_PKT_LOG_SZ_MAX 13 /* 8 KiB */
/*
* Select the data packet size (log2 of number of bytes): Use the
* maximum data packet size. We only retransmit complete packets, so
* there is no benefit from using smaller data packets.
*/
#define DATA_PKT_LOG_SZ DATA_PKT_LOG_SZ_MAX
#define DATA_PKT_SZ (1 << DATA_PKT_LOG_SZ)
#define WILC_SPI_COMMAND_STAT_SUCCESS 0
#define WILC_GET_RESP_HDR_START(h) (((h) >> 4) & 0xf)
struct wilc_spi_cmd {
u8 cmd_type;
union {
struct {
u8 addr[3];
u8 crc[];
} __packed simple_cmd;
struct {
u8 addr[3];
u8 size[2];
u8 crc[];
} __packed dma_cmd;
struct {
u8 addr[3];
u8 size[3];
u8 crc[];
} __packed dma_cmd_ext;
struct {
u8 addr[2];
Annotation
- Immediate include surface: `linux/clk.h`, `linux/spi/spi.h`, `linux/crc7.h`, `linux/crc-itu-t.h`, `linux/gpio/consumer.h`, `netdev.h`, `cfg80211.h`.
- Detected declarations: `struct wilc_spi`, `struct wilc_gpios`, `struct wilc_spi_cmd`, `struct wilc_spi_read_rsp_data`, `struct wilc_spi_rsp_data`, `struct wilc_spi_special_cmd_rsp`, `function wilc_parse_gpios`, `function wilc_wlan_power`, `function wilc_bus_probe`, `function wilc_bus_remove`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.