Merge remote-tracking branch 'origin/hheinold/usb2514'
This commit is contained in:
commit
37a977e6f4
|
@ -317,3 +317,4 @@ CONFIG_CRC_T10DIF=y
|
||||||
CONFIG_CRC_ITU_T=y
|
CONFIG_CRC_ITU_T=y
|
||||||
CONFIG_CRC7=y
|
CONFIG_CRC7=y
|
||||||
CONFIG_LIBCRC32C=y
|
CONFIG_LIBCRC32C=y
|
||||||
|
CONFIG_USB_ACM=y
|
||||||
|
|
|
@ -17,7 +17,7 @@ SRCREV = "bcc4fa827be7f59486ff305d664b42a142025f9b"
|
||||||
SRCREV_sysmocom-odu = "f11945e1d688bef5d2a81cc0255b19ed416cab42"
|
SRCREV_sysmocom-odu = "f11945e1d688bef5d2a81cc0255b19ed416cab42"
|
||||||
LINUX_VERSION_sysmocom-odu = "3.2.0"
|
LINUX_VERSION_sysmocom-odu = "3.2.0"
|
||||||
|
|
||||||
PR = "r32"
|
PR = "r33"
|
||||||
PV = "${LINUX_VERSION}+git${SRCPV}"
|
PV = "${LINUX_VERSION}+git${SRCPV}"
|
||||||
|
|
||||||
SRC_URI = "git://git.sysmocom.de/sysmo-bts/linux.git;protocol=git;branch=v3.2 \
|
SRC_URI = "git://git.sysmocom.de/sysmo-bts/linux.git;protocol=git;branch=v3.2 \
|
||||||
|
|
|
@ -0,0 +1,51 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
cd /sys/class/gpio
|
||||||
|
|
||||||
|
# !mdm1_pwr_ind
|
||||||
|
echo 22 > export
|
||||||
|
echo in > ./gpio22/direction
|
||||||
|
|
||||||
|
# mdm1_rst=0
|
||||||
|
echo 26 > export
|
||||||
|
echo out > ./gpio26/direction
|
||||||
|
echo 0 > ./gpio26/value
|
||||||
|
|
||||||
|
# !mdm1_shdn=1
|
||||||
|
echo 59 > export
|
||||||
|
echo out > ./gpio59/direction
|
||||||
|
echo 1 > ./gpio59/value
|
||||||
|
|
||||||
|
# mdm_ldo_en=1
|
||||||
|
echo 58 > export
|
||||||
|
echo out > ./gpio58/direction
|
||||||
|
echo 1 > ./gpio58/value
|
||||||
|
|
||||||
|
# !mdm2_pwr_ind
|
||||||
|
echo 57 > export
|
||||||
|
echo in > ./gpio57/direction
|
||||||
|
|
||||||
|
# mdm2_rst=0
|
||||||
|
echo 55 > export
|
||||||
|
echo out > ./gpio55/direction
|
||||||
|
echo 0 > ./gpio55/value
|
||||||
|
|
||||||
|
# mdm2_on=1
|
||||||
|
echo 50 > export
|
||||||
|
echo out > ./gpio50/direction
|
||||||
|
echo 1 > ./gpio50/value
|
||||||
|
|
||||||
|
# !gnss_rst=1
|
||||||
|
echo 114 > export
|
||||||
|
echo out > ./gpio114/direction
|
||||||
|
echo 1 > ./gpio114/value
|
||||||
|
|
||||||
|
# !adsb_rst=1
|
||||||
|
echo 53 > export
|
||||||
|
echo out > ./gpio53/direction
|
||||||
|
echo 1 > ./gpio53/value
|
||||||
|
|
||||||
|
# adsb_frame
|
||||||
|
echo 54 > export
|
||||||
|
echo in > ./gpio54/direction
|
||||||
|
|
|
@ -0,0 +1,335 @@
|
||||||
|
/*
|
||||||
|
i2c-dev.h - i2c-bus driver, char device interface
|
||||||
|
|
||||||
|
Copyright (C) 1995-97 Simon G. Vogl
|
||||||
|
Copyright (C) 1998-99 Frodo Looijaard <frodol@dds.nl>
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
|
MA 02110-1301 USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* $Id: i2c-dev.h 5894 2010-12-12 13:22:29Z khali $ */
|
||||||
|
|
||||||
|
#ifndef LIB_I2CDEV_H
|
||||||
|
#define LIB_I2CDEV_H
|
||||||
|
|
||||||
|
#include <linux/types.h>
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
|
||||||
|
|
||||||
|
/* -- i2c.h -- */
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* I2C Message - used for pure i2c transaction, also from /dev interface
|
||||||
|
*/
|
||||||
|
struct i2c_msg {
|
||||||
|
__u16 addr; /* slave address */
|
||||||
|
unsigned short flags;
|
||||||
|
#define I2C_M_TEN 0x10 /* we have a ten bit chip address */
|
||||||
|
#define I2C_M_RD 0x01
|
||||||
|
#define I2C_M_NOSTART 0x4000
|
||||||
|
#define I2C_M_REV_DIR_ADDR 0x2000
|
||||||
|
#define I2C_M_IGNORE_NAK 0x1000
|
||||||
|
#define I2C_M_NO_RD_ACK 0x0800
|
||||||
|
short len; /* msg length */
|
||||||
|
char *buf; /* pointer to msg data */
|
||||||
|
};
|
||||||
|
|
||||||
|
/* To determine what functionality is present */
|
||||||
|
|
||||||
|
#define I2C_FUNC_I2C 0x00000001
|
||||||
|
#define I2C_FUNC_10BIT_ADDR 0x00000002
|
||||||
|
#define I2C_FUNC_PROTOCOL_MANGLING 0x00000004 /* I2C_M_{REV_DIR_ADDR,NOSTART,..} */
|
||||||
|
#define I2C_FUNC_SMBUS_PEC 0x00000008
|
||||||
|
#define I2C_FUNC_SMBUS_BLOCK_PROC_CALL 0x00008000 /* SMBus 2.0 */
|
||||||
|
#define I2C_FUNC_SMBUS_QUICK 0x00010000
|
||||||
|
#define I2C_FUNC_SMBUS_READ_BYTE 0x00020000
|
||||||
|
#define I2C_FUNC_SMBUS_WRITE_BYTE 0x00040000
|
||||||
|
#define I2C_FUNC_SMBUS_READ_BYTE_DATA 0x00080000
|
||||||
|
#define I2C_FUNC_SMBUS_WRITE_BYTE_DATA 0x00100000
|
||||||
|
#define I2C_FUNC_SMBUS_READ_WORD_DATA 0x00200000
|
||||||
|
#define I2C_FUNC_SMBUS_WRITE_WORD_DATA 0x00400000
|
||||||
|
#define I2C_FUNC_SMBUS_PROC_CALL 0x00800000
|
||||||
|
#define I2C_FUNC_SMBUS_READ_BLOCK_DATA 0x01000000
|
||||||
|
#define I2C_FUNC_SMBUS_WRITE_BLOCK_DATA 0x02000000
|
||||||
|
#define I2C_FUNC_SMBUS_READ_I2C_BLOCK 0x04000000 /* I2C-like block xfer */
|
||||||
|
#define I2C_FUNC_SMBUS_WRITE_I2C_BLOCK 0x08000000 /* w/ 1-byte reg. addr. */
|
||||||
|
|
||||||
|
#define I2C_FUNC_SMBUS_BYTE (I2C_FUNC_SMBUS_READ_BYTE | \
|
||||||
|
I2C_FUNC_SMBUS_WRITE_BYTE)
|
||||||
|
#define I2C_FUNC_SMBUS_BYTE_DATA (I2C_FUNC_SMBUS_READ_BYTE_DATA | \
|
||||||
|
I2C_FUNC_SMBUS_WRITE_BYTE_DATA)
|
||||||
|
#define I2C_FUNC_SMBUS_WORD_DATA (I2C_FUNC_SMBUS_READ_WORD_DATA | \
|
||||||
|
I2C_FUNC_SMBUS_WRITE_WORD_DATA)
|
||||||
|
#define I2C_FUNC_SMBUS_BLOCK_DATA (I2C_FUNC_SMBUS_READ_BLOCK_DATA | \
|
||||||
|
I2C_FUNC_SMBUS_WRITE_BLOCK_DATA)
|
||||||
|
#define I2C_FUNC_SMBUS_I2C_BLOCK (I2C_FUNC_SMBUS_READ_I2C_BLOCK | \
|
||||||
|
I2C_FUNC_SMBUS_WRITE_I2C_BLOCK)
|
||||||
|
|
||||||
|
/* Old name, for compatibility */
|
||||||
|
#define I2C_FUNC_SMBUS_HWPEC_CALC I2C_FUNC_SMBUS_PEC
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Data for SMBus Messages
|
||||||
|
*/
|
||||||
|
#define I2C_SMBUS_BLOCK_MAX 32 /* As specified in SMBus standard */
|
||||||
|
#define I2C_SMBUS_I2C_BLOCK_MAX 32 /* Not specified but we use same structure */
|
||||||
|
union i2c_smbus_data {
|
||||||
|
__u8 byte;
|
||||||
|
__u16 word;
|
||||||
|
__u8 block[I2C_SMBUS_BLOCK_MAX + 2]; /* block[0] is used for length */
|
||||||
|
/* and one more for PEC */
|
||||||
|
};
|
||||||
|
|
||||||
|
/* smbus_access read or write markers */
|
||||||
|
#define I2C_SMBUS_READ 1
|
||||||
|
#define I2C_SMBUS_WRITE 0
|
||||||
|
|
||||||
|
/* SMBus transaction types (size parameter in the above functions)
|
||||||
|
Note: these no longer correspond to the (arbitrary) PIIX4 internal codes! */
|
||||||
|
#define I2C_SMBUS_QUICK 0
|
||||||
|
#define I2C_SMBUS_BYTE 1
|
||||||
|
#define I2C_SMBUS_BYTE_DATA 2
|
||||||
|
#define I2C_SMBUS_WORD_DATA 3
|
||||||
|
#define I2C_SMBUS_PROC_CALL 4
|
||||||
|
#define I2C_SMBUS_BLOCK_DATA 5
|
||||||
|
#define I2C_SMBUS_I2C_BLOCK_BROKEN 6
|
||||||
|
#define I2C_SMBUS_BLOCK_PROC_CALL 7 /* SMBus 2.0 */
|
||||||
|
#define I2C_SMBUS_I2C_BLOCK_DATA 8
|
||||||
|
|
||||||
|
|
||||||
|
/* ----- commands for the ioctl like i2c_command call:
|
||||||
|
* note that additional calls are defined in the algorithm and hw
|
||||||
|
* dependent layers - these can be listed here, or see the
|
||||||
|
* corresponding header files.
|
||||||
|
*/
|
||||||
|
/* -> bit-adapter specific ioctls */
|
||||||
|
#define I2C_RETRIES 0x0701 /* number of times a device address */
|
||||||
|
/* should be polled when not */
|
||||||
|
/* acknowledging */
|
||||||
|
#define I2C_TIMEOUT 0x0702 /* set timeout - call with int */
|
||||||
|
|
||||||
|
|
||||||
|
/* this is for i2c-dev.c */
|
||||||
|
#define I2C_SLAVE 0x0703 /* Change slave address */
|
||||||
|
/* Attn.: Slave address is 7 or 10 bits */
|
||||||
|
#define I2C_SLAVE_FORCE 0x0706 /* Change slave address */
|
||||||
|
/* Attn.: Slave address is 7 or 10 bits */
|
||||||
|
/* This changes the address, even if it */
|
||||||
|
/* is already taken! */
|
||||||
|
#define I2C_TENBIT 0x0704 /* 0 for 7 bit addrs, != 0 for 10 bit */
|
||||||
|
|
||||||
|
#define I2C_FUNCS 0x0705 /* Get the adapter functionality */
|
||||||
|
#define I2C_RDWR 0x0707 /* Combined R/W transfer (one stop only)*/
|
||||||
|
#define I2C_PEC 0x0708 /* != 0 for SMBus PEC */
|
||||||
|
|
||||||
|
#define I2C_SMBUS 0x0720 /* SMBus-level access */
|
||||||
|
|
||||||
|
/* -- i2c.h -- */
|
||||||
|
|
||||||
|
|
||||||
|
/* Note: 10-bit addresses are NOT supported! */
|
||||||
|
|
||||||
|
/* This is the structure as used in the I2C_SMBUS ioctl call */
|
||||||
|
struct i2c_smbus_ioctl_data {
|
||||||
|
char read_write;
|
||||||
|
__u8 command;
|
||||||
|
int size;
|
||||||
|
union i2c_smbus_data *data;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* This is the structure as used in the I2C_RDWR ioctl call */
|
||||||
|
struct i2c_rdwr_ioctl_data {
|
||||||
|
struct i2c_msg *msgs; /* pointers to i2c_msgs */
|
||||||
|
int nmsgs; /* number of i2c_msgs */
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
static inline __s32 i2c_smbus_access(int file, char read_write, __u8 command,
|
||||||
|
int size, union i2c_smbus_data *data)
|
||||||
|
{
|
||||||
|
struct i2c_smbus_ioctl_data args;
|
||||||
|
|
||||||
|
args.read_write = read_write;
|
||||||
|
args.command = command;
|
||||||
|
args.size = size;
|
||||||
|
args.data = data;
|
||||||
|
return ioctl(file,I2C_SMBUS,&args);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static inline __s32 i2c_smbus_write_quick(int file, __u8 value)
|
||||||
|
{
|
||||||
|
return i2c_smbus_access(file,value,0,I2C_SMBUS_QUICK,NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline __s32 i2c_smbus_read_byte(int file)
|
||||||
|
{
|
||||||
|
union i2c_smbus_data data;
|
||||||
|
if (i2c_smbus_access(file,I2C_SMBUS_READ,0,I2C_SMBUS_BYTE,&data))
|
||||||
|
return -1;
|
||||||
|
else
|
||||||
|
return 0x0FF & data.byte;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline __s32 i2c_smbus_write_byte(int file, __u8 value)
|
||||||
|
{
|
||||||
|
return i2c_smbus_access(file,I2C_SMBUS_WRITE,value,
|
||||||
|
I2C_SMBUS_BYTE,NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline __s32 i2c_smbus_read_byte_data(int file, __u8 command)
|
||||||
|
{
|
||||||
|
union i2c_smbus_data data;
|
||||||
|
if (i2c_smbus_access(file,I2C_SMBUS_READ,command,
|
||||||
|
I2C_SMBUS_BYTE_DATA,&data))
|
||||||
|
return -1;
|
||||||
|
else
|
||||||
|
return 0x0FF & data.byte;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline __s32 i2c_smbus_write_byte_data(int file, __u8 command,
|
||||||
|
__u8 value)
|
||||||
|
{
|
||||||
|
union i2c_smbus_data data;
|
||||||
|
data.byte = value;
|
||||||
|
return i2c_smbus_access(file,I2C_SMBUS_WRITE,command,
|
||||||
|
I2C_SMBUS_BYTE_DATA, &data);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline __s32 i2c_smbus_read_word_data(int file, __u8 command)
|
||||||
|
{
|
||||||
|
union i2c_smbus_data data;
|
||||||
|
if (i2c_smbus_access(file,I2C_SMBUS_READ,command,
|
||||||
|
I2C_SMBUS_WORD_DATA,&data))
|
||||||
|
return -1;
|
||||||
|
else
|
||||||
|
return 0x0FFFF & data.word;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline __s32 i2c_smbus_write_word_data(int file, __u8 command,
|
||||||
|
__u16 value)
|
||||||
|
{
|
||||||
|
union i2c_smbus_data data;
|
||||||
|
data.word = value;
|
||||||
|
return i2c_smbus_access(file,I2C_SMBUS_WRITE,command,
|
||||||
|
I2C_SMBUS_WORD_DATA, &data);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline __s32 i2c_smbus_process_call(int file, __u8 command, __u16 value)
|
||||||
|
{
|
||||||
|
union i2c_smbus_data data;
|
||||||
|
data.word = value;
|
||||||
|
if (i2c_smbus_access(file,I2C_SMBUS_WRITE,command,
|
||||||
|
I2C_SMBUS_PROC_CALL,&data))
|
||||||
|
return -1;
|
||||||
|
else
|
||||||
|
return 0x0FFFF & data.word;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Returns the number of read bytes */
|
||||||
|
static inline __s32 i2c_smbus_read_block_data(int file, __u8 command,
|
||||||
|
__u8 *values)
|
||||||
|
{
|
||||||
|
union i2c_smbus_data data;
|
||||||
|
int i;
|
||||||
|
if (i2c_smbus_access(file,I2C_SMBUS_READ,command,
|
||||||
|
I2C_SMBUS_BLOCK_DATA,&data))
|
||||||
|
return -1;
|
||||||
|
else {
|
||||||
|
for (i = 1; i <= data.block[0]; i++)
|
||||||
|
values[i-1] = data.block[i];
|
||||||
|
return data.block[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline __s32 i2c_smbus_write_block_data(int file, __u8 command,
|
||||||
|
__u8 length, const __u8 *values)
|
||||||
|
{
|
||||||
|
union i2c_smbus_data data;
|
||||||
|
int i;
|
||||||
|
if (length > 32)
|
||||||
|
length = 32;
|
||||||
|
for (i = 1; i <= length; i++)
|
||||||
|
data.block[i] = values[i-1];
|
||||||
|
data.block[0] = length;
|
||||||
|
return i2c_smbus_access(file,I2C_SMBUS_WRITE,command,
|
||||||
|
I2C_SMBUS_BLOCK_DATA, &data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Returns the number of read bytes */
|
||||||
|
/* Until kernel 2.6.22, the length is hardcoded to 32 bytes. If you
|
||||||
|
ask for less than 32 bytes, your code will only work with kernels
|
||||||
|
2.6.23 and later. */
|
||||||
|
static inline __s32 i2c_smbus_read_i2c_block_data(int file, __u8 command,
|
||||||
|
__u8 length, __u8 *values)
|
||||||
|
{
|
||||||
|
union i2c_smbus_data data;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if (length > 32)
|
||||||
|
length = 32;
|
||||||
|
data.block[0] = length;
|
||||||
|
if (i2c_smbus_access(file,I2C_SMBUS_READ,command,
|
||||||
|
length == 32 ? I2C_SMBUS_I2C_BLOCK_BROKEN :
|
||||||
|
I2C_SMBUS_I2C_BLOCK_DATA,&data))
|
||||||
|
return -1;
|
||||||
|
else {
|
||||||
|
for (i = 1; i <= data.block[0]; i++)
|
||||||
|
values[i-1] = data.block[i];
|
||||||
|
return data.block[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline __s32 i2c_smbus_write_i2c_block_data(int file, __u8 command,
|
||||||
|
__u8 length,
|
||||||
|
const __u8 *values)
|
||||||
|
{
|
||||||
|
union i2c_smbus_data data;
|
||||||
|
int i;
|
||||||
|
if (length > 32)
|
||||||
|
length = 32;
|
||||||
|
for (i = 1; i <= length; i++)
|
||||||
|
data.block[i] = values[i-1];
|
||||||
|
data.block[0] = length;
|
||||||
|
return i2c_smbus_access(file,I2C_SMBUS_WRITE,command,
|
||||||
|
I2C_SMBUS_I2C_BLOCK_BROKEN, &data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Returns the number of read bytes */
|
||||||
|
static inline __s32 i2c_smbus_block_process_call(int file, __u8 command,
|
||||||
|
__u8 length, __u8 *values)
|
||||||
|
{
|
||||||
|
union i2c_smbus_data data;
|
||||||
|
int i;
|
||||||
|
if (length > 32)
|
||||||
|
length = 32;
|
||||||
|
for (i = 1; i <= length; i++)
|
||||||
|
data.block[i] = values[i-1];
|
||||||
|
data.block[0] = length;
|
||||||
|
if (i2c_smbus_access(file,I2C_SMBUS_WRITE,command,
|
||||||
|
I2C_SMBUS_BLOCK_PROC_CALL,&data))
|
||||||
|
return -1;
|
||||||
|
else {
|
||||||
|
for (i = 1; i <= data.block[0]; i++)
|
||||||
|
values[i-1] = data.block[i];
|
||||||
|
return data.block[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* LIB_I2CDEV_H */
|
|
@ -0,0 +1,180 @@
|
||||||
|
/* usb2514 - small utility to set configuration of USB2514 hub chip
|
||||||
|
* (C) 2013-2014 by sysmocom - s.f.m.c. GmbH, Author: Harald Welte
|
||||||
|
* All Rights Reserved
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <limits.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
|
/* #include <linux/i2c-dev.h> */
|
||||||
|
#include "i2c-dev.h"
|
||||||
|
|
||||||
|
|
||||||
|
#define USB2514_SLAVE_ADDR 0x2C
|
||||||
|
|
||||||
|
/* Default configuration as per data sheet */
|
||||||
|
static const uint8_t usb2514_default[256] = {
|
||||||
|
0x24, 0x04, 0x14, 0x25, 0xB3, 0x0B, 0x9B, 0x20, /* 0x00 */
|
||||||
|
0x02, 0x00, 0x00, 0x00, 0x01, 0x32, 0x01, 0x32, /* 0x08 */
|
||||||
|
0x32, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10 */
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x18 */
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x20 */
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x28 */
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x30 */
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38 */
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x40 */
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x48 */
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x50 */
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x58 */
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x60 */
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x68 */
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x70 */
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x78 */
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x80 */
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x88 */
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x90 */
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x98 */
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa0 */
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa8 */
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xb0 */
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xb8 */
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc0 */
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc8 */
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd0 */
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd8 */
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xe0 */
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xe8 */
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xf0 */
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, /* 0xf8 */
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Default configuration as per data sheet */
|
||||||
|
static const uint8_t usb2514_odu[256] = {
|
||||||
|
0x24, 0x04, 0x14, 0x25, 0xB3, 0x0B, 0x9B, 0x20, /* 0x00 */
|
||||||
|
0x02, 0x00, 0x00, 0x00, 0x01, 0x32, 0x01, 0x32, /* 0x08 */
|
||||||
|
0x32, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10 */
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x18 */
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x20 */
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x28 */
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x30 */
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x38 */
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x40 */
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x48 */
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x50 */
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x58 */
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x60 */
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x68 */
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x70 */
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x78 */
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x80 */
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x88 */
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x90 */
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x98 */
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa0 */
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xa8 */
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xb0 */
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xb8 */
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc0 */
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc8 */
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd0 */
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd8 */
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xe0 */
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xe8 */
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xf0 */
|
||||||
|
#if 1 /* swap modem + AIS ports (1,2,3) */
|
||||||
|
0x00, 0x00, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x01, /* 0xf8 */
|
||||||
|
#else
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, /* 0xf8 */
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
static int g_fd;
|
||||||
|
|
||||||
|
static unsigned long get_support(void)
|
||||||
|
{
|
||||||
|
int rc;
|
||||||
|
unsigned long funcs;
|
||||||
|
|
||||||
|
rc = ioctl(g_fd, I2C_FUNCS, funcs);
|
||||||
|
|
||||||
|
printf("supported functions: 0x%lx\n", funcs);
|
||||||
|
|
||||||
|
return funcs;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int write_regs(const uint8_t *regs)
|
||||||
|
{
|
||||||
|
unsigned int i;
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
for (i = 0; i < 256; i+= 32) {
|
||||||
|
printf("Writing block of %u bytes at index %u\n", 32, i);
|
||||||
|
rc = i2c_smbus_write_block_data(g_fd, i, 32, regs+i);
|
||||||
|
if (rc < 0)
|
||||||
|
fprintf(stderr, "Error writing registers at "
|
||||||
|
"offset %u: %d\n", i, rc);
|
||||||
|
}
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
int rc;
|
||||||
|
int adapter_nr;
|
||||||
|
long slave_addr = USB2514_SLAVE_ADDR;
|
||||||
|
char filename[PATH_MAX];
|
||||||
|
|
||||||
|
if (argc < 2) {
|
||||||
|
fprintf(stderr, "You have to specify I2C bus number\n");
|
||||||
|
exit(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
adapter_nr = atoi(argv[1]);
|
||||||
|
snprintf(filename, sizeof(filename)-1, "/dev/i2c-%d", adapter_nr);
|
||||||
|
rc = open(filename, O_RDWR);
|
||||||
|
if (rc < 0) {
|
||||||
|
fprintf(stderr, "Error opening the device: %d\n", rc);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_fd = rc;
|
||||||
|
|
||||||
|
get_support();
|
||||||
|
|
||||||
|
rc = ioctl(g_fd, I2C_SLAVE, slave_addr);
|
||||||
|
if (rc < 0) {
|
||||||
|
fprintf(stderr, "Error setting slave addr: %d\n", rc);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
rc = write_regs(usb2514_odu);
|
||||||
|
if (rc < 0) {
|
||||||
|
fprintf(stderr, "Error writing default regs: %d\n", rc);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
exit(0);
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
[Unit]
|
||||||
|
Description=Power-on and configurate usb-hub and devices
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
ExecStart=/usr/bin/gpio_usb2514 ; /usr/bin/usb2514 1
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
|
@ -0,0 +1,29 @@
|
||||||
|
SUMMARY = "small utility to set configuration of USB2514 hub chip on the sysmo-odu"
|
||||||
|
HOMEPAGE = ""
|
||||||
|
LICENSE = "GPLv2+"
|
||||||
|
LIC_FILES_CHKSUM = "file://${WORKDIR}/usb2514.c;beginline=1;endline=18;md5=3b8421a1c05d21add65cc20fccfa29cd"
|
||||||
|
DEPENDS += "lmsensors-apps"
|
||||||
|
|
||||||
|
SRC_URI = "file://usb2514.c \
|
||||||
|
file://gpio_usb2514 \
|
||||||
|
file://i2c-dev.h \
|
||||||
|
file://usb2514.service \
|
||||||
|
"
|
||||||
|
|
||||||
|
SRC_URI[md5sum] = ""
|
||||||
|
SRC_URI[sha256sum] = ""
|
||||||
|
|
||||||
|
do_compile() {
|
||||||
|
${CC} -o ${WORKDIR}/usb2514 ${WORKDIR}/usb2514.c
|
||||||
|
}
|
||||||
|
|
||||||
|
do_install() {
|
||||||
|
install -d ${D}${bindir}/
|
||||||
|
install -m 0755 ${WORKDIR}/usb2514 ${D}${bindir}/
|
||||||
|
install -m 0755 ${WORKDIR}/gpio_usb2514 ${D}${bindir}/
|
||||||
|
install -d ${D}${systemd_unitdir}/system/multi-user.target.wants/
|
||||||
|
install -m 0644 /${WORKDIR}/usb2514.service ${D}${systemd_unitdir}/system/
|
||||||
|
ln -sf ../usb2514.service ${D}${systemd_unitdir}/system/multi-user.target.wants/
|
||||||
|
}
|
||||||
|
|
||||||
|
FILES_${PN} += "${systemd_unitdir}"
|
Loading…
Reference in New Issue