--- zzzz-none-000/linux-4.9.279/drivers/mmc/host/sdhci.h 2021-08-08 06:38:54.000000000 +0000 +++ puma7-arm-6591-750/linux-4.9.279/drivers/mmc/host/sdhci.h 2023-02-08 10:58:13.000000000 +0000 @@ -10,6 +10,13 @@ * the Free Software Foundation; either version 2 of the License, or (at * your option) any later version. */ + +/* + * Includes Intel Corporation's changes/modifications dated: 2017-2018. + * Changed/modified portions - Copyright © 2017-2018 , Intel Corporation. + */ + + #ifndef __SDHCI_HW_H #define __SDHCI_HW_H @@ -20,6 +27,11 @@ #include +#if (defined(CONFIG_ARCH_GEN3) && defined(CONFIG_HW_MUTEXES)) +#include +#include +#endif + /* * Controller registers */ @@ -69,6 +81,9 @@ #define SDHCI_SPACE_AVAILABLE 0x00000400 #define SDHCI_DATA_AVAILABLE 0x00000800 #define SDHCI_CARD_PRESENT 0x00010000 +#ifdef CONFIG_ARCH_GEN3 +#define SDHCI_CARD_IS_STABLE 0x00020000 +#endif #define SDHCI_WRITE_PROTECT 0x00080000 #define SDHCI_DATA_LVL_MASK 0x00F00000 #define SDHCI_DATA_LVL_SHIFT 20 @@ -426,6 +441,13 @@ #define SDHCI_QUIRK2_ACMD23_BROKEN (1<<14) /* Broken Clock divider zero in controller */ #define SDHCI_QUIRK2_CLOCK_DIV_ZERO_BROKEN (1<<15) +#ifdef CONFIG_ARCH_GEN3 +/* Two or more processors access the controller, HW mutex is needed to avoid + control conflicts. */ +#define SDHCI_QUIRK2_HW_MUTEX (1<<16) +/* Don't execute HS200 tuning */ +#define SDHCI_QUIRK2_DONT_TUNE_HS200 (1<<17) +#endif int irq; /* Device IRQ */ void __iomem *ioaddr; /* Mapped address */ @@ -459,6 +481,10 @@ #define SDHCI_SIGNALING_330 (1<<14) /* Host is capable of 3.3V signaling */ #define SDHCI_SIGNALING_180 (1<<15) /* Host is capable of 1.8V signaling */ #define SDHCI_SIGNALING_120 (1<<16) /* Host is capable of 1.2V signaling */ +#ifdef CONFIG_ARCH_GEN3 +/* Two or more processors access the controller, HW Mutex is necessary to avoid confliction*/ +#define SDHCI_DISABLE_REGISTER_WRITE (1<<17) /* Disable write on Host Driver - for non-destructive initialization */ +#endif unsigned int version; /* SDHCI spec. version */ @@ -522,10 +548,18 @@ unsigned int tuning_count; /* Timer count for re-tuning */ unsigned int tuning_mode; /* Re-tuning mode supported by host */ +#if (defined(CONFIG_ARCH_GEN3) && defined(CONFIG_HW_MUTEXES)) + unsigned int irq_enable_count; /* Count to enable recursive locking */ +#endif + #define SDHCI_TUNING_MODE_1 0 #define SDHCI_TUNING_MODE_2 1 #define SDHCI_TUNING_MODE_3 2 +#ifdef CONFIG_ARCH_GEN3 + struct task_struct *irq_thread; +#endif + unsigned long private[0] ____cacheline_aligned; }; @@ -699,4 +733,49 @@ extern int sdhci_runtime_resume_host(struct sdhci_host *host); #endif +#if (defined(CONFIG_ARCH_GEN3) && defined(CONFIG_HW_MUTEXES)) + +void sdhci_clock_gating(struct sdhci_host *host, bool enable); + +extern void sdhci_dump_status(struct sdhci_host *host); + +#define SDHCI_HOST_SUPPORTS_HW_MUTEX(sdhci) \ + ((sdhci)->quirks2 & SDHCI_QUIRK2_HW_MUTEX) +#define MMC_HOST_SUPPORTS_HW_MUTEX(mmc) SDHCI_HOST_SUPPORTS_HW_MUTEX( ((struct sdhci_host*)mmc->private)) + +#define EMMC_HW_MUTEX_IS_LOCKED() hw_mutex_is_locked(HW_MUTEX_EMMC) + +#define MMC_LOCK_HW_MUTEX(mmc) \ +do { \ + struct sdhci_host *sdhci = (struct sdhci_host*)mmc->private; \ + if (SDHCI_HOST_SUPPORTS_HW_MUTEX(sdhci)) \ + { \ + hw_mutex_lock(HW_MUTEX_EMMC); \ + sdhci_clock_gating(sdhci, 1); \ + if (sdhci->irq_enable_count == 0) \ + { \ + enable_irq(sdhci->irq); \ + } \ + sdhci->irq_enable_count++; \ + } \ +} while(0) + +#define MMC_UNLOCK_HW_MUTEX(mmc) \ +do{ \ + struct sdhci_host *sdhci = (struct sdhci_host*)mmc->private; \ + if (SDHCI_HOST_SUPPORTS_HW_MUTEX(sdhci)) \ + { \ + WARN_ON(sdhci->irq_enable_count == 0); \ + if (sdhci->irq_enable_count == 1) \ + { \ + disable_irq(sdhci->irq); \ + } \ + sdhci->irq_enable_count -= (sdhci->irq_enable_count == 0) ? 0 : 1; \ + sdhci_clock_gating(sdhci, 0); \ + hw_mutex_unlock(HW_MUTEX_EMMC); \ + } \ +} while(0) + +#endif /* CONFIG_ARCH_GEN3 */ + #endif /* __SDHCI_HW_H */