[topgen] Add scanmode to ip port

If IP uses its own sw controlled reset/clock, it needs scanmode input to
improve DFT coverage. Now topgen reads `scan` field from ip hjson and
add `scanmode_i` port accordingly.

See the example of spi_device
diff --git a/hw/top_earlgrey/doc/top_earlgrey.gen.hjson b/hw/top_earlgrey/doc/top_earlgrey.gen.hjson
index 6a1a682..c3d73c6 100644
--- a/hw/top_earlgrey/doc/top_earlgrey.gen.hjson
+++ b/hw/top_earlgrey/doc/top_earlgrey.gen.hjson
@@ -78,6 +78,7 @@
           width: 1
         }
       ]
+      scan: "false"
     }
     {
       name: gpio
@@ -104,6 +105,7 @@
           width: 32
         }
       ]
+      scan: "false"
     }
     {
       name: spi_device
@@ -164,6 +166,7 @@
           width: 1
         }
       ]
+      scan: "true"
     }
     {
       name: flash_ctrl
@@ -204,6 +207,7 @@
           width: 1
         }
       ]
+      scan: "false"
     }
     {
       name: rv_timer
@@ -224,6 +228,7 @@
           width: 1
         }
       ]
+      scan: "false"
     }
     {
       name: hmac
@@ -248,6 +253,7 @@
           width: 1
         }
       ]
+      scan: "false"
     }
     {
       name: rv_plic
@@ -267,6 +273,7 @@
       available_output_list: []
       available_inout_list: []
       interrupt_list: []
+      scan: "false"
     }
   ]
   memory:
diff --git a/hw/top_earlgrey/doc/top_earlgrey.tpl.sv b/hw/top_earlgrey/doc/top_earlgrey.tpl.sv
index 92d564e..4bb4ec5 100644
--- a/hw/top_earlgrey/doc/top_earlgrey.tpl.sv
+++ b/hw/top_earlgrey/doc/top_earlgrey.tpl.sv
@@ -389,6 +389,9 @@
       .irq_id_o   (irq_id),
       .msip_o     (msip),
     % endif
+    % if m["scan"] == "true":
+      .scanmode_i   (scanmode_i),
+    % endif
       .clk_i(${"clk_i" if m["clock"] == "main" else "clk_"+ m["clock"] + "_i"}),
       .rst_ni(${"ndmreset_n" if m["clock"] == "main" else "rst_" + m["clock"] + "_ni"})
   );
diff --git a/hw/top_earlgrey/rtl/top_earlgrey.sv b/hw/top_earlgrey/rtl/top_earlgrey.sv
index 11574bd..d18e26f 100644
--- a/hw/top_earlgrey/rtl/top_earlgrey.sv
+++ b/hw/top_earlgrey/rtl/top_earlgrey.sv
@@ -372,6 +372,7 @@
       .intr_rxerr_o (intr_spi_device_rxerr),
       .intr_rxoverflow_o (intr_spi_device_rxoverflow),
       .intr_txunderflow_o (intr_spi_device_txunderflow),
+      .scanmode_i   (scanmode_i),
       .clk_i(clk_i),
       .rst_ni(ndmreset_n)
   );