Skip to content

Commit

Permalink
[pinmux] Rework wakeup detectors
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Schaffner <[email protected]>
  • Loading branch information
msfschaffner committed Feb 12, 2021
1 parent e3bbe17 commit 390251b
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 149 deletions.
42 changes: 9 additions & 33 deletions hw/ip/pinmux/data/pinmux.hjson
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,6 @@
package: "pinmux_pkg",
default: "'0"
}
// IO POK signal from AST
{ struct: "io_pok",
type: "uni",
name: "io_pok",
act: "rcv",
package: "pinmux_pkg",
default: "{pinmux_pkg::NIOPokSignals{1'b1}}"
}
// Define pwr mgr <-> pinmux signals
{ struct: "logic",
type: "uni",
Expand Down Expand Up @@ -187,18 +179,6 @@
default: "0",
local: "true"
},

// TODO: Enable these once supported by topgen and the C header generation script.
// These parameters are currently located in pinmux_pkg.sv
// // If a bit is set to 1 in this vector, wakeup detectors are connected
// // to this DIO.
// { name: "DioPeriphHasWkup",
// desc: "Indicates which DIOs shall be connected to the WakeupDetectors.",
// type: "logic [NDioPads-1:0]",
// // TODO: need to generate this via topgen
// default: "'1",
// local: "true"
// },
],
registers: [
//////////////////////////
Expand Down Expand Up @@ -688,7 +668,6 @@
}

},
# wakeup detector config
{ multireg: { name: "WKUP_DETECTOR",
desc: "Configuration of wakeup condition detectors."
count: "NWkupDetect",
Expand All @@ -705,35 +684,32 @@
desc: "Wakeup detection mode."
enum: [
{ value: "0",
name: "Disabled",
desc: "Pin wakeup detector is disabled."
name: "Posedge",
desc: "Trigger a wakeup request when observing a positive edge."
},
{ value: "1",
name: "Negedge",
desc: "Trigger a wakeup request when observing a negative edge."
},
{ value: "2",
name: "Posedge",
desc: "Trigger a wakeup request when observing a positive edge."
},
{ value: "3",
name: "Edge",
desc: "Trigger a wakeup request when observing an edge in any direction."
},
{ value: "4",
name: "TimedLow",
{ value: "3",
name: "TimedHigh",
desc: '''
Trigger a wakeup request when pin is driven LOW for a certain amount
Trigger a wakeup request when pin is driven HIGH for a certain amount
of always-on clock cycles as configured in !!WKUP_DETECTOR_CNT_TH.
'''
},
{ value: "5",
name: "TimedHigh",
{ value: "4",
name: "TimedLow",
desc: '''
Trigger a wakeup request when pin is driven HIGH for a certain amount
Trigger a wakeup request when pin is driven LOW for a certain amount
of always-on clock cycles as configured in !!WKUP_DETECTOR_CNT_TH.
'''
},

]
}
{ bits: "3",
Expand Down
34 changes: 9 additions & 25 deletions hw/ip/pinmux/data/pinmux.hjson.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -191,18 +191,6 @@
default: "${usb_dn_pull_sel}",
local: "true"
},

// TODO: Enable these once supported by topgen and the C header generation script.
// These parameters are currently located in pinmux_pkg.sv
// // If a bit is set to 1 in this vector, wakeup detectors are connected
// // to this DIO.
// { name: "DioPeriphHasWkup",
// desc: "Indicates which DIOs shall be connected to the WakeupDetectors.",
// type: "logic [NDioPads-1:0]",
// // TODO: need to generate this via topgen
// default: "'1",
// local: "true"
// },
],
registers: [
//////////////////////////
Expand Down Expand Up @@ -692,7 +680,6 @@
}

},
# wakeup detector config
{ multireg: { name: "WKUP_DETECTOR",
desc: "Configuration of wakeup condition detectors."
count: "NWkupDetect",
Expand All @@ -709,35 +696,32 @@
desc: "Wakeup detection mode."
enum: [
{ value: "0",
name: "Disabled",
desc: "Pin wakeup detector is disabled."
name: "Posedge",
desc: "Trigger a wakeup request when observing a positive edge."
},
{ value: "1",
name: "Negedge",
desc: "Trigger a wakeup request when observing a negative edge."
},
{ value: "2",
name: "Posedge",
desc: "Trigger a wakeup request when observing a positive edge."
},
{ value: "3",
name: "Edge",
desc: "Trigger a wakeup request when observing an edge in any direction."
},
{ value: "4",
name: "TimedLow",
{ value: "3",
name: "TimedHigh",
desc: '''
Trigger a wakeup request when pin is driven LOW for a certain amount
Trigger a wakeup request when pin is driven HIGH for a certain amount
of always-on clock cycles as configured in !!WKUP_DETECTOR_CNT_TH.
'''
},
{ value: "5",
name: "TimedHigh",
{ value: "4",
name: "TimedLow",
desc: '''
Trigger a wakeup request when pin is driven HIGH for a certain amount
Trigger a wakeup request when pin is driven LOW for a certain amount
of always-on clock cycles as configured in !!WKUP_DETECTOR_CNT_TH.
'''
},

]
}
{ bits: "3",
Expand Down
27 changes: 2 additions & 25 deletions hw/ip/pinmux/rtl/pinmux.sv
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,6 @@ module pinmux
input [NDioPads-1:0] dio_in_i
);

////////////////////////////
// Parameters / Constants //
////////////////////////////

// TODO: these need to be parameterizable via topgen at some point.
// They have been placed here such that they do not generate
// warnings in the C header generation step, since logic is not supported
// as a data type yet.
localparam logic [pinmux_reg_pkg::NDioPads-1:0] DioPeriphHasWkup
= {pinmux_reg_pkg::NDioPads{1'b1}};

//////////////////////////////////
// Regfile Breakout and Mapping //
//////////////////////////////////
Expand Down Expand Up @@ -297,22 +286,10 @@ module pinmux
// Wakeup detectors //
//////////////////////

logic [NWkupDetect-1:0] aon_wkup_req;
logic [AlignedMuxSize-1:0] dio_data_mux;
assign dio_data_mux = AlignedMuxSize'(dio_in_i);

// Only connect DIOs that are not excempt
for (genvar k = 0; k < NDioPads; k++) begin : gen_dio_wkup
if (DioPeriphHasWkup[k]) begin : gen_dio_wkup_connect
assign dio_data_mux[k] = dio_in_i[k];
end else begin : gen_dio_wkup_tie_off
assign dio_data_mux[k] = 1'b0;
end
end

for (genvar k = NDioPads; k < AlignedMuxSize; k++) begin : gen_dio_data_mux_tie_off
assign dio_data_mux[k] = 1'b0;
end

logic [NWkupDetect-1:0] aon_wkup_req;
for (genvar k = 0; k < NWkupDetect; k++) begin : gen_wkup_detect
logic pin_value;
assign pin_value = (reg2hw.wkup_detector[k].miodio.q) ?
Expand Down
9 changes: 4 additions & 5 deletions hw/ip/pinmux/rtl/pinmux_pkg.sv
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@ package pinmux_pkg;

// Wakeup Detector Modes
typedef enum logic [2:0] {
Disabled = 3'b000,
Posedge = 3'b000,
Negedge = 3'b001,
Posedge = 3'b010,
Edge = 3'b011,
LowTimed = 3'b100,
HighTimed = 3'b101
Edge = 3'b010,
HighTimed = 3'b011,
LowTimed = 3'b100
} wkup_mode_e;

// DFT Test Mode straps
Expand Down
14 changes: 7 additions & 7 deletions hw/ip/pinmux/rtl/pinmux_wkup.sv
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ module pinmux_wkup import pinmux_pkg::*; import pinmux_reg_pkg::*; #(
always_ff @(posedge clk_aon_i or negedge rst_aon_ni) begin : p_sync
if (!rst_aon_ni) begin
aon_wkup_en_q <= 1'b0;
aon_wkup_mode_q <= Disabled;
aon_wkup_mode_q <= Posedge;
aon_filter_en_q <= 1'b0;
aon_wkup_cnt_th_q <= '0;
end else begin
Expand Down Expand Up @@ -119,17 +119,17 @@ module pinmux_wkup import pinmux_pkg::*; import pinmux_reg_pkg::*; #(
if (aon_wkup_en_q) begin
unique case (aon_wkup_mode_q)
Negedge: aon_wkup_pulse = aon_falling;
Posedge: aon_wkup_pulse = aon_rising;
Edge: aon_wkup_pulse = aon_rising | aon_falling;
LowTimed: begin
aon_cnt_en = ~aon_filter_out_d;
aon_wkup_pulse = aon_cnt_eq_th;
end
HighTimed: begin
aon_cnt_en = aon_filter_out_d;
aon_wkup_pulse = aon_cnt_eq_th;
end
default: ; // also covers "Disabled"
LowTimed: begin
aon_cnt_en = ~aon_filter_out_d;
aon_wkup_pulse = aon_cnt_eq_th;
end
// Default to rising
default: aon_wkup_pulse = aon_rising;
endcase
end
end
Expand Down
20 changes: 0 additions & 20 deletions hw/top_earlgrey/data/autogen/top_earlgrey.gen.hjson
Original file line number Diff line number Diff line change
Expand Up @@ -4360,16 +4360,6 @@
inst_name: pinmux_aon
index: -1
}
{
struct: io_pok
type: uni
name: io_pok
act: rcv
package: pinmux_pkg
default: "{pinmux_pkg::NIOPokSignals{1'b1}}"
inst_name: pinmux_aon
index: -1
}
{
struct: logic
type: uni
Expand Down Expand Up @@ -13075,16 +13065,6 @@
inst_name: pinmux_aon
index: -1
}
{
struct: io_pok
type: uni
name: io_pok
act: rcv
package: pinmux_pkg
default: "{pinmux_pkg::NIOPokSignals{1'b1}}"
inst_name: pinmux_aon
index: -1
}
{
struct: logic
type: uni
Expand Down
42 changes: 9 additions & 33 deletions hw/top_earlgrey/ip/pinmux/data/autogen/pinmux.hjson
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,6 @@
package: "pinmux_pkg",
default: "'0"
}
// IO POK signal from AST
{ struct: "io_pok",
type: "uni",
name: "io_pok",
act: "rcv",
package: "pinmux_pkg",
default: "{pinmux_pkg::NIOPokSignals{1'b1}}"
}
// Define pwr mgr <-> pinmux signals
{ struct: "logic",
type: "uni",
Expand Down Expand Up @@ -195,18 +187,6 @@
default: "5",
local: "true"
},

// TODO: Enable these once supported by topgen and the C header generation script.
// These parameters are currently located in pinmux_pkg.sv
// // If a bit is set to 1 in this vector, wakeup detectors are connected
// // to this DIO.
// { name: "DioPeriphHasWkup",
// desc: "Indicates which DIOs shall be connected to the WakeupDetectors.",
// type: "logic [NDioPads-1:0]",
// // TODO: need to generate this via topgen
// default: "'1",
// local: "true"
// },
],
registers: [
//////////////////////////
Expand Down Expand Up @@ -696,7 +676,6 @@
}

},
# wakeup detector config
{ multireg: { name: "WKUP_DETECTOR",
desc: "Configuration of wakeup condition detectors."
count: "NWkupDetect",
Expand All @@ -713,35 +692,32 @@
desc: "Wakeup detection mode."
enum: [
{ value: "0",
name: "Disabled",
desc: "Pin wakeup detector is disabled."
name: "Posedge",
desc: "Trigger a wakeup request when observing a positive edge."
},
{ value: "1",
name: "Negedge",
desc: "Trigger a wakeup request when observing a negative edge."
},
{ value: "2",
name: "Posedge",
desc: "Trigger a wakeup request when observing a positive edge."
},
{ value: "3",
name: "Edge",
desc: "Trigger a wakeup request when observing an edge in any direction."
},
{ value: "4",
name: "TimedLow",
{ value: "3",
name: "TimedHigh",
desc: '''
Trigger a wakeup request when pin is driven LOW for a certain amount
Trigger a wakeup request when pin is driven HIGH for a certain amount
of always-on clock cycles as configured in !!WKUP_DETECTOR_CNT_TH.
'''
},
{ value: "5",
name: "TimedHigh",
{ value: "4",
name: "TimedLow",
desc: '''
Trigger a wakeup request when pin is driven HIGH for a certain amount
Trigger a wakeup request when pin is driven LOW for a certain amount
of always-on clock cycles as configured in !!WKUP_DETECTOR_CNT_TH.
'''
},

]
}
{ bits: "3",
Expand Down
1 change: 0 additions & 1 deletion hw/top_earlgrey/rtl/autogen/top_earlgrey.sv
Original file line number Diff line number Diff line change
Expand Up @@ -1534,7 +1534,6 @@ module top_earlgrey #(
.lc_pinmux_strap_i('0),
.lc_pinmux_strap_o(),
.dft_strap_test_o(),
.io_pok_i({pinmux_pkg::NIOPokSignals{1'b1}}),
.sleep_en_i(1'b0),
.aon_wkup_req_o(pwrmgr_aon_wakeups[0]),
.usb_wkup_req_o(pwrmgr_aon_wakeups[1]),
Expand Down

0 comments on commit 390251b

Please sign in to comment.