blob: 77e67d0cba167cd0471192ad3863d72cc5dc3c8b [file] [log] [blame]
developere0cea0f2021-12-16 16:08:26 +08001// SPDX-License-Identifier: GPL-2.0
2/*
3 * spi.h
4 * SPI driver implementation file
5 *
6 * Author(s):
7 * laj
8 *
9 * Distributed by:
10 * Silicon Laboratories, Inc
11 *
12 * File Description:
13 * This is the implementation file for the SPI driver used
14 * in the ProSLIC demonstration code. It calls the library
15 * that initializes and talks to the proslic motherboard.
16 *
17 * Dependancies:
18 *
19 */
20//#include "../iowrapper.h" // This is the motherboard interface library
21#include <linux/kernel.h>
22#include <linux/delay.h>
23#include "config_inc/si_voice_datatypes.h"
24#include "inc/si_voice_ctrl.h"
25#include "spi.h"
26#include "proslic_sys.h"
27
28/*
29** Function: SPI_Init
30**
31** Description:
32** Initializes the SPI interface
33**
34** Input Parameters:
35** none
36**
37** Return:
38** none
39*/
40int SPI_Init (ctrl_S *hSpi){
41 int ret;
42
43 ret = proslic_spi_setup();
44
45 return 0;
46}
47
48/*
49** Function: spiGci_ResetWrapper
50**
51** Description:
52** Sets the reset pin of the ProSLIC
53*/
54int ctrl_ResetWrapper (void *hSpiGci, int status){
55
56 printk("ctrl_ResetWrapper");
57 proslic_reset(NULL, status);
58
59 return 0;
60}
61
62/*
63** SPI/GCI register read
64**
65** Description:
66** Reads a single ProSLIC register
67**
68** Input Parameters:
69** channel: ProSLIC channel to read from
70** regAddr: Address of register to read
71** return data: data to read from register
72**
73** Return:
74** none
75*/
76uInt8 ctrl_ReadRegisterWrapper (void *hSpiGci, uInt8 channel, uInt8 regAddr){
77
78
79 return proslic_read_register(hSpiGci,channel,regAddr);
80}
81
82
83/*
84** Function: spiGci_WriteRegisterWrapper
85**
86** Description:
87** Writes a single ProSLIC register
88**
89** Input Parameters:
90** channel: ProSLIC channel to write to
91** address: Address of register to write
92** data: data to write to register
93**
94** Return:
95** none
96*/
97int ctrl_WriteRegisterWrapper (void *hSpiGci, unsigned char channel, unsigned char regAddr, unsigned char data){
98
99 proslic_write_register(hSpiGci,channel,regAddr, data);
100 return 0;
101}
102
103
104/*
105** Function: SPI_ReadRAMWrapper
106**
107** Description:
108** Reads a single ProSLIC RAM location
109**
110** Input Parameters:
111** channel: ProSLIC channel to read from
112** address: Address of RAM location to read
113** pData: data to read from RAM location
114**
115** Return:
116** none
117*/
118ramData ctrl_ReadRAMWrapper (void *hSpiGci, unsigned char channel, unsigned short ramAddr){
119 ramData data;
120
121 data = proslic_read_ram(hSpiGci,channel,ramAddr);
122
123 return data;
124}
125
126
127/*
128** Function: SPI_WriteRAMWrapper
129**
130** Description:
131** Writes a single ProSLIC RAM location
132**
133** Input Parameters:
134** channel: ProSLIC channel to write to
135** address: Address of RAM location to write
136** data: data to write to RAM location
137**
138** Return:
139** none
140*/
141int ctrl_WriteRAMWrapper (void *hSpiGci, unsigned char channel, unsigned short ramAddr, ramData data){
142
143 proslic_write_ram(hSpiGci,channel,ramAddr,data);
144
145 return 0;
146}
147
148
149
150/*
151** $Log: proslic_spi_api.c,v $
152** Revision 1.11 2008/07/24 21:06:16 lajordan
153** no message
154**
155** Revision 1.10 2008/03/19 18:20:09 lajordan
156** no message
157**
158** Revision 1.9 2007/06/04 16:35:51 lajordan
159** added profiling
160**
161** Revision 1.8 2007/02/27 19:25:48 lajordan
162** updated api
163**
164** Revision 1.7 2007/02/05 23:43:27 lajordan
165** fixed register access func
166**
167** Revision 1.6 2006/11/22 21:38:19 lajordan
168** broadcast added
169**
170** Revision 1.5 2006/07/21 20:31:26 lajordan
171** fixed cant connect message
172**
173** Revision 1.4 2006/07/19 18:15:56 lajordan
174** fixed spi init
175**
176** Revision 1.3 2006/07/18 21:50:16 lajordan
177** removed extraneous endif
178**
179** Revision 1.2 2006/07/18 21:48:51 lajordan
180** added 16 bit accesses example code
181**
182** Revision 1.1.1.1 2006/07/13 20:26:08 lajordan
183** no message
184**
185** Revision 1.1.1.1 2006/07/06 22:06:23 lajordan
186** no message
187**
188** Revision 1.3 2006/06/29 19:11:18 laj
189** lpt driver completed
190**
191** Revision 1.2 2006/06/21 23:46:58 laj
192** register reads/writes added
193**
194** Revision 1.1 2006/06/21 23:18:07 laj
195** no message
196**
197** Revision 1.1 2006/06/21 22:42:26 laj
198** new api style
199**
200** Revision 1.3 2005/11/14 17:42:34 laj
201** added SPI_init
202**
203** Revision 1.2 2005/11/07 23:20:54 laj
204** took out extra spaces
205**
206*/