blob: 811643ceb8642cd4e3e17f7df9efa97d4eab2e77 [file] [log] [blame]
Thorsten Knollb8f623b2022-12-04 09:20:03 +01001// SPDX-FileCopyrightText: 2020 Efabless Corporation
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14// SPDX-License-Identifier: Apache-2.0
15
16`default_nettype none
17
18`ifndef __USER_DEFINES_H
19// User GPIO initial configuration parameters
20`define __USER_DEFINES_H
21
22// deliberately erroneous placeholder value; user required to config GPIO's to other
23`define GPIO_MODE_INVALID 13'hXXXX
24
25// Authoritive source of these MODE defs is: caravel/verilog/rtl/user_defines.v
26// Useful GPIO mode values. These match the names used in defs.h.
27//
28
29`define GPIO_MODE_MGMT_STD_INPUT_NOPULL 10'h007
30`define GPIO_MODE_MGMT_STD_INPUT_PULLDOWN 10'h047
31`define GPIO_MODE_MGMT_STD_INPUT_PULLUP 10'h087
32`define GPIO_MODE_MGMT_STD_OUTPUT 10'h00b
33`define GPIO_MODE_MGMT_STD_BIDIRECTIONAL 10'h009
34
35`define GPIO_MODE_USER_STD_INPUT_NOPULL 10'h006
36`define GPIO_MODE_USER_STD_INPUT_PULLDOWN 10'h046
37`define GPIO_MODE_USER_STD_INPUT_PULLUP 10'h086
38`define GPIO_MODE_USER_STD_OUTPUT 10'h00a
39`define GPIO_MODE_USER_STD_BIDIRECTIONAL 10'h008
40
41// The power-on configuration for GPIO 0 to 4 is fixed and cannot be
42// modified (allowing the SPI and debug to always be accessible unless
43// overridden by a flash program).
44
45// The values below can be any of the standard types defined above,
46// or they can be any 13-bit value if the user wants a non-standard
47// startup state for the GPIO. By default, every GPIO from 5 to 37
48// is set to power up as an input controlled by the management SoC.
49// Users may want to redefine these so that the user project powers
50// up in a state that can be used immediately without depending on
51// the management SoC to run a startup program to configure the GPIOs.
52
53// tiny_user_project i/o
54// generated by configure.py
55{% for n in range(5, 38) -%}
56{%- if io_in_range[0] <= n < io_in_range[1] %}
57`define USER_CONFIG_GPIO_{{ n }}_INIT `GPIO_MODE_USER_STD_INPUT_NOPULL
58{%- elif io_out_range[0] <= n < io_out_range[1] %}
59`define USER_CONFIG_GPIO_{{ n }}_INIT `GPIO_MODE_USER_STD_OUTPUT
60{%- else %}
61`define USER_CONFIG_GPIO_{{ n }}_INIT `GPIO_MODE_USER_STD_INPUT_PULLDOWN
62{%- endif -%}
63{% endfor %}
64
65`endif // __USER_DEFINES_H