fx3_firmware: use SPI Manufacturer to tell boards apart
This commit is contained in:
parent
a6a58e5ed6
commit
9d24fe7ebe
6 changed files with 77 additions and 14 deletions
|
|
@ -184,6 +184,21 @@ void NuandGPIOReconfigure(CyBool_t fullGpif, CyBool_t warm)
|
|||
}
|
||||
}
|
||||
|
||||
uint16_t NuandGetProductID() {
|
||||
if (NuandGetSPIManufacturer() == 0xEF) {
|
||||
return USB_NUAND_BLADERF2_PRODUCT_ID;
|
||||
}
|
||||
return USB_NUAND_BLADERF_PRODUCT_ID;
|
||||
}
|
||||
|
||||
void NuandFpgaConfigSwFlipLut(uint16_t flipLut[256]) {
|
||||
if (NuandGetProductID() == USB_NUAND_BLADERF_PRODUCT_ID) {
|
||||
NuandFpgaConfigSwFlipLut_bladeRF1(flipLut);
|
||||
} else {
|
||||
NuandFpgaConfigSwFlipLut_bladeRF2(flipLut);
|
||||
}
|
||||
}
|
||||
|
||||
void CyFxGpioInit(void)
|
||||
{
|
||||
CyU3PGpioClock_t gpioClock;
|
||||
|
|
@ -794,6 +809,9 @@ static void extractSerialAndCal(void)
|
|||
|
||||
status = NuandReadOtp(0, 0x100, otp_buf);
|
||||
|
||||
/* Call this here while flash chip is init'd */
|
||||
cacheSPIManufacturer();
|
||||
|
||||
if (!NuandExtractField((void*)otp_buf, 0x100, "S", serial_buf, 32)) {
|
||||
for (i = 0; i < 32; i++) {
|
||||
CyFxUSBSerial[2+i*2] = serial_buf[i];
|
||||
|
|
@ -817,6 +835,19 @@ static void extractSerialAndCal(void)
|
|||
void bladeRFInit(void)
|
||||
{
|
||||
CyU3PReturnStatus_t apiRetStatus = CY_U3P_SUCCESS;
|
||||
const uint8_t *usb3_device_descr;
|
||||
const uint8_t *usb2_device_descr;
|
||||
const uint8_t *usb_product_descr;
|
||||
|
||||
if (NuandGetProductID() == USB_NUAND_BLADERF_PRODUCT_ID) {
|
||||
usb3_device_descr = CyFxUSB30DeviceDscr_bladeRF1;
|
||||
usb2_device_descr = CyFxUSB20DeviceDscr_bladeRF1;
|
||||
usb_product_descr = CyFxUSBProductDscr_bladeRF1;
|
||||
} else {
|
||||
usb3_device_descr = CyFxUSB30DeviceDscr_bladeRF2;
|
||||
usb2_device_descr = CyFxUSB20DeviceDscr_bladeRF2;
|
||||
usb_product_descr = CyFxUSBProductDscr_bladeRF2;
|
||||
}
|
||||
|
||||
/* Start the USB functionality. */
|
||||
apiRetStatus = CyU3PUsbStart();
|
||||
|
|
@ -839,14 +870,14 @@ void bladeRFInit(void)
|
|||
/* Set the USB Enumeration descriptors */
|
||||
|
||||
/* Super speed device descriptor. */
|
||||
apiRetStatus = CyU3PUsbSetDesc(CY_U3P_USB_SET_SS_DEVICE_DESCR, 0, (uint8_t *)CyFxUSB30DeviceDscr);
|
||||
apiRetStatus = CyU3PUsbSetDesc(CY_U3P_USB_SET_SS_DEVICE_DESCR, 0, (uint8_t *)usb3_device_descr);
|
||||
if (apiRetStatus != CY_U3P_SUCCESS) {
|
||||
LOG_ERROR(apiRetStatus);
|
||||
CyFxAppErrorHandler(apiRetStatus);
|
||||
}
|
||||
|
||||
/* High speed device descriptor. */
|
||||
apiRetStatus = CyU3PUsbSetDesc(CY_U3P_USB_SET_HS_DEVICE_DESCR, 0, (uint8_t *)CyFxUSB20DeviceDscr);
|
||||
apiRetStatus = CyU3PUsbSetDesc(CY_U3P_USB_SET_HS_DEVICE_DESCR, 0, (uint8_t *)usb2_device_descr);
|
||||
if (apiRetStatus != CY_U3P_SUCCESS) {
|
||||
LOG_ERROR(apiRetStatus);
|
||||
CyFxAppErrorHandler(apiRetStatus);
|
||||
|
|
@ -907,7 +938,7 @@ void bladeRFInit(void)
|
|||
/* Product string descriptor */
|
||||
apiRetStatus = CyU3PUsbSetDesc(CY_U3P_USB_SET_STRING_DESCR,
|
||||
BLADE_USB_STR_INDEX_PRODUCT,
|
||||
(uint8_t *)CyFxUSBProductDscr);
|
||||
(uint8_t *)usb_product_descr);
|
||||
|
||||
if (apiRetStatus != CY_U3P_SUCCESS) {
|
||||
LOG_ERROR(apiRetStatus);
|
||||
|
|
|
|||
|
|
@ -58,8 +58,6 @@
|
|||
// doesn't actually use BULK, EP exists for debugging purposes
|
||||
|
||||
/* Extern definitions for the USB Descriptors */
|
||||
extern const uint8_t CyFxUSB20DeviceDscr[];
|
||||
extern const uint8_t CyFxUSB30DeviceDscr[];
|
||||
extern const uint8_t CyFxUSBDeviceQualDscr[];
|
||||
extern const uint8_t CyFxUSBFSConfigDscr[];
|
||||
extern const uint8_t CyFxUSBHSConfigDscr[];
|
||||
|
|
@ -67,7 +65,12 @@ extern const uint8_t CyFxUSBBOSDscr[];
|
|||
extern const uint8_t CyFxUSBSSConfigDscr[];
|
||||
extern const uint8_t CyFxUSBStringLangIDDscr[];
|
||||
extern const uint8_t CyFxUSBManufactureDscr[];
|
||||
extern const uint8_t CyFxUSBProductDscr[];
|
||||
extern const uint8_t CyFxUSB20DeviceDscr_bladeRF1[];
|
||||
extern const uint8_t CyFxUSB30DeviceDscr_bladeRF1[];
|
||||
extern const uint8_t CyFxUSBProductDscr_bladeRF1[];
|
||||
extern const uint8_t CyFxUSB20DeviceDscr_bladeRF2[];
|
||||
extern const uint8_t CyFxUSB30DeviceDscr_bladeRF2[];
|
||||
extern const uint8_t CyFxUSBProductDscr_bladeRF2[];
|
||||
|
||||
#include "cyu3externcend.h"
|
||||
|
||||
|
|
@ -80,6 +83,8 @@ void NuandAllowSuspend(CyBool_t set_allow_suspend);
|
|||
|
||||
/* defined in bladerf{1,2}.c */
|
||||
void NuandFpgaConfigSwFlipLut(uint16_t flipLut[256]);
|
||||
void NuandFpgaConfigSwFlipLut_bladeRF1(uint16_t flipLut[256]);
|
||||
void NuandFpgaConfigSwFlipLut_bladeRF2(uint16_t flipLut[256]);
|
||||
|
||||
extern uint32_t glAppMode;
|
||||
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@
|
|||
#define BLADERF_PID_HIGH (USB_NUAND_BLADERF_PRODUCT_ID >> 8)
|
||||
|
||||
/* Standard device descriptor for USB 3.0 */
|
||||
const uint8_t CyFxUSB30DeviceDscr[] __attribute__ ((aligned (32))) __attribute__ ((section(".usbdscr"))) =
|
||||
const uint8_t CyFxUSB30DeviceDscr_bladeRF1[] __attribute__ ((aligned (32))) __attribute__ ((section(".usbdscr"))) =
|
||||
{
|
||||
0x12, /* Descriptor size */
|
||||
CY_U3P_USB_DEVICE_DESCR, /* Device descriptor type */
|
||||
|
|
@ -53,7 +53,7 @@ const uint8_t CyFxUSB30DeviceDscr[] __attribute__ ((aligned (32))) __attribute__
|
|||
};
|
||||
|
||||
/* Standard device descriptor for USB 2.0 */
|
||||
const uint8_t CyFxUSB20DeviceDscr[] __attribute__ ((aligned (32))) __attribute__ ((section(".usbdscr"))) =
|
||||
const uint8_t CyFxUSB20DeviceDscr_bladeRF1[] __attribute__ ((aligned (32))) __attribute__ ((section(".usbdscr"))) =
|
||||
{
|
||||
0x12, /* Descriptor size */
|
||||
CY_U3P_USB_DEVICE_DESCR, /* Device descriptor type */
|
||||
|
|
@ -72,7 +72,7 @@ const uint8_t CyFxUSB20DeviceDscr[] __attribute__ ((aligned (32))) __attribute__
|
|||
};
|
||||
|
||||
/* Standard product string descriptor */
|
||||
const uint8_t CyFxUSBProductDscr[] __attribute__ ((aligned (32))) __attribute__ ((section(".usbdscr"))) =
|
||||
const uint8_t CyFxUSBProductDscr_bladeRF1[] __attribute__ ((aligned (32))) __attribute__ ((section(".usbdscr"))) =
|
||||
{
|
||||
0x10, /* Descriptor size */
|
||||
CY_U3P_USB_STRING_DESCR, /* Device descriptor type */
|
||||
|
|
@ -91,7 +91,7 @@ const uint8_t CyFxUSBProductDscr[] __attribute__ ((aligned (32))) __attribute__
|
|||
* same cache line. */
|
||||
const uint8_t CyFxUsbDscrAlignBuffer[32] __attribute__ ((aligned (32))) __attribute__ ((section(".usbdscr"))) = {};
|
||||
|
||||
void NuandFpgaConfigSwFlipLut(uint16_t flipLut[256])
|
||||
void NuandFpgaConfigSwFlipLut_bladeRF1(uint16_t flipLut[256])
|
||||
{
|
||||
uint32_t i;
|
||||
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@
|
|||
#define BLADERF_PID_HIGH (USB_NUAND_BLADERF2_PRODUCT_ID >> 8)
|
||||
|
||||
/* Standard device descriptor for USB 3.0 */
|
||||
const uint8_t CyFxUSB30DeviceDscr[] __attribute__ ((aligned (32))) __attribute__ ((section(".usbdscr"))) =
|
||||
const uint8_t CyFxUSB30DeviceDscr_bladeRF2[] __attribute__ ((aligned (32))) __attribute__ ((section(".usbdscr"))) =
|
||||
{
|
||||
0x12, /* Descriptor size */
|
||||
CY_U3P_USB_DEVICE_DESCR, /* Device descriptor type */
|
||||
|
|
@ -53,7 +53,7 @@ const uint8_t CyFxUSB30DeviceDscr[] __attribute__ ((aligned (32))) __attribute__
|
|||
};
|
||||
|
||||
/* Standard device descriptor for USB 2.0 */
|
||||
const uint8_t CyFxUSB20DeviceDscr[] __attribute__ ((aligned (32))) __attribute__ ((section(".usbdscr"))) =
|
||||
const uint8_t CyFxUSB20DeviceDscr_bladeRF2[] __attribute__ ((aligned (32))) __attribute__ ((section(".usbdscr"))) =
|
||||
{
|
||||
0x12, /* Descriptor size */
|
||||
CY_U3P_USB_DEVICE_DESCR, /* Device descriptor type */
|
||||
|
|
@ -72,7 +72,7 @@ const uint8_t CyFxUSB20DeviceDscr[] __attribute__ ((aligned (32))) __attribute__
|
|||
};
|
||||
|
||||
/* Standard product string descriptor */
|
||||
const uint8_t CyFxUSBProductDscr[] __attribute__ ((aligned (32))) __attribute__ ((section(".usbdscr"))) =
|
||||
const uint8_t CyFxUSBProductDscr_bladeRF2[] __attribute__ ((aligned (32))) __attribute__ ((section(".usbdscr"))) =
|
||||
{
|
||||
0x18, /* Descriptor size */
|
||||
CY_U3P_USB_STRING_DESCR, /* Device descriptor type */
|
||||
|
|
@ -95,7 +95,7 @@ const uint8_t CyFxUSBProductDscr[] __attribute__ ((aligned (32))) __attribute__
|
|||
* same cache line. */
|
||||
const uint8_t CyFxUsbDscrAlignBuffer[32] __attribute__ ((aligned (32))) __attribute__ ((section(".usbdscr"))) = {};
|
||||
|
||||
void NuandFpgaConfigSwFlipLut(uint16_t flipLut[256])
|
||||
void NuandFpgaConfigSwFlipLut_bladeRF2(uint16_t flipLut[256])
|
||||
{
|
||||
uint32_t i;
|
||||
|
||||
|
|
|
|||
|
|
@ -97,6 +97,30 @@ CyU3PReturnStatus_t NuandExso() {
|
|||
return status;
|
||||
}
|
||||
|
||||
static uint8_t spi_mfn[2];
|
||||
static CyBool_t cached_spi_mfn = CyFalse;
|
||||
void cacheSPIManufacturer() {
|
||||
uint8_t location[4];
|
||||
|
||||
location[0] = 0x90; // RD Manu
|
||||
location[1] = 0x0;
|
||||
location[2] = 0x0;
|
||||
location[3] = 0x0;
|
||||
|
||||
CyU3PSpiSetSsnLine (CyFalse);
|
||||
CyU3PSpiTransmitWords (location, 4);
|
||||
CyU3PSpiReceiveWords(spi_mfn, 2);
|
||||
CyU3PSpiSetSsnLine (CyTrue);
|
||||
cached_spi_mfn = CyTrue;
|
||||
}
|
||||
|
||||
uint8_t NuandGetSPIManufacturer() {
|
||||
if (!cached_spi_mfn) {
|
||||
cacheSPIManufacturer();
|
||||
}
|
||||
return spi_mfn[0];
|
||||
}
|
||||
|
||||
CyU3PReturnStatus_t NuandReadOtp(size_t offset, size_t size, void *buf) {
|
||||
CyU3PReturnStatus_t status;
|
||||
|
||||
|
|
|
|||
|
|
@ -28,6 +28,9 @@
|
|||
CyU3PReturnStatus_t NuandReadOtp(size_t offset, size_t size, void *buf);
|
||||
CyU3PReturnStatus_t NuandWriteOtp(size_t offset, size_t size, void *buf);
|
||||
CyU3PReturnStatus_t NuandLockOtp();
|
||||
uint8_t NuandGetSPIManufacturer();
|
||||
void cacheSPIManufacturer();
|
||||
|
||||
|
||||
CyU3PReturnStatus_t NuandFlashInit();
|
||||
void NuandFlashDeinit();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue