Skip to content

Commit

Permalink
Linux SDIO driver code - Initial version
Browse files Browse the repository at this point in the history
Signed-off-by: Sateesh Kotapati <[email protected]>
  • Loading branch information
sateeshkotapati committed Nov 27, 2024
0 parents commit 00a7da0
Show file tree
Hide file tree
Showing 27 changed files with 8,712 additions and 0 deletions.
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Procedure for SDIO SAPI Execution

## Steps

1. Navigate to the driver source directory:
```sh
cd linux-sdio-driver/platforms/linux/Driver/sdio/src
```

2. Compile the driver:
```sh
make clean
make
```

3. Insert the driver:
```sh
insmod rpssdio.ko
```

29 changes: 29 additions & 0 deletions platforms/linux/Driver/common/include/platform_specific.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/***************************************************************************//**
* @file
* @brief Platform specific
*******************************************************************************
* # License
* <b>Copyright 2024 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* The licensor of this software is Silicon Laboratories Inc. Your use of this
* software is governed by the terms of Silicon Labs Master Software License
* Agreement (MSLA) available at
* www.silabs.com/about-us/legal/master-software-license-agreement. This
* software is distributed to you in Source Code format and is governed by the
* sections of the MSLA applicable to Source Code.
*
******************************************************************************/

#ifndef PLATFORM_SPECIFIC_H
#define PLATFORM_SPECIFIC_H
#include "sli_global.h"

#include "sli_nic.h"

#define SLI_DPRINT(lvl, fmt, args...) if (lvl & SLI_DEBUG_LVL) printk(fmt, ##args)

#ifndef NULL
#define NULL 0
#endif
#endif
171 changes: 171 additions & 0 deletions platforms/linux/Driver/common/include/sli_api.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
/***************************************************************************//**
* @file sli_api.h
* @brief API specific Defines
*******************************************************************************
* # License
* <b>Copyright 2024 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* The licensor of this software is Silicon Laboratories Inc. Your use of this
* software is governed by the terms of Silicon Labs Master Software License
* Agreement (MSLA) available at
* www.silabs.com/about-us/legal/master-software-license-agreement. This
* software is distributed to you in Source Code format and is governed by the
* sections of the MSLA applicable to Source Code.
*
******************************************************************************/


#ifndef SLI_API_H
#define SLI_API_H

/**
* Include Files
*/
#include "sli_global.h"
#include "sli_app_util.h"
/**
* Global Defines
*/

//! Host interfaces
#define SLI_SPI 0
#define SLI_UART 1
#define SLI_USB 2
#define SLI_SDIO 3

#ifdef RS9116
//! Upgrade Image types
#define BURN_NWP_FW 'B'
#else
#define SLI_UPGRADE_IMAGE_I_FW '2'
#endif
#define SLI_UPGRADE_BL '#'


//! Firmware Upgradation form host params
#define FW_UP_PL 0
#define FW_UP_REQ 1
#ifdef RS9116
#define SLI_RPS_HEADER 64
#else
#define SLI_RPS_HEADER 32
#endif
#define SLI_FW_UP_SUCCESS 0x0003

//!Load Image types
#ifdef RS9116
#define LOAD_NWP_FW 'A'
#else
#define LOAD_NWP_FW '1'
#endif
#define LOAD_DEFAULT_NWP_FW_ACTIVE_LOW 0x71

//!Select Default image
#define SELECT_DEFAULT_NWP_FW '5'

// bypass bootup
#define ENABLE_GPIO_BASED_BYPASS '7'
#define DISABLE_GPIO_BASED_BYPASS '8'

//!load default
#define SLI_LOAD_DEFAULT '9'

//! Check CRC
#define CHECK_NWP_INTEGRITY 'K'


