Commit graph

82 commits

Author SHA1 Message Date
Benjamin Cabé
dcec4ee653 driver: sdhc: fix typo in SAM4E hsmci driver
Fix parameter name (HSMCI -> hsmci)

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2025-06-17 16:12:17 +02:00
Khoa Nguyen
463f518192 drivers: Update dtc transfer info alignment
Update dtc transfer info alignment for Renesas drivers

Signed-off-by: Khoa Nguyen <khoa.nguyen.xh@renesas.com>
2025-05-30 10:26:34 +02:00
Jiafei Pan
51e0fcf80c drivers: sdhc: imx_usdhc: enable MMIO mapping
Enable MMIO mapping in the driver.

Signed-off-by: Jiafei Pan <Jiafei.Pan@nxp.com>
2025-05-12 16:47:49 +02:00
Jiafei Pan
819125f726 drivers: sdhc: imx_usdhc: run clang-format on the driver
Format the driver by using clang-format.

Signed-off-by: Jiafei Pan <Jiafei.Pan@nxp.com>
2025-05-12 16:47:49 +02:00
Paul Alvin
327c78ec0a drivers: sdhc: Add driver support for xlnx SDHC
Add driver support for xlnx SD/EMMC host controller. The driver
currently support SD host controller version 3.0 and EMMC host
controller version 5.1. This driver functions with the SDHC subsystem to
perform operations on device.

Driver support both interrupt and polled mode data transfer. Uses ADMA2
to perform data transfer.

Signed-off-by: Paul Alvin <alvin.paulp@amd.com>
2025-04-28 12:56:50 -05:00
Pieter De Gendt
7b1d748e8b drivers: Wrap device driver APIs using DEVICE_API macro
Put the device APIs in their respective linker sections with the
DEVICE_API wrapper macro.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2025-04-28 13:41:03 +02:00
Hao Luo
6f4b92d64d soc: ambiq: Optimize the inclusion relationship of header files
Optimized the inclusion relationship of header files

Signed-off-by: Hao Luo <hluo@ambiq.com>
2025-04-17 09:06:18 +02:00
Darren Lu
129ccf981c drivers: sdhc: add sdhc driver for Ambiq MCU
Add SDHC/SDIO driver support for Ambiq Apollo4 MCU.

Signed-off-by: Darren Lu <dlu@ambiq.com>
2025-04-11 06:33:24 +02:00
Khoa Nguyen
c768144002 drivers: Correct value of event macro for all Renesas SoC
Since the RA2L1 uses the macro "ICU_EVENT" instead of
"ELC_EVENT" (which is currently used) to input into
the IELSR register, the ek_ra2l1 board cannot assign
any interrupts for any driver.

This commit aim to correct the Event macro to input correct
value for IELSR register on all the Renesas SoC by using
"BSP_PRV_IELS_ENUM" macro.

Signed-off-by: Khoa Nguyen <khoa.nguyen.xh@renesas.com>
2025-02-28 18:29:17 +01:00
Benjamin Cabé
ff9fd96036 drivers: fix spelling of "transfer"
s/trasnfer/transfer/

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2025-02-21 11:41:46 +00:00
Benjamin Cabé
67633f8df5 drivers: sdhc: fix spelling of "programing"
s/programing/programming/

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2025-02-19 18:51:13 +01:00
Jordan Yates
30f88d8bf5 sdhc: sdhc_spi: additional SPI PM calls
`sdhc_spi_card_busy` requires additional PM calls to ensure the bus is
enabled in the API call.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2025-02-17 21:03:47 +01:00
Mert Ekren
b11b640571 drivers: sdhc: Add MAX32666 SDHC driver
This commit adds MAX32666 SDHC driver.

Co-Authored-By: Anil Kara <Anil.Kara@analog.com>
Co-Authored-By: Tahsin Mutlugun <Tahsin.Mutlugun@analog.com>
Signed-off-by: Mert Ekren <mert.ekren@analog.com>
2025-02-14 20:20:03 +01:00
Egill Sigurdur
18acd4ce40 drivers: sdhc: Fix acronym expansion for SD Host Controller in Kconfig
Fixes an issue in which "SDHC" had been incorrectly expanded to
"Secure Digital High Capacity" instead of "SD Host Controller".

