blob: 026784fcde82dda8edf9d42533202a6c15454b3f [file] [log] [blame]
Forest Bond92b96792009-06-13 07:38:31 -04001/*
2 * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
3 * All rights reserved.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 *
20 * File: control.c
21 *
22 * Purpose: Handle USB control endpoint
23 *
24 * Author: Jerry Chen
25 *
26 * Date: Apr. 5, 2004
27 *
28 * Functions:
29 * CONTROLnsRequestOut - Write variable length bytes to MEM/BB/MAC/EEPROM
30 * CONTROLnsRequestIn - Read variable length bytes from MEM/BB/MAC/EEPROM
31 * ControlvWriteByte - Write one byte to MEM/BB/MAC/EEPROM
32 * ControlvReadByte - Read one byte from MEM/BB/MAC/EEPROM
Daniel Kenji Toyamaf9ea02a2010-03-29 22:40:54 +110033 * ControlvMaskByte - Read one byte from MEM/BB/MAC/EEPROM and clear/set
34 * some bits in the same address
Forest Bond92b96792009-06-13 07:38:31 -040035 *
36 * Revision History:
37 * 04-05-2004 Jerry Chen: Initial release
Daniel Kenji Toyamaf9ea02a2010-03-29 22:40:54 +110038 * 11-24-2004 Warren Hsu: Add ControlvWriteByte, ControlvReadByte,
39 * ControlvMaskByte
Forest Bond92b96792009-06-13 07:38:31 -040040 *
41 */
42
Forest Bond92b96792009-06-13 07:38:31 -040043#include "control.h"
Forest Bond92b96792009-06-13 07:38:31 -040044#include "rndis.h"
Forest Bond92b96792009-06-13 07:38:31 -040045
Daniel Kenji Toyamaf9ea02a2010-03-29 22:40:54 +110046/* static int msglevel =MSG_LEVEL_INFO; */
47/* static int msglevel =MSG_LEVEL_DEBUG; */
Forest Bond92b96792009-06-13 07:38:31 -040048
Malcolm Priestleyfe5d00e2012-12-10 22:14:36 +000049void ControlvWriteByte(struct vnt_private *pDevice, u8 reg, u8 reg_off,
50 u8 data)
Forest Bond92b96792009-06-13 07:38:31 -040051{
Malcolm Priestleyfe5d00e2012-12-10 22:14:36 +000052
53 CONTROLnsRequestOut(pDevice, MESSAGE_TYPE_WRITE, reg_off, reg,
54 sizeof(u8), &data);
55
56 return;
Forest Bond92b96792009-06-13 07:38:31 -040057}
58
Malcolm Priestleyfe5d00e2012-12-10 22:14:36 +000059void ControlvReadByte(struct vnt_private *pDevice, u8 reg, u8 reg_off,
60 u8 *data)
Forest Bond92b96792009-06-13 07:38:31 -040061{
Malcolm Priestleyfe5d00e2012-12-10 22:14:36 +000062 CONTROLnsRequestIn(pDevice, MESSAGE_TYPE_READ,
63 reg_off, reg, sizeof(u8), data);
64 return;
Forest Bond92b96792009-06-13 07:38:31 -040065}
66
Malcolm Priestleyfe5d00e2012-12-10 22:14:36 +000067void ControlvMaskByte(struct vnt_private *pDevice, u8 reg_type, u8 reg_off,
68 u8 reg_mask, u8 data)
Forest Bond92b96792009-06-13 07:38:31 -040069{
Malcolm Priestleyfe5d00e2012-12-10 22:14:36 +000070 u8 reg_data[2];
71
72 reg_data[0] = data;
73 reg_data[1] = reg_mask;
74
75 CONTROLnsRequestOut(pDevice, MESSAGE_TYPE_WRITE_MASK, reg_off,
76 reg_type, ARRAY_SIZE(reg_data), reg_data);
77
78 return;
Forest Bond92b96792009-06-13 07:38:31 -040079}