mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-18 16:56:53 +07:00
92a578b064
This time we have some more new material than we used to have during the last couple of development cycles. The most important part of it to me is the introduction of a unified interface for accessing device properties provided by platform firmware. It works with Device Trees and ACPI in a uniform way and drivers using it need not worry about where the properties come from as long as the platform firmware (either DT or ACPI) makes them available. It covers both devices and "bare" device node objects without struct device representation as that turns out to be necessary in some cases. This has been in the works for quite a few months (and development cycles) and has been approved by all of the relevant maintainers. On top of that, some drivers are switched over to the new interface (at25, leds-gpio, gpio_keys_polled) and some additional changes are made to the core GPIO subsystem to allow device drivers to manipulate GPIOs in the "canonical" way on platforms that provide GPIO information in their ACPI tables, but don't assign names to GPIO lines (in which case the driver needs to do that on the basis of what it knows about the device in question). That also has been approved by the GPIO core maintainers and the rfkill driver is now going to use it. Second is support for hardware P-states in the intel_pstate driver. It uses CPUID to detect whether or not the feature is supported by the processor in which case it will be enabled by default. However, it can be disabled entirely from the kernel command line if necessary. Next is support for a platform firmware interface based on ACPI operation regions used by the PMIC (Power Management Integrated Circuit) chips on the Intel Baytrail-T and Baytrail-T-CR platforms. That interface is used for manipulating power resources and for thermal management: sensor temperature reporting, trip point setting and so on. Also the ACPI core is now going to support the _DEP configuration information in a limited way. Basically, _DEP it supposed to reflect off-the-hierarchy dependencies between devices which may be very indirect, like when AML for one device accesses locations in an operation region handled by another device's driver (usually, the device depended on this way is a serial bus or GPIO controller). The support added this time is sufficient to make the ACPI battery driver work on Asus T100A, but it is general enough to be able to cover some other use cases in the future. Finally, we have a new cpufreq driver for the Loongson1B processor. In addition to the above, there are fixes and cleanups all over the place as usual and a traditional ACPICA update to a recent upstream release. As far as the fixes go, the ACPI LPSS (Low-power Subsystem) driver for Intel platforms should be able to handle power management of the DMA engine correctly, the cpufreq-dt driver should interact with the thermal subsystem in a better way and the ACPI backlight driver should handle some more corner cases, among other things. On top of the ACPICA update there are fixes for race conditions in the ACPICA's interrupt handling code which might lead to some random and strange looking failures on some systems. In the cleanups department the most visible part is the series of commits targeted at getting rid of the CONFIG_PM_RUNTIME configuration option. That was triggered by a discussion regarding the generic power domains code during which we realized that trying to support certain combinations of PM config options was painful and not really worth it, because nobody would use them in production anyway. For this reason, we decided to make CONFIG_PM_SLEEP select CONFIG_PM_RUNTIME and that lead to the conclusion that the latter became redundant and CONFIG_PM could be used instead of it. The material here makes that replacement in a major part of the tree, but there will be at least one more batch of that in the second part of the merge window. Specifics: - Support for retrieving device properties information from ACPI _DSD device configuration objects and a unified device properties interface for device drivers (and subsystems) on top of that. As stated above, this works with Device Trees and ACPI and allows device drivers to be written in a platform firmware (DT or ACPI) agnostic way. The at25, leds-gpio and gpio_keys_polled drivers are now going to use this new interface and the GPIO subsystem is additionally modified to allow device drivers to assign names to GPIO resources returned by ACPI _CRS objects (in case _DSD is not present or does not provide the expected data). The changes in this set are mostly from Mika Westerberg, Rafael J Wysocki, Aaron Lu, and Darren Hart with some fixes from others (Fabio Estevam, Geert Uytterhoeven). - Support for Hardware Managed Performance States (HWP) as described in Volume 3, section 14.4, of the Intel SDM in the intel_pstate driver. CPUID is used to detect whether or not the feature is supported by the processor. If supported, it will be enabled automatically unless the intel_pstate=no_hwp switch is present in the kernel command line. From Dirk Brandewie. - New Intel Broadwell-H ID for intel_pstate (Dirk Brandewie). - Support for firmware interface based on ACPI operation regions used by the PMIC chips on the Intel Baytrail-T and Baytrail-T-CR platforms for power resource control and thermal management (Aaron Lu). - Limited support for retrieving off-the-hierarchy dependencies between devices from ACPI _DEP device configuration objects and deferred probing support for the ACPI battery driver based on the _DEP information to make that driver work on Asus T100A (Lan Tianyu). - New cpufreq driver for the Loongson1B processor (Kelvin Cheung). - ACPICA update to upstream revision 20141107 which only affects tools (Bob Moore). - Fixes for race conditions in the ACPICA's interrupt handling code and in the ACPI code related to system suspend and resume (Lv Zheng and Rafael J Wysocki). - ACPI core fix for an RCU-related issue in the ioremap() regions management code that slowed down significantly after CPUs had been allowed to enter idle states even if they'd had RCU callbakcs queued and triggered some problems in certain proprietary graphics driver (and elsewhere). The fix replaces synchronize_rcu() in that code with synchronize_rcu_expedited() which makes the issue go away. From Konstantin Khlebnikov. - ACPI LPSS (Low-Power Subsystem) driver fix to handle power management of the DMA engine included into the LPSS correctly. The problem is that the DMA engine doesn't have ACPI PM support of its own and it simply is turned off when the last LPSS device having ACPI PM support goes into D3cold. To work around that, the PM domain used by the ACPI LPSS driver is redesigned so at least one device with ACPI PM support will be on as long as the DMA engine is in use. From Andy Shevchenko. - ACPI backlight driver fix to avoid using it on "Win8-compatible" systems where it doesn't work and where it was used by default by mistake (Aaron Lu). - Assorted minor ACPI core fixes and cleanups from Tomasz Nowicki, Sudeep Holla, Huang Rui, Hanjun Guo, Fabian Frederick, and Ashwin Chaugule (mostly related to the upcoming ARM64 support). - Intel RAPL (Running Average Power Limit) power capping driver fixes and improvements including new processor IDs (Jacob Pan). - Generic power domains modification to power up domains after attaching devices to them to meet the expectations of device drivers and bus types assuming devices to be accessible at probe time (Ulf Hansson). - Preliminary support for controlling device clocks from the generic power domains core code and modifications of the ARM/shmobile platform to use that feature (Ulf Hansson). - Assorted minor fixes and cleanups of the generic power domains core code (Ulf Hansson, Geert Uytterhoeven). - Assorted minor fixes and cleanups of the device clocks control code in the PM core (Geert Uytterhoeven, Grygorii Strashko). - Consolidation of device power management Kconfig options by making CONFIG_PM_SLEEP select CONFIG_PM_RUNTIME and removing the latter which is now redundant (Rafael J Wysocki and Kevin Hilman). That is the first batch of the changes needed for this purpose. - Core device runtime power management support code cleanup related to the execution of callbacks (Andrzej Hajda). - cpuidle ARM support improvements (Lorenzo Pieralisi). - cpuidle cleanup related to the CPUIDLE_FLAG_TIME_VALID flag and a new MAINTAINERS entry for ARM Exynos cpuidle (Daniel Lezcano and Bartlomiej Zolnierkiewicz). - New cpufreq driver callback (->ready) to be executed when the cpufreq core is ready to use a given policy object and cpufreq-dt driver modification to use that callback for cooling device registration (Viresh Kumar). - cpufreq core fixes and cleanups (Viresh Kumar, Vince Hsu, James Geboski, Tomeu Vizoso). - Assorted fixes and cleanups in the cpufreq-pcc, intel_pstate, cpufreq-dt, pxa2xx cpufreq drivers (Lenny Szubowicz, Ethan Zhao, Stefan Wahren, Petr Cvek). - OPP (Operating Performance Points) framework modification to allow OPPs to be removed too and update of a few cpufreq drivers (cpufreq-dt, exynos5440, imx6q, cpufreq) to remove OPPs (added during initialization) on driver removal (Viresh Kumar). - Hibernation core fixes and cleanups (Tina Ruchandani and Markus Elfring). - PM Kconfig fix related to CPU power management (Pankaj Dubey). - cpupower tool fix (Prarit Bhargava). / -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (GNU/Linux) iQIcBAABCAAGBQJUhj6JAAoJEILEb/54YlRxTM4P/j5g5SfqvY0QKsn7sR7MGZ6v nsgCBhJAqTw3ocNC7EAs8z9h2GWy1KbKpakKYWAh9Fs1yZoey7tFSlcv/Rgjlp70 uU5sDQHtpE9mHKiymdsowiQuWgpl962L4k+k8hUslhlvgk1PvVbpajR6OqG8G+pD asuIW9eh1APNkLyXmRJ3ZPomzs0VmRdZJ0NEs0lKX9mJskqEvxPIwdaxq3iaJq9B Fo0J345zUDcJnxWblDRdHlOigCimglElfN5qJwaC4KpwUKuBvLRKbp4f69+wfT0c kYFiR29X5KjJ2kLfP/wKsLyuDCYYXRq3tCia5M1tAqOjZ+UA89H/GDftx/5lntmv qUlBa35VfdS1SX4HyApZitOHiLgo+It/hl8Z9bJnhyVw66NxmMQ8JYN2imb8Lhqh XCLR7BxLTah82AapLJuQ0ZDHPzZqMPG2veC2vAzRMYzVijict/p4Y2+qBqONltER 4rs9uRVn+hamX33lCLg8BEN8zqlnT3rJFIgGaKjq/wXHAU/zpE9CjOrKMQcAg9+s t51XMNPwypHMAYyGVhEL89ImjXnXxBkLRuquhlmEpvQchIhR+mR3dLsarGn7da44 WPIQJXzcsojXczcwwfqsJCR4I1FTFyQIW+UNh02GkDRgRovQqo+Jk762U7vQwqH+ LBdhvVaS1VW4v+FWXEoZ =5dox -----END PGP SIGNATURE----- Merge tag 'pm+acpi-3.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm Pull ACPI and power management updates from Rafael Wysocki: "This time we have some more new material than we used to have during the last couple of development cycles. The most important part of it to me is the introduction of a unified interface for accessing device properties provided by platform firmware. It works with Device Trees and ACPI in a uniform way and drivers using it need not worry about where the properties come from as long as the platform firmware (either DT or ACPI) makes them available. It covers both devices and "bare" device node objects without struct device representation as that turns out to be necessary in some cases. This has been in the works for quite a few months (and development cycles) and has been approved by all of the relevant maintainers. On top of that, some drivers are switched over to the new interface (at25, leds-gpio, gpio_keys_polled) and some additional changes are made to the core GPIO subsystem to allow device drivers to manipulate GPIOs in the "canonical" way on platforms that provide GPIO information in their ACPI tables, but don't assign names to GPIO lines (in which case the driver needs to do that on the basis of what it knows about the device in question). That also has been approved by the GPIO core maintainers and the rfkill driver is now going to use it. Second is support for hardware P-states in the intel_pstate driver. It uses CPUID to detect whether or not the feature is supported by the processor in which case it will be enabled by default. However, it can be disabled entirely from the kernel command line if necessary. Next is support for a platform firmware interface based on ACPI operation regions used by the PMIC (Power Management Integrated Circuit) chips on the Intel Baytrail-T and Baytrail-T-CR platforms. That interface is used for manipulating power resources and for thermal management: sensor temperature reporting, trip point setting and so on. Also the ACPI core is now going to support the _DEP configuration information in a limited way. Basically, _DEP it supposed to reflect off-the-hierarchy dependencies between devices which may be very indirect, like when AML for one device accesses locations in an operation region handled by another device's driver (usually, the device depended on this way is a serial bus or GPIO controller). The support added this time is sufficient to make the ACPI battery driver work on Asus T100A, but it is general enough to be able to cover some other use cases in the future. Finally, we have a new cpufreq driver for the Loongson1B processor. In addition to the above, there are fixes and cleanups all over the place as usual and a traditional ACPICA update to a recent upstream release. As far as the fixes go, the ACPI LPSS (Low-power Subsystem) driver for Intel platforms should be able to handle power management of the DMA engine correctly, the cpufreq-dt driver should interact with the thermal subsystem in a better way and the ACPI backlight driver should handle some more corner cases, among other things. On top of the ACPICA update there are fixes for race conditions in the ACPICA's interrupt handling code which might lead to some random and strange looking failures on some systems. In the cleanups department the most visible part is the series of commits targeted at getting rid of the CONFIG_PM_RUNTIME configuration option. That was triggered by a discussion regarding the generic power domains code during which we realized that trying to support certain combinations of PM config options was painful and not really worth it, because nobody would use them in production anyway. For this reason, we decided to make CONFIG_PM_SLEEP select CONFIG_PM_RUNTIME and that lead to the conclusion that the latter became redundant and CONFIG_PM could be used instead of it. The material here makes that replacement in a major part of the tree, but there will be at least one more batch of that in the second part of the merge window. Specifics: - Support for retrieving device properties information from ACPI _DSD device configuration objects and a unified device properties interface for device drivers (and subsystems) on top of that. As stated above, this works with Device Trees and ACPI and allows device drivers to be written in a platform firmware (DT or ACPI) agnostic way. The at25, leds-gpio and gpio_keys_polled drivers are now going to use this new interface and the GPIO subsystem is additionally modified to allow device drivers to assign names to GPIO resources returned by ACPI _CRS objects (in case _DSD is not present or does not provide the expected data). The changes in this set are mostly from Mika Westerberg, Rafael J Wysocki, Aaron Lu, and Darren Hart with some fixes from others (Fabio Estevam, Geert Uytterhoeven). - Support for Hardware Managed Performance States (HWP) as described in Volume 3, section 14.4, of the Intel SDM in the intel_pstate driver. CPUID is used to detect whether or not the feature is supported by the processor. If supported, it will be enabled automatically unless the intel_pstate=no_hwp switch is present in the kernel command line. From Dirk Brandewie. - New Intel Broadwell-H ID for intel_pstate (Dirk Brandewie). - Support for firmware interface based on ACPI operation regions used by the PMIC chips on the Intel Baytrail-T and Baytrail-T-CR platforms for power resource control and thermal management (Aaron Lu). - Limited support for retrieving off-the-hierarchy dependencies between devices from ACPI _DEP device configuration objects and deferred probing support for the ACPI battery driver based on the _DEP information to make that driver work on Asus T100A (Lan Tianyu). - New cpufreq driver for the Loongson1B processor (Kelvin Cheung). - ACPICA update to upstream revision 20141107 which only affects tools (Bob Moore). - Fixes for race conditions in the ACPICA's interrupt handling code and in the ACPI code related to system suspend and resume (Lv Zheng and Rafael J Wysocki). - ACPI core fix for an RCU-related issue in the ioremap() regions management code that slowed down significantly after CPUs had been allowed to enter idle states even if they'd had RCU callbakcs queued and triggered some problems in certain proprietary graphics driver (and elsewhere). The fix replaces synchronize_rcu() in that code with synchronize_rcu_expedited() which makes the issue go away. From Konstantin Khlebnikov. - ACPI LPSS (Low-Power Subsystem) driver fix to handle power management of the DMA engine included into the LPSS correctly. The problem is that the DMA engine doesn't have ACPI PM support of its own and it simply is turned off when the last LPSS device having ACPI PM support goes into D3cold. To work around that, the PM domain used by the ACPI LPSS driver is redesigned so at least one device with ACPI PM support will be on as long as the DMA engine is in use. From Andy Shevchenko. - ACPI backlight driver fix to avoid using it on "Win8-compatible" systems where it doesn't work and where it was used by default by mistake (Aaron Lu). - Assorted minor ACPI core fixes and cleanups from Tomasz Nowicki, Sudeep Holla, Huang Rui, Hanjun Guo, Fabian Frederick, and Ashwin Chaugule (mostly related to the upcoming ARM64 support). - Intel RAPL (Running Average Power Limit) power capping driver fixes and improvements including new processor IDs (Jacob Pan). - Generic power domains modification to power up domains after attaching devices to them to meet the expectations of device drivers and bus types assuming devices to be accessible at probe time (Ulf Hansson). - Preliminary support for controlling device clocks from the generic power domains core code and modifications of the ARM/shmobile platform to use that feature (Ulf Hansson). - Assorted minor fixes and cleanups of the generic power domains core code (Ulf Hansson, Geert Uytterhoeven). - Assorted minor fixes and cleanups of the device clocks control code in the PM core (Geert Uytterhoeven, Grygorii Strashko). - Consolidation of device power management Kconfig options by making CONFIG_PM_SLEEP select CONFIG_PM_RUNTIME and removing the latter which is now redundant (Rafael J Wysocki and Kevin Hilman). That is the first batch of the changes needed for this purpose. - Core device runtime power management support code cleanup related to the execution of callbacks (Andrzej Hajda). - cpuidle ARM support improvements (Lorenzo Pieralisi). - cpuidle cleanup related to the CPUIDLE_FLAG_TIME_VALID flag and a new MAINTAINERS entry for ARM Exynos cpuidle (Daniel Lezcano and Bartlomiej Zolnierkiewicz). - New cpufreq driver callback (->ready) to be executed when the cpufreq core is ready to use a given policy object and cpufreq-dt driver modification to use that callback for cooling device registration (Viresh Kumar). - cpufreq core fixes and cleanups (Viresh Kumar, Vince Hsu, James Geboski, Tomeu Vizoso). - Assorted fixes and cleanups in the cpufreq-pcc, intel_pstate, cpufreq-dt, pxa2xx cpufreq drivers (Lenny Szubowicz, Ethan Zhao, Stefan Wahren, Petr Cvek). - OPP (Operating Performance Points) framework modification to allow OPPs to be removed too and update of a few cpufreq drivers (cpufreq-dt, exynos5440, imx6q, cpufreq) to remove OPPs (added during initialization) on driver removal (Viresh Kumar). - Hibernation core fixes and cleanups (Tina Ruchandani and Markus Elfring). - PM Kconfig fix related to CPU power management (Pankaj Dubey). - cpupower tool fix (Prarit Bhargava)" * tag 'pm+acpi-3.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: (120 commits) i2c-omap / PM: Drop CONFIG_PM_RUNTIME from i2c-omap.c dmaengine / PM: Replace CONFIG_PM_RUNTIME with CONFIG_PM tools: cpupower: fix return checks for sysfs_get_idlestate_count() drivers: sh / PM: Replace CONFIG_PM_RUNTIME with CONFIG_PM e1000e / igb / PM: Eliminate CONFIG_PM_RUNTIME MMC / PM: Replace CONFIG_PM_RUNTIME with CONFIG_PM MFD / PM: Replace CONFIG_PM_RUNTIME with CONFIG_PM misc / PM: Replace CONFIG_PM_RUNTIME with CONFIG_PM media / PM: Replace CONFIG_PM_RUNTIME with CONFIG_PM input / PM: Replace CONFIG_PM_RUNTIME with CONFIG_PM leds: leds-gpio: Fix multiple instances registration without 'label' property iio / PM: Replace CONFIG_PM_RUNTIME with CONFIG_PM hsi / OMAP / PM: Replace CONFIG_PM_RUNTIME with CONFIG_PM i2c-hid / PM: Replace CONFIG_PM_RUNTIME with CONFIG_PM drm / exynos / PM: Replace CONFIG_PM_RUNTIME with CONFIG_PM gpio / PM: Replace CONFIG_PM_RUNTIME with CONFIG_PM hwrandom / exynos / PM: Use CONFIG_PM in #ifdef block / PM: Replace CONFIG_PM_RUNTIME with CONFIG_PM USB / PM: Drop CONFIG_PM_RUNTIME from the USB core PM: Merge the SET*_RUNTIME_PM_OPS() macros ...
524 lines
13 KiB
C
524 lines
13 KiB
C
/*
|
|
* Copyright (C) 2010 Marvell International Ltd.
|
|
* Zhangfei Gao <zhangfei.gao@marvell.com>
|
|
* Kevin Wang <dwang4@marvell.com>
|
|
* Mingwei Wang <mwwang@marvell.com>
|
|
* Philip Rakity <prakity@marvell.com>
|
|
* Mark Brown <markb@marvell.com>
|
|
*
|
|
* This software is licensed under the terms of the GNU General Public
|
|
* License version 2, as published by the Free Software Foundation, and
|
|
* may be copied, distributed, and modified under those terms.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
*/
|
|
#include <linux/err.h>
|
|
#include <linux/init.h>
|
|
#include <linux/platform_device.h>
|
|
#include <linux/clk.h>
|
|
#include <linux/io.h>
|
|
#include <linux/gpio.h>
|
|
#include <linux/mmc/card.h>
|
|
#include <linux/mmc/host.h>
|
|
#include <linux/mmc/slot-gpio.h>
|
|
#include <linux/platform_data/pxa_sdhci.h>
|
|
#include <linux/slab.h>
|
|
#include <linux/delay.h>
|
|
#include <linux/module.h>
|
|
#include <linux/of.h>
|
|
#include <linux/of_device.h>
|
|
#include <linux/of_gpio.h>
|
|
#include <linux/pm.h>
|
|
#include <linux/pm_runtime.h>
|
|
#include <linux/mbus.h>
|
|
|
|
#include "sdhci.h"
|
|
#include "sdhci-pltfm.h"
|
|
|
|
#define PXAV3_RPM_DELAY_MS 50
|
|
|
|
#define SD_CLOCK_BURST_SIZE_SETUP 0x10A
|
|
#define SDCLK_SEL 0x100
|
|
#define SDCLK_DELAY_SHIFT 9
|
|
#define SDCLK_DELAY_MASK 0x1f
|
|
|
|
#define SD_CFG_FIFO_PARAM 0x100
|
|
#define SDCFG_GEN_PAD_CLK_ON (1<<6)
|
|
#define SDCFG_GEN_PAD_CLK_CNT_MASK 0xFF
|
|
#define SDCFG_GEN_PAD_CLK_CNT_SHIFT 24
|
|
|
|
#define SD_SPI_MODE 0x108
|
|
#define SD_CE_ATA_1 0x10C
|
|
|
|
#define SD_CE_ATA_2 0x10E
|
|
#define SDCE_MISC_INT (1<<2)
|
|
#define SDCE_MISC_INT_EN (1<<1)
|
|
|
|
struct sdhci_pxa {
|
|
struct clk *clk_core;
|
|
struct clk *clk_io;
|
|
u8 power_mode;
|
|
};
|
|
|
|
/*
|
|
* These registers are relative to the second register region, for the
|
|
* MBus bridge.
|
|
*/
|
|
#define SDHCI_WINDOW_CTRL(i) (0x80 + ((i) << 3))
|
|
#define SDHCI_WINDOW_BASE(i) (0x84 + ((i) << 3))
|
|
#define SDHCI_MAX_WIN_NUM 8
|
|
|
|
static int mv_conf_mbus_windows(struct platform_device *pdev,
|
|
const struct mbus_dram_target_info *dram)
|
|
{
|
|
int i;
|
|
void __iomem *regs;
|
|
struct resource *res;
|
|
|
|
if (!dram) {
|
|
dev_err(&pdev->dev, "no mbus dram info\n");
|
|
return -EINVAL;
|
|
}
|
|
|
|
res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
|
|
if (!res) {
|
|
dev_err(&pdev->dev, "cannot get mbus registers\n");
|
|
return -EINVAL;
|
|
}
|
|
|
|
regs = ioremap(res->start, resource_size(res));
|
|
if (!regs) {
|
|
dev_err(&pdev->dev, "cannot map mbus registers\n");
|
|
return -ENOMEM;
|
|
}
|
|
|
|
for (i = 0; i < SDHCI_MAX_WIN_NUM; i++) {
|
|
writel(0, regs + SDHCI_WINDOW_CTRL(i));
|
|
writel(0, regs + SDHCI_WINDOW_BASE(i));
|
|
}
|
|
|
|
for (i = 0; i < dram->num_cs; i++) {
|
|
const struct mbus_dram_window *cs = dram->cs + i;
|
|
|
|
/* Write size, attributes and target id to control register */
|
|
writel(((cs->size - 1) & 0xffff0000) |
|
|
(cs->mbus_attr << 8) |
|
|
(dram->mbus_dram_target_id << 4) | 1,
|
|
regs + SDHCI_WINDOW_CTRL(i));
|
|
/* Write base address to base register */
|
|
writel(cs->base, regs + SDHCI_WINDOW_BASE(i));
|
|
}
|
|
|
|
iounmap(regs);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static void pxav3_reset(struct sdhci_host *host, u8 mask)
|
|
{
|
|
struct platform_device *pdev = to_platform_device(mmc_dev(host->mmc));
|
|
struct sdhci_pxa_platdata *pdata = pdev->dev.platform_data;
|
|
|
|
sdhci_reset(host, mask);
|
|
|
|
if (mask == SDHCI_RESET_ALL) {
|
|
/*
|
|
* tune timing of read data/command when crc error happen
|
|
* no performance impact
|
|
*/
|
|
if (pdata && 0 != pdata->clk_delay_cycles) {
|
|
u16 tmp;
|
|
|
|
tmp = readw(host->ioaddr + SD_CLOCK_BURST_SIZE_SETUP);
|
|
tmp |= (pdata->clk_delay_cycles & SDCLK_DELAY_MASK)
|
|
<< SDCLK_DELAY_SHIFT;
|
|
tmp |= SDCLK_SEL;
|
|
writew(tmp, host->ioaddr + SD_CLOCK_BURST_SIZE_SETUP);
|
|
}
|
|
}
|
|
}
|
|
|
|
#define MAX_WAIT_COUNT 5
|
|
static void pxav3_gen_init_74_clocks(struct sdhci_host *host, u8 power_mode)
|
|
{
|
|
struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
|
|
struct sdhci_pxa *pxa = pltfm_host->priv;
|
|
u16 tmp;
|
|
int count;
|
|
|
|
if (pxa->power_mode == MMC_POWER_UP
|
|
&& power_mode == MMC_POWER_ON) {
|
|
|
|
dev_dbg(mmc_dev(host->mmc),
|
|
"%s: slot->power_mode = %d,"
|
|
"ios->power_mode = %d\n",
|
|
__func__,
|
|
pxa->power_mode,
|
|
power_mode);
|
|
|
|
/* set we want notice of when 74 clocks are sent */
|
|
tmp = readw(host->ioaddr + SD_CE_ATA_2);
|
|
tmp |= SDCE_MISC_INT_EN;
|
|
writew(tmp, host->ioaddr + SD_CE_ATA_2);
|
|
|
|
/* start sending the 74 clocks */
|
|
tmp = readw(host->ioaddr + SD_CFG_FIFO_PARAM);
|
|
tmp |= SDCFG_GEN_PAD_CLK_ON;
|
|
writew(tmp, host->ioaddr + SD_CFG_FIFO_PARAM);
|
|
|
|
/* slowest speed is about 100KHz or 10usec per clock */
|
|
udelay(740);
|
|
count = 0;
|
|
|
|
while (count++ < MAX_WAIT_COUNT) {
|
|
if ((readw(host->ioaddr + SD_CE_ATA_2)
|
|
& SDCE_MISC_INT) == 0)
|
|
break;
|
|
udelay(10);
|
|
}
|
|
|
|
if (count == MAX_WAIT_COUNT)
|
|
dev_warn(mmc_dev(host->mmc), "74 clock interrupt not cleared\n");
|
|
|
|
/* clear the interrupt bit if posted */
|
|
tmp = readw(host->ioaddr + SD_CE_ATA_2);
|
|
tmp |= SDCE_MISC_INT;
|
|
writew(tmp, host->ioaddr + SD_CE_ATA_2);
|
|
}
|
|
pxa->power_mode = power_mode;
|
|
}
|
|
|
|
static void pxav3_set_uhs_signaling(struct sdhci_host *host, unsigned int uhs)
|
|
{
|
|
u16 ctrl_2;
|
|
|
|
/*
|
|
* Set V18_EN -- UHS modes do not work without this.
|
|
* does not change signaling voltage
|
|
*/
|
|
ctrl_2 = sdhci_readw(host, SDHCI_HOST_CONTROL2);
|
|
|
|
/* Select Bus Speed Mode for host */
|
|
ctrl_2 &= ~SDHCI_CTRL_UHS_MASK;
|
|
switch (uhs) {
|
|
case MMC_TIMING_UHS_SDR12:
|
|
ctrl_2 |= SDHCI_CTRL_UHS_SDR12;
|
|
break;
|
|
case MMC_TIMING_UHS_SDR25:
|
|
ctrl_2 |= SDHCI_CTRL_UHS_SDR25;
|
|
break;
|
|
case MMC_TIMING_UHS_SDR50:
|
|
ctrl_2 |= SDHCI_CTRL_UHS_SDR50 | SDHCI_CTRL_VDD_180;
|
|
break;
|
|
case MMC_TIMING_UHS_SDR104:
|
|
ctrl_2 |= SDHCI_CTRL_UHS_SDR104 | SDHCI_CTRL_VDD_180;
|
|
break;
|
|
case MMC_TIMING_MMC_DDR52:
|
|
case MMC_TIMING_UHS_DDR50:
|
|
ctrl_2 |= SDHCI_CTRL_UHS_DDR50 | SDHCI_CTRL_VDD_180;
|
|
break;
|
|
}
|
|
|
|
sdhci_writew(host, ctrl_2, SDHCI_HOST_CONTROL2);
|
|
dev_dbg(mmc_dev(host->mmc),
|
|
"%s uhs = %d, ctrl_2 = %04X\n",
|
|
__func__, uhs, ctrl_2);
|
|
}
|
|
|
|
static const struct sdhci_ops pxav3_sdhci_ops = {
|
|
.set_clock = sdhci_set_clock,
|
|
.platform_send_init_74_clocks = pxav3_gen_init_74_clocks,
|
|
.get_max_clock = sdhci_pltfm_clk_get_max_clock,
|
|
.set_bus_width = sdhci_set_bus_width,
|
|
.reset = pxav3_reset,
|
|
.set_uhs_signaling = pxav3_set_uhs_signaling,
|
|
};
|
|
|
|
static struct sdhci_pltfm_data sdhci_pxav3_pdata = {
|
|
.quirks = SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK
|
|
| SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC
|
|
| SDHCI_QUIRK_32BIT_ADMA_SIZE
|
|
| SDHCI_QUIRK_CAP_CLOCK_BASE_BROKEN,
|
|
.ops = &pxav3_sdhci_ops,
|
|
};
|
|
|
|
#ifdef CONFIG_OF
|
|
static const struct of_device_id sdhci_pxav3_of_match[] = {
|
|
{
|
|
.compatible = "mrvl,pxav3-mmc",
|
|
},
|
|
{
|
|
.compatible = "marvell,armada-380-sdhci",
|
|
},
|
|
{},
|
|
};
|
|
MODULE_DEVICE_TABLE(of, sdhci_pxav3_of_match);
|
|
|
|
static struct sdhci_pxa_platdata *pxav3_get_mmc_pdata(struct device *dev)
|
|
{
|
|
struct sdhci_pxa_platdata *pdata;
|
|
struct device_node *np = dev->of_node;
|
|
u32 clk_delay_cycles;
|
|
|
|
pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
|
|
if (!pdata)
|
|
return NULL;
|
|
|
|
of_property_read_u32(np, "mrvl,clk-delay-cycles", &clk_delay_cycles);
|
|
if (clk_delay_cycles > 0)
|
|
pdata->clk_delay_cycles = clk_delay_cycles;
|
|
|
|
return pdata;
|
|
}
|
|
#else
|
|
static inline struct sdhci_pxa_platdata *pxav3_get_mmc_pdata(struct device *dev)
|
|
{
|
|
return NULL;
|
|
}
|
|
#endif
|
|
|
|
static int sdhci_pxav3_probe(struct platform_device *pdev)
|
|
{
|
|
struct sdhci_pltfm_host *pltfm_host;
|
|
struct sdhci_pxa_platdata *pdata = pdev->dev.platform_data;
|
|
struct device *dev = &pdev->dev;
|
|
struct device_node *np = pdev->dev.of_node;
|
|
struct sdhci_host *host = NULL;
|
|
struct sdhci_pxa *pxa = NULL;
|
|
const struct of_device_id *match;
|
|
int ret;
|
|
|
|
pxa = devm_kzalloc(&pdev->dev, sizeof(struct sdhci_pxa), GFP_KERNEL);
|
|
if (!pxa)
|
|
return -ENOMEM;
|
|
|
|
host = sdhci_pltfm_init(pdev, &sdhci_pxav3_pdata, 0);
|
|
if (IS_ERR(host))
|
|
return PTR_ERR(host);
|
|
|
|
if (of_device_is_compatible(np, "marvell,armada-380-sdhci")) {
|
|
ret = mv_conf_mbus_windows(pdev, mv_mbus_dram_info());
|
|
if (ret < 0)
|
|
goto err_mbus_win;
|
|
}
|
|
|
|
|
|
pltfm_host = sdhci_priv(host);
|
|
pltfm_host->priv = pxa;
|
|
|
|
pxa->clk_io = devm_clk_get(dev, "io");
|
|
if (IS_ERR(pxa->clk_io))
|
|
pxa->clk_io = devm_clk_get(dev, NULL);
|
|
if (IS_ERR(pxa->clk_io)) {
|
|
dev_err(dev, "failed to get io clock\n");
|
|
ret = PTR_ERR(pxa->clk_io);
|
|
goto err_clk_get;
|
|
}
|
|
pltfm_host->clk = pxa->clk_io;
|
|
clk_prepare_enable(pxa->clk_io);
|
|
|
|
pxa->clk_core = devm_clk_get(dev, "core");
|
|
if (!IS_ERR(pxa->clk_core))
|
|
clk_prepare_enable(pxa->clk_core);
|
|
|
|
/* enable 1/8V DDR capable */
|
|
host->mmc->caps |= MMC_CAP_1_8V_DDR;
|
|
|
|
match = of_match_device(of_match_ptr(sdhci_pxav3_of_match), &pdev->dev);
|
|
if (match) {
|
|
ret = mmc_of_parse(host->mmc);
|
|
if (ret)
|
|
goto err_of_parse;
|
|
sdhci_get_of_property(pdev);
|
|
pdata = pxav3_get_mmc_pdata(dev);
|
|
} else if (pdata) {
|
|
/* on-chip device */
|
|
if (pdata->flags & PXA_FLAG_CARD_PERMANENT)
|
|
host->mmc->caps |= MMC_CAP_NONREMOVABLE;
|
|
|
|
/* If slot design supports 8 bit data, indicate this to MMC. */
|
|
if (pdata->flags & PXA_FLAG_SD_8_BIT_CAPABLE_SLOT)
|
|
host->mmc->caps |= MMC_CAP_8_BIT_DATA;
|
|
|
|
if (pdata->quirks)
|
|
host->quirks |= pdata->quirks;
|
|
if (pdata->quirks2)
|
|
host->quirks2 |= pdata->quirks2;
|
|
if (pdata->host_caps)
|
|
host->mmc->caps |= pdata->host_caps;
|
|
if (pdata->host_caps2)
|
|
host->mmc->caps2 |= pdata->host_caps2;
|
|
if (pdata->pm_caps)
|
|
host->mmc->pm_caps |= pdata->pm_caps;
|
|
|
|
if (gpio_is_valid(pdata->ext_cd_gpio)) {
|
|
ret = mmc_gpio_request_cd(host->mmc, pdata->ext_cd_gpio,
|
|
0);
|
|
if (ret) {
|
|
dev_err(mmc_dev(host->mmc),
|
|
"failed to allocate card detect gpio\n");
|
|
goto err_cd_req;
|
|
}
|
|
}
|
|
}
|
|
|
|
pm_runtime_enable(&pdev->dev);
|
|
pm_runtime_get_sync(&pdev->dev);
|
|
pm_runtime_set_autosuspend_delay(&pdev->dev, PXAV3_RPM_DELAY_MS);
|
|
pm_runtime_use_autosuspend(&pdev->dev);
|
|
pm_suspend_ignore_children(&pdev->dev, 1);
|
|
|
|
ret = sdhci_add_host(host);
|
|
if (ret) {
|
|
dev_err(&pdev->dev, "failed to add host\n");
|
|
goto err_add_host;
|
|
}
|
|
|
|
platform_set_drvdata(pdev, host);
|
|
|
|
if (host->mmc->pm_caps & MMC_PM_KEEP_POWER) {
|
|
device_init_wakeup(&pdev->dev, 1);
|
|
host->mmc->pm_flags |= MMC_PM_WAKE_SDIO_IRQ;
|
|
} else {
|
|
device_init_wakeup(&pdev->dev, 0);
|
|
}
|
|
|
|
pm_runtime_put_autosuspend(&pdev->dev);
|
|
|
|
return 0;
|
|
|
|
err_add_host:
|
|
pm_runtime_put_sync(&pdev->dev);
|
|
pm_runtime_disable(&pdev->dev);
|
|
err_of_parse:
|
|
err_cd_req:
|
|
clk_disable_unprepare(pxa->clk_io);
|
|
if (!IS_ERR(pxa->clk_core))
|
|
clk_disable_unprepare(pxa->clk_core);
|
|
err_clk_get:
|
|
err_mbus_win:
|
|
sdhci_pltfm_free(pdev);
|
|
return ret;
|
|
}
|
|
|
|
static int sdhci_pxav3_remove(struct platform_device *pdev)
|
|
{
|
|
struct sdhci_host *host = platform_get_drvdata(pdev);
|
|
struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
|
|
struct sdhci_pxa *pxa = pltfm_host->priv;
|
|
|
|
pm_runtime_get_sync(&pdev->dev);
|
|
sdhci_remove_host(host, 1);
|
|
pm_runtime_disable(&pdev->dev);
|
|
|
|
clk_disable_unprepare(pxa->clk_io);
|
|
if (!IS_ERR(pxa->clk_core))
|
|
clk_disable_unprepare(pxa->clk_core);
|
|
|
|
sdhci_pltfm_free(pdev);
|
|
|
|
return 0;
|
|
}
|
|
|
|
#ifdef CONFIG_PM_SLEEP
|
|
static int sdhci_pxav3_suspend(struct device *dev)
|
|
{
|
|
int ret;
|
|
struct sdhci_host *host = dev_get_drvdata(dev);
|
|
|
|
pm_runtime_get_sync(dev);
|
|
ret = sdhci_suspend_host(host);
|
|
pm_runtime_mark_last_busy(dev);
|
|
pm_runtime_put_autosuspend(dev);
|
|
|
|
return ret;
|
|
}
|
|
|
|
static int sdhci_pxav3_resume(struct device *dev)
|
|
{
|
|
int ret;
|
|
struct sdhci_host *host = dev_get_drvdata(dev);
|
|
|
|
pm_runtime_get_sync(dev);
|
|
ret = sdhci_resume_host(host);
|
|
pm_runtime_mark_last_busy(dev);
|
|
pm_runtime_put_autosuspend(dev);
|
|
|
|
return ret;
|
|
}
|
|
#endif
|
|
|
|
#ifdef CONFIG_PM
|
|
static int sdhci_pxav3_runtime_suspend(struct device *dev)
|
|
{
|
|
struct sdhci_host *host = dev_get_drvdata(dev);
|
|
struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
|
|
struct sdhci_pxa *pxa = pltfm_host->priv;
|
|
unsigned long flags;
|
|
|
|
spin_lock_irqsave(&host->lock, flags);
|
|
host->runtime_suspended = true;
|
|
spin_unlock_irqrestore(&host->lock, flags);
|
|
|
|
clk_disable_unprepare(pxa->clk_io);
|
|
if (!IS_ERR(pxa->clk_core))
|
|
clk_disable_unprepare(pxa->clk_core);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int sdhci_pxav3_runtime_resume(struct device *dev)
|
|
{
|
|
struct sdhci_host *host = dev_get_drvdata(dev);
|
|
struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
|
|
struct sdhci_pxa *pxa = pltfm_host->priv;
|
|
unsigned long flags;
|
|
|
|
clk_prepare_enable(pxa->clk_io);
|
|
if (!IS_ERR(pxa->clk_core))
|
|
clk_prepare_enable(pxa->clk_core);
|
|
|
|
spin_lock_irqsave(&host->lock, flags);
|
|
host->runtime_suspended = false;
|
|
spin_unlock_irqrestore(&host->lock, flags);
|
|
|
|
return 0;
|
|
}
|
|
#endif
|
|
|
|
#ifdef CONFIG_PM
|
|
static const struct dev_pm_ops sdhci_pxav3_pmops = {
|
|
SET_SYSTEM_SLEEP_PM_OPS(sdhci_pxav3_suspend, sdhci_pxav3_resume)
|
|
SET_RUNTIME_PM_OPS(sdhci_pxav3_runtime_suspend,
|
|
sdhci_pxav3_runtime_resume, NULL)
|
|
};
|
|
|
|
#define SDHCI_PXAV3_PMOPS (&sdhci_pxav3_pmops)
|
|
|
|
#else
|
|
#define SDHCI_PXAV3_PMOPS NULL
|
|
#endif
|
|
|
|
static struct platform_driver sdhci_pxav3_driver = {
|
|
.driver = {
|
|
.name = "sdhci-pxav3",
|
|
#ifdef CONFIG_OF
|
|
.of_match_table = sdhci_pxav3_of_match,
|
|
#endif
|
|
.pm = SDHCI_PXAV3_PMOPS,
|
|
},
|
|
.probe = sdhci_pxav3_probe,
|
|
.remove = sdhci_pxav3_remove,
|
|
};
|
|
|
|
module_platform_driver(sdhci_pxav3_driver);
|
|
|
|
MODULE_DESCRIPTION("SDHCI driver for pxav3");
|
|
MODULE_AUTHOR("Marvell International Ltd.");
|
|
MODULE_LICENSE("GPL v2");
|
|
|