Signed-off-by: Egill Sigurdur <egill@egill.xyz>
2025-02-14 19:14:21 +00:00
Thomas Stranger
3652918f5e drivers: sdhc: fix infineon cat1 gpio initialization
Initialize the cyhal_sdio_config, such that the init
function won't do the pin configuration.
The gpios are setup using the zephyr pinctrl driver already.

Before the latest hal update the values were ignored and
the gpio configuration completely skipped.
But this is no longer the case and this commit
fixes that by setting the gpio pins to nc,

Also, explicitly set sdio_config.clock to NULL, to make
it clearer that the driver will check for that.

Signed-off-by: Thomas Stranger <thomas.stranger@outlook.com>
2025-01-29 07:08:58 +01:00
Thomas Stranger
b0583fc9e5 drivers: sdhc: fix infineon cat1 resource type initialization
The driver should use resource type SDHC not SDIODEV.

In a older HAL version the value was not used as parameter
for clock initialization so it didn't matter, but breaks
the initialization of the driver with the latest hal.

Signed-off-by: Thomas Stranger <thomas.stranger@outlook.com>
2025-01-29 07:08:58 +01:00
Tran Van Quy
8f91d0c072 drivers: sdhc: support SDHC driver on Renesas RA8
This is initial commit to support SDHC driver on Renesas RA8
with r_sdhi modules

Signed-off-by: Tran Van Quy <quy.tran.pz@renesas.com>
2024-12-25 06:33:12 +01:00
Jordan Yates
a1ad0ad6c6 sdhc: spi: wait for VDD stable before clocking
The SD physical layer specification requires that the operating supply
be stable for at least 1 millisecond before providing the required 74
clocks. The maximum VDD ramp time is specified at 35ms, giving a total
minimum delay of 36ms.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2024-12-11 07:58:17 +01:00
Jordan Yates
a16bfb39ff sdhc: spi: power card before 74 clock signals
Power on the SD card before sending the required 74 clock signals.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2024-12-11 07:58:17 +01:00
Pieter De Gendt
c4fbec2377 drivers: sdhc: Place API into iterable section
Add wrapper DEVICE_API macro to all sdhc_driver_api instances.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2024-12-02 23:04:22 +01:00
Aymeric Aillet
d41ce536c5 drivers: rcar: Select CONFIG_PINCTRL
Select PINCTRL for drivers: pwm, sdhc, serial

Signed-off-by: Aymeric Aillet <aymeric.aillet@iot.bzh>
2024-11-22 17:41:02 +01:00
Gerson Fernando Budke
0cc8f93e8a soc: atmel: Drop PINCTRL from Kconfig.defconfig
This Kconfig has wrongly been added to defconfig files. It is not the
right place for it. It has never been the right place for it. Drivers
that need it should select the symbol in their Kconfig entries. Drop
PINCTL from Kconfig.defconfig and add proper select at Kconfig.sam*.

Fixes #78619

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
2024-11-04 13:43:26 -06:00
Bill Waters
eb19d32588 drivers: Remove CONFIG_PINCTRL in defconfig files
The CONFIG_PINCTRL setting is removed from the board
_defconfig files.  And "select PINCTRL" is added to
the appropriate driver files.

Signed-off-by: Bill Waters <bill.waters@infineon.com>
2024-09-23 18:08:14 -04:00
Sylvio Alves
0aec059630 drivers: sdhc: esp32: remove unused code
Removed unused entry in SDHC driver and initialize
variables accordingly.

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2024-09-16 20:18:33 +02:00
Raffael Rostagno
90c6106926 drivers: esp32: Interrupts flags configuration
Allows configuring interrupts flags in the device tree for
ESP32 devices.

Signed-off-by: Raffael Rostagno <raffael.rostagno@espressif.com>
2024-08-22 14:25:25 -04:00
Raffael Rostagno
0b3a34cdca drivers: esp32: Interrupts priority configuration
Allows configuring interrupts priority in the device tree for
ESP32 devices.

