ricardgb opened a new pull request, #22465:
URL: https://github.com/apache/nuttx/pull/22465

   ## Summary
   
   Fixes #22464.
   
   Two commits, both in `arch/xtensa/src/esp32s3/esp32s3_qspi.c`:
   
   1. **Link with `CONFIG_ESP32S3_SPI_DMA`.** `esp32s3_qspi_alloc()` uses 
`ALIGN_UP()` without the
      header that defines it; every configuration that uses the QSPI bus with 
DMA failed to link
      with an undefined reference to `ALIGN_UP`. Include `nuttx/nuttx.h`.
   2. **`esp32s3_qspi_setmode()`.** It changed `SPI_MISC_REG` and 
`SPI_USER_REG` with
      `regval &= MASK` where `regval &= ~MASK` was meant: the other bits of 
both registers were
      cleared (`SPI_CS1_DIS`, `SPI_CS2_DIS`, `SPI_USR_MOSI`, `SPI_CS_HOLD`), 
and a mode bit that
      was set could not be cleared again. Clear only the bit that is changed.
   
   ## Impact
   
   ESP32-S3, QSPI bus (`CONFIG_ESP32S3_SPI_IO_QIO`) only. The first commit 
makes configurations
   with `CONFIG_ESP32S3_SPI_DMA` link; no change of code that linked before. 
The second changes
   the registers only for users of an SPI mode other than 0 (mode 0 after the 
initialization
   returns early, before and after this PR).
   
   ## Testing
   
   Host: Ubuntu, GCC 13 / xtensa-esp32s3-elf-gcc. Master `a63275cdce8`.
   
   **Link:** `esp32s3-devkit:eth_lan9250` with `LAN9250_SQI`, 
`ESP32S3_SPI_IO_QIO` and
   `ESP32S3_SPI_DMA` (the steps of the issue):
   
   | | Result |
   |---|---|
   | master | `undefined reference to 'ALIGN_UP'` |
   | this PR | links, `nuttx.bin` generated; the warning is gone |
   
   Build only: I have no LAN9250.
   
   **setmode:** custom ESP32-S3 board (rev v0.2) with a QSPI display on SPI2, 
registers read after
   each call:
   
   | After | `SPI_MISC_REG` master | `SPI_USER_REG` master | `SPI_MISC_REG` 
this PR | `SPI_USER_REG` this PR |
   |---|---|---|---|---|
   | `esp32s3_qspibus_initialize()` | `00000006` | `08000040` | `00000006` | 
`08000040` |
   | `QSPI_SETMODE(MODE3)` | `20000000` | `00000000` | `20000006` | `08000040` |
   | `QSPI_SETMODE(MODE0)` | `20000000` | `00000000` | `00000006` | `08000040` |
   
   On the same board, with this PR: the display (AXS15231B, needs mode 3, 40 
MHz, pixels through
   `QSPI_MEMORY()` with DMA, commands through `QSPI_COMMAND()`) shows its 
picture with
   `QSPI_SETMODE(MODE3)`.
   
   `./tools/checkpatch.sh -g HEAD~2..HEAD`: all checks pass.
   
   *Disclosure: this change was prepared with the help of an AI agent (Claude 
Code, Anthropic); it
   was tested on real hardware and human-reviewed.*
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to