static bool verbose = false;
+enum device_type {
+ TYPE_NONE = 0,
+ TYPE_ECP5 = 1,
+ TYPE_NX = 2,
+};
+
+struct device_info {
+ const char* name;
+ uint32_t id;
+ enum device_type type;
+};
+
+static struct device_info connected_device = {0};
+
+
// ---------------------------------------------------------
// FLASH definitions
// ---------------------------------------------------------
// ECP5 specific JTAG functions
// ---------------------------------------------------------
-
static void print_idcode(uint32_t idcode){
- for(int i = 0; i < sizeof(ecp_devices)/sizeof(struct ecp_device_id); i++){
+ connected_device.id = idcode;
+
+ /* ECP5 Parts */
+ for(int i = 0; i < sizeof(ecp_devices)/sizeof(struct device_id_pair); i++){
if(idcode == ecp_devices[i].device_id)
{
+ connected_device.name = ecp_devices[i].device_name;
+ connected_device.type = TYPE_ECP5;
printf("IDCODE: 0x%08x (%s)\n", idcode ,ecp_devices[i].device_name);
return;
}
}
+
+ /* NX Parts */
+ for(int i = 0; i < sizeof(nx_devices)/sizeof(struct device_id_pair); i++){
+ if(idcode == nx_devices[i].device_id)
+ {
+ connected_device.name = nx_devices[i].device_name;
+ connected_device.type = TYPE_NX;
+ printf("IDCODE: 0x%08x (%s)\n", idcode ,nx_devices[i].device_name);
+ return;
+ }
+ }
printf("IDCODE: 0x%08x does not match :(\n", idcode);
}
print_idcode(idcode);
}
-
-static void print_status_register(uint32_t status){
+void print_ecp5_status_register(uint32_t status){
printf("ECP5 Status Register: 0x%08x\n", status);
if(verbose){
}
}
+void print_nx_status_register(uint32_t status){
+ printf("NX Status Register: 0x%08x\n", status);
+}
+
+
+void print_status_register(uint32_t status){
+ if(connected_device.type == TYPE_ECP5){
+ print_ecp5_status_register(status);
+ }else if(connected_device.type == TYPE_NX){
+ print_nx_status_register(status);
+ }
+}
+
+
static void read_status_register(){
#include <stdint.h>
/* Not sure if all of these are applicable to the JTAG interface */
-enum lattice_cmd
+enum lattice_ecp5_cmd
{
ISC_NOOP = 0xFF, /* 0 bits - Non-operation */
READ_ID = 0xE0, /* 24 bits - Read out the 32-bit IDCODE of the device */
};
-struct ecp_device_id {
+struct device_id_pair {
const char* device_name;
uint32_t device_id;
};
-const struct ecp_device_id ecp_devices[] =
+const struct device_id_pair ecp_devices[] =
{
{"LFE5U-12" , 0x21111043 },
{"LFE5U-25" , 0x41111043 },
{"LFE5UM5G-45", 0x81112043 },
{"LFE5UM5G-85", 0x81113043 }
};
+
+const struct device_id_pair nx_devices[] =
+{
+ /* Crosslink NX */
+ {"LIFCL-17", 0x010F0043 },
+ {"LIFCL-40-ES", 0x010F1043 },
+ {"LIFCL-40", 0x110F1043 },
+ /* Certus NX */
+ {"LFD2NX-17", 0x310F0043 },
+ {"LFD2NX-40", 0x310F1043 },
+};