Signed-off-by: Raffael Rostagno <raffael.rostagno@espressif.com>
2024-08-22 14:25:25 -04:00
Daniel DeGrasse
17f71e19f0 drivers: sdhc: imx_usdhc: assume card is present if no detection method
The imx USDHC driver previously queried the peripheral's internal card
detect signal to check card presence if no card detect method was
configured. However, some boards do not route the card detect signal and
do not work correctly with the DAT3 detection method supported by this
peripheral. As a fallback, assume the card is present in the slot but
log a warning to the user.

Fixes #42227

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2024-08-22 14:19:37 -04:00
Jordan Yates
b3a4b15e4b sdhc: sdhc_spi: handle PM on SPI bus
Handle SPI buses that have device runtime PM enabled.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2024-08-21 18:26:37 +01:00
Jordan Yates
cc84a87e4b sdhc: sdhc_spi: log message on power state change
Add a basic log message when power is applied or removed from the SDHC
card.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2024-08-20 19:42:37 -04:00
Pisit Sawangvonganan
1bcae0ea9f style: drivers: comply with MISRA C:2012 Rule 15.6
Add missing braces to comply with MISRA C:2012 Rule 15.6 and
also following Zephyr's style guideline.

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2024-08-20 10:33:51 +02:00
Raffael Rostagno
847832d8f7 sdhc: esp32: Register writing macros cleanup
Macros to write specific peripheral registers were removed as a
compile flag was added to hal_espressif requesting struct bitfields
to have strict volatile access (thus 32-bit access), allowing for
the cleanup.

Signed-off-by: Raffael Rostagno <raffael.rostagno@espressif.com>
2024-08-17 08:55:37 -04:00
Raffael Rostagno
1857197422 sdhc: esp32: Clock control setting from DTS
Enable SDIO clock using clock control subsystem instead of
low level functions.

Signed-off-by: Raffael Rostagno <raffael.rostagno@espressif.com>
2024-08-17 08:55:37 -04:00
Jordan Yates
5d87cd654f sdhc: sdhc_spi: compile-time determine if sdhc_ones needed
Use the new `SPI_MOSI_OVERRUN_DT` macro to determine at compile-time
whether the 512 byte array of `sdhc_ones` is required.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2024-08-08 06:17:45 -04:00
Lingao Meng
302422ad9d everywhere: replace double words
import os
import re

common_words = set([
    'about', 'after', 'all', 'also', 'an', 'and',
     'any', 'are', 'as', 'at',
    'be', 'because', 'but', 'by', 'can', 'come',
    'could', 'day', 'do', 'even',
    'first', 'for', 'get', 'give', 'go', 'has',
    'have', 'he', 'her',
    'him', 'his', 'how', 'I', 'in', 'into', 'it',
    'its', 'just',
    'know', 'like', 'look', 'make', 'man', 'many',
    'me', 'more', 'my', 'new',
    'no', 'not', 'now', 'of', 'one', 'only', 'or',
    'other', 'our', 'out',
    'over', 'people', 'say', 'see', 'she', 'so',
    'some', 'take', 'tell', 'than',
    'their', 'them', 'then', 'there', 'these',
    'they', 'think',
    'this', 'time', 'two', 'up', 'use', 'very',
    'want', 'was', 'way',
    'we', 'well', 'what', 'when', 'which', 'who',
    'will', 'with', 'would',
    'year', 'you', 'your'
])

valid_extensions = set([
    'c', 'h', 'yaml', 'cmake', 'conf', 'txt', 'overlay',
    'rst', 'dtsi',
    'Kconfig', 'dts', 'defconfig', 'yml', 'ld', 'sh', 'py',
    'soc', 'cfg'
])

