Skip to content
Permalink
Browse files

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

Signed-off-by: Michael Brown <mcb30@ipxe.org>
  • Loading branch information
mcb30 committed Jul 10, 2017
1 parent 6a258d8 commit 340f03392d37e1f8552b3bd3021705744caecf25
Showing with 61 additions and 49 deletions.
  1. +57 −0 src/drivers/net/smscusb.c
  2. +4 −49 src/drivers/net/smscusb.h
@@ -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
@@ -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
*

0 comments on commit 340f033

Please sign in to comment.
You can’t perform that action at this time.