1#
2# Boot count configuration
3#
4
5menuconfig BOOTCOUNT_LIMIT
6	bool "Enable support for checking boot count limit"
7	help
8	  Enable checking for exceeding the boot count limit.
9	  More information: http://www.denx.de/wiki/DULG/UBootBootCountLimit
10
11if BOOTCOUNT_LIMIT
12
13choice
14	prompt "Boot count device"
15	default BOOTCOUNT_AM33XX if AM33XX || SOC_DA8XX
16	default BOOTCOUNT_AT91 if AT91SAM9XE
17	default BOOTCOUNT_GENERIC
18
19config BOOTCOUNT_GENERIC
20	bool "Generic default boot counter"
21	help
22	  Generic bootcount stored at SYS_BOOTCOUNT_ADDR.
23
24	  SYS_BOOTCOUNT_ADDR:
25	    Set to the address where the bootcount and bootcount magic
26	    will be stored.
27
28config BOOTCOUNT_EXT
29	bool "Boot counter on EXT filesystem"
30	depends on FS_EXT4
31	select EXT4_WRITE
32	help
33	  Add support for maintaining boot count in a file on an EXT
34	  filesystem.
35
36config BOOTCOUNT_AM33XX
37	bool "Boot counter in AM33XX RTC IP block"
38	depends on AM33XX || SOC_DA8XX
39	select SPL_AM33XX_ENABLE_RTC32K_OSC if AM33XX
40	help
41	  A bootcount driver for the RTC IP block found on many TI platforms.
42	  This requires the RTC clocks, etc, to be enabled prior to use and
43	  not all boards with this IP block on it will have the RTC in use.
44
45config BOOTCOUNT_AM33XX_NVMEM
46	bool "Boot counter in AM33XX RTC IP block with upgrade_available flag"
47	depends on AM33XX
48        select SPL_AM33XX_ENABLE_RTC32K_OSC if AM33XX
49	help
50	  Add support for maintaining bootcount,upgrade_available,
51	  version and BOOTMAGIC in a AM33xx RTC IP block
52	  scratch register2.
53
54	  A bootcount driver for the RTC IP block found on many TI platforms.
55	  This requires the RTC clocks, etc, to be enabled prior to use and
56	  not all boards with this IP block on it will have the RTC in use.
57
58	  If there is upgrade in software then "upgrade_available" is 1,
59	  "bootcount" is incremented otherwise "upgrade_available" and
60	  "bootcount" is  always 0. So the Userspace Application must set
61	  the "upgrade_available" and "bootcount" variable to 0, if a boot
62	  was successfully.
63
64config BOOTCOUNT_ENV
65	bool "Boot counter in environment"
66	help
67	  If no softreset save registers are found on the hardware
68	  "bootcount" is stored in the environment. To prevent a
69	  saveenv on all reboots, the environment variable
70	  "upgrade_available" is used. If "upgrade_available" is
71	  0, "bootcount" is always 0, if "upgrade_available" is
72	  1 "bootcount" is incremented in the environment.
73	  So the Userspace Application must set the "upgrade_available"
74	  and "bootcount" variable to 0, if a boot was successfully.
75
76config BOOTCOUNT_RAM
77	bool "Boot counter in RAM"
78	help
79	  Store the bootcount in DRAM protected against against bit errors
80	  due to short power loss or holding a system in RESET.
81
82config BOOTCOUNT_I2C
83	bool "Boot counter on I2C device"
84	help
85	  Enable support for the bootcounter on an i2c (like RTC) device.
86	  CONFIG_SYS_I2C_RTC_ADDR = i2c chip address
87	  CONFIG_SYS_BOOTCOUNT_ADDR = i2c addr which is used for
88	                              the bootcounter.
89
90config BOOTCOUNT_AT91
91	bool "Boot counter for Atmel AT91SAM9XE"
92	depends on AT91SAM9XE
93
94config DM_BOOTCOUNT
95        bool "Boot counter in a device-model device"
96	help
97	  Enables reading/writing the bootcount in a device-model based
98	  backing store.  If an entry in /chosen/u-boot,bootcount-device
99	  exists, this will be the preferred bootcount device; otherwise
100	  the first available bootcount device will be used.
101
102endchoice
103
104if DM_BOOTCOUNT
105
106menu "Backing stores for device-model backed bootcount"
107config DM_BOOTCOUNT_RTC
108	bool "Support RTC devices as a backing store for bootcount"
109	depends on DM_RTC
110	help
111	  Enabled reading/writing the bootcount in a DM RTC device.
112	  The wrapper device is to be specified with the compatible string
113	  'u-boot,bootcount-rtc' and the 'rtc'-property (a phandle pointing
114	  to the underlying RTC device) and an optional 'offset' property
115	  are supported.
116
117	  Accesses to the backing store are performed using the write16
118	  and read16 ops of DM RTC devices.
119
120config DM_BOOTCOUNT_I2C_EEPROM
121	bool "Support i2c eeprom devices as a backing store for bootcount"
122	depends on I2C_EEPROM
123	help
124	  Enabled reading/writing the bootcount in a DM i2c eeprom device.
125	  The wrapper device is to be specified with the compatible string
126	  'u-boot,bootcount-i2c-eeprom' and the 'i2c-eeprom'-property (a phandle
127	  pointing to the underlying i2c eeprom device) and an optional 'offset'
128	  property are supported.
129
130config DM_BOOTCOUNT_SPI_FLASH
131	bool "Support SPI flash devices as a backing store for bootcount"
132	depends on DM_SPI_FLASH
133	help
134	  Enabled reading/writing the bootcount in a DM SPI flash device.
135	  The wrapper device is to be specified with the compatible string
136	  'u-boot,bootcount-spi-flash' and the 'spi-flash'-property (a phandle
137	  pointing to the underlying SPI flash device) and an optional 'offset'
138	  property are supported.
139
140config BOOTCOUNT_MEM
141	bool "Support memory based bootcounter"
142	help
143	  Enabling Memory based bootcount, typically in a SoC register which
144	  is not cleared on softreset.
145	  compatible = "u-boot,bootcount";
146
147config DM_BOOTCOUNT_SYSCON
148	bool "Support SYSCON devices as a backing store for bootcount"
149	select REGMAP
150	select SYSCON
151	help
152	  Enable reading/writing the bootcount value in a DM SYSCON device.
153	  The driver supports a fixed 32 bits size register using the native
154	  endianness. However, this can be controlled from the SYSCON DT node
155	  configuration.
156
157	  Accessing the backend is done using the regmap interface.
158
159endmenu
160
161endif
162
163config BOOTCOUNT_BOOTLIMIT
164	int "Maximum number of reboot cycles allowed"
165	default 0
166	help
167	  Set the Maximum number of reboot cycles allowed without the boot
168	  counter being cleared.
169	  If set to 0 do not set a boot limit in the environment.
170
171config BOOTCOUNT_ALEN
172	int "I2C address length"
173	default 1
174	depends on BOOTCOUNT_I2C
175	help
176	  Length of the the I2C address at SYS_BOOTCOUNT_ADDR for storing
177	  the boot counter.
178
179config SYS_BOOTCOUNT_SINGLEWORD
180	bool "Use single word to pack boot count and magic value"
181	depends on BOOTCOUNT_GENERIC
182	help
183	  This option enables packing boot count magic value and boot count
184	  into single word (32 bits).
185
186config SYS_BOOTCOUNT_EXT_INTERFACE
187	string "Interface on which to find boot counter EXT filesystem"
188	default "mmc"
189	depends on BOOTCOUNT_EXT
190	help
191	  Set the interface to use when locating the filesystem to use for the
192	  boot counter.
193
194config SYS_BOOTCOUNT_EXT_DEVPART
195	string "Partition of the boot counter EXT filesystem"
196	default "0:1"
197	depends on BOOTCOUNT_EXT
198	help
199	  Set the partition to use when locating the filesystem to use for the
200	  boot counter.
201
202config SYS_BOOTCOUNT_EXT_NAME
203	string "Path and filename of the EXT filesystem based boot counter"
204	default "/boot/failures"
205	depends on BOOTCOUNT_EXT
206	help
207	  Set the filename and path of the file used to store the boot counter.
208
209config SYS_BOOTCOUNT_ADDR
210	hex "RAM address used for reading and writing the boot counter"
211	default 0x44E3E000 if BOOTCOUNT_AM33XX || BOOTCOUNT_AM33XX_NVMEM
212	default 0xE0115FF8 if ARCH_LS1043A || ARCH_LS1021A
213	depends on BOOTCOUNT_AM33XX || BOOTCOUNT_GENERIC || BOOTCOUNT_EXT || \
214		   BOOTCOUNT_I2C || BOOTCOUNT_AM33XX_NVMEM
215	help
216	  Set the address used for reading and writing the boot counter.
217
218config SYS_BOOTCOUNT_MAGIC
219	hex "Magic value for the boot counter"
220	default 0xB001C041 if BOOTCOUNT_GENERIC || BOOTCOUNT_EXT || \
221			      BOOTCOUNT_AM33XX || BOOTCOUNT_ENV || \
222			      BOOTCOUNT_RAM || BOOTCOUNT_I2C || \
223			      BOOTCOUNT_AT91 || DM_BOOTCOUNT
224	default 0xB0 if BOOTCOUNT_AM33XX_NVMEM
225	depends on BOOTCOUNT_GENERIC || BOOTCOUNT_EXT || \
226		   BOOTCOUNT_AM33XX || BOOTCOUNT_ENV || \
227		   BOOTCOUNT_RAM || BOOTCOUNT_I2C || \
228		   BOOTCOUNT_AT91 || DM_BOOTCOUNT || \
229		   BOOTCOUNT_AM33XX_NVMEM
230	help
231	  Set the magic value used for the boot counter.
232
233endif
234