diff --git a/CODEOWNERS b/CODEOWNERS index 224d8377721..d2bf0acc564 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -100,6 +100,7 @@ /boards/arm/hexiwear*/ @MaureenHelm @mmahadevan108 @dleach02 /boards/arm/hexiwear*/doc/ @MaureenHelm @MeganHansen /boards/arm/ip_k66f/ @parthitce @lmajewski +/boards/arm/legend/ @mbittan @simonguinot /boards/arm/lpcxpresso*/ @MaureenHelm @mmahadevan108 @dleach02 /boards/arm/lpcxpresso*/doc/ @MaureenHelm @MeganHansen /boards/arm/mimx8mm_evk/ @Mani-Sadhasivam diff --git a/boards/arm/legend/Kconfig.board b/boards/arm/legend/Kconfig.board new file mode 100644 index 00000000000..6820a8c0dcd --- /dev/null +++ b/boards/arm/legend/Kconfig.board @@ -0,0 +1,8 @@ +# Legend board family configuration + +# Copyright (c) 2021 Seagate Technology +# SPDX-License-Identifier: Apache-2.0 + +config BOARD_LEGEND + bool "Legend board" + depends on SOC_STM32F070XB diff --git a/boards/arm/legend/Kconfig.defconfig b/boards/arm/legend/Kconfig.defconfig new file mode 100644 index 00000000000..06c47f232fd --- /dev/null +++ b/boards/arm/legend/Kconfig.defconfig @@ -0,0 +1,15 @@ +# Legend board family configuration + +# Copyright (c) 2021, Seagate Technology LLC +# SPDX-License-Identifier: Apache-2.0 + +if BOARD_LEGEND + +config BOARD + default "legend" + +config SPI_STM32_INTERRUPT + default y + depends on SPI + +endif # BOARD_LEGEND diff --git a/boards/arm/legend/board.cmake b/boards/arm/legend/board.cmake new file mode 100644 index 00000000000..f154f6bc8fa --- /dev/null +++ b/boards/arm/legend/board.cmake @@ -0,0 +1,6 @@ +# SPDX-License-Identifier: Apache-2.0 + +board_runner_args(jlink "--device=STM32F070CB" "--speed=4000") + +include(${ZEPHYR_BASE}/boards/common/openocd.board.cmake) +include(${ZEPHYR_BASE}/boards/common/jlink.board.cmake) diff --git a/boards/arm/legend/doc/img/firecuda_gaming_hard_drive.png b/boards/arm/legend/doc/img/firecuda_gaming_hard_drive.png new file mode 100644 index 00000000000..d307b423339 Binary files /dev/null and b/boards/arm/legend/doc/img/firecuda_gaming_hard_drive.png differ diff --git a/boards/arm/legend/doc/index.rst b/boards/arm/legend/doc/index.rst new file mode 100644 index 00000000000..6d6e2e33b58 --- /dev/null +++ b/boards/arm/legend/doc/index.rst @@ -0,0 +1,131 @@ +.. _legend: + +Legend +###### + +Overview +******** +The Legend board family contains two revisions: 25hdd and 25ssd. + +The Legend 2.5" HDD board (revision 25hdd) can be found in the Seagate FireCuda +Gaming Hard Drive, Gaming Drive for Xbox and Gaming Drive for PlayStation +devices. A 2.5" drive and two chips are embedded: an ASMedia ASM1153 USB-to-SATA +bridge controller and a STM32F070 MCU. The former is handling the USB to HDD I/Os +while the latter is dedicated to the LED effects. The two chips are connected +together through I2C. + +The Legend 2.5" SSD board (revision 25ssd) is found in the Seagate SSD Gaming +Drive for Xbox. A Realtek RTS5411S USB hub is embedded and connected to a Phison +U17 2.5" SSD, as well as a STM32F070 MCU. + +On both boards, the Zephyr port is running on the STM32F070 MCU. + +.. image:: img/firecuda_gaming_hard_drive.png + :width: 750px + :align: center + :alt: Seagate FireCuda Gaming Hard Drive + +Hardware +******** + +- STM32F070cb MCU: + + - ARM Cortex-M0+ + - 16KB SRAM + - 128KB on-chip flash + +- External devices connected to the STM32F070cb MCU: + + - ASMedia ASM1153 USB-to-SATA bridge (I2C master on port 1) (HDD only) + - 6 (hdd) or 4 (ssd) Everlight B1414 LEDs connected on SPI1 MOSI + - 1 white LED (HDD only) + - 64KB external SPI flash connected on SPI2 + +Supported Features +================== + +All the hardware features available on the Legend 2.5" boards are supported by +Zephyr. + ++-----------+------------+-------------------------------------+ +| Interface | Controller | Driver/Component | ++===========+============+=====================================+ +| NVIC | on-chip | nested vector interrupt controller | ++-----------+------------+-------------------------------------+ +| SYSTICK | on-chip | systick | ++-----------+------------+-------------------------------------+ +| CLOCK | on-chip | clock and reset control | ++-----------+------------+-------------------------------------+ +| GPIO | on-chip | gpio | ++-----------+------------+-------------------------------------+ +| I2C | on-chip | i2c master/slave controller | ++-----------+------------+-------------------------------------+ +| UART | on-chip | serial | ++-----------+------------+-------------------------------------+ +| SPI flash | on-chip | spi_nor | ++-----------+------------+-------------------------------------+ +| LED strip | on-chip | ws2812 | ++-----------+------------+-------------------------------------+ +| USB | on-chip | usb | ++-----------+------------+-------------------------------------+ + + +Connections and IOs +=================== + ++---------+-----------------+----------------------------+ +| Name | Function | Usage | ++=========+=================+============================+ +| PB6 | I2C1 | I2C1 SCL (HDD only) | ++---------+-----------------+----------------------------+ +| PB7 | I2C1 | I2C1 SDA (HDD only) | ++---------+-----------------+----------------------------+ +| PA10 | UART | USART0 RX | ++---------+-----------------+----------------------------+ +| PA9 | UART | USART0 TX | ++---------+-----------------+----------------------------+ +| PB0 | PWM | Activity LED (HDD only) | ++---------+-----------------+----------------------------+ +| PB12 | SPI2 | SPI2 Enable | ++---------+-----------------+----------------------------+ +| PB13 | SPI2 | SPI2 Clock | ++---------+-----------------+----------------------------+ +| PB14 | SPI2 | SPI2 MISO | ++---------+-----------------+----------------------------+ +| PB15 | SPI2 | SPI2 MOSI | ++---------+-----------------+----------------------------+ +| PA7 | LED strip | SPI1 MOSI | ++---------+-----------------+----------------------------+ +| PA12 | USB | USB DM (SSD only) | ++---------+-----------------+----------------------------+ +| PA13 | USB | USB DP (SSD only) | ++---------+-----------------+----------------------------+ + +Programming and Debugging +************************* + +Flashing +======== + +The STM32F070cb MCU can be flashed by connecting an external debug probe to the +SWD port (on-board 4-pin header). In the default OpenOCD configuration, the +ST Link interface is selected. You may need to replace it with the interface of +your debug probe. + +Once the debug probe is connected to both the Legend board and your host +computer, then you can simply run the ``west flash`` command to write a firmware +image into flash. + +Debugging +========= + +Please refer to the `Flashing`_ section and run the ``west debug`` command +instead of ``west flash``. + +References +********** + +- `STM32F070 reference manual`_ + +.. _STM32F070 reference manual: + http://www.st.com/resource/en/reference_manual/dm00031936.pdf diff --git a/boards/arm/legend/legend.dts b/boards/arm/legend/legend.dts new file mode 100644 index 00000000000..87d04152ba4 --- /dev/null +++ b/boards/arm/legend/legend.dts @@ -0,0 +1,191 @@ +/* + * Copyright (c) 2021 Seagate Technology LLC + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/dts-v1/; +#include +#include +#include +#include + +/ { + chosen { + zephyr,console = &usart1; + zephyr,shell-uart = &usart1; + zephyr,sram = &sram0; + zephyr,flash = &flash0; + }; + + aliases { + watchdog0 = &iwdg; + }; + + board_id: brd-id { + compatible = "gpio-keys"; + brd_id0: brd_id_0 { + label = "BRD_ID_0"; + gpios = <&gpioc 13 0>; + }; + brd_id1: brd_id_1 { + label = "BRD_ID_1"; + gpios = <&gpioc 14 0>; + }; + brd_id2: brd_id_2 { + label = "BRD_ID_2"; + gpios = <&gpioc 15 0>; + }; + }; + +}; + +&usart1 { + pinctrl-0 = <&usart1_tx_pa9 &usart1_rx_pa10>; + current-speed = <115200>; + status = "okay"; +}; + +&i2c1 { + pinctrl-0 = <&i2c1_scl_pb6 &i2c1_sda_pb7>; + clock-frequency = ; + status = "okay"; +}; + +&spi1 { + pinctrl-0 = <&spi1_sck_pa5 &spi1_miso_pa6 &spi1_mosi_pa7>; + dmas = <&dma1 3 0x20440>, <&dma1 2 0x20480>; + dma-names = "tx", "rx"; + status = "okay"; + + led_strip_spi: b1414@0 { + compatible = "everlight,b1414", "worldsemi,ws2812-spi"; + label = "B1414"; + + /* SPI */ + reg = <0>; /* ignored, but necessary for SPI bindings */ + spi-max-frequency = ; + + /* B1414 */ + spi-one-frame = ; + spi-zero-frame = ; + color-mapping = , + , + ; + reset-delay = <250>; + }; +}; + +&spi2 { + pinctrl-0 = <&spi2_sck_pb13 &spi2_miso_pb14 &spi2_mosi_pb15>; + cs-gpios = <&gpiob 12 GPIO_ACTIVE_LOW>; + status = "okay"; + + spi_nor: spi_nor@0 { + status = "okay"; + compatible = "jedec,spi-nor"; + reg = <0>; + spi-max-frequency = <8000000>; + label = "SPI_FLASH_0"; + size = <1048576>; + /* + * Main flash source + * + * Vendor : Puya + * Model : P25Q21H + * Total size : 256 KB + * Erase size : whole chip, 64 and 32 KB blocks, 4 KB sectors, + * 256 B pages + * Write size : up to 256 B (page size) + * Lifetime : 100K erase/program cycles on each sector/block + */ + jedec-id = [85 40 12]; + /* + * Alternate flash source + * + * Vendor : Fudan + * Model : FM25F01B + * Total size : 128 KB + * Erase size : whole chip, 64 and 32 KB blocks, 4 KB sectors + * Write size : up to 256 B (page size) + * Lifetime : 100K erase/program cycles on each sector/block + * + * jedec-id = [a1 31 11]; + * + * Model only found in first Jordan (2"5) EVT revision + * + * Vendor : Fudan + * Model : FM25F005 + * Total size : 64 KB + * Erase size : whole chip, 64 and 32 KB blocks, 4 KB sectors + * + * jedec-id = [a1 31 10]; + */ + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + product_info: partition@0 { + label = "product-info"; + reg = <0x00000000 0x1000>; + }; + led_das: partition@10000 { + label = "led-das"; + reg = <0x00001000 0x0000f000>; + }; + }; + }; +}; + +&spi_nor { + status = "okay"; +}; + +&dma1 { + status = "okay"; +}; + +&timers3 { + pwm3: pwm { + pinctrl-0 = <&tim3_ch3_pb0>; + /* + * The maximum period needed on Legend devices for activity LED + * hardware blinking is 250ms (i.e. "error" fast blink at 4 Hz). + * + * We can use the following equation to compute the + * corresponding prescaler value: + * + * period_max = counter_size / cycles_per_second + * + * With: + * + * cycles_per_second = 48 MHz / (prescaler + 1) + * counter_size = 2^16 + * period_max = 0.25 + * + * Which gives: + * + * prescaler = 48 MHz * 0.25 / 2^16 + 1 = 182 + * + * So any prescaler value above 182 is good for a 4 Hz hardware + * blinking. In addition the PWM frequency must be as high as + * possible to fool eyes and cameras with steady brightness + * levels. + */ + st,prescaler = <200>; + status = "disabled"; + }; +}; + +&gpiod { + status = "disabled"; +}; + +&gpiof { + status = "disabled"; +}; + +&iwdg { + status = "okay"; +}; diff --git a/boards/arm/legend/legend.yaml b/boards/arm/legend/legend.yaml new file mode 100644 index 00000000000..b8c8d7d7628 --- /dev/null +++ b/boards/arm/legend/legend.yaml @@ -0,0 +1,19 @@ +identifier: legend +name: Legend +type: mcu +arch: arm +ram: 16 +flash: 128 +toolchain: + - zephyr + - gnuarmemb + - xtools +supported: + - gpio + - i2c + - pwm + - spi +testing: + ignore_tags: + - net + - bluetooth diff --git a/boards/arm/legend/legend_25hdd.overlay b/boards/arm/legend/legend_25hdd.overlay new file mode 100644 index 00000000000..9a82a092299 --- /dev/null +++ b/boards/arm/legend/legend_25hdd.overlay @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2021 Seagate Technology LLC + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/ { + model = "Seagate Legend 2.5 HDD board"; + compatible = "legend25_hdd", "seagate,legend25_hdd"; + + aliases { + pwm-led0 = &pwm_led0; + led-strip = &led_strip_spi; + }; + + led_pwm: pwmleds { + compatible = "pwm-leds"; + label = "LED PWM"; + + pwm_led0: pwm_led_0 { + label = "Activity LED"; + pwms = <&pwm3 3 255 PWM_POLARITY_NORMAL>; + }; + }; +}; + +&clk_hsi { + status = "okay"; +}; + +&pll { + clocks = <&clk_hsi>; + prediv = <1>; + mul = <6>; + status = "okay"; +}; + +&rcc { + clocks = <&pll>; + clock-frequency = ; + ahb-prescaler = <1>; + apb1-prescaler = <1>; +}; + +&led_strip_spi { + chain-length = <6>; + status = "okay"; +}; + +&timers3 { + status = "okay"; +}; + +&pwm3 { + status = "okay"; +}; diff --git a/boards/arm/legend/legend_25ssd.overlay b/boards/arm/legend/legend_25ssd.overlay new file mode 100644 index 00000000000..2f0f4d19baf --- /dev/null +++ b/boards/arm/legend/legend_25ssd.overlay @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2021 Seagate Technology LLC + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/ { + model = "Seagate Legend 2.5 SSD board"; + compatible = "legend25_ssd", "seagate,legend25_ssd"; + + aliases { + led-strip = &led_strip_spi; + }; +}; + +&clk_hse { + clock-frequency = ; /* 24MHz external clock */ + status = "okay"; +}; + +&pll { + clocks = <&clk_hse>; + prediv = <1>; + mul = <2>; + status = "okay"; +}; + +&rcc { + clocks = <&pll>; + clock-frequency = ; + ahb-prescaler = <1>; + apb1-prescaler = <1>; +}; + +&led_strip_spi { + chain-length = <4>; + status = "okay"; +}; + +&usb { + status = "okay"; +}; diff --git a/boards/arm/legend/legend_defconfig b/boards/arm/legend/legend_defconfig new file mode 100644 index 00000000000..63720f0538f --- /dev/null +++ b/boards/arm/legend/legend_defconfig @@ -0,0 +1,23 @@ +# SPDX-License-Identifier: Apache-2.0 + +# Zephyr Kernel Configuration +CONFIG_SOC_SERIES_STM32F0X=y + +# Platform Configuration +CONFIG_SOC_STM32F070XB=y + +# Serial Drivers +CONFIG_SERIAL=y +CONFIG_UART_INTERRUPT_DRIVEN=y +# enable console +CONFIG_CONSOLE=y +CONFIG_UART_CONSOLE=y + +# Pinmux Driver +CONFIG_PINMUX=y + +# GPIO Controller +CONFIG_GPIO=y + +# Clock Control +CONFIG_CLOCK_CONTROL=y diff --git a/boards/arm/legend/revision.cmake b/boards/arm/legend/revision.cmake new file mode 100644 index 00000000000..c51bf31b529 --- /dev/null +++ b/boards/arm/legend/revision.cmake @@ -0,0 +1,8 @@ +set(LEGEND_REVISIONS "25hdd" "25ssd") +if (NOT DEFINED BOARD_REVISION) + set(BOARD_REVISION "25hdd") +else() + if (NOT BOARD_REVISION IN_LIST LEGEND_REVISIONS) + message(FATAL_ERROR "${BOARD_REVISION} is not a valid revision for Legend. Accepted revisions: ${LEGEND_REVISIONS}") + endif() +endif() diff --git a/boards/arm/legend/support/openocd.cfg b/boards/arm/legend/support/openocd.cfg new file mode 100644 index 00000000000..f0d0b22a310 --- /dev/null +++ b/boards/arm/legend/support/openocd.cfg @@ -0,0 +1,12 @@ +source [find board/st_nucleo_f0.cfg] + +$_TARGETNAME configure -event gdb-attach { + echo "Debugger attaching: halting execution" + reset halt + gdb_breakpoint_override hard +} + +$_TARGETNAME configure -event gdb-detach { + echo "Debugger detaching: resuming execution" + resume +} diff --git a/include/dt-bindings/led/seagate_legend_b1414.h b/include/dt-bindings/led/seagate_legend_b1414.h new file mode 100644 index 00000000000..e7f5b8a315d --- /dev/null +++ b/include/dt-bindings/led/seagate_legend_b1414.h @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2021, Seagate Technology LLC + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ZEPHYR_SAMPLES_DRIVERS_LED_B1414_H_ +#define ZEPHYR_SAMPLES_DRIVERS_LED_B1414_H_ + +/* + * At 6 MHz: 1 bit in 166.666 ns + * 1200 ns -> 7.2 bits + * 300 ns -> 1.8 bits + * 900 ns -> 5.4 bits + */ +#define SPI_FREQ 6000000 +#define ZERO_FRAME 0x60 +#define ONE_FRAME 0x7C + +#endif