#define HOST_INTF_REG_OUT 0x4105003C
#define HOST_INTF_REG_IN 0x41050034
#define BOARD_READY 0xABCD
#define REG_READ 0xD1
#define REG_WRITE 0xD2
#define PONG_WRITE 0xD4
#define PING_WRITE 0xD5
#define GPIO_RESET 0xD7
#define LOAD_BOOTLOADER 0xD8
#ifdef RS9116
#define HOST_INTERACT_REG_VALID (0xA0 << 8)
#define HOST_INTERACT_REG_VALID_READ (0xAB << 8)
#else
#define HOST_INTERACT_REG_VALID (0xAB << 8)
#define HOST_INTERACT_REG_VALID_READ (0xAB << 8)
#endif
#define PONG_AVAIL 'O'
#define PING_AVAIL 'I'
#define PONG_VALID 'O'
#define PING_VALID 'I'
#define LOADING_INITIATED '1'
#define SEND_RPS_FILE '2'
#define FWUP_SUCCESSFUL 'S'
#define EOF_REACHED 'E'
#define BOOTUP_OPTIONS_LAST_CONFIG_NOT_SAVED 0xF1
#define BOOTUP_OPTIONS_CHECKSUM_FAIL 0xF2
#define INVALID_OPTION 0xF3
#define CHECKSUM_SUCCESS 0xAA
#define CHECKSUM_FAILURE 0xCC
#define CHECKSUM_INVALID_ADDRESS 0x4C

#define SLI_SUCCESS 0
#define SLI_BUSY -1
#define SLI_FAIL -2
#define SLI_BUFFER_FULL -3
#define SLI_IN_SLEEP -4


#define SLI_RESET_LOOP_COUNTER(X) X = 0;
#define SLI_WHILE_LOOP(X, Y) while((X++) < (uint32)Y)
#define SLI_LOOP_COUNT_UPGRADE_IMAGE 0xFFFF
#define SLI_LOOP_COUNT_WAKEUP_REQ 0xFFFFFFFF
#define SLI_LOOP_COUNT_WAKEUP_WAIT 0xFFFFFFFF
#define SLI_LOOP_COUNT_UPGRADE_REQ 0xFFFF
#define SLI_LOOP_COUNT_UPGRADE_CHUNK 0xFFFF
#define SLI_LOOP_COUNT_UPGRADE_STATUS 0xFFFF
#define SLI_LOOP_COUNT_SELECT_OPTION 0xFFFF
#define SLI_CHECK_LOOP_COUNTER(X, Y) { if(X >= Y)\
return -1;}

//!SPI Internal Register Offset
#define SLI_SPI_INT_REG_ADDR 0x00 //@ register access method
#define SPI_SPI_MODE_REG_ADDR 0x08 //@ register access method

//!Power Mode Constants
#define SLI_POWER_MODE_0 0x0000
#define SLI_POWER_MODE_1 0x0001
#define SLI_POWER_MODE_2 0x0002
#define SLI_POWER_MODE_3 0x0003
#define SLI_POWER_MODE_8 0x0008
#define SLI_POWER_MODE_9 0x0009

#define RSI_RSP_SOFT_RESET 0x1C

#define BIT(a) ((long int)1 << a)

/*=====================================================================================*/
/**
* This is platform dependent operation.Needs to be implemented
* specific to the platform.This timer is mentioned in the following functions
* Application/TCPDemo/Source/main.c
* WLAN/SPI/Source/spi_functs.c
* WLAN/SPI/Source/spi_iface_init.c
*
*/



extern volatile sli_powerstate sli_pwstate;
/*
* Function Prototype Definitions
*/


uint8* sli_fill_parameters(uint32 type, uint8 *buffer);
void config_gpio_output(uint8 value);
void config_gpio_input(void);
uint8 get_gpio_value();
uint8 get_spi_intr_gpio_value();
int16 sli_module_power_cycle(void);
int16 sli_execute_cmd(uint8 *descparam,uint8 *payloadparam,uint16 size_param);


#endif
139 changes: 139 additions & 0 deletions platforms/linux/Driver/common/include/sli_app.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
/***************************************************************************//**
* @file
* @brief HEADER, APP, APPLICATION Header file
*******************************************************************************
* # License
* <b>Copyright 2024 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* The licensor of this software is Silicon Laboratories Inc. Your use of this
* software is governed by the terms of Silicon Labs Master Software License
* Agreement (MSLA) available at
* www.silabs.com/about-us/legal/master-software-license-agreement. This
* software is distributed to you in Source Code format and is governed by the
* sections of the MSLA applicable to Source Code.
*
******************************************************************************/
#include "sli_config.h"
#include "sensor_data.h"
#ifndef SLI_APP_H
#define SLI_APP_H
#define SLI_MAXSOCKETS 10 //@ Maximum number of open sockets

/* Application control block */


