mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-20 02:34:23 +08:00
c0f486fde3
- Fix a regression in leds-gpio introduced by a recent commit that inadvertently changed the name of one of the properties used by the driver (Fabio Estevam). - Fix a regression in the ACPI backlight driver introduced by a recent fix that missed one special case that had to be taken into account (Aaron Lu). - Drop the level of some new kernel messages from the ACPI core introduced by a recent commit to KERN_DEBUG which they should have used from the start and drop some other unuseful KERN_ERR messages printed by ACPI (Rafael J Wysocki). - Revert an incorrect commit modifying the cpupower tool (Prarit Bhargava). - Fix two regressions introduced by recent commits in the OPP library and clean up some existing minor issues in that code (Viresh Kumar). - Continue to replace CONFIG_PM_RUNTIME with CONFIG_PM throughout the tree (or drop it where that can be done) in order to make it possible to eliminate CONFIG_PM_RUNTIME (Rafael J Wysocki, Ulf Hansson, Ludovic Desroches). There will be one more "CONFIG_PM_RUNTIME removal" batch after this one, because some new uses of it have been introduced during the current merge window, but that should be sufficient to finally get rid of it. - Make the ACPI EC driver more robust against race conditions related to GPE handler installation failures (Lv Zheng). - Prevent the ACPI device PM core code from attempting to disable GPEs that it has not enabled which confuses ACPICA and makes it report errors unnecessarily (Rafael J Wysocki). - Add a "force" command line switch to the intel_pstate driver to make it possible to override the blacklisting of some systems in that driver if needed (Ethan Zhao). - Improve intel_pstate code documentation and add a MAINTAINERS entry for it (Kristen Carlson Accardi). - Make the ACPI fan driver create cooling device interfaces witn names that reflect the IDs of the ACPI device objects they are associated with, except for "generic" ACPI fans (PNP ID "PNP0C0B"). That's necessary for user space thermal management tools to be able to connect the fans with the parts of the system they are supposed to be cooling properly. From Srinivas Pandruvada. / -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (GNU/Linux) iQIcBAABCAAGBQJUk0IDAAoJEILEb/54YlRx7fgP/3+yF/0TnEW93j2ALDAQFiLF tSv2A2vQC8vtMJjjWx0z/HqPh86gfaReEFZmUJD/Q/e2LXEnxNZJ+QMjcekPVkDM mTvcIMc2MR8vOA/oMkgxeaKregrrx7RkCfojd+NWZhVukkjl+mvBHgAnYjXRL+NZ unDWGlbHG97vq/3kGjPYhDS00nxHblw8NHFBu5HL5RxwABdWoeZJITwqxXWyuPLw nlqNWlOxmwvtSbw2VMKz0uof1nFHyQLykYsMG0ZsyayCRdWUZYkEqmE7GGpCLkLu D6yfmlpen6ccIOsEAae0eXBt50IFY9Tihk5lovx1mZmci2SNRg29BqMI105wIn0u 8b8Ej7MNHp7yMxRpB5WfU90p/y7ioJns9guFZxY0CKaRnrI2+BLt3RscMi3MPI06 Cu2/WkSSa09fhDPA+pk+VDYsmWgyVawigesNmMP5/cvYO/yYywVRjOuO1k77qQGp 4dSpFYEHfpxinejZnVZOk2V9MkvSLoSMux6wPV0xM0IE1iD0ulVpHjTJrwp80ph4 +bfUFVr/vrD1y7EKbf1PD363ZKvJhWhvQWDgETsM1vgLf21PfWO7C2kflIAsWsdQ 1ukD5nCBRlP4K73hG7bdM6kRztXhUdR0SHg85/t0KB/ExiVqtcXIzB60D0G1lENd QlKbq3O4lim1WGuhazQY =5fo2 -----END PGP SIGNATURE----- Merge tag 'pm+acpi-3.19-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm Pull more ACPI and power management updates from Rafael Wysocki: "These are regression fixes (leds-gpio, ACPI backlight driver, operating performance points library, ACPI device enumeration messages, cpupower tool), other bug fixes (ACPI EC driver, ACPI device PM), some cleanups in the operating performance points (OPP) framework, continuation of CONFIG_PM_RUNTIME elimination, a couple of minor intel_pstate driver changes, a new MAINTAINERS entry for it and an ACPI fan driver change needed for better support of thermal management in user space. Specifics: - Fix a regression in leds-gpio introduced by a recent commit that inadvertently changed the name of one of the properties used by the driver (Fabio Estevam). - Fix a regression in the ACPI backlight driver introduced by a recent fix that missed one special case that had to be taken into account (Aaron Lu). - Drop the level of some new kernel messages from the ACPI core introduced by a recent commit to KERN_DEBUG which they should have used from the start and drop some other unuseful KERN_ERR messages printed by ACPI (Rafael J Wysocki). - Revert an incorrect commit modifying the cpupower tool (Prarit Bhargava). - Fix two regressions introduced by recent commits in the OPP library and clean up some existing minor issues in that code (Viresh Kumar). - Continue to replace CONFIG_PM_RUNTIME with CONFIG_PM throughout the tree (or drop it where that can be done) in order to make it possible to eliminate CONFIG_PM_RUNTIME (Rafael J Wysocki, Ulf Hansson, Ludovic Desroches). There will be one more "CONFIG_PM_RUNTIME removal" batch after this one, because some new uses of it have been introduced during the current merge window, but that should be sufficient to finally get rid of it. - Make the ACPI EC driver more robust against race conditions related to GPE handler installation failures (Lv Zheng). - Prevent the ACPI device PM core code from attempting to disable GPEs that it has not enabled which confuses ACPICA and makes it report errors unnecessarily (Rafael J Wysocki). - Add a "force" command line switch to the intel_pstate driver to make it possible to override the blacklisting of some systems in that driver if needed (Ethan Zhao). - Improve intel_pstate code documentation and add a MAINTAINERS entry for it (Kristen Carlson Accardi). - Make the ACPI fan driver create cooling device interfaces witn names that reflect the IDs of the ACPI device objects they are associated with, except for "generic" ACPI fans (PNP ID "PNP0C0B"). That's necessary for user space thermal management tools to be able to connect the fans with the parts of the system they are supposed to be cooling properly. From Srinivas Pandruvada" * tag 'pm+acpi-3.19-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: (32 commits) MAINTAINERS: add entry for intel_pstate ACPI / video: update the skip case for acpi_video_device_in_dod() power / PM: Eliminate CONFIG_PM_RUNTIME NFC / PM: Replace CONFIG_PM_RUNTIME with CONFIG_PM SCSI / PM: Replace CONFIG_PM_RUNTIME with CONFIG_PM ACPI / EC: Fix unexpected ec_remove_handlers() invocations Revert "tools: cpupower: fix return checks for sysfs_get_idlestate_count()" tracing / PM: Replace CONFIG_PM_RUNTIME with CONFIG_PM x86 / PM: Replace CONFIG_PM_RUNTIME in io_apic.c PM: Remove the SET_PM_RUNTIME_PM_OPS() macro mmc: atmel-mci: use SET_RUNTIME_PM_OPS() macro PM / Kconfig: Replace PM_RUNTIME with PM in dependencies ARM / PM: Replace CONFIG_PM_RUNTIME with CONFIG_PM sound / PM: Replace CONFIG_PM_RUNTIME with CONFIG_PM phy / PM: Replace CONFIG_PM_RUNTIME with CONFIG_PM video / PM: Replace CONFIG_PM_RUNTIME with CONFIG_PM tty / PM: Replace CONFIG_PM_RUNTIME with CONFIG_PM spi: Replace CONFIG_PM_RUNTIME with CONFIG_PM ACPI / PM: Do not disable wakeup GPEs that have not been enabled ACPI / utils: Drop error messages from acpi_evaluate_reference() ...
405 lines
10 KiB
C
405 lines
10 KiB
C
/*
|
|
* Universal Flash Storage Host controller Platform bus based glue driver
|
|
*
|
|
* This code is based on drivers/scsi/ufs/ufshcd-pltfrm.c
|
|
* Copyright (C) 2011-2013 Samsung India Software Operations
|
|
*
|
|
* Authors:
|
|
* Santosh Yaraganavi <santosh.sy@samsung.com>
|
|
* Vinayak Holikatti <h.vinayak@samsung.com>
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public License
|
|
* as published by the Free Software Foundation; either version 2
|
|
* of the License, or (at your option) any later version.
|
|
* See the COPYING file in the top-level directory or visit
|
|
* <http://www.gnu.org/licenses/gpl-2.0.html>
|
|
*
|
|
* 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.
|
|
*
|
|
* This program is provided "AS IS" and "WITH ALL FAULTS" and
|
|
* without warranty of any kind. You are solely responsible for
|
|
* determining the appropriateness of using and distributing
|
|
* the program and assume all risks associated with your exercise
|
|
* of rights with respect to the program, including but not limited
|
|
* to infringement of third party rights, the risks and costs of
|
|
* program errors, damage to or loss of data, programs or equipment,
|
|
* and unavailability or interruption of operations. Under no
|
|
* circumstances will the contributor of this Program be liable for
|
|
* any damages of any kind arising from your use or distribution of
|
|
* this program.
|
|
*/
|
|
|
|
#include <linux/platform_device.h>
|
|
#include <linux/pm_runtime.h>
|
|
#include <linux/of.h>
|
|
|
|
#include "ufshcd.h"
|
|
|
|
static const struct of_device_id ufs_of_match[];
|
|
static struct ufs_hba_variant_ops *get_variant_ops(struct device *dev)
|
|
{
|
|
if (dev->of_node) {
|
|
const struct of_device_id *match;
|
|
|
|
match = of_match_node(ufs_of_match, dev->of_node);
|
|
if (match)
|
|
return (struct ufs_hba_variant_ops *)match->data;
|
|
}
|
|
|
|
return NULL;
|
|
}
|
|
|
|
static int ufshcd_parse_clock_info(struct ufs_hba *hba)
|
|
{
|
|
int ret = 0;
|
|
int cnt;
|
|
int i;
|
|
struct device *dev = hba->dev;
|
|
struct device_node *np = dev->of_node;
|
|
char *name;
|
|
u32 *clkfreq = NULL;
|
|
struct ufs_clk_info *clki;
|
|
int len = 0;
|
|
size_t sz = 0;
|
|
|
|
if (!np)
|
|
goto out;
|
|
|
|
INIT_LIST_HEAD(&hba->clk_list_head);
|
|
|
|
cnt = of_property_count_strings(np, "clock-names");
|
|
if (!cnt || (cnt == -EINVAL)) {
|
|
dev_info(dev, "%s: Unable to find clocks, assuming enabled\n",
|
|
__func__);
|
|
} else if (cnt < 0) {
|
|
dev_err(dev, "%s: count clock strings failed, err %d\n",
|
|
__func__, cnt);
|
|
ret = cnt;
|
|
}
|
|
|
|
if (cnt <= 0)
|
|
goto out;
|
|
|
|
if (!of_get_property(np, "freq-table-hz", &len)) {
|
|
dev_info(dev, "freq-table-hz property not specified\n");
|
|
goto out;
|
|
}
|
|
|
|
if (len <= 0)
|
|
goto out;
|
|
|
|
sz = len / sizeof(*clkfreq);
|
|
if (sz != 2 * cnt) {
|
|
dev_err(dev, "%s len mismatch\n", "freq-table-hz");
|
|
ret = -EINVAL;
|
|
goto out;
|
|
}
|
|
|
|
clkfreq = devm_kzalloc(dev, sz * sizeof(*clkfreq),
|
|
GFP_KERNEL);
|
|
if (!clkfreq) {
|
|
ret = -ENOMEM;
|
|
goto out;
|
|
}
|
|
|
|
ret = of_property_read_u32_array(np, "freq-table-hz",
|
|
clkfreq, sz);
|
|
if (ret && (ret != -EINVAL)) {
|
|
dev_err(dev, "%s: error reading array %d\n",
|
|
"freq-table-hz", ret);
|
|
return ret;
|
|
}
|
|
|
|
for (i = 0; i < sz; i += 2) {
|
|
ret = of_property_read_string_index(np,
|
|
"clock-names", i/2, (const char **)&name);
|
|
if (ret)
|
|
goto out;
|
|
|
|
clki = devm_kzalloc(dev, sizeof(*clki), GFP_KERNEL);
|
|
if (!clki) {
|
|
ret = -ENOMEM;
|
|
goto out;
|
|
}
|
|
|
|
clki->min_freq = clkfreq[i];
|
|
clki->max_freq = clkfreq[i+1];
|
|
clki->name = kstrdup(name, GFP_KERNEL);
|
|
dev_dbg(dev, "%s: min %u max %u name %s\n", "freq-table-hz",
|
|
clki->min_freq, clki->max_freq, clki->name);
|
|
list_add_tail(&clki->list, &hba->clk_list_head);
|
|
}
|
|
out:
|
|
return ret;
|
|
}
|
|
|
|
#define MAX_PROP_SIZE 32
|
|
static int ufshcd_populate_vreg(struct device *dev, const char *name,
|
|
struct ufs_vreg **out_vreg)
|
|
{
|
|
int ret = 0;
|
|
char prop_name[MAX_PROP_SIZE];
|
|
struct ufs_vreg *vreg = NULL;
|
|
struct device_node *np = dev->of_node;
|
|
|
|
if (!np) {
|
|
dev_err(dev, "%s: non DT initialization\n", __func__);
|
|
goto out;
|
|
}
|
|
|
|
snprintf(prop_name, MAX_PROP_SIZE, "%s-supply", name);
|
|
if (!of_parse_phandle(np, prop_name, 0)) {
|
|
dev_info(dev, "%s: Unable to find %s regulator, assuming enabled\n",
|
|
__func__, prop_name);
|
|
goto out;
|
|
}
|
|
|
|
vreg = devm_kzalloc(dev, sizeof(*vreg), GFP_KERNEL);
|
|
if (!vreg)
|
|
return -ENOMEM;
|
|
|
|
vreg->name = kstrdup(name, GFP_KERNEL);
|
|
|
|
/* if fixed regulator no need further initialization */
|
|
snprintf(prop_name, MAX_PROP_SIZE, "%s-fixed-regulator", name);
|
|
if (of_property_read_bool(np, prop_name))
|
|
goto out;
|
|
|
|
snprintf(prop_name, MAX_PROP_SIZE, "%s-max-microamp", name);
|
|
ret = of_property_read_u32(np, prop_name, &vreg->max_uA);
|
|
if (ret) {
|
|
dev_err(dev, "%s: unable to find %s err %d\n",
|
|
__func__, prop_name, ret);
|
|
goto out_free;
|
|
}
|
|
|
|
vreg->min_uA = 0;
|
|
if (!strcmp(name, "vcc")) {
|
|
if (of_property_read_bool(np, "vcc-supply-1p8")) {
|
|
vreg->min_uV = UFS_VREG_VCC_1P8_MIN_UV;
|
|
vreg->max_uV = UFS_VREG_VCC_1P8_MAX_UV;
|
|
} else {
|
|
vreg->min_uV = UFS_VREG_VCC_MIN_UV;
|
|
vreg->max_uV = UFS_VREG_VCC_MAX_UV;
|
|
}
|
|
} else if (!strcmp(name, "vccq")) {
|
|
vreg->min_uV = UFS_VREG_VCCQ_MIN_UV;
|
|
vreg->max_uV = UFS_VREG_VCCQ_MAX_UV;
|
|
} else if (!strcmp(name, "vccq2")) {
|
|
vreg->min_uV = UFS_VREG_VCCQ2_MIN_UV;
|
|
vreg->max_uV = UFS_VREG_VCCQ2_MAX_UV;
|
|
}
|
|
|
|
goto out;
|
|
|
|
out_free:
|
|
devm_kfree(dev, vreg);
|
|
vreg = NULL;
|
|
out:
|
|
if (!ret)
|
|
*out_vreg = vreg;
|
|
return ret;
|
|
}
|
|
|
|
/**
|
|
* ufshcd_parse_regulator_info - get regulator info from device tree
|
|
* @hba: per adapter instance
|
|
*
|
|
* Get regulator info from device tree for vcc, vccq, vccq2 power supplies.
|
|
* If any of the supplies are not defined it is assumed that they are always-on
|
|
* and hence return zero. If the property is defined but parsing is failed
|
|
* then return corresponding error.
|
|
*/
|
|
static int ufshcd_parse_regulator_info(struct ufs_hba *hba)
|
|
{
|
|
int err;
|
|
struct device *dev = hba->dev;
|
|
struct ufs_vreg_info *info = &hba->vreg_info;
|
|
|
|
err = ufshcd_populate_vreg(dev, "vdd-hba", &info->vdd_hba);
|
|
if (err)
|
|
goto out;
|
|
|
|
err = ufshcd_populate_vreg(dev, "vcc", &info->vcc);
|
|
if (err)
|
|
goto out;
|
|
|
|
err = ufshcd_populate_vreg(dev, "vccq", &info->vccq);
|
|
if (err)
|
|
goto out;
|
|
|
|
err = ufshcd_populate_vreg(dev, "vccq2", &info->vccq2);
|
|
out:
|
|
return err;
|
|
}
|
|
|
|
#ifdef CONFIG_PM
|
|
/**
|
|
* ufshcd_pltfrm_suspend - suspend power management function
|
|
* @dev: pointer to device handle
|
|
*
|
|
* Returns 0 if successful
|
|
* Returns non-zero otherwise
|
|
*/
|
|
static int ufshcd_pltfrm_suspend(struct device *dev)
|
|
{
|
|
return ufshcd_system_suspend(dev_get_drvdata(dev));
|
|
}
|
|
|
|
/**
|
|
* ufshcd_pltfrm_resume - resume power management function
|
|
* @dev: pointer to device handle
|
|
*
|
|
* Returns 0 if successful
|
|
* Returns non-zero otherwise
|
|
*/
|
|
static int ufshcd_pltfrm_resume(struct device *dev)
|
|
{
|
|
return ufshcd_system_resume(dev_get_drvdata(dev));
|
|
}
|
|
|
|
static int ufshcd_pltfrm_runtime_suspend(struct device *dev)
|
|
{
|
|
return ufshcd_runtime_suspend(dev_get_drvdata(dev));
|
|
}
|
|
static int ufshcd_pltfrm_runtime_resume(struct device *dev)
|
|
{
|
|
return ufshcd_runtime_resume(dev_get_drvdata(dev));
|
|
}
|
|
static int ufshcd_pltfrm_runtime_idle(struct device *dev)
|
|
{
|
|
return ufshcd_runtime_idle(dev_get_drvdata(dev));
|
|
}
|
|
#else /* !CONFIG_PM */
|
|
#define ufshcd_pltfrm_suspend NULL
|
|
#define ufshcd_pltfrm_resume NULL
|
|
#define ufshcd_pltfrm_runtime_suspend NULL
|
|
#define ufshcd_pltfrm_runtime_resume NULL
|
|
#define ufshcd_pltfrm_runtime_idle NULL
|
|
#endif /* CONFIG_PM */
|
|
|
|
static void ufshcd_pltfrm_shutdown(struct platform_device *pdev)
|
|
{
|
|
ufshcd_shutdown((struct ufs_hba *)platform_get_drvdata(pdev));
|
|
}
|
|
|
|
/**
|
|
* ufshcd_pltfrm_probe - probe routine of the driver
|
|
* @pdev: pointer to Platform device handle
|
|
*
|
|
* Returns 0 on success, non-zero value on failure
|
|
*/
|
|
static int ufshcd_pltfrm_probe(struct platform_device *pdev)
|
|
{
|
|
struct ufs_hba *hba;
|
|
void __iomem *mmio_base;
|
|
struct resource *mem_res;
|
|
int irq, err;
|
|
struct device *dev = &pdev->dev;
|
|
|
|
mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
|
mmio_base = devm_ioremap_resource(dev, mem_res);
|
|
if (IS_ERR(*(void **)&mmio_base)) {
|
|
err = PTR_ERR(*(void **)&mmio_base);
|
|
goto out;
|
|
}
|
|
|
|
irq = platform_get_irq(pdev, 0);
|
|
if (irq < 0) {
|
|
dev_err(dev, "IRQ resource not available\n");
|
|
err = -ENODEV;
|
|
goto out;
|
|
}
|
|
|
|
err = ufshcd_alloc_host(dev, &hba);
|
|
if (err) {
|
|
dev_err(&pdev->dev, "Allocation failed\n");
|
|
goto out;
|
|
}
|
|
|
|
hba->vops = get_variant_ops(&pdev->dev);
|
|
|
|
err = ufshcd_parse_clock_info(hba);
|
|
if (err) {
|
|
dev_err(&pdev->dev, "%s: clock parse failed %d\n",
|
|
__func__, err);
|
|
goto out;
|
|
}
|
|
err = ufshcd_parse_regulator_info(hba);
|
|
if (err) {
|
|
dev_err(&pdev->dev, "%s: regulator init failed %d\n",
|
|
__func__, err);
|
|
goto out;
|
|
}
|
|
|
|
pm_runtime_set_active(&pdev->dev);
|
|
pm_runtime_enable(&pdev->dev);
|
|
|
|
err = ufshcd_init(hba, mmio_base, irq);
|
|
if (err) {
|
|
dev_err(dev, "Intialization failed\n");
|
|
goto out_disable_rpm;
|
|
}
|
|
|
|
platform_set_drvdata(pdev, hba);
|
|
|
|
return 0;
|
|
|
|
out_disable_rpm:
|
|
pm_runtime_disable(&pdev->dev);
|
|
pm_runtime_set_suspended(&pdev->dev);
|
|
out:
|
|
return err;
|
|
}
|
|
|
|
/**
|
|
* ufshcd_pltfrm_remove - remove platform driver routine
|
|
* @pdev: pointer to platform device handle
|
|
*
|
|
* Returns 0 on success, non-zero value on failure
|
|
*/
|
|
static int ufshcd_pltfrm_remove(struct platform_device *pdev)
|
|
{
|
|
struct ufs_hba *hba = platform_get_drvdata(pdev);
|
|
|
|
pm_runtime_get_sync(&(pdev)->dev);
|
|
ufshcd_remove(hba);
|
|
return 0;
|
|
}
|
|
|
|
static const struct of_device_id ufs_of_match[] = {
|
|
{ .compatible = "jedec,ufs-1.1"},
|
|
{},
|
|
};
|
|
|
|
static const struct dev_pm_ops ufshcd_dev_pm_ops = {
|
|
.suspend = ufshcd_pltfrm_suspend,
|
|
.resume = ufshcd_pltfrm_resume,
|
|
.runtime_suspend = ufshcd_pltfrm_runtime_suspend,
|
|
.runtime_resume = ufshcd_pltfrm_runtime_resume,
|
|
.runtime_idle = ufshcd_pltfrm_runtime_idle,
|
|
};
|
|
|
|
static struct platform_driver ufshcd_pltfrm_driver = {
|
|
.probe = ufshcd_pltfrm_probe,
|
|
.remove = ufshcd_pltfrm_remove,
|
|
.shutdown = ufshcd_pltfrm_shutdown,
|
|
.driver = {
|
|
.name = "ufshcd",
|
|
.pm = &ufshcd_dev_pm_ops,
|
|
.of_match_table = ufs_of_match,
|
|
},
|
|
};
|
|
|
|
module_platform_driver(ufshcd_pltfrm_driver);
|
|
|
|
MODULE_AUTHOR("Santosh Yaragnavi <santosh.sy@samsung.com>");
|
|
MODULE_AUTHOR("Vinayak Holikatti <h.vinayak@samsung.com>");
|
|
MODULE_DESCRIPTION("UFS host controller Pltform bus based glue driver");
|
|
MODULE_LICENSE("GPL");
|
|
MODULE_VERSION(UFSHCD_DRIVER_VERSION);
|