1/*
2 * Copyright (c) 2021 Seagate Technology LLC
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7/dts-v1/;
8#include <st/f0/stm32f070Xb.dtsi>
9#include <st/f0/stm32f070cbtx-pinctrl.dtsi>
10#include <dt-bindings/led/led.h>
11#include <dt-bindings/led/seagate_legend_b1414.h>
12
13/ {
14	chosen {
15		zephyr,console = &usart1;
16		zephyr,shell-uart = &usart1;
17		zephyr,sram = &sram0;
18		zephyr,flash = &flash0;
19	};
20
21	aliases {
22		watchdog0 = &iwdg;
23	};
24
25	board_id: brd-id {
26		compatible = "gpio-keys";
27		brd_id0: brd_id_0 {
28			label = "BRD_ID_0";
29			gpios = <&gpioc 13 0>;
30		};
31		brd_id1: brd_id_1 {
32			label = "BRD_ID_1";
33			gpios = <&gpioc 14 0>;
34		};
35		brd_id2: brd_id_2 {
36			label = "BRD_ID_2";
37			gpios = <&gpioc 15 0>;
38		};
39	};
40
41};
42
43&usart1 {
44	pinctrl-0 = <&usart1_tx_pa9 &usart1_rx_pa10>;
45	current-speed = <115200>;
46	status = "okay";
47};
48
49&i2c1 {
50	pinctrl-0 = <&i2c1_scl_pb6 &i2c1_sda_pb7>;
51	clock-frequency = <I2C_BITRATE_STANDARD>;
52	status = "okay";
53};
54
55&spi1 {
56	pinctrl-0 = <&spi1_sck_pa5 &spi1_miso_pa6 &spi1_mosi_pa7>;
57	dmas = <&dma1 3 0x20440>, <&dma1 2 0x20480>;
58	dma-names = "tx", "rx";
59	status = "okay";
60
61	led_strip_spi: b1414@0 {
62		compatible = "everlight,b1414", "worldsemi,ws2812-spi";
63		label = "B1414";
64
65		/* SPI */
66		reg = <0>; /* ignored, but necessary for SPI bindings */
67		spi-max-frequency = <SPI_FREQ>;
68
69		/* B1414 */
70		spi-one-frame = <ONE_FRAME>;
71		spi-zero-frame = <ZERO_FRAME>;
72		color-mapping = <LED_COLOR_ID_RED>,
73				<LED_COLOR_ID_GREEN>,
74				<LED_COLOR_ID_BLUE>;
75		reset-delay = <250>;
76	};
77};
78
79&spi2 {
80	pinctrl-0 = <&spi2_sck_pb13 &spi2_miso_pb14 &spi2_mosi_pb15>;
81	cs-gpios = <&gpiob 12 GPIO_ACTIVE_LOW>;
82	status = "okay";
83
84	spi_nor: spi_nor@0 {
85		status = "okay";
86		compatible = "jedec,spi-nor";
87		reg = <0>;
88		spi-max-frequency = <8000000>;
89		label = "SPI_FLASH_0";
90		size = <1048576>;
91		/*
92		 * Main flash source
93		 *
94		 * Vendor     : Puya
95		 * Model      : P25Q21H
96		 * Total size : 256 KB
97		 * Erase size : whole chip, 64 and 32 KB blocks, 4 KB sectors,
98		 *              256 B pages
99		 * Write size : up to 256 B (page size)
100		 * Lifetime   : 100K erase/program cycles on each sector/block
101		 */
102		jedec-id = [85 40 12];
103		/*
104		 * Alternate flash source
105		 *
106		 * Vendor     : Fudan
107		 * Model      : FM25F01B
108		 * Total size : 128 KB
109		 * Erase size : whole chip, 64 and 32 KB blocks, 4 KB sectors
110		 * Write size : up to 256 B (page size)
111		 * Lifetime   : 100K erase/program cycles on each sector/block
112		 *
113		 * jedec-id = [a1 31 11];
114		 *
115		 * Model only found in first Jordan (2"5) EVT revision
116		 *
117		 * Vendor     : Fudan
118		 * Model      : FM25F005
119		 * Total size : 64 KB
120		 * Erase size : whole chip, 64 and 32 KB blocks, 4 KB sectors
121		 *
122		 * jedec-id = [a1 31 10];
123		 */
124		partitions {
125			compatible = "fixed-partitions";
126			#address-cells = <1>;
127			#size-cells = <1>;
128
129			product_info: partition@0 {
130				label = "product-info";
131				reg = <0x00000000 0x1000>;
132			};
133			led_das: partition@10000 {
134				label = "led-das";
135				reg = <0x00001000 0x0000f000>;
136			};
137		};
138	};
139};
140
141&spi_nor {
142	status = "okay";
143};
144
145&dma1 {
146	status = "okay";
147};
148
149&timers3 {
150	pwm3: pwm {
151		pinctrl-0 = <&tim3_ch3_pb0>;
152		/*
153		 * The maximum period needed on Legend devices for activity LED
154		 * hardware blinking is 250ms (i.e. "error" fast blink at 4 Hz).
155		 *
156		 * We can use the following equation to compute the
157		 * corresponding prescaler value:
158		 *
159		 * period_max = counter_size / cycles_per_second
160		 *
161		 * With:
162		 *
163		 * cycles_per_second = 48 MHz / (prescaler + 1)
164		 * counter_size = 2^16
165		 * period_max = 0.25
166		 *
167		 * Which gives:
168		 *
169		 * prescaler = 48 MHz * 0.25 / 2^16 + 1 = 182
170		 *
171		 * So any prescaler value above 182 is good for a 4 Hz hardware
172		 * blinking. In addition the PWM frequency must be as high as
173		 * possible to fool eyes and cameras with steady brightness
174		 * levels.
175		 */
176		st,prescaler = <200>;
177		status = "disabled";
178	};
179};
180
181&gpiod {
182	status = "disabled";
183};
184
185&gpiof {
186	status = "disabled";
187};
188
189&iwdg {
190	status = "okay";
191};
192