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
...
767 lines
19 KiB
C
767 lines
19 KiB
C
/* linux/drivers/mmc/host/sdhci-s3c.c
|
|
*
|
|
* Copyright 2008 Openmoko Inc.
|
|
* Copyright 2008 Simtec Electronics
|
|
* Ben Dooks <ben@simtec.co.uk>
|
|
* http://armlinux.simtec.co.uk/
|
|
*
|
|
* SDHCI (HSMMC) support for Samsung SoC
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
* published by the Free Software Foundation.
|
|
*/
|
|
|
|
#include <linux/delay.h>
|
|
#include <linux/dma-mapping.h>
|
|
#include <linux/platform_device.h>
|
|
#include <linux/platform_data/mmc-sdhci-s3c.h>
|
|
#include <linux/slab.h>
|
|
#include <linux/clk.h>
|
|
#include <linux/io.h>
|
|
#include <linux/gpio.h>
|
|
#include <linux/module.h>
|
|
#include <linux/of.h>
|
|
#include <linux/of_gpio.h>
|
|
#include <linux/pm.h>
|
|
#include <linux/pm_runtime.h>
|
|
|
|
#include <linux/mmc/host.h>
|
|
|
|
#include "sdhci-s3c-regs.h"
|
|
#include "sdhci.h"
|
|
|
|
#define MAX_BUS_CLK (4)
|
|
|
|
/**
|
|
* struct sdhci_s3c - S3C SDHCI instance
|
|
* @host: The SDHCI host created
|
|
* @pdev: The platform device we where created from.
|
|
* @ioarea: The resource created when we claimed the IO area.
|
|
* @pdata: The platform data for this controller.
|
|
* @cur_clk: The index of the current bus clock.
|
|
* @clk_io: The clock for the internal bus interface.
|
|
* @clk_bus: The clocks that are available for the SD/MMC bus clock.
|
|
*/
|
|
struct sdhci_s3c {
|
|
struct sdhci_host *host;
|
|
struct platform_device *pdev;
|
|
struct resource *ioarea;
|
|
struct s3c_sdhci_platdata *pdata;
|
|
int cur_clk;
|
|
int ext_cd_irq;
|
|
int ext_cd_gpio;
|
|
|
|
struct clk *clk_io;
|
|
struct clk *clk_bus[MAX_BUS_CLK];
|
|
unsigned long clk_rates[MAX_BUS_CLK];
|
|
|
|
bool no_divider;
|
|
};
|
|
|
|
/**
|
|
* struct sdhci_s3c_driver_data - S3C SDHCI platform specific driver data
|
|
* @sdhci_quirks: sdhci host specific quirks.
|
|
*
|
|
* Specifies platform specific configuration of sdhci controller.
|
|
* Note: A structure for driver specific platform data is used for future
|
|
* expansion of its usage.
|
|
*/
|
|
struct sdhci_s3c_drv_data {
|
|
unsigned int sdhci_quirks;
|
|
bool no_divider;
|
|
};
|
|
|
|
static inline struct sdhci_s3c *to_s3c(struct sdhci_host *host)
|
|
{
|
|
return sdhci_priv(host);
|
|
}
|
|
|
|
/**
|
|
* sdhci_s3c_get_max_clk - callback to get maximum clock frequency.
|
|
* @host: The SDHCI host instance.
|
|
*
|
|
* Callback to return the maximum clock rate acheivable by the controller.
|
|
*/
|
|
static unsigned int sdhci_s3c_get_max_clk(struct sdhci_host *host)
|
|
{
|
|
struct sdhci_s3c *ourhost = to_s3c(host);
|
|
unsigned long rate, max = 0;
|
|
int src;
|
|
|
|
for (src = 0; src < MAX_BUS_CLK; src++) {
|
|
rate = ourhost->clk_rates[src];
|
|
if (rate > max)
|
|
max = rate;
|
|
}
|
|
|
|
return max;
|
|
}
|
|
|
|
/**
|
|
* sdhci_s3c_consider_clock - consider one the bus clocks for current setting
|
|
* @ourhost: Our SDHCI instance.
|
|
* @src: The source clock index.
|
|
* @wanted: The clock frequency wanted.
|
|
*/
|
|
static unsigned int sdhci_s3c_consider_clock(struct sdhci_s3c *ourhost,
|
|
unsigned int src,
|
|
unsigned int wanted)
|
|
{
|
|
unsigned long rate;
|
|
struct clk *clksrc = ourhost->clk_bus[src];
|
|
int shift;
|
|
|
|
if (IS_ERR(clksrc))
|
|
return UINT_MAX;
|
|
|
|
/*
|
|
* If controller uses a non-standard clock division, find the best clock
|
|
* speed possible with selected clock source and skip the division.
|
|
*/
|
|
if (ourhost->no_divider) {
|
|
rate = clk_round_rate(clksrc, wanted);
|
|
return wanted - rate;
|
|
}
|
|
|
|
rate = ourhost->clk_rates[src];
|
|
|
|
for (shift = 0; shift <= 8; ++shift) {
|
|
if ((rate >> shift) <= wanted)
|
|
break;
|
|
}
|
|
|
|
if (shift > 8) {
|
|
dev_dbg(&ourhost->pdev->dev,
|
|
"clk %d: rate %ld, min rate %lu > wanted %u\n",
|
|
src, rate, rate / 256, wanted);
|
|
return UINT_MAX;
|
|
}
|
|
|
|
dev_dbg(&ourhost->pdev->dev, "clk %d: rate %ld, want %d, got %ld\n",
|
|
src, rate, wanted, rate >> shift);
|
|
|
|
return wanted - (rate >> shift);
|
|
}
|
|
|
|
/**
|
|
* sdhci_s3c_set_clock - callback on clock change
|
|
* @host: The SDHCI host being changed
|
|
* @clock: The clock rate being requested.
|
|
*
|
|
* When the card's clock is going to be changed, look at the new frequency
|
|
* and find the best clock source to go with it.
|
|
*/
|
|
static void sdhci_s3c_set_clock(struct sdhci_host *host, unsigned int clock)
|
|
{
|
|
struct sdhci_s3c *ourhost = to_s3c(host);
|
|
unsigned int best = UINT_MAX;
|
|
unsigned int delta;
|
|
int best_src = 0;
|
|
int src;
|
|
u32 ctrl;
|
|
|
|
host->mmc->actual_clock = 0;
|
|
|
|
/* don't bother if the clock is going off. */
|
|
if (clock == 0) {
|
|
sdhci_set_clock(host, clock);
|
|
return;
|
|
}
|
|
|
|
for (src = 0; src < MAX_BUS_CLK; src++) {
|
|
delta = sdhci_s3c_consider_clock(ourhost, src, clock);
|
|
if (delta < best) {
|
|
best = delta;
|
|
best_src = src;
|
|
}
|
|
}
|
|
|
|
dev_dbg(&ourhost->pdev->dev,
|
|
"selected source %d, clock %d, delta %d\n",
|
|
best_src, clock, best);
|
|
|
|
/* select the new clock source */
|
|
if (ourhost->cur_clk != best_src) {
|
|
struct clk *clk = ourhost->clk_bus[best_src];
|
|
|
|
clk_prepare_enable(clk);
|
|
if (ourhost->cur_clk >= 0)
|
|
clk_disable_unprepare(
|
|
ourhost->clk_bus[ourhost->cur_clk]);
|
|
|
|
ourhost->cur_clk = best_src;
|
|
host->max_clk = ourhost->clk_rates[best_src];
|
|
}
|
|
|
|
/* turn clock off to card before changing clock source */
|
|
writew(0, host->ioaddr + SDHCI_CLOCK_CONTROL);
|
|
|
|
ctrl = readl(host->ioaddr + S3C_SDHCI_CONTROL2);
|
|
ctrl &= ~S3C_SDHCI_CTRL2_SELBASECLK_MASK;
|
|
ctrl |= best_src << S3C_SDHCI_CTRL2_SELBASECLK_SHIFT;
|
|
writel(ctrl, host->ioaddr + S3C_SDHCI_CONTROL2);
|
|
|
|
/* reprogram default hardware configuration */
|
|
writel(S3C64XX_SDHCI_CONTROL4_DRIVE_9mA,
|
|
host->ioaddr + S3C64XX_SDHCI_CONTROL4);
|
|
|
|
ctrl = readl(host->ioaddr + S3C_SDHCI_CONTROL2);
|
|
ctrl |= (S3C64XX_SDHCI_CTRL2_ENSTAASYNCCLR |
|
|
S3C64XX_SDHCI_CTRL2_ENCMDCNFMSK |
|
|
S3C_SDHCI_CTRL2_ENFBCLKRX |
|
|
S3C_SDHCI_CTRL2_DFCNT_NONE |
|
|
S3C_SDHCI_CTRL2_ENCLKOUTHOLD);
|
|
writel(ctrl, host->ioaddr + S3C_SDHCI_CONTROL2);
|
|
|
|
/* reconfigure the controller for new clock rate */
|
|
ctrl = (S3C_SDHCI_CTRL3_FCSEL1 | S3C_SDHCI_CTRL3_FCSEL0);
|
|
if (clock < 25 * 1000000)
|
|
ctrl |= (S3C_SDHCI_CTRL3_FCSEL3 | S3C_SDHCI_CTRL3_FCSEL2);
|
|
writel(ctrl, host->ioaddr + S3C_SDHCI_CONTROL3);
|
|
|
|
sdhci_set_clock(host, clock);
|
|
}
|
|
|
|
/**
|
|
* sdhci_s3c_get_min_clock - callback to get minimal supported clock value
|
|
* @host: The SDHCI host being queried
|
|
*
|
|
* To init mmc host properly a minimal clock value is needed. For high system
|
|
* bus clock's values the standard formula gives values out of allowed range.
|
|
* The clock still can be set to lower values, if clock source other then
|
|
* system bus is selected.
|
|
*/
|
|
static unsigned int sdhci_s3c_get_min_clock(struct sdhci_host *host)
|
|
{
|
|
struct sdhci_s3c *ourhost = to_s3c(host);
|
|
unsigned long rate, min = ULONG_MAX;
|
|
int src;
|
|
|
|
for (src = 0; src < MAX_BUS_CLK; src++) {
|
|
rate = ourhost->clk_rates[src] / 256;
|
|
if (!rate)
|
|
continue;
|
|
if (rate < min)
|
|
min = rate;
|
|
}
|
|
|
|
return min;
|
|
}
|
|
|
|
/* sdhci_cmu_get_max_clk - callback to get maximum clock frequency.*/
|
|
static unsigned int sdhci_cmu_get_max_clock(struct sdhci_host *host)
|
|
{
|
|
struct sdhci_s3c *ourhost = to_s3c(host);
|
|
unsigned long rate, max = 0;
|
|
int src;
|
|
|
|
for (src = 0; src < MAX_BUS_CLK; src++) {
|
|
struct clk *clk;
|
|
|
|
clk = ourhost->clk_bus[src];
|
|
if (IS_ERR(clk))
|
|
continue;
|
|
|
|
rate = clk_round_rate(clk, ULONG_MAX);
|
|
if (rate > max)
|
|
max = rate;
|
|
}
|
|
|
|
return max;
|
|
}
|
|
|
|
/* sdhci_cmu_get_min_clock - callback to get minimal supported clock value. */
|
|
static unsigned int sdhci_cmu_get_min_clock(struct sdhci_host *host)
|
|
{
|
|
struct sdhci_s3c *ourhost = to_s3c(host);
|
|
unsigned long rate, min = ULONG_MAX;
|
|
int src;
|
|
|
|
for (src = 0; src < MAX_BUS_CLK; src++) {
|
|
struct clk *clk;
|
|
|
|
clk = ourhost->clk_bus[src];
|
|
if (IS_ERR(clk))
|
|
continue;
|
|
|
|
rate = clk_round_rate(clk, 0);
|
|
if (rate < min)
|
|
min = rate;
|
|
}
|
|
|
|
return min;
|
|
}
|
|
|
|
/* sdhci_cmu_set_clock - callback on clock change.*/
|
|
static void sdhci_cmu_set_clock(struct sdhci_host *host, unsigned int clock)
|
|
{
|
|
struct sdhci_s3c *ourhost = to_s3c(host);
|
|
struct device *dev = &ourhost->pdev->dev;
|
|
unsigned long timeout;
|
|
u16 clk = 0;
|
|
int ret;
|
|
|
|
host->mmc->actual_clock = 0;
|
|
|
|
/* If the clock is going off, set to 0 at clock control register */
|
|
if (clock == 0) {
|
|
sdhci_writew(host, 0, SDHCI_CLOCK_CONTROL);
|
|
return;
|
|
}
|
|
|
|
sdhci_s3c_set_clock(host, clock);
|
|
|
|
ret = clk_set_rate(ourhost->clk_bus[ourhost->cur_clk], clock);
|
|
if (ret != 0) {
|
|
dev_err(dev, "%s: failed to set clock rate %uHz\n",
|
|
mmc_hostname(host->mmc), clock);
|
|
return;
|
|
}
|
|
|
|
clk = SDHCI_CLOCK_INT_EN;
|
|
sdhci_writew(host, clk, SDHCI_CLOCK_CONTROL);
|
|
|
|
/* Wait max 20 ms */
|
|
timeout = 20;
|
|
while (!((clk = sdhci_readw(host, SDHCI_CLOCK_CONTROL))
|
|
& SDHCI_CLOCK_INT_STABLE)) {
|
|
if (timeout == 0) {
|
|
dev_err(dev, "%s: Internal clock never stabilised.\n",
|
|
mmc_hostname(host->mmc));
|
|
return;
|
|
}
|
|
timeout--;
|
|
mdelay(1);
|
|
}
|
|
|
|
clk |= SDHCI_CLOCK_CARD_EN;
|
|
sdhci_writew(host, clk, SDHCI_CLOCK_CONTROL);
|
|
}
|
|
|
|
/**
|
|
* sdhci_s3c_set_bus_width - support 8bit buswidth
|
|
* @host: The SDHCI host being queried
|
|
* @width: MMC_BUS_WIDTH_ macro for the bus width being requested
|
|
*
|
|
* We have 8-bit width support but is not a v3 controller.
|
|
* So we add platform_bus_width() and support 8bit width.
|
|
*/
|
|
static void sdhci_s3c_set_bus_width(struct sdhci_host *host, int width)
|
|
{
|
|
u8 ctrl;
|
|
|
|
ctrl = sdhci_readb(host, SDHCI_HOST_CONTROL);
|
|
|
|
switch (width) {
|
|
case MMC_BUS_WIDTH_8:
|
|
ctrl |= SDHCI_CTRL_8BITBUS;
|
|
ctrl &= ~SDHCI_CTRL_4BITBUS;
|
|
break;
|
|
case MMC_BUS_WIDTH_4:
|
|
ctrl |= SDHCI_CTRL_4BITBUS;
|
|
ctrl &= ~SDHCI_CTRL_8BITBUS;
|
|
break;
|
|
default:
|
|
ctrl &= ~SDHCI_CTRL_4BITBUS;
|
|
ctrl &= ~SDHCI_CTRL_8BITBUS;
|
|
break;
|
|
}
|
|
|
|
sdhci_writeb(host, ctrl, SDHCI_HOST_CONTROL);
|
|
}
|
|
|
|
static struct sdhci_ops sdhci_s3c_ops = {
|
|
.get_max_clock = sdhci_s3c_get_max_clk,
|
|
.set_clock = sdhci_s3c_set_clock,
|
|
.get_min_clock = sdhci_s3c_get_min_clock,
|
|
.set_bus_width = sdhci_s3c_set_bus_width,
|
|
.reset = sdhci_reset,
|
|
.set_uhs_signaling = sdhci_set_uhs_signaling,
|
|
};
|
|
|
|
#ifdef CONFIG_OF
|
|
static int sdhci_s3c_parse_dt(struct device *dev,
|
|
struct sdhci_host *host, struct s3c_sdhci_platdata *pdata)
|
|
{
|
|
struct device_node *node = dev->of_node;
|
|
u32 max_width;
|
|
|
|
/* if the bus-width property is not specified, assume width as 1 */
|
|
if (of_property_read_u32(node, "bus-width", &max_width))
|
|
max_width = 1;
|
|
pdata->max_width = max_width;
|
|
|
|
/* get the card detection method */
|
|
if (of_get_property(node, "broken-cd", NULL)) {
|
|
pdata->cd_type = S3C_SDHCI_CD_NONE;
|
|
return 0;
|
|
}
|
|
|
|
if (of_get_property(node, "non-removable", NULL)) {
|
|
pdata->cd_type = S3C_SDHCI_CD_PERMANENT;
|
|
return 0;
|
|
}
|
|
|
|
if (of_get_named_gpio(node, "cd-gpios", 0))
|
|
return 0;
|
|
|
|
/* assuming internal card detect that will be configured by pinctrl */
|
|
pdata->cd_type = S3C_SDHCI_CD_INTERNAL;
|
|
return 0;
|
|
}
|
|
#else
|
|
static int sdhci_s3c_parse_dt(struct device *dev,
|
|
struct sdhci_host *host, struct s3c_sdhci_platdata *pdata)
|
|
{
|
|
return -EINVAL;
|
|
}
|
|
#endif
|
|
|
|
static const struct of_device_id sdhci_s3c_dt_match[];
|
|
|
|
static inline struct sdhci_s3c_drv_data *sdhci_s3c_get_driver_data(
|
|
struct platform_device *pdev)
|
|
{
|
|
#ifdef CONFIG_OF
|
|
if (pdev->dev.of_node) {
|
|
const struct of_device_id *match;
|
|
match = of_match_node(sdhci_s3c_dt_match, pdev->dev.of_node);
|
|
return (struct sdhci_s3c_drv_data *)match->data;
|
|
}
|
|
#endif
|
|
return (struct sdhci_s3c_drv_data *)
|
|
platform_get_device_id(pdev)->driver_data;
|
|
}
|
|
|
|
static int sdhci_s3c_probe(struct platform_device *pdev)
|
|
{
|
|
struct s3c_sdhci_platdata *pdata;
|
|
struct sdhci_s3c_drv_data *drv_data;
|
|
struct device *dev = &pdev->dev;
|
|
struct sdhci_host *host;
|
|
struct sdhci_s3c *sc;
|
|
struct resource *res;
|
|
int ret, irq, ptr, clks;
|
|
|
|
if (!pdev->dev.platform_data && !pdev->dev.of_node) {
|
|
dev_err(dev, "no device data specified\n");
|
|
return -ENOENT;
|
|
}
|
|
|
|
irq = platform_get_irq(pdev, 0);
|
|
if (irq < 0) {
|
|
dev_err(dev, "no irq specified\n");
|
|
return irq;
|
|
}
|
|
|
|
host = sdhci_alloc_host(dev, sizeof(struct sdhci_s3c));
|
|
if (IS_ERR(host)) {
|
|
dev_err(dev, "sdhci_alloc_host() failed\n");
|
|
return PTR_ERR(host);
|
|
}
|
|
sc = sdhci_priv(host);
|
|
|
|
pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
|
|
if (!pdata) {
|
|
ret = -ENOMEM;
|
|
goto err_pdata_io_clk;
|
|
}
|
|
|
|
if (pdev->dev.of_node) {
|
|
ret = sdhci_s3c_parse_dt(&pdev->dev, host, pdata);
|
|
if (ret)
|
|
goto err_pdata_io_clk;
|
|
} else {
|
|
memcpy(pdata, pdev->dev.platform_data, sizeof(*pdata));
|
|
sc->ext_cd_gpio = -1; /* invalid gpio number */
|
|
}
|
|
|
|
drv_data = sdhci_s3c_get_driver_data(pdev);
|
|
|
|
sc->host = host;
|
|
sc->pdev = pdev;
|
|
sc->pdata = pdata;
|
|
sc->cur_clk = -1;
|
|
|
|
platform_set_drvdata(pdev, host);
|
|
|
|
sc->clk_io = devm_clk_get(dev, "hsmmc");
|
|
if (IS_ERR(sc->clk_io)) {
|
|
dev_err(dev, "failed to get io clock\n");
|
|
ret = PTR_ERR(sc->clk_io);
|
|
goto err_pdata_io_clk;
|
|
}
|
|
|
|
/* enable the local io clock and keep it running for the moment. */
|
|
clk_prepare_enable(sc->clk_io);
|
|
|
|
for (clks = 0, ptr = 0; ptr < MAX_BUS_CLK; ptr++) {
|
|
char name[14];
|
|
|
|
snprintf(name, 14, "mmc_busclk.%d", ptr);
|
|
sc->clk_bus[ptr] = devm_clk_get(dev, name);
|
|
if (IS_ERR(sc->clk_bus[ptr]))
|
|
continue;
|
|
|
|
clks++;
|
|
sc->clk_rates[ptr] = clk_get_rate(sc->clk_bus[ptr]);
|
|
|
|
dev_info(dev, "clock source %d: %s (%ld Hz)\n",
|
|
ptr, name, sc->clk_rates[ptr]);
|
|
}
|
|
|
|
if (clks == 0) {
|
|
dev_err(dev, "failed to find any bus clocks\n");
|
|
ret = -ENOENT;
|
|
goto err_no_busclks;
|
|
}
|
|
|
|
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
|
host->ioaddr = devm_ioremap_resource(&pdev->dev, res);
|
|
if (IS_ERR(host->ioaddr)) {
|
|
ret = PTR_ERR(host->ioaddr);
|
|
goto err_req_regs;
|
|
}
|
|
|
|
/* Ensure we have minimal gpio selected CMD/CLK/Detect */
|
|
if (pdata->cfg_gpio)
|
|
pdata->cfg_gpio(pdev, pdata->max_width);
|
|
|
|
host->hw_name = "samsung-hsmmc";
|
|
host->ops = &sdhci_s3c_ops;
|
|
host->quirks = 0;
|
|
host->quirks2 = 0;
|
|
host->irq = irq;
|
|
|
|
/* Setup quirks for the controller */
|
|
host->quirks |= SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC;
|
|
host->quirks |= SDHCI_QUIRK_NO_HISPD_BIT;
|
|
if (drv_data) {
|
|
host->quirks |= drv_data->sdhci_quirks;
|
|
sc->no_divider = drv_data->no_divider;
|
|
}
|
|
|
|
#ifndef CONFIG_MMC_SDHCI_S3C_DMA
|
|
|
|
/* we currently see overruns on errors, so disable the SDMA
|
|
* support as well. */
|
|
host->quirks |= SDHCI_QUIRK_BROKEN_DMA;
|
|
|
|
#endif /* CONFIG_MMC_SDHCI_S3C_DMA */
|
|
|
|
/* It seems we do not get an DATA transfer complete on non-busy
|
|
* transfers, not sure if this is a problem with this specific
|
|
* SDHCI block, or a missing configuration that needs to be set. */
|
|
host->quirks |= SDHCI_QUIRK_NO_BUSY_IRQ;
|
|
|
|
/* This host supports the Auto CMD12 */
|
|
host->quirks |= SDHCI_QUIRK_MULTIBLOCK_READ_ACMD12;
|
|
|
|
/* Samsung SoCs need BROKEN_ADMA_ZEROLEN_DESC */
|
|
host->quirks |= SDHCI_QUIRK_BROKEN_ADMA_ZEROLEN_DESC;
|
|
|
|
if (pdata->cd_type == S3C_SDHCI_CD_NONE ||
|
|
pdata->cd_type == S3C_SDHCI_CD_PERMANENT)
|
|
host->quirks |= SDHCI_QUIRK_BROKEN_CARD_DETECTION;
|
|
|
|
if (pdata->cd_type == S3C_SDHCI_CD_PERMANENT)
|
|
host->mmc->caps = MMC_CAP_NONREMOVABLE;
|
|
|
|
switch (pdata->max_width) {
|
|
case 8:
|
|
host->mmc->caps |= MMC_CAP_8_BIT_DATA;
|
|
case 4:
|
|
host->mmc->caps |= MMC_CAP_4_BIT_DATA;
|
|
break;
|
|
}
|
|
|
|
if (pdata->pm_caps)
|
|
host->mmc->pm_caps |= pdata->pm_caps;
|
|
|
|
host->quirks |= (SDHCI_QUIRK_32BIT_DMA_ADDR |
|
|
SDHCI_QUIRK_32BIT_DMA_SIZE);
|
|
|
|
/* HSMMC on Samsung SoCs uses SDCLK as timeout clock */
|
|
host->quirks |= SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK;
|
|
|
|
/*
|
|
* If controller does not have internal clock divider,
|
|
* we can use overriding functions instead of default.
|
|
*/
|
|
if (sc->no_divider) {
|
|
sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
|
|
sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
|
|
sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
|
|
}
|
|
|
|
/* It supports additional host capabilities if needed */
|
|
if (pdata->host_caps)
|
|
host->mmc->caps |= pdata->host_caps;
|
|
|
|
if (pdata->host_caps2)
|
|
host->mmc->caps2 |= pdata->host_caps2;
|
|
|
|
pm_runtime_enable(&pdev->dev);
|
|
pm_runtime_set_autosuspend_delay(&pdev->dev, 50);
|
|
pm_runtime_use_autosuspend(&pdev->dev);
|
|
pm_suspend_ignore_children(&pdev->dev, 1);
|
|
|
|
mmc_of_parse(host->mmc);
|
|
|
|
ret = sdhci_add_host(host);
|
|
if (ret) {
|
|
dev_err(dev, "sdhci_add_host() failed\n");
|
|
goto err_req_regs;
|
|
}
|
|
|
|
#ifdef CONFIG_PM
|
|
if (pdata->cd_type != S3C_SDHCI_CD_INTERNAL)
|
|
clk_disable_unprepare(sc->clk_io);
|
|
#endif
|
|
return 0;
|
|
|
|
err_req_regs:
|
|
pm_runtime_disable(&pdev->dev);
|
|
|
|
err_no_busclks:
|
|
clk_disable_unprepare(sc->clk_io);
|
|
|
|
err_pdata_io_clk:
|
|
sdhci_free_host(host);
|
|
|
|
return ret;
|
|
}
|
|
|
|
static int sdhci_s3c_remove(struct platform_device *pdev)
|
|
{
|
|
struct sdhci_host *host = platform_get_drvdata(pdev);
|
|
struct sdhci_s3c *sc = sdhci_priv(host);
|
|
|
|
if (sc->ext_cd_irq)
|
|
free_irq(sc->ext_cd_irq, sc);
|
|
|
|
#ifdef CONFIG_PM
|
|
if (sc->pdata->cd_type != S3C_SDHCI_CD_INTERNAL)
|
|
clk_prepare_enable(sc->clk_io);
|
|
#endif
|
|
sdhci_remove_host(host, 1);
|
|
|
|
pm_runtime_dont_use_autosuspend(&pdev->dev);
|
|
pm_runtime_disable(&pdev->dev);
|
|
|
|
clk_disable_unprepare(sc->clk_io);
|
|
|
|
sdhci_free_host(host);
|
|
|
|
return 0;
|
|
}
|
|
|
|
#ifdef CONFIG_PM_SLEEP
|
|
static int sdhci_s3c_suspend(struct device *dev)
|
|
{
|
|
struct sdhci_host *host = dev_get_drvdata(dev);
|
|
|
|
return sdhci_suspend_host(host);
|
|
}
|
|
|
|
static int sdhci_s3c_resume(struct device *dev)
|
|
{
|
|
struct sdhci_host *host = dev_get_drvdata(dev);
|
|
|
|
return sdhci_resume_host(host);
|
|
}
|
|
#endif
|
|
|
|
#ifdef CONFIG_PM
|
|
static int sdhci_s3c_runtime_suspend(struct device *dev)
|
|
{
|
|
struct sdhci_host *host = dev_get_drvdata(dev);
|
|
struct sdhci_s3c *ourhost = to_s3c(host);
|
|
struct clk *busclk = ourhost->clk_io;
|
|
int ret;
|
|
|
|
ret = sdhci_runtime_suspend_host(host);
|
|
|
|
if (ourhost->cur_clk >= 0)
|
|
clk_disable_unprepare(ourhost->clk_bus[ourhost->cur_clk]);
|
|
clk_disable_unprepare(busclk);
|
|
return ret;
|
|
}
|
|
|
|
static int sdhci_s3c_runtime_resume(struct device *dev)
|
|
{
|
|
struct sdhci_host *host = dev_get_drvdata(dev);
|
|
struct sdhci_s3c *ourhost = to_s3c(host);
|
|
struct clk *busclk = ourhost->clk_io;
|
|
int ret;
|
|
|
|
clk_prepare_enable(busclk);
|
|
if (ourhost->cur_clk >= 0)
|
|
clk_prepare_enable(ourhost->clk_bus[ourhost->cur_clk]);
|
|
ret = sdhci_runtime_resume_host(host);
|
|
return ret;
|
|
}
|
|
#endif
|
|
|
|
#ifdef CONFIG_PM
|
|
static const struct dev_pm_ops sdhci_s3c_pmops = {
|
|
SET_SYSTEM_SLEEP_PM_OPS(sdhci_s3c_suspend, sdhci_s3c_resume)
|
|
SET_RUNTIME_PM_OPS(sdhci_s3c_runtime_suspend, sdhci_s3c_runtime_resume,
|
|
NULL)
|
|
};
|
|
|
|
#define SDHCI_S3C_PMOPS (&sdhci_s3c_pmops)
|
|
|
|
#else
|
|
#define SDHCI_S3C_PMOPS NULL
|
|
#endif
|
|
|
|
#if defined(CONFIG_CPU_EXYNOS4210) || defined(CONFIG_SOC_EXYNOS4212)
|
|
static struct sdhci_s3c_drv_data exynos4_sdhci_drv_data = {
|
|
.no_divider = true,
|
|
};
|
|
#define EXYNOS4_SDHCI_DRV_DATA ((kernel_ulong_t)&exynos4_sdhci_drv_data)
|
|
#else
|
|
#define EXYNOS4_SDHCI_DRV_DATA ((kernel_ulong_t)NULL)
|
|
#endif
|
|
|
|
static struct platform_device_id sdhci_s3c_driver_ids[] = {
|
|
{
|
|
.name = "s3c-sdhci",
|
|
.driver_data = (kernel_ulong_t)NULL,
|
|
}, {
|
|
.name = "exynos4-sdhci",
|
|
.driver_data = EXYNOS4_SDHCI_DRV_DATA,
|
|
},
|
|
{ }
|
|
};
|
|
MODULE_DEVICE_TABLE(platform, sdhci_s3c_driver_ids);
|
|
|
|
#ifdef CONFIG_OF
|
|
static const struct of_device_id sdhci_s3c_dt_match[] = {
|
|
{ .compatible = "samsung,s3c6410-sdhci", },
|
|
{ .compatible = "samsung,exynos4210-sdhci",
|
|
.data = (void *)EXYNOS4_SDHCI_DRV_DATA },
|
|
{},
|
|
};
|
|
MODULE_DEVICE_TABLE(of, sdhci_s3c_dt_match);
|
|
#endif
|
|
|
|
static struct platform_driver sdhci_s3c_driver = {
|
|
.probe = sdhci_s3c_probe,
|
|
.remove = sdhci_s3c_remove,
|
|
.id_table = sdhci_s3c_driver_ids,
|
|
.driver = {
|
|
.name = "s3c-sdhci",
|
|
.of_match_table = of_match_ptr(sdhci_s3c_dt_match),
|
|
.pm = SDHCI_S3C_PMOPS,
|
|
},
|
|
};
|
|
|
|
module_platform_driver(sdhci_s3c_driver);
|
|
|
|
MODULE_DESCRIPTION("Samsung SDHCI (HSMMC) glue");
|
|
MODULE_AUTHOR("Ben Dooks, <ben@simtec.co.uk>");
|
|
MODULE_LICENSE("GPL v2");
|
|
MODULE_ALIAS("platform:s3c-sdhci");
|