summaryrefslogtreecommitdiffstats
path: root/include/linux/mfd/viperboard.h
blob: 0557667fe544148f9820e2d3baa6ea2fbc9cdcaf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
 *  include/linux/mfd/viperboard.h
 *
 *  Nano River Technologies viperboard definitions
 *
 *  (C) 2012 by Lemonage GmbH
 *  Author: Lars Poeschel <poeschel@lemonage.de>
 *  All rights reserved.
 */

#ifndef __MFD_VIPERBOARD_H__
#define __MFD_VIPERBOARD_H__

#include <linux/types.h>
#include <linux/usb.h>

#define VPRBRD_EP_OUT               0x02
#define VPRBRD_EP_IN                0x86

#define VPRBRD_I2C_MSG_LEN          512 /* max length of a msg on USB level */

#define VPRBRD_I2C_FREQ_6MHZ        1                        /*   6 MBit/s */
#define VPRBRD_I2C_FREQ_3MHZ        2                        /*   3 MBit/s */
#define VPRBRD_I2C_FREQ_1MHZ        3                        /*   1 MBit/s */
#define VPRBRD_I2C_FREQ_FAST        4                        /* 400 kbit/s */
#define VPRBRD_I2C_FREQ_400KHZ      VPRBRD_I2C_FREQ_FAST
#define VPRBRD_I2C_FREQ_200KHZ      5                        /* 200 kbit/s */
#define VPRBRD_I2C_FREQ_STD         6                        /* 100 kbit/s */
#define VPRBRD_I2C_FREQ_100KHZ      VPRBRD_I2C_FREQ_STD
#define VPRBRD_I2C_FREQ_10KHZ       7                        /*  10 kbit/s */

#define VPRBRD_I2C_CMD_WRITE        0x00
#define VPRBRD_I2C_CMD_READ         0x01
#define VPRBRD_I2C_CMD_ADDR         0x02

#define VPRBRD_USB_TYPE_OUT	    0x40
#define VPRBRD_USB_TYPE_IN	    0xc0
#define VPRBRD_USB_TIMEOUT_MS       100
#define VPRBRD_USB_REQUEST_I2C_FREQ 0xe6
#define VPRBRD_USB_REQUEST_I2C      0xe9
#define VPRBRD_USB_REQUEST_MAJOR    0xea
#define VPRBRD_USB_REQUEST_MINOR    0xeb
#define VPRBRD_USB_REQUEST_ADC      0xec
#define VPRBRD_USB_REQUEST_GPIOA    0xed
#define VPRBRD_USB_REQUEST_GPIOB    0xdd

struct vprbrd_i2c_write_hdr {
	u8 cmd;
	u16 addr;
	u8 len1;
	u8 len2;
	u8 last;
	u8 chan;
	u16 spi;
} __packed;

struct vprbrd_i2c_read_hdr {
	u8 cmd;
	u16 addr;
	u8 len0;
	u8 len1;
	u8 len2;
	u8 len3;
	u8 len4;
	u8 len5;
	u16 tf1;                        /* transfer 1 length */
	u16 tf2;                        /* transfer 2 length */
} __packed;

struct vprbrd_i2c_status {
	u8 unknown[11];
	u8 status;
} __packed;

struct vprbrd_i2c_write_msg {
	struct vprbrd_i2c_write_hdr header;
	u8 data[VPRBRD_I2C_MSG_LEN
		- sizeof(struct vprbrd_i2c_write_hdr)];
} __packed;

struct vprbrd_i2c_read_msg {
	struct vprbrd_i2c_read_hdr header;
	u8 data[VPRBRD_I2C_MSG_LEN
		- sizeof(struct vprbrd_i2c_read_hdr)];
} __packed;

struct vprbrd_i2c_addr_msg {
	u8 cmd;
	u8 addr;
	u8 unknown1;
	u16 len;
	u8 unknown2;
	u8 unknown3;
} __packed;

/* Structure to hold all device specific stuff */
struct vprbrd {
	struct usb_device *usb_dev; /* the usb device for this device */
	struct mutex lock;
	u8 buf[sizeof(struct vprbrd_i2c_write_msg)];
	struct platform_device pdev;
};

#endif /* __MFD_VIPERBOARD_H__ */