Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Functions
i2c-diolan-u2c.c File Reference
#include <linux/kernel.h>
#include <linux/errno.h>
#include <linux/module.h>
#include <linux/types.h>
#include <linux/slab.h>
#include <linux/usb.h>
#include <linux/i2c.h>

Go to the source code of this file.

Data Structures

struct  i2c_diolan_u2c
 

Macros

#define DRIVER_NAME   "i2c-diolan-u2c"
 
#define USB_VENDOR_ID_DIOLAN   0x0abf
 
#define USB_DEVICE_ID_DIOLAN_U2C   0x3370
 
#define DIOLAN_OUT_EP   0x02
 
#define DIOLAN_IN_EP   0x84
 
#define CMD_I2C_READ   0x01
 
#define CMD_I2C_WRITE   0x02
 
#define CMD_I2C_SCAN   0x03 /* Returns list of detected devices */
 
#define CMD_I2C_RELEASE_SDA   0x04
 
#define CMD_I2C_RELEASE_SCL   0x05
 
#define CMD_I2C_DROP_SDA   0x06
 
#define CMD_I2C_DROP_SCL   0x07
 
#define CMD_I2C_READ_SDA   0x08
 
#define CMD_I2C_READ_SCL   0x09
 
#define CMD_GET_FW_VERSION   0x0a
 
#define CMD_GET_SERIAL   0x0b
 
#define CMD_I2C_START   0x0c
 
#define CMD_I2C_STOP   0x0d
 
#define CMD_I2C_REPEATED_START   0x0e
 
#define CMD_I2C_PUT_BYTE   0x0f
 
#define CMD_I2C_GET_BYTE   0x10
 
#define CMD_I2C_PUT_ACK   0x11
 
#define CMD_I2C_GET_ACK   0x12
 
#define CMD_I2C_PUT_BYTE_ACK   0x13
 
#define CMD_I2C_GET_BYTE_ACK   0x14
 
#define CMD_I2C_SET_SPEED   0x1b
 
#define CMD_I2C_GET_SPEED   0x1c
 
#define CMD_I2C_SET_CLK_SYNC   0x24
 
#define CMD_I2C_GET_CLK_SYNC   0x25
 
#define CMD_I2C_SET_CLK_SYNC_TO   0x26
 
#define CMD_I2C_GET_CLK_SYNC_TO   0x27
 
#define RESP_OK   0x00
 
#define RESP_FAILED   0x01
 
#define RESP_BAD_MEMADDR   0x04
 
#define RESP_DATA_ERR   0x05
 
#define RESP_NOT_IMPLEMENTED   0x06
 
#define RESP_NACK   0x07
 
#define RESP_TIMEOUT   0x09
 
#define U2C_I2C_SPEED_FAST   0 /* 400 kHz */
 
#define U2C_I2C_SPEED_STD   1 /* 100 kHz */
 
#define U2C_I2C_SPEED_2KHZ   242 /* 2 kHz, minimum speed */
 
#define U2C_I2C_SPEED(f)   ((DIV_ROUND_UP(1000000, (f)) - 10) / 2 + 1)
 
#define U2C_I2C_FREQ_FAST   400000
 
#define U2C_I2C_FREQ_STD   100000
 
#define U2C_I2C_FREQ(s)   (1000000 / (2 * (s - 1) + 10))
 
#define DIOLAN_USB_TIMEOUT   100 /* in ms */
 
#define DIOLAN_SYNC_TIMEOUT   20 /* in ms */
 
#define DIOLAN_OUTBUF_LEN   128
 
#define DIOLAN_FLUSH_LEN   (DIOLAN_OUTBUF_LEN - 4)
 
#define DIOLAN_INBUF_LEN   256 /* Maximum supported receive length */
 

Functions

 module_param (frequency, uint, S_IRUGO|S_IWUSR)
 
 MODULE_PARM_DESC (frequency,"I2C clock frequency in hertz")
 
 MODULE_DEVICE_TABLE (usb, diolan_u2c_table)
 
 module_usb_driver (diolan_u2c_driver)
 
 MODULE_AUTHOR ("Guenter Roeck <[email protected]>")
 
 MODULE_DESCRIPTION (DRIVER_NAME" driver")
 
 MODULE_LICENSE ("GPL")
 

Macro Definition Documentation

#define CMD_GET_FW_VERSION   0x0a

Definition at line 41 of file i2c-diolan-u2c.c.

#define CMD_GET_SERIAL   0x0b

Definition at line 42 of file i2c-diolan-u2c.c.

#define CMD_I2C_DROP_SCL   0x07

Definition at line 38 of file i2c-diolan-u2c.c.

#define CMD_I2C_DROP_SDA   0x06

Definition at line 37 of file i2c-diolan-u2c.c.

#define CMD_I2C_GET_ACK   0x12

Definition at line 49 of file i2c-diolan-u2c.c.

#define CMD_I2C_GET_BYTE   0x10

Definition at line 47 of file i2c-diolan-u2c.c.

#define CMD_I2C_GET_BYTE_ACK   0x14

Definition at line 51 of file i2c-diolan-u2c.c.

#define CMD_I2C_GET_CLK_SYNC   0x25

Definition at line 55 of file i2c-diolan-u2c.c.

#define CMD_I2C_GET_CLK_SYNC_TO   0x27

Definition at line 57 of file i2c-diolan-u2c.c.

#define CMD_I2C_GET_SPEED   0x1c

Definition at line 53 of file i2c-diolan-u2c.c.

#define CMD_I2C_PUT_ACK   0x11