def filter_repeated_words(text):
    # Split the text into lines
    lines = text.split('\n')

    # Combine lines into a single string with unique separator
    combined_text = '/*sep*/'.join(lines)

    # Replace repeated words within a line
    def replace_within_line(match):
        return match.group(1)

    # Regex for matching repeated words within a line
    within_line_pattern =
	re.compile(r'\b(' +
		'|'.join(map(re.escape, common_words)) +
		r')\b\s+\b\1\b')
    combined_text = within_line_pattern.
		sub(replace_within_line, combined_text)

    # Replace repeated words across line boundaries
    def replace_across_lines(match):
        return match.group(1) + match.group(2)

    # Regex for matching repeated words across line boundaries
    across_lines_pattern = re.
		compile(r'\b(' + '|'.join(
			map(re.escape, common_words)) +
			r')\b(\s*[*\/\n\s]*)\b\1\b')
    combined_text = across_lines_pattern.
		sub(replace_across_lines, combined_text)

    # Split the text back into lines
    filtered_text = combined_text.split('/*sep*/')

    return '\n'.join(filtered_text)

def process_file(file_path):
    with open(file_path, 'r', encoding='utf-8') as file:
        text = file.read()

    new_text = filter_repeated_words(text)

    with open(file_path, 'w', encoding='utf-8') as file:
        file.write(new_text)

def process_directory(directory_path):
    for root, dirs, files in os.walk(directory_path):
        dirs[:] = [d for d in dirs if not d.startswith('.')]
        for file in files:
            # Filter out hidden files
            if file.startswith('.'):
                continue
            file_extension = file.split('.')[-1]
            if
	file_extension in valid_extensions:  # 只处理指定后缀的文件
                file_path = os.path.join(root, file)
                print(f"Processed file: {file_path}")
                process_file(file_path)

directory_to_process = "/home/mi/works/github/zephyrproject/zephyr"
process_directory(directory_to_process)

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2024-06-25 06:05:35 -04:00
Daniel Leung
db9d3134c5 kernel: mm: rename Z_MEM_PHYS/VIRT_ADDR to K_MEM_*
This is part of a series to move memory management functions
away from the z_ namespace and into its own namespace. Also
make documentation available via doxygen.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2024-06-12 21:13:26 -04:00
Daniel Leung
552e29790d kernel: mm: rename z_phys_un/map to k_mem_*_phys_bare
This renames z_phys_map() and z_phys_unmap() to
k_mem_map_phys_bare() and k_mem_unmap_phys_bare()
respectively. This is part of the series to move memory
management functions away from the z_ namespace.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2024-06-12 21:13:26 -04:00
Daniel DeGrasse
a2087bed16 drivers: sdhc: sdhc_spi: rework CMD12 failure logic
Rework CMD12 failure logic for SDHC SPI driver. Previously, the error
code of CMD12 was not checked, so even if CMD12 failed to send the
initial command would be retried. Change this behavior to retry CMD12
until it succeeds. If CMD12 fails, its error code will be propagated to
the caller. Otherwise, the return code from the command being sent by
the caller will be propagated.

Fixes #72365

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2024-05-17 09:30:12 +02:00
Daniel DeGrasse
cb9d8bac54 drivers: sdhc: sdhc_spi: release bus on error
Properly release SPI bus on transmit error within the SDHC SPI driver.
In these cases return code is not checked, as we wish to return the
error code from the failed transfer to the SD stack.

Fixes #72364

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2024-05-17 09:30:12 +02:00
Daniel DeGrasse
3b718bf1fe drivers: sdhc: rcar_mmc: remove frequency correction code
RCAR MMC driver previously had to report inaccurate maximum supported
frequency to SD subsystem so that the subsystem would select SDR104 mode
timing. Remove this logic, as it should no longer be needed.

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2024-05-16 09:21:03 +02:00
Daniel DeGrasse
bf61a47887 drivers: sdhc: imx_usdhc: extend reset timeout duration
Some instances of the USDHC peripheral take longer to reset, and will
timeout with the previous delay of 100 cycles. Extend this delay to 1000
cycles to resolve this.

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2024-05-14 20:23:28 -04:00
Daniel DeGrasse
da9361e544 drivers: sdhc: imx_usdhc: remove dead code for waiting for clock gate
Remove function for waiting for clock gate, as this is not used anywhere
within the USDHC driver.

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2024-05-14 20:23:28 -04:00
Daniel DeGrasse
bd17c86299 drivers: sdhc: imx_usdhc: move voltage selection to separate function
Some USDHC IP instances do not have the voltage control bit present, as
they can only operate at 3.3V. Move code to select 1.8V mode into a
separate helper, and guard the call to UDSHC_SelectVoltage() behind a
feature macro from MCUX SDK.

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2024-05-14 20:23:28 -04:00
Benjamin Cabé
30ce8b1b18 drivers: fix bad SPDX-License-Identifier header
fix typo in SPDX header

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2024-05-08 09:23:16 -04:00
Mykola Kvach
b8f7fc3cc3 drivers: sdhc: add support of Renesas MMC driver
Add basic functionality of Renesas SD/MMC driver. It can be used
for both gen3 and gen4 R-car boards, but tested only with H3ULCB,
Salvator XS M3 and Spider boards. This driver working with SDHC
subsystem.

