From 12d3401f64fe43e91821e4f58d71de097c477b2d Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Mon, 1 Apr 2013 05:47:12 -0300 Subject: [PATCH] fw/include/atusb/: move shared protocol definitions from ep0.h to atusb.h --- atusb/fw/include/atusb/atusb.h | 84 ++++++++++++++++++++++++++++++++++ atusb/fw/include/atusb/ep0.h | 69 ++++------------------------ 2 files changed, 93 insertions(+), 60 deletions(-) create mode 100644 atusb/fw/include/atusb/atusb.h diff --git a/atusb/fw/include/atusb/atusb.h b/atusb/fw/include/atusb/atusb.h new file mode 100644 index 0000000..c8fe6c8 --- /dev/null +++ b/atusb/fw/include/atusb/atusb.h @@ -0,0 +1,84 @@ +/* + * atusb.h - Definitions shared between kernel and ATUSB firmware + * + * Written 2013 by Werner Almesberger + * + * 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, version 2, or + * (at your option) any later version. + * + * This file should be identical for kernel and firmware. + * Kernel: drivers/net/ieee802154/atusb.h + * Firmware: ben-wpan/atusb/fw/include/atusb/atusb.h + */ + +#ifndef _ATUSB_H +#define _ATUSB_H + +#define ATUSB_VENDOR_ID 0x20b7 /* Qi Hardware*/ +#define ATUSB_PRODUCT_ID 0x1540 /* ATUSB */ + +#define ATUSB_BUILD_SIZE 256 /* maximum build version/date message length */ + +/* Commands to our device. Make sure this is synced with the firmware */ +enum atusb_requests { + ATUSB_ID = 0x00, /* system status/control grp */ + ATUSB_BUILD, + ATUSB_RESET, + ATUSB_RF_RESET = 0x10, /* debug/test group */ + ATUSB_POLL_INT, + ATUSB_TEST, /* atusb-sil only */ + ATUSB_TIMER, + ATUSB_GPIO, + ATUSB_SLP_TR, + ATUSB_GPIO_CLEANUP, + ATUSB_REG_WRITE = 0x20, /* transceiver group */ + ATUSB_REG_READ, + ATUSB_BUF_WRITE, + ATUSB_BUF_READ, + ATUSB_SRAM_WRITE, + ATUSB_SRAM_READ, + ATUSB_SPI_WRITE = 0x30, /* SPI group */ + ATUSB_SPI_READ1, + ATUSB_SPI_READ2, + ATUSB_SPI_WRITE2_SYNC, + ATUSB_RX_MODE = 0x40, /* HardMAC group */ + ATUSB_TX, +}; + +/* + * Direction bRequest wValue wIndex wLength + * + * ->host ATUSB_ID - - 3 + * ->host ATUSB_BUILD - - #bytes + * host-> ATUSB_RESET - - 0 + * + * host-> ATUSB_RF_RESET - - 0 + * ->host ATUSB_POLL_INT - - 1 + * host-> ATUSB_TEST - - 0 + * ->host ATUSB_TIMER - - #bytes (6) + * ->host ATUSB_GPIO dir+data mask+p# 3 + * host-> ATUSB_SLP_TR - - 0 + * host-> ATUSB_GPIO_CLEANUP - - 0 + * + * host-> ATUSB_REG_WRITE value addr 0 + * ->host ATUSB_REG_READ - addr 1 + * host-> ATUSB_BUF_WRITE - - #bytes + * ->host ATUSB_BUF_READ - - #bytes + * host-> ATUSB_SRAM_WRITE - addr #bytes + * ->host ATUSB_SRAM_READ - addr #bytes + * + * host-> ATUSB_SPI_WRITE byte0 byte1 #bytes + * ->host ATUSB_SPI_READ1 byte0 - #bytes + * ->host ATUSB_SPI_READ2 byte0 byte1 #bytes + * ->host ATUSB_SPI_WRITE2_SYNC byte0 byte1 0/1 + * + * host-> ATUSB_RX_MODE on - 0 + * host-> ATUSB_TX flags 0 #bytes + */ + +#define ATUSB_REQ_FROM_DEV (USB_TYPE_VENDOR | USB_DIR_IN) +#define ATUSB_REQ_TO_DEV (USB_TYPE_VENDOR | USB_DIR_OUT) + +#endif /* !_ATUSB_H */ diff --git a/atusb/fw/include/atusb/ep0.h b/atusb/fw/include/atusb/ep0.h index 48c3093..56cd175 100644 --- a/atusb/fw/include/atusb/ep0.h +++ b/atusb/fw/include/atusb/ep0.h @@ -1,8 +1,8 @@ /* * include/atusb/ep0.h - EP0 extension protocol * - * Written 2008-2011 by Werner Almesberger - * Copyright 2008-2011 Werner Almesberger + * Written 2008-2011, 2013 by Werner Almesberger + * Copyright 2008-2011, 2013 Werner Almesberger * * 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 @@ -14,36 +14,8 @@ #ifndef EP0_H #define EP0_H -/* - * Direction bRequest wValue wIndex wLength - * - * ->host ATUSB_ID - - 3 - * ->host ATUSB_BUILD - - #bytes - * host-> ATUSB_RESET - - 0 - * - * host-> ATUSB_RF_RESET - - 0 - * ->host ATUSB_POLL_INT - - 1 - * host-> ATUSB_TEST - - 0 - * ->host ATUSB_TIMER - - #bytes (6) - * ->host ATUSB_GPIO dir+data mask+p# 3 - * host-> ATUSB_SLP_TR - - 0 - * host-> ATUSB_GPIO_CLEANUP - - 0 - * - * host-> ATUSB_REG_WRITE value addr 0 - * ->host ATUSB_REG_READ - addr 1 - * host-> ATUSB_BUF_WRITE - - #bytes - * ->host ATUSB_BUF_READ - - #bytes - * host-> ATUSB_SRAM_WRITE - addr #bytes - * ->host ATUSB_SRAM_READ - addr #bytes - * - * host-> ATUSB_SPI_WRITE byte0 byte1 #bytes - * ->host ATUSB_SPI_READ1 byte0 - #bytes - * ->host ATUSB_SPI_READ2 byte0 byte1 #bytes - * ->host ATUSB_SPI_WRITE2_SYNC byte0 byte1 0/1 - * - * host-> ATUSB_RX_MODE on - 0 - * host-> ATUSB_TX flags 0 #bytes - */ +#include + /* * EP0 protocol: @@ -70,35 +42,12 @@ * recipient (0 = device) */ +#define USB_TYPE_VENDOR 0x40 +#define USB_DIR_IN 0x80 +#define USB_DIR_OUT 0x00 -#define ATUSB_TO_DEV(req) (0x40 | (req) << 8) -#define ATUSB_FROM_DEV(req) (0xc0 | (req) << 8) - - -enum atspi_requests { - ATUSB_ID = 0x00, /* system status/control grp */ - ATUSB_BUILD, - ATUSB_RESET, - ATUSB_RF_RESET = 0x10, /* debug/test group */ - ATUSB_POLL_INT, - ATUSB_TEST, /* atusb-sil only */ - ATUSB_TIMER, - ATUSB_GPIO, - ATUSB_SLP_TR, - ATUSB_GPIO_CLEANUP, - ATUSB_REG_WRITE = 0x20, /* transceiver group */ - ATUSB_REG_READ, - ATUSB_BUF_WRITE, - ATUSB_BUF_READ, - ATUSB_SRAM_WRITE, - ATUSB_SRAM_READ, - ATUSB_SPI_WRITE = 0x30, /* SPI group */ - ATUSB_SPI_READ1, - ATUSB_SPI_READ2, - ATUSB_SPI_WRITE2_SYNC, - ATUSB_RX_MODE = 0x40, /* HardMAC group */ - ATUSB_TX, -}; +#define ATUSB_FROM_DEV(req) (ATUSB_REQ_FROM_DEV | (req) << 8) +#define ATUSB_TO_DEV(req) (ATUSB_REQ_TO_DEV | (req) << 8) void ep0_init(void);