Definition at line 48 of file i2c-diolan-u2c.c.

#define CMD_I2C_PUT_BYTE   0x0f

Definition at line 46 of file i2c-diolan-u2c.c.

#define CMD_I2C_PUT_BYTE_ACK   0x13

Definition at line 50 of file i2c-diolan-u2c.c.

#define CMD_I2C_READ   0x01

Definition at line 32 of file i2c-diolan-u2c.c.

#define CMD_I2C_READ_SCL   0x09

Definition at line 40 of file i2c-diolan-u2c.c.

#define CMD_I2C_READ_SDA   0x08

Definition at line 39 of file i2c-diolan-u2c.c.

#define CMD_I2C_RELEASE_SCL   0x05

Definition at line 36 of file i2c-diolan-u2c.c.

#define CMD_I2C_RELEASE_SDA   0x04

Definition at line 35 of file i2c-diolan-u2c.c.

#define CMD_I2C_REPEATED_START   0x0e

Definition at line 45 of file i2c-diolan-u2c.c.

#define CMD_I2C_SCAN   0x03 /* Returns list of detected devices */

Definition at line 34 of file i2c-diolan-u2c.c.

#define CMD_I2C_SET_CLK_SYNC   0x24

Definition at line 54 of file i2c-diolan-u2c.c.

#define CMD_I2C_SET_CLK_SYNC_TO   0x26

Definition at line 56 of file i2c-diolan-u2c.c.

#define CMD_I2C_SET_SPEED   0x1b

Definition at line 52 of file i2c-diolan-u2c.c.

#define CMD_I2C_START   0x0c

Definition at line 43 of file i2c-diolan-u2c.c.

#define CMD_I2C_STOP   0x0d

Definition at line 44 of file i2c-diolan-u2c.c.

#define CMD_I2C_WRITE   0x02

Definition at line 33 of file i2c-diolan-u2c.c.

#define DIOLAN_FLUSH_LEN   (DIOLAN_OUTBUF_LEN - 4)

Definition at line 80 of file i2c-diolan-u2c.c.

#define DIOLAN_IN_EP   0x84

Definition at line 29 of file i2c-diolan-u2c.c.

#define DIOLAN_INBUF_LEN   256 /* Maximum supported receive length */

Definition at line 81 of file i2c-diolan-u2c.c.

#define DIOLAN_OUT_EP   0x02

Definition at line 28 of file i2c-diolan-u2c.c.

#define DIOLAN_OUTBUF_LEN   128

Definition at line 79 of file i2c-diolan-u2c.c.

#define DIOLAN_SYNC_TIMEOUT   20 /* in ms */

Definition at line 77 of file i2c-diolan-u2c.c.

#define DIOLAN_USB_TIMEOUT   100 /* in ms */

Definition at line 76 of file i2c-diolan-u2c.c.

#define DRIVER_NAME   "i2c-diolan-u2c"

Definition at line 23 of file i2c-diolan-u2c.c.

#define RESP_BAD_MEMADDR   0x04

Definition at line 61 of file i2c-diolan-u2c.c.

#define RESP_DATA_ERR   0x05

Definition at line 62 of file i2c-diolan-u2c.c.

#define RESP_FAILED   0x01

Definition at line 60 of file i2c-diolan-u2c.c.

#define RESP_NACK   0x07

Definition at line 64 of file i2c-diolan-u2c.c.

#define RESP_NOT_IMPLEMENTED   0x06

Definition at line 63 of file i2c-diolan-u2c.c.

#define RESP_OK   0x00

Definition at line 59 of file i2c-diolan-u2c.c.

#define RESP_TIMEOUT   0x09

Definition at line 65 of file i2c-diolan-u2c.c.

#define U2C_I2C_FREQ (   s)    (1000000 / (2 * (s - 1) + 10))

Definition at line 74 of file i2c-diolan-u2c.c.

#define U2C_I2C_FREQ_FAST   400000

Definition at line 72 of file i2c-diolan-u2c.c.

#define U2C_I2C_FREQ_STD   100000

Definition at line 73 of file i2c-diolan-u2c.c.

#define U2C_I2C_SPEED (   f)    ((DIV_ROUND_UP(1000000, (f)) - 10) / 2 + 1)

Definition at line 70 of file i2c-diolan-u2c.c.

#define U2C_I2C_SPEED_2KHZ   242 /* 2 kHz, minimum speed */

Definition at line 69 of file i2c-diolan-u2c.c.

#define U2C_I2C_SPEED_FAST   0 /* 400 kHz */

Definition at line 67 of file i2c-diolan-u2c.c.

#define U2C_I2C_SPEED_STD   1 /* 100 kHz */

Definition at line 68 of file i2c-diolan-u2c.c.

#define USB_DEVICE_ID_DIOLAN_U2C   0x3370

Definition at line 26 of file i2c-diolan-u2c.c.

#define USB_VENDOR_ID_DIOLAN   0x0abf

Definition at line 25 of file i2c-diolan-u2c.c.

Function Documentation

MODULE_AUTHOR ( "Guenter Roeck <[email protected]>"  )
MODULE_DESCRIPTION ( DRIVER_NAME" driver"  )
MODULE_DEVICE_TABLE ( usb  ,
diolan_u2c_table   
)
MODULE_LICENSE ( "GPL"  )
module_param ( frequency  ,
uint  ,
S_IRUGO S_IWUSR 
)
MODULE_PARM_DESC ( frequency  ,
"I2C clock frequency in hertz"   
)
module_usb_driver ( diolan_u2c_driver  )