1
0
mirror of git://projects.qi-hardware.com/ben-wpan.git synced 2024-11-22 23:25:54 +02:00

libatspi: new function atspi_test_mode to enter test mode

- include/atspi.h, lib/atspi.c: new function atspi_test_mode to enter test
  mode
- lib/driver.h (struct atspi_driver): add backend function test_mode
- lib/atusb.c (atusb_test_mode), lib/atusb.c (atusb_driver): enter test
  mode
- lib/atusd.c (atusd_driver): test mode is not supported
This commit is contained in:
Werner Almesberger 2010-11-11 02:29:07 -03:00
parent 2337557a8c
commit 5d63a009c8
5 changed files with 30 additions and 0 deletions

View File

@ -29,6 +29,7 @@ int atspi_clear_error(struct atspi_dsc *dsc);
void atspi_reset(struct atspi_dsc *dsc); void atspi_reset(struct atspi_dsc *dsc);
void atspi_reset_rf(struct atspi_dsc *dsc); void atspi_reset_rf(struct atspi_dsc *dsc);
int atspi_test_mode(struct atspi_dsc *dsc);
void atspi_reg_write(struct atspi_dsc *dsc, uint8_t reg, uint8_t value); void atspi_reg_write(struct atspi_dsc *dsc, uint8_t reg, uint8_t value);
uint8_t atspi_reg_read(struct atspi_dsc *dsc, uint8_t reg); uint8_t atspi_reg_read(struct atspi_dsc *dsc, uint8_t reg);

View File

@ -99,6 +99,15 @@ void atspi_reset_rf(struct atspi_dsc *dsc)
} }
int atspi_test_mode(struct atspi_dsc *dsc)
{
if (!dsc->driver->test_mode)
return 0;
dsc->driver->test_mode(dsc->handle);
return 1;
}
void atspi_reg_write(struct atspi_dsc *dsc, uint8_t reg, uint8_t value) void atspi_reg_write(struct atspi_dsc *dsc, uint8_t reg, uint8_t value)
{ {
dsc->driver->reg_write(dsc->handle, reg, value); dsc->driver->reg_write(dsc->handle, reg, value);

View File

@ -108,6 +108,23 @@ static void atusb_reset_rf(void *dsc)
} }
static void atusb_test_mode(void *dsc)
{
usb_dev_handle *dev = dsc;
int res;
if (error)
return;
res =
usb_control_msg(dev, TO_DEV, ATSPI_TEST, 0, 0, NULL, 0, 1000);
if (res < 0) {
fprintf(stderr, "ATSPI_TEST: %d\n", res);
error = 1;
}
}
/* ----- register access --------------------------------------------------- */ /* ----- register access --------------------------------------------------- */
@ -221,6 +238,7 @@ struct atspi_driver atusb_driver = {
.clear_error = atusb_clear_error, .clear_error = atusb_clear_error,
.reset = atusb_reset, .reset = atusb_reset,
.reset_rf = atusb_reset_rf, .reset_rf = atusb_reset_rf,
.test_mode = atusb_test_mode,
.reg_write = atusb_reg_write, .reg_write = atusb_reg_write,
.reg_read = atusb_reg_read, .reg_read = atusb_reg_read,
.buf_write = atusb_buf_write, .buf_write = atusb_buf_write,

View File

@ -320,6 +320,7 @@ struct atspi_driver atusd_driver = {
.close = atusd_close, .close = atusd_close,
.reset = NULL, .reset = NULL,
.reset_rf = atusd_reset_rf, .reset_rf = atusd_reset_rf,
.test_mode = NULL,
.reg_write = atusd_reg_write, .reg_write = atusd_reg_write,
.reg_read = atusd_reg_read, .reg_read = atusd_reg_read,
.buf_write = atusd_buf_write, .buf_write = atusd_buf_write,

View File

@ -25,6 +25,7 @@ struct atspi_driver {
int (*clear_error)(void *dsc); int (*clear_error)(void *dsc);
void (*reset)(void *dsc); void (*reset)(void *dsc);
void (*reset_rf)(void *dsc); void (*reset_rf)(void *dsc);
void (*test_mode)(void *dsc);
void (*reg_write)(void *dsc, uint8_t reg, uint8_t value); void (*reg_write)(void *dsc, uint8_t reg, uint8_t value);
uint8_t (*reg_read)(void *dsc, uint8_t reg); uint8_t (*reg_read)(void *dsc, uint8_t reg);
void (*buf_write)(void *dsc, const void *buf, int size); void (*buf_write)(void *dsc, const void *buf, int size);