The driver supports regularal reading/writing throught SD/MMC
controller buffer, DMA mode w/o interrupts and timing tuning.

Add gpio5 and sd0 nodes to h3ulcb and salvator xs which are needed
for working with SD cards. The GPIO node is needed for switching
voltage on SD card through gpio regulator driver.

Notes:
    * the driver doesn't support SPI mode;
    * SCC tuning and DMA mode based on IRQs are enabled by default;
    * an address of a data buffer has to be aligned to 128 bytes if it
      is not, driver will use non-DMA mode automatically;
    * Renesas MMC DMAC doesn't support 64-bit DMA addresses, so for
      case when we have 64-bit xref data address we use non-DMA mode;
    * SD/MMC controller supports block size between 512 and 1 with
      a lot of restrictions, more details you can find in code;
    * support of HS400 mode isn't implemented inside driver.

Signed-off-by: Mykola Kvach <mykola_kvach@epam.com>
2024-05-01 10:55:11 -04:00
Raffael Rostagno
f4a6fd1f3f drivers: esp32: SDHC implementation
Implementation of SDHC driver for ESP32

Signed-off-by: Raffael Rostagno <raffael.rostagno@espressif.com>
2024-04-30 18:23:06 +02:00
Pisit Sawangvonganan
e7875de3f9 drivers: sdhc: set 'sdhc_driver_api' as 'static const'
This change marks each instance of the 'api' as 'static const'.
The rationale is that 'api' is used for declaring internal
module interfaces and is not intended to be modified at runtime.
By using 'static const', we ensure immutability, leading to usage of only
.rodata and a reduction in the .data area.

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2024-01-24 21:25:06 +00:00
Daniel DeGrasse
429188723e drivers: sdhc: sdhc_spi: wait for card response until cmd timeout
In sdhc_spi_response_get, the logic for slow cards previously only
retried reads 16 times. Instead of using this approach, read from the
card every 10 ms until the command timeout is reached or it responds.
This way, the command timeout will be respected for cards that do not
respond.

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2024-01-20 12:44:02 +01:00
Tanmay Kathpalia
aeb25e3da1 drivers: sdhc: Cadence SDHC driver bug fixes and other improvements
* Internal Clock not getting stable during initialization
* SD clock was not enabled
* Removed duplicate file.
* Removed write to readonly registers
* Moved function pointer structure from data section to RO section
* Wrong macro names
* Refactoring of lower layer header file.

Signed-off-by: Tanmay Kathpalia <tanmay.kathpalia@intel.com>
2024-01-19 15:14:17 +00:00
Anisetti Avinash Krishna
eb2cd31407 drivers: sdhc: intel_emmc_host: Fix return value
Fixes uninitialized variable return by returning zero
at the end of function.

Signed-off-by: Anisetti Avinash Krishna <anisetti.avinash.krishna@intel.com>
2023-12-19 08:52:00 +01:00
Murlidhar Roy
eb006b992f drivers: sdhc: add cdns sdhc/combophy driver files
Add SDHC driver files with new SD framework changes
SDHC driver includes combophy configurations.

Added mmc binding yaml file

Signed-off-by: Murlidhar Roy <murlidhar.roy@intel.com>
2023-12-18 15:00:38 +01:00