/*===================================================*/
/**
* Sockets Structure
* Structure linking socket number to protocol
*/
typedef struct {
uint8 ip_version[2]; //@ ip version
uint8 socketDescriptor[2]; //@ socket descriptor
uint8 protocol; //@ PROTOCOL_UDP, PROTOCOL_TCP or PROTOCOL_UNDEFINED
uint8 src_port[2]; //@ socket local port number
union{
uint8 ipv4_address[4]; //@ Destination ipv4 address
uint8 ipv6_address[16]; //@ Destination ipv6 address
}dest_ip;
uint8 dest_port[2]; //@ Destination port number
} sli_socketsStr;

/*===================================================*/
/**
* Sockets Structure Array
* Array of Structures linking socket number to protocol
*/
typedef struct {
rsi_socketsStr socketsArray[RSI_MAXSOCKETS+1];
//@ Socket numbers are from 1 to 10
} sli_sockets;


//! Host MIB structure and Object OID list
typedef struct MIB_ENTRY_STRUCT
{

char *obj_id;
} MIB_ENTRY;


typedef struct
{
/* Error code */
uint16 error_code;
/* Buffer to receive to response from Wi-Fi module */
sli_uCmdRsp *uCmdRspFrame;

/* For Certificate */
struct SET_CHUNK_S set_chunks;
/* received paket count */
uint32 rcvd_data_pkt_count;
/* Mac address */
uint8 mac_addr[6];
#if SLI_CONCURRENT_MODE
/* Mac address */
uint8 ap_mac_addr[6];
#endif
/* packet pending flag */
volatile uint32 pkt_pending;

#if (SLI_POWER_MODE == SLI_POWER_MODE_3)
//! backup of frame type
uint8 ps_descparam[16];
//! Paket pending for power save
void * ps_pkt_pending;
//! size of currently held packet
uint16 ps_size_param;
//! devide sleep indication
uint16 ps_ok_to_send;
#endif
#if (SLI_POWER_MODE)
uint16 power_save_enable;
#endif
#if (defined(SLI_UART_INTERFACE) && !defined(TCP_IP_BYPASS))
volatile int ack_flag;
#endif
/* PER Continous wave mode state*/
int8 per_cont_mode_state;

sli_uConnected_station_t stations_connected[SLI_NO_OF_CLIENTS_SUPPORTED];

/* Buffer to hold the received packet */
uint8 read_packet_buffer[SLI_MAX_PAYLOAD_SIZE];

/* For Webpage write */
uint8 webpage_morechunks;

/* flag to enable send data*/
uint8 glbl_send_data;

/*structure to store socket information */
volatile sli_sockets socketsStrArray;

/* Send buffer data */
uint8 send_buffer[SLI_MAX_PAYLOAD_SIZE];

uint8 write_packet_buffer[SLI_MAX_PAYLOAD_SIZE];

#if JSON_LOAD
/* Json buffer */
uint8 json_buffer[JSON_BUFFER_SIZE];
uint8 json_load_done;
/* User Data Structures */
app_data_t sensor_data;
#endif
#if WEB_PAGE_LOAD
uint8 webpage_load_done;
#endif
//! frame sent for the send command, includes data
sli_uSend uSendFrame;
uint8 abort_call;
}sli_app_cb_t;

#define SLI_FILL_PARAMETERS(x,y) sli_fill_parameters(x,y)

extern sli_app_cb_t sli_app_cb;

#endif
30 changes: 30 additions & 0 deletions platforms/linux/Driver/common/include/sli_app_util.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/***************************************************************************//**
* @file
* @brief Util Header file, the things that are useful for application
*******************************************************************************
* # License
* <b>Copyright 2024 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* The licensor of this software is Silicon Laboratories Inc. Your use of this
* software is governed by the terms of Silicon Labs Master Software License
* Agreement (MSLA) available at
* www.silabs.com/about-us/legal/master-software-license-agreement. This
* software is distributed to you in Source Code format and is governed by the
* sections of the MSLA applicable to Source Code.
*
******************************************************************************/

#ifndef SLI_APP_UTIL_H
#define SLI_APP_UTIL_H
#include "sli_global.h"


uint32 sli_bytes4R_to_uint32(uint8 *dBuf);
uint16 sli_bytes2R_to_uint16(uint8 *dBuf);


void sli_uint32_to_4bytes(uint8 *dBuf, uint32 val);
void sli_uint16_to_2bytes(uint8 *dBuf, uint16 val);

#endif
Loading

0 comments on commit 00a7da0

Please sign in to comment.