1/*-
2 * Copyright (c) 1998 Nicolas Souchu
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
--- 9 unchanged lines hidden (view full) ---
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 * $Id: smb.c,v 1.3 1998/09/09 18:57:38 nsouch Exp $
27 *
28 */
29#include <sys/param.h>
30#include <sys/kernel.h>
31#include <sys/systm.h>
32#include <sys/module.h>
33#include <sys/bus.h>
34#include <sys/conf.h>
--- 117 unchanged lines hidden (view full) ---
152 sc->sc_count--;
153
154 return (0);
155}
156
157static int
158smbwrite(dev_t dev, struct uio * uio, int ioflag)
159{
160 device_t smbdev = IIC_DEVICE(minor(dev));
161 struct smb_softc *sc = IIC_SOFTC(minor(dev));
162 int count;
163
164 if (!sc || !smbdev)
165 return (EINVAL);
166
167 if (sc->sc_count == 0)
168 return (EINVAL);
169
170 count = min(uio->uio_resid, BUFSIZE);
171 uiomove(sc->sc_buffer, count, uio);
172
173 /* we consider the command char as the first character to send */
174 smbus_bwrite(device_get_parent(smbdev), sc->sc_addr,
175 sc->sc_buffer[0], count-1, sc->sc_buffer+1);
176
177 return (0);
178}
179
180static int
181smbread(dev_t dev, struct uio * uio, int ioflag)
182{
183 /* not supported */
184
185 return (EINVAL);
--- 4 unchanged lines hidden (view full) ---
190{
191 device_t smbdev = IIC_DEVICE(minor(dev));
192 struct smb_softc *sc = IIC_SOFTC(minor(dev));
193 device_t parent = device_get_parent(smbdev);
194
195 int error = 0;
196 struct smbcmd *s = (struct smbcmd *)data;
197
198 if (!sc)
199 return (EINVAL);
200
201 switch (cmd) {
202 case SMB_QUICK_WRITE:
203 smbus_quick(parent, sc->sc_addr, SMB_QWRITE);
204 goto end;
205
206 case SMB_QUICK_READ:
207 smbus_quick(parent, sc->sc_addr, SMB_QREAD);
208 goto end;
209 };
210
211 if (!s)
212 return (EINVAL);
213
214 switch (cmd) {
215 case SMB_SENDB:
216 smbus_sendb(parent, sc->sc_addr, s->cmd);
217 break;
218
219 case SMB_RECVB:
220 smbus_recvb(parent, sc->sc_addr, &s->cmd);
221 break;
222
223 case SMB_WRITEB:
224 smbus_writeb(parent, sc->sc_addr, s->cmd, s->data.byte);
225 break;
226
227 case SMB_WRITEW:
228 smbus_writew(parent, sc->sc_addr, s->cmd, s->data.word);
229 break;
230
231 case SMB_READB:
232 if (s->data.byte_ptr)
233 smbus_readb(parent, sc->sc_addr, s->cmd,
234 s->data.byte_ptr);
235 break;
236
237 case SMB_READW:
238 if (s->data.word_ptr)
239 smbus_readw(parent, sc->sc_addr, s->cmd, s->data.word_ptr);
240 break;
241
242 case SMB_PCALL:
243 if (s->data.process.rdata)
244 smbus_pcall(parent, sc->sc_addr, s->cmd,
245 s->data.process.sdata, s->data.process.rdata);
246 break;
247
248 case SMB_BWRITE:
249 if (s->count && s->data.byte_ptr)
250 smbus_bwrite(parent, sc->sc_addr, s->cmd, s->count,
251 s->data.byte_ptr);
252 break;
253
254 case SMB_BREAD:
255 if (s->count && s->data.byte_ptr)
256 smbus_bread(parent, sc->sc_addr, s->cmd, s->count,
257 s->data.byte_ptr);
258 break;
259
260 default:
261 error = ENODEV;
262 }
263
264end:
--- 21 unchanged lines hidden ---
2 * Copyright (c) 1998 Nicolas Souchu
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
--- 9 unchanged lines hidden (view full) ---
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 * $Id: smb.c,v 1.3 1998/09/09 18:57:38 nsouch Exp $
27 *
28 */
29#include <sys/param.h>
30#include <sys/kernel.h>
31#include <sys/systm.h>
32#include <sys/module.h>
33#include <sys/bus.h>
34#include <sys/conf.h>
--- 117 unchanged lines hidden (view full) ---
152 sc->sc_count--;
153
154 return (0);
155}
156
157static int
158smbwrite(dev_t dev, struct uio * uio, int ioflag)
159{
160 device_t smbdev = IIC_DEVICE(minor(dev));
161 struct smb_softc *sc = IIC_SOFTC(minor(dev));
162 int count;
163
164 if (!sc || !smbdev)
165 return (EINVAL);
166
167 if (sc->sc_count == 0)
168 return (EINVAL);
169
170 count = min(uio->uio_resid, BUFSIZE);
171 uiomove(sc->sc_buffer, count, uio);
172
173 /* we consider the command char as the first character to send */
174 smbus_bwrite(device_get_parent(smbdev), sc->sc_addr,
175 sc->sc_buffer[0], count-1, sc->sc_buffer+1);
176
177 return (0);
178}
179
180static int
181smbread(dev_t dev, struct uio * uio, int ioflag)
182{
183 /* not supported */
184
185 return (EINVAL);
--- 4 unchanged lines hidden (view full) ---
190{
191 device_t smbdev = IIC_DEVICE(minor(dev));
192 struct smb_softc *sc = IIC_SOFTC(minor(dev));
193 device_t parent = device_get_parent(smbdev);
194
195 int error = 0;
196 struct smbcmd *s = (struct smbcmd *)data;
197
198 if (!sc)
199 return (EINVAL);
200
201 switch (cmd) {
202 case SMB_QUICK_WRITE:
203 smbus_quick(parent, sc->sc_addr, SMB_QWRITE);
204 goto end;
205
206 case SMB_QUICK_READ:
207 smbus_quick(parent, sc->sc_addr, SMB_QREAD);
208 goto end;
209 };
210
211 if (!s)
212 return (EINVAL);
213
214 switch (cmd) {
215 case SMB_SENDB:
216 smbus_sendb(parent, sc->sc_addr, s->cmd);
217 break;
218
219 case SMB_RECVB:
220 smbus_recvb(parent, sc->sc_addr, &s->cmd);
221 break;
222
223 case SMB_WRITEB:
224 smbus_writeb(parent, sc->sc_addr, s->cmd, s->data.byte);
225 break;
226
227 case SMB_WRITEW:
228 smbus_writew(parent, sc->sc_addr, s->cmd, s->data.word);
229 break;
230
231 case SMB_READB:
232 if (s->data.byte_ptr)
233 smbus_readb(parent, sc->sc_addr, s->cmd,
234 s->data.byte_ptr);
235 break;
236
237 case SMB_READW:
238 if (s->data.word_ptr)
239 smbus_readw(parent, sc->sc_addr, s->cmd, s->data.word_ptr);
240 break;
241
242 case SMB_PCALL:
243 if (s->data.process.rdata)
244 smbus_pcall(parent, sc->sc_addr, s->cmd,
245 s->data.process.sdata, s->data.process.rdata);
246 break;
247
248 case SMB_BWRITE:
249 if (s->count && s->data.byte_ptr)
250 smbus_bwrite(parent, sc->sc_addr, s->cmd, s->count,
251 s->data.byte_ptr);
252 break;
253
254 case SMB_BREAD:
255 if (s->count && s->data.byte_ptr)
256 smbus_bread(parent, sc->sc_addr, s->cmd, s->count,
257 s->data.byte_ptr);
258 break;
259
260 default:
261 error = ENODEV;
262 }
263
264end:
--- 21 unchanged lines hidden ---