-- -*- Mode: LUA; tab-width: 2 -*-

peripheral {
   name = "WR Core System Controller";
   description = "";
   prefix = "sysc";
   hdl_entity = "wrc_syscon_wb";

   reg {
      name = "Syscon reset register";
      prefix = "RSTR";
      
      field {
         name = "Reset trigger";
         prefix = "TRIG";
         description = "Write 0xdeadbee latch the state of RSTR.RST to the reset line of the LM32 CPU.";
         type = PASS_THROUGH;
         size = 28;
      };
      
      field {
      	name = "Reset line state value";
      	prefix = "RST";
      	description = "State of the reset line";
      	type = BIT;
      	access_bus = READ_WRITE;
      	access_dev = READ_ONLY;      
      };
   };

   reg {
      name = "GPIO Set/Readback Register";
      prefix = "GPSR";


      field {
         name = "Status LED";
         description = "Write 1: turn on the Status LED";
         prefix = "led_stat";
         type = MONOSTABLE;
      };

      field {
         name = "Link LED";
         description = "Write 1: turn on the Link LED";
         prefix = "led_link";
         type = MONOSTABLE;
      };

      field {
         name = "FMC I2C bitbanged SCL";
         prefix = "fmc_scl";
         description = "write 1: Set FMC SCL line to 1 (pullup)\
                        read : returns the current status of the SCL line.";
         type = BIT;
         access_bus = READ_WRITE;
         access_dev = READ_WRITE;
         load = LOAD_EXT;
      };

      field {
         name = "FMC I2C bitbanged SDA";
         prefix = "fmc_sda";
         description = "write 1: Set FMC SDA line to 1 (pullup)\
                        read : returns the current status of the SCL line.";
         type = BIT;
         access_bus = READ_WRITE;
         access_dev = READ_WRITE;
         load = LOAD_EXT;
      };


      field {
         name = "Network AP reset";
         description = "write 1: resets the networking subsystem";
         prefix = "Net_RST";
         type = MONOSTABLE;
      };

      field {
         name = "SPEC Pushbutton 1 state";
         prefix = "Btn1";
         description = "read : returns the state of the Button 1 on the SPEC board";
         type = BIT;
         access_bus = READ_ONLY;
         access_dev = WRITE_ONLY;
      };

      field {
         name = "SPEC Pushbutton 2 state";
         prefix = "Btn2";
         description = "read : returns the state of the Button 2 on the SPEC board";
         type = BIT;
         access_bus = READ_ONLY;
         access_dev = WRITE_ONLY;
      };

      field {
         name = "SFP detect (MOD_DEF0 signal)";
         prefix = "sfp_det";
         description = "read : returns the state of the SFP's MOD_DEF0 line";
         type = BIT;
         access_bus = READ_ONLY;
         access_dev = WRITE_ONLY;
      };

      field {
         name = "SFP I2C bitbanged SCL";
         prefix = "sfp_scl";
         description = "write 1: Set SFP SCL line to 1 (pullup)\
                        read : returns the current status of the SCL line.";
         type = BIT;
         access_bus = READ_WRITE;
         access_dev = READ_WRITE;
         load = LOAD_EXT;
         align = 8;
      };
      
      field {
         name = "SFP I2C bitbanged SDA";
         prefix = "sfp_sda";
         description = "write 1: Set SFP SDA line to 1 (pullup)\
                        read : returns the current status of the SCL line.";
         type = BIT;
         access_bus = READ_WRITE;
         access_dev = READ_WRITE;
         load = LOAD_EXT;
         align = 9;
      };
  
      field {
        name = "SPI bitbanged SCLK";
        prefix = "spi_sclk";
        description = "write 1: drive SPI CLK to 1\
                       read: always 0";
        type = BIT;
        access_bus = READ_WRITE;
        access_dev = READ_WRITE;
        load = LOAD_EXT;
        align = 10;
      };

      field {
        name = "SPI bitbanged NCS";
        prefix = "spi_ncs";
        description = "write 1: drive SPI NCS to 1\
                       read: always 0";
        type = BIT;
        access_bus = READ_WRITE;
        access_dev = READ_WRITE;
        load = LOAD_EXT;
        align = 11;
      };

      field {
        name = "SPI bitbanged MOSI";
        prefix = "spi_mosi";
        description = "write 1: drive SPI MOSI line to 1\
                       read: always 0";
        type = BIT;
        access_bus = READ_WRITE;
        access_dev = READ_WRITE;
        load = LOAD_EXT;
        align = 12;
      };

      field {
        name = "SPI bitbanged MISO";
        prefix = "spi_miso";
        description = "read: current state of SPI MISO line";
        type = BIT;
        access_bus = READ_ONLY;
        access_dev = WRITE_ONLY;
        load = LOAD_EXT;
        align = 13;
      };

   };

   reg {
      name = "GPIO Clear Register";
      prefix = "GPCR";

    field {
         name = "Status LED";
         description = "Write 1: turn on the Status LED";
         prefix = "led_stat";
         type = MONOSTABLE;
      };

      field {
         name = "Link LED";
         description = "Write 1: turn on the Link LED";
         prefix = "led_link";
         type = MONOSTABLE;
      };

      field {
         name = "FMC I2C bitbanged SCL";
         prefix = "fmc_scl";
         description = "write 1: Set FMC SCL line to 1 (pullup)\
                        read : returns the current status of the SCL line.";
         type = MONOSTABLE;
      };

      field {
         name = "FMC I2C bitbanged SDA";
         prefix = "fmc_sda";
         description = "write 1: Set FMC SDA line to 1 (pullup)\
                        read : returns the current status of the SCL line.";
         type = MONOSTABLE;
      };

      field {
         name = "SFP I2C bitbanged SCL";
         prefix = "sfp_scl";
         description = "write 1: Set SFP SCL line to 0.";
         type = MONOSTABLE;
         align = 8;
      };

      field {
         name = "FMC I2C bitbanged SDA";
         prefix = "sfp_sda";
         description = "write 1: Set SFP SDA line to 0.";
         type = MONOSTABLE;
         align = 9;
      };

      field {
        name = "SPI bitbanged SCLK";
        prefix = "spi_sclk";
        description = "write 1: Set SPI CLK line to 0.";
        type = MONOSTABLE;
        align = 10;
      };

      field {
        name = "SPI bitbanged CS";
        prefix = "spi_cs";
        description = "write 1: Set SPI CS line to 0";
        type = MONOSTABLE;
        align = 11;
      };

      field {
        name = "SPI bitbanged MOSI";
        prefix = "spi_mosi";
        description = "write 1: Set SPI MOSI line to 0.";
        type = MONOSTABLE;
        align = 12;
      };

   };

   reg {
      name = "Hardware Feature Register";
      prefix = "HWFR";

      field {
         name = "Memory size";
         prefix = "MEMSIZE";
         size = 4;
         description = "Size of installed memory: 0 = 64 kB ... 0xf = 1024 kB";
         type = SLV;
         access_bus = READ_ONLY;
         access_dev = WRITE_ONLY;
      };

      field {
         name = "Storage type";
         prefix = "STORAGE_TYPE";
         size = 2;
         description = "Storage memory type (0 - Flash, 1 - I2C EEPROM, 2 - 1-Wire EEPROM)";
         type = SLV;
         align = 8;
         access_bus = READ_ONLY;
         access_dev = WRITE_ONLY;
      };

      field {
         name = "Map version";
         description = "memory map version";
         prefix = "mapver";
         type = CONSTANT;
         align = 12;
         size = 4;
         value = 1;
         access_bus = READ_ONLY;
         access_dev = WRITE_ONLY;
      };

      field {
         name = "Storage sector size";
         prefix = "STORAGE_SEC";
         size = 16;
         description = "Storage sector size in KB";
         type = SLV;
         align = 16;
         access_bus = READ_ONLY;
         access_dev = WRITE_ONLY;
      };


   };

   reg {
      name = "Hardware Info Register";
      prefix = "HWIR";
      field {
        name = "Board name";
        prefix = "NAME";
        size = 32;
        description = "4-letter name of the board";
        type = SLV;
        access_bus = READ_ONLY;
        access_dev = WRITE_ONLY;
      };
   };

   reg {
      name = "Storage SDBFS info";
      prefix = "SDBFS";
      field {
        name = "Base address";
        prefix = "BADDR";
        size = 32;
        description = "Default base address in storage, where WRPC should write SDBFS image";
        type = SLV;
        access_bus = READ_ONLY;
        access_dev = WRITE_ONLY;
      };
   };

   reg {
      name = "Timer Control Register";
      prefix = "TCR";

      field {
         name = "Timer Divider";
         description = "Division for obtain 1 millisecond ticks from the system clock: \
                        <b>f_tick = f_clk_sys / (TDIV * 256)</b>";
         prefix = "TDIV";
         size = 12;
         type = SLV;
         access_bus = READ_ONLY;
         access_dev = WRITE_ONLY;
      };

      field {
         name = "Timer Enable";
         description = "write 1: enable timer\
                        write 0: disable timer";

         prefix = "ENABLE";
         type = BIT;
         access_bus = READ_WRITE;
         access_dev = READ_ONLY;
         align = 31;
      };
   };

   reg {
      name = "Timer Counter Value Register";
      prefix = "TVR";

      field {
         name = "Timer Counter Value";
         size = 32;
         type =SLV;
         access_bus = READ_ONLY;
         access_dev = WRITE_ONLY;
      };
   };


  reg {
    name = "User Diag: version register";
    prefix = "DIAG_INFO";

    field {
      name = "Ver";
      prefix = "VER";
      size = 16;
      type = SLV;
      access_bus = READ_ONLY;
      access_dev = WRITE_ONLY;
    };

    field {
      name = "Id";
      prefix = "ID";
      size = 16;
      type = SLV;
      access_bus = READ_ONLY;
      access_dev = WRITE_ONLY;
    };
  };

  reg {
    name = "User Diag: number of words";
    prefix = "DIAG_NW";

    field {
      name = "Read/write words";
      prefix = "RW";
      size = 16;
      type = SLV;
      access_bus = READ_ONLY;
      access_dev = WRITE_ONLY;
    };
    field {
      name = "Read-only words";
      prefix = "RO";
      size = 16;
      type = SLV;
      access_bus = READ_ONLY;
      access_dev = WRITE_ONLY;
    };
  };

  reg {
    name = "User Diag: Control Register";
    prefix = "DIAG_CR";

    field {
      name = "Address";
      prefix = "ADR";
      size = 16;
      type = SLV;
      access_bus = READ_WRITE;
      access_dev = READ_WRITE;
      load = LOAD_EXT;
    };

    field {
      name = "R/W";
      prefix = "RW";
      size = 1;
      type = BIT;
      align = 31;
      access_bus = READ_WRITE;
      access_dev = READ_ONLY;
    };
  };

  reg {
    name = "User Diag: data to read/write";
    prefix = "DIAG_DAT";
    field {
      name = "Data";
      size = 32;
      type = SLV;
      access_bus = READ_WRITE;
      access_dev = READ_WRITE;
      load = LOAD_EXT;
    };
  };
};
