david/ipxe
david
/
ipxe
Archived
1
0
Fork 0

[smscusb] Move non-inline register access functions to smscusb.c

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown 2017-07-10 11:54:24 +01:00
parent 6a258d8d55
commit 340f03392d
2 changed files with 61 additions and 49 deletions

View File

@ -42,6 +42,63 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
static struct profiler smscusb_intr_profiler __profiler =
{ .name = "smscusb.intr" };
/******************************************************************************
*
* Register access
*
******************************************************************************
*/
/**
* Write register (without byte-swapping)
*
* @v smscusb Smscusb device
* @v address Register address
* @v value Register value
* @ret rc Return status code
*/
int smscusb_raw_writel ( struct smscusb_device *smscusb, unsigned int address,
uint32_t value ) {
int rc;
/* Write register */
DBGCIO ( smscusb, "SMSCUSB %p [%03x] <= %08x\n",
smscusb, address, le32_to_cpu ( value ) );
if ( ( rc = usb_control ( smscusb->usb, SMSCUSB_REGISTER_WRITE, 0,
address, &value, sizeof ( value ) ) ) != 0 ) {
DBGC ( smscusb, "SMSCUSB %p could not write %03x: %s\n",
smscusb, address, strerror ( rc ) );
return rc;
}
return 0;
}
/**
* Read register (without byte-swapping)
*
* @v smscusb SMSC USB device
* @v address Register address
* @ret value Register value
* @ret rc Return status code
*/
int smscusb_raw_readl ( struct smscusb_device *smscusb, unsigned int address,
uint32_t *value ) {
int rc;
/* Read register */
if ( ( rc = usb_control ( smscusb->usb, SMSCUSB_REGISTER_READ, 0,
address, value, sizeof ( *value ) ) ) != 0 ) {
DBGC ( smscusb, "SMSCUSB %p could not read %03x: %s\n",
smscusb, address, strerror ( rc ) );
return rc;
}
DBGCIO ( smscusb, "SMSCUSB %p [%03x] => %08x\n",
smscusb, address, le32_to_cpu ( *value ) );
return 0;
}
/******************************************************************************
*
* EEPROM access

View File

@ -170,30 +170,10 @@ struct smscusb_device {
uint32_t int_sts;
};
/**
* Write register (without byte-swapping)
*
* @v smscusb Smscusb device
* @v address Register address
* @v value Register value
* @ret rc Return status code
*/
static int smscusb_raw_writel ( struct smscusb_device *smscusb,
unsigned int address, uint32_t value ) {
int rc;
/* Write register */
DBGCIO ( smscusb, "SMSCUSB %p [%03x] <= %08x\n",
smscusb, address, le32_to_cpu ( value ) );
if ( ( rc = usb_control ( smscusb->usb, SMSCUSB_REGISTER_WRITE, 0,
address, &value, sizeof ( value ) ) ) != 0 ) {
DBGC ( smscusb, "SMSCUSB %p could not write %03x: %s\n",
smscusb, address, strerror ( rc ) );
return rc;
}
return 0;
}
extern int smscusb_raw_writel ( struct smscusb_device *smscusb,
unsigned int address, uint32_t value );
extern int smscusb_raw_readl ( struct smscusb_device *smscusb,
unsigned int address, uint32_t *value );
/**
* Write register
@ -216,31 +196,6 @@ smscusb_writel ( struct smscusb_device *smscusb, unsigned int address,
return 0;
}
/**
* Read register (without byte-swapping)
*
* @v smscusb SMSC USB device
* @v address Register address
* @ret value Register value
* @ret rc Return status code
*/
static int smscusb_raw_readl ( struct smscusb_device *smscusb,
unsigned int address, uint32_t *value ) {
int rc;
/* Read register */
if ( ( rc = usb_control ( smscusb->usb, SMSCUSB_REGISTER_READ, 0,
address, value, sizeof ( *value ) ) ) != 0 ) {
DBGC ( smscusb, "SMSCUSB %p could not read %03x: %s\n",
smscusb, address, strerror ( rc ) );
return rc;
}
DBGCIO ( smscusb, "SMSCUSB %p [%03x] => %08x\n",
smscusb, address, le32_to_cpu ( *value ) );
return 0;
}
/**
* Read register
*