2019-05-28 09:57:24 -07:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
2011-04-01 05:43:33 -07:00
|
|
|
/*
|
|
|
|
* Copyright (C) ST-Ericsson SA 2010
|
|
|
|
*
|
|
|
|
* Authors: Sundar Iyer <sundar.iyer@stericsson.com> for ST-Ericsson
|
|
|
|
* Bengt Jonsson <bengt.g.jonsson@stericsson.com> for ST-Ericsson
|
|
|
|
*
|
|
|
|
* Power domain regulators on DB8500
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/err.h>
|
|
|
|
#include <linux/spinlock.h>
|
|
|
|
#include <linux/platform_device.h>
|
2011-08-12 01:28:10 -07:00
|
|
|
#include <linux/mfd/dbx500-prcmu.h>
|
2011-04-01 05:43:33 -07:00
|
|
|
#include <linux/regulator/driver.h>
|
|
|
|
#include <linux/regulator/machine.h>
|
|
|
|
#include <linux/regulator/db8500-prcmu.h>
|
2012-05-18 01:39:06 -07:00
|
|
|
#include <linux/regulator/of_regulator.h>
|
|
|
|
#include <linux/of.h>
|
2011-07-17 13:28:23 -07:00
|
|
|
#include <linux/module.h>
|
2012-01-13 08:30:31 -07:00
|
|
|
#include "dbx500-prcmu.h"
|
2011-04-01 05:43:33 -07:00
|
|
|
|
|
|
|
static int db8500_regulator_enable(struct regulator_dev *rdev)
|
|
|
|
{
|
2012-01-13 08:30:31 -07:00
|
|
|
struct dbx500_regulator_info *info = rdev_get_drvdata(rdev);
|
2011-04-01 05:43:33 -07:00
|
|
|
|
|
|
|
if (info == NULL)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
dev_vdbg(rdev_get_dev(rdev), "regulator-%s-enable\n",
|
|
|
|
info->desc.name);
|
|
|
|
|
2012-01-13 08:30:31 -07:00
|
|
|
if (!info->is_enabled) {
|
|
|
|
info->is_enabled = true;
|
|
|
|
if (!info->exclude_from_power_state)
|
|
|
|
power_state_active_enable();
|
|
|
|
}
|
2011-04-01 05:43:33 -07:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int db8500_regulator_disable(struct regulator_dev *rdev)
|
|
|
|
{
|
2012-01-13 08:30:31 -07:00
|
|
|
struct dbx500_regulator_info *info = rdev_get_drvdata(rdev);
|
2011-04-01 05:43:33 -07:00
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
if (info == NULL)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
dev_vdbg(rdev_get_dev(rdev), "regulator-%s-disable\n",
|
|
|
|
info->desc.name);
|
|
|
|
|
2012-01-13 08:30:31 -07:00
|
|
|
if (info->is_enabled) {
|
|
|
|
info->is_enabled = false;
|
|
|
|
if (!info->exclude_from_power_state)
|
|
|
|
ret = power_state_active_disable();
|
|
|
|
}
|
2011-04-01 05:43:33 -07:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int db8500_regulator_is_enabled(struct regulator_dev *rdev)
|
|
|
|
{
|
2012-01-13 08:30:31 -07:00
|
|
|
struct dbx500_regulator_info *info = rdev_get_drvdata(rdev);
|
2011-04-01 05:43:33 -07:00
|
|
|
|
|
|
|
if (info == NULL)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
dev_vdbg(rdev_get_dev(rdev), "regulator-%s-is_enabled (is_enabled):"
|
|
|
|
" %i\n", info->desc.name, info->is_enabled);
|
|
|
|
|
|
|
|
return info->is_enabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* db8500 regulator operations */
|
2019-04-11 18:54:19 -07:00
|
|
|
static const struct regulator_ops db8500_regulator_ops = {
|
2011-04-01 05:43:33 -07:00
|
|
|
.enable = db8500_regulator_enable,
|
|
|
|
.disable = db8500_regulator_disable,
|
|
|
|
.is_enabled = db8500_regulator_is_enabled,
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* EPOD control
|
|
|
|
*/
|
|
|
|
static bool epod_on[NUM_EPOD_ID];
|
|
|
|
static bool epod_ramret[NUM_EPOD_ID];
|
|
|
|
|
|
|
|
static int enable_epod(u16 epod_id, bool ramret)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (ramret) {
|
|
|
|
if (!epod_on[epod_id]) {
|
|
|
|
ret = prcmu_set_epod(epod_id, EPOD_STATE_RAMRET);
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
epod_ramret[epod_id] = true;
|
|
|
|
} else {
|
|
|
|
ret = prcmu_set_epod(epod_id, EPOD_STATE_ON);
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
epod_on[epod_id] = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int disable_epod(u16 epod_id, bool ramret)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (ramret) {
|
|
|
|
if (!epod_on[epod_id]) {
|
|
|
|
ret = prcmu_set_epod(epod_id, EPOD_STATE_OFF);
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
epod_ramret[epod_id] = false;
|
|
|
|
} else {
|
|
|
|
if (epod_ramret[epod_id]) {
|
|
|
|
ret = prcmu_set_epod(epod_id, EPOD_STATE_RAMRET);
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
} else {
|
|
|
|
ret = prcmu_set_epod(epod_id, EPOD_STATE_OFF);
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
epod_on[epod_id] = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Regulator switch
|
|
|
|
*/
|
|
|
|
static int db8500_regulator_switch_enable(struct regulator_dev *rdev)
|
|
|
|
{
|
2012-01-13 08:30:31 -07:00
|
|
|
struct dbx500_regulator_info *info = rdev_get_drvdata(rdev);
|
2011-04-01 05:43:33 -07:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (info == NULL)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
dev_vdbg(rdev_get_dev(rdev), "regulator-switch-%s-enable\n",
|
|
|
|
info->desc.name);
|
|
|
|
|
|
|
|
ret = enable_epod(info->epod_id, info->is_ramret);
|
|
|
|
if (ret < 0) {
|
|
|
|
dev_err(rdev_get_dev(rdev),
|
|
|
|
"regulator-switch-%s-enable: prcmu call failed\n",
|
|
|
|
info->desc.name);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
info->is_enabled = true;
|
|
|
|
out:
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int db8500_regulator_switch_disable(struct regulator_dev *rdev)
|
|
|
|
{
|
2012-01-13 08:30:31 -07:00
|
|
|
struct dbx500_regulator_info *info = rdev_get_drvdata(rdev);
|
2011-04-01 05:43:33 -07:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (info == NULL)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
dev_vdbg(rdev_get_dev(rdev), "regulator-switch-%s-disable\n",
|
|
|
|
info->desc.name);
|
|
|
|
|
|
|
|
ret = disable_epod(info->epod_id, info->is_ramret);
|
|
|
|
if (ret < 0) {
|
|
|
|
dev_err(rdev_get_dev(rdev),
|
|
|
|
"regulator_switch-%s-disable: prcmu call failed\n",
|
|
|
|
info->desc.name);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2020-05-05 23:17:26 -07:00
|
|
|
info->is_enabled = false;
|
2011-04-01 05:43:33 -07:00
|
|
|
out:
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int db8500_regulator_switch_is_enabled(struct regulator_dev *rdev)
|
|
|
|
{
|
2012-01-13 08:30:31 -07:00
|
|
|
struct dbx500_regulator_info *info = rdev_get_drvdata(rdev);
|
2011-04-01 05:43:33 -07:00
|
|
|
|
|
|
|
if (info == NULL)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
dev_vdbg(rdev_get_dev(rdev),
|
|
|
|
"regulator-switch-%s-is_enabled (is_enabled): %i\n",
|
|
|
|
info->desc.name, info->is_enabled);
|
|
|
|
|
|
|
|
return info->is_enabled;
|
|
|
|
}
|
|
|
|
|
2019-04-11 18:54:19 -07:00
|
|
|
static const struct regulator_ops db8500_regulator_switch_ops = {
|
2011-04-01 05:43:33 -07:00
|
|
|
.enable = db8500_regulator_switch_enable,
|
|
|
|
.disable = db8500_regulator_switch_disable,
|
|
|
|
.is_enabled = db8500_regulator_switch_is_enabled,
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Regulator information
|
|
|
|
*/
|
2012-01-13 08:30:31 -07:00
|
|
|
static struct dbx500_regulator_info
|
|
|
|
dbx500_regulator_info[DB8500_NUM_REGULATORS] = {
|
2011-04-01 05:43:33 -07:00
|
|
|
[DB8500_REGULATOR_VAPE] = {
|
|
|
|
.desc = {
|
|
|
|
.name = "db8500-vape",
|
2019-04-11 18:54:20 -07:00
|
|
|
.of_match = of_match_ptr("db8500_vape"),
|
2011-04-01 05:43:33 -07:00
|
|
|
.id = DB8500_REGULATOR_VAPE,
|
|
|
|
.ops = &db8500_regulator_ops,
|
|
|
|
.type = REGULATOR_VOLTAGE,
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
[DB8500_REGULATOR_VARM] = {
|
|
|
|
.desc = {
|
|
|
|
.name = "db8500-varm",
|
2019-04-11 18:54:20 -07:00
|
|
|
.of_match = of_match_ptr("db8500_varm"),
|
2011-04-01 05:43:33 -07:00
|
|
|
.id = DB8500_REGULATOR_VARM,
|
|
|
|
.ops = &db8500_regulator_ops,
|
|
|
|
.type = REGULATOR_VOLTAGE,
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
[DB8500_REGULATOR_VMODEM] = {
|
|
|
|
.desc = {
|
|
|
|
.name = "db8500-vmodem",
|
2019-04-11 18:54:20 -07:00
|
|
|
.of_match = of_match_ptr("db8500_vmodem"),
|
2011-04-01 05:43:33 -07:00
|
|
|
.id = DB8500_REGULATOR_VMODEM,
|
|
|
|
.ops = &db8500_regulator_ops,
|
|
|
|
.type = REGULATOR_VOLTAGE,
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
[DB8500_REGULATOR_VPLL] = {
|
|
|
|
.desc = {
|
|
|
|
.name = "db8500-vpll",
|
2019-04-11 18:54:20 -07:00
|
|
|
.of_match = of_match_ptr("db8500_vpll"),
|
2011-04-01 05:43:33 -07:00
|
|
|
.id = DB8500_REGULATOR_VPLL,
|
|
|
|
.ops = &db8500_regulator_ops,
|
|
|
|
.type = REGULATOR_VOLTAGE,
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
[DB8500_REGULATOR_VSMPS1] = {
|
|
|
|
.desc = {
|
|
|
|
.name = "db8500-vsmps1",
|
2019-04-11 18:54:20 -07:00
|
|
|
.of_match = of_match_ptr("db8500_vsmps1"),
|
2011-04-01 05:43:33 -07:00
|
|
|
.id = DB8500_REGULATOR_VSMPS1,
|
|
|
|
.ops = &db8500_regulator_ops,
|
|
|
|
.type = REGULATOR_VOLTAGE,
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
[DB8500_REGULATOR_VSMPS2] = {
|
|
|
|
.desc = {
|
|
|
|
.name = "db8500-vsmps2",
|
2019-04-11 18:54:20 -07:00
|
|
|
.of_match = of_match_ptr("db8500_vsmps2"),
|
2011-04-01 05:43:33 -07:00
|
|
|
.id = DB8500_REGULATOR_VSMPS2,
|
|
|
|
.ops = &db8500_regulator_ops,
|
|
|
|
.type = REGULATOR_VOLTAGE,
|
|
|
|
.owner = THIS_MODULE,
|
2014-03-21 05:14:11 -07:00
|
|
|
.fixed_uV = 1800000,
|
|
|
|
.n_voltages = 1,
|
2011-04-01 05:43:33 -07:00
|
|
|
},
|
|
|
|
.exclude_from_power_state = true,
|
|
|
|
},
|
|
|
|
[DB8500_REGULATOR_VSMPS3] = {
|
|
|
|
.desc = {
|
|
|
|
.name = "db8500-vsmps3",
|
2019-04-11 18:54:20 -07:00
|
|
|
.of_match = of_match_ptr("db8500_vsmps3"),
|
2011-04-01 05:43:33 -07:00
|
|
|
.id = DB8500_REGULATOR_VSMPS3,
|
|
|
|
.ops = &db8500_regulator_ops,
|
|
|
|
.type = REGULATOR_VOLTAGE,
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
[DB8500_REGULATOR_VRF1] = {
|
|
|
|
.desc = {
|
|
|
|
.name = "db8500-vrf1",
|
2019-04-11 18:54:20 -07:00
|
|
|
.of_match = of_match_ptr("db8500_vrf1"),
|
2011-04-01 05:43:33 -07:00
|
|
|
.id = DB8500_REGULATOR_VRF1,
|
|
|
|
.ops = &db8500_regulator_ops,
|
|
|
|
.type = REGULATOR_VOLTAGE,
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
[DB8500_REGULATOR_SWITCH_SVAMMDSP] = {
|
|
|
|
.desc = {
|
|
|
|
.name = "db8500-sva-mmdsp",
|
2019-04-11 18:54:20 -07:00
|
|
|
.of_match = of_match_ptr("db8500_sva_mmdsp"),
|
2011-04-01 05:43:33 -07:00
|
|
|
.id = DB8500_REGULATOR_SWITCH_SVAMMDSP,
|
|
|
|
.ops = &db8500_regulator_switch_ops,
|
|
|
|
.type = REGULATOR_VOLTAGE,
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
},
|
|
|
|
.epod_id = EPOD_ID_SVAMMDSP,
|
|
|
|
},
|
|
|
|
[DB8500_REGULATOR_SWITCH_SVAMMDSPRET] = {
|
|
|
|
.desc = {
|
|
|
|
.name = "db8500-sva-mmdsp-ret",
|
2019-04-11 18:54:20 -07:00
|
|
|
.of_match = of_match_ptr("db8500_sva_mmdsp_ret"),
|
2011-04-01 05:43:33 -07:00
|
|
|
.id = DB8500_REGULATOR_SWITCH_SVAMMDSPRET,
|
|
|
|
.ops = &db8500_regulator_switch_ops,
|
|
|
|
.type = REGULATOR_VOLTAGE,
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
},
|
|
|
|
.epod_id = EPOD_ID_SVAMMDSP,
|
|
|
|
.is_ramret = true,
|
|
|
|
},
|
|
|
|
[DB8500_REGULATOR_SWITCH_SVAPIPE] = {
|
|
|
|
.desc = {
|
|
|
|
.name = "db8500-sva-pipe",
|
2019-04-11 18:54:20 -07:00
|
|
|
.of_match = of_match_ptr("db8500_sva_pipe"),
|
2011-04-01 05:43:33 -07:00
|
|
|
.id = DB8500_REGULATOR_SWITCH_SVAPIPE,
|
|
|
|
.ops = &db8500_regulator_switch_ops,
|
|
|
|
.type = REGULATOR_VOLTAGE,
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
},
|
|
|
|
.epod_id = EPOD_ID_SVAPIPE,
|
|
|
|
},
|
|
|
|
[DB8500_REGULATOR_SWITCH_SIAMMDSP] = {
|
|
|
|
.desc = {
|
|
|
|
.name = "db8500-sia-mmdsp",
|
2019-04-11 18:54:20 -07:00
|
|
|
.of_match = of_match_ptr("db8500_sia_mmdsp"),
|
2011-04-01 05:43:33 -07:00
|
|
|
.id = DB8500_REGULATOR_SWITCH_SIAMMDSP,
|
|
|
|
.ops = &db8500_regulator_switch_ops,
|
|
|
|
.type = REGULATOR_VOLTAGE,
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
},
|
|
|
|
.epod_id = EPOD_ID_SIAMMDSP,
|
|
|
|
},
|
|
|
|
[DB8500_REGULATOR_SWITCH_SIAMMDSPRET] = {
|
|
|
|
.desc = {
|
|
|
|
.name = "db8500-sia-mmdsp-ret",
|
2019-04-11 18:54:20 -07:00
|
|
|
.of_match = of_match_ptr("db8500_sia_mmdsp_ret"),
|
2011-04-01 05:43:33 -07:00
|
|
|
.id = DB8500_REGULATOR_SWITCH_SIAMMDSPRET,
|
|
|
|
.ops = &db8500_regulator_switch_ops,
|
|
|
|
.type = REGULATOR_VOLTAGE,
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
},
|
|
|
|
.epod_id = EPOD_ID_SIAMMDSP,
|
|
|
|
.is_ramret = true,
|
|
|
|
},
|
|
|
|
[DB8500_REGULATOR_SWITCH_SIAPIPE] = {
|
|
|
|
.desc = {
|
|
|
|
.name = "db8500-sia-pipe",
|
2019-04-11 18:54:20 -07:00
|
|
|
.of_match = of_match_ptr("db8500_sia_pipe"),
|
2011-04-01 05:43:33 -07:00
|
|
|
.id = DB8500_REGULATOR_SWITCH_SIAPIPE,
|
|
|
|
.ops = &db8500_regulator_switch_ops,
|
|
|
|
.type = REGULATOR_VOLTAGE,
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
},
|
|
|
|
.epod_id = EPOD_ID_SIAPIPE,
|
|
|
|
},
|
|
|
|
[DB8500_REGULATOR_SWITCH_SGA] = {
|
|
|
|
.desc = {
|
|
|
|
.name = "db8500-sga",
|
2019-04-11 18:54:20 -07:00
|
|
|
.of_match = of_match_ptr("db8500_sga"),
|
2011-04-01 05:43:33 -07:00
|
|
|
.id = DB8500_REGULATOR_SWITCH_SGA,
|
|
|
|
.ops = &db8500_regulator_switch_ops,
|
|
|
|
.type = REGULATOR_VOLTAGE,
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
},
|
|
|
|
.epod_id = EPOD_ID_SGA,
|
|
|
|
},
|
|
|
|
[DB8500_REGULATOR_SWITCH_B2R2_MCDE] = {
|
|
|
|
.desc = {
|
|
|
|
.name = "db8500-b2r2-mcde",
|
2019-04-11 18:54:20 -07:00
|
|
|
.of_match = of_match_ptr("db8500_b2r2_mcde"),
|
2011-04-01 05:43:33 -07:00
|
|
|
.id = DB8500_REGULATOR_SWITCH_B2R2_MCDE,
|
|
|
|
.ops = &db8500_regulator_switch_ops,
|
|
|
|
.type = REGULATOR_VOLTAGE,
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
},
|
|
|
|
.epod_id = EPOD_ID_B2R2_MCDE,
|
|
|
|
},
|
|
|
|
[DB8500_REGULATOR_SWITCH_ESRAM12] = {
|
|
|
|
.desc = {
|
|
|
|
.name = "db8500-esram12",
|
2019-04-11 18:54:20 -07:00
|
|
|
.of_match = of_match_ptr("db8500_esram12"),
|
2011-04-01 05:43:33 -07:00
|
|
|
.id = DB8500_REGULATOR_SWITCH_ESRAM12,
|
|
|
|
.ops = &db8500_regulator_switch_ops,
|
|
|
|
.type = REGULATOR_VOLTAGE,
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
},
|
|
|
|
.epod_id = EPOD_ID_ESRAM12,
|
|
|
|
.is_enabled = true,
|
|
|
|
},
|
|
|
|
[DB8500_REGULATOR_SWITCH_ESRAM12RET] = {
|
|
|
|
.desc = {
|
|
|
|
.name = "db8500-esram12-ret",
|
2019-04-11 18:54:20 -07:00
|
|
|
.of_match = of_match_ptr("db8500_esram12_ret"),
|
2011-04-01 05:43:33 -07:00
|
|
|
.id = DB8500_REGULATOR_SWITCH_ESRAM12RET,
|
|
|
|
.ops = &db8500_regulator_switch_ops,
|
|
|
|
.type = REGULATOR_VOLTAGE,
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
},
|
|
|
|
.epod_id = EPOD_ID_ESRAM12,
|
|
|
|
.is_ramret = true,
|
|
|
|
},
|
|
|
|
[DB8500_REGULATOR_SWITCH_ESRAM34] = {
|
|
|
|
.desc = {
|
|
|
|
.name = "db8500-esram34",
|
2019-04-11 18:54:20 -07:00
|
|
|
.of_match = of_match_ptr("db8500_esram34"),
|
2011-04-01 05:43:33 -07:00
|
|
|
.id = DB8500_REGULATOR_SWITCH_ESRAM34,
|
|
|
|
.ops = &db8500_regulator_switch_ops,
|
|
|
|
.type = REGULATOR_VOLTAGE,
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
},
|
|
|
|
.epod_id = EPOD_ID_ESRAM34,
|
|
|
|
.is_enabled = true,
|
|
|
|
},
|
|
|
|
[DB8500_REGULATOR_SWITCH_ESRAM34RET] = {
|
|
|
|
.desc = {
|
|
|
|
.name = "db8500-esram34-ret",
|
2019-04-11 18:54:20 -07:00
|
|
|
.of_match = of_match_ptr("db8500_esram34_ret"),
|
2011-04-01 05:43:33 -07:00
|
|
|
.id = DB8500_REGULATOR_SWITCH_ESRAM34RET,
|
|
|
|
.ops = &db8500_regulator_switch_ops,
|
|
|
|
.type = REGULATOR_VOLTAGE,
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
},
|
|
|
|
.epod_id = EPOD_ID_ESRAM34,
|
|
|
|
.is_ramret = true,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2019-04-11 18:54:20 -07:00
|
|
|
static int db8500_regulator_probe(struct platform_device *pdev)
|
2012-05-18 01:39:04 -07:00
|
|
|
{
|
2019-04-11 18:54:20 -07:00
|
|
|
struct regulator_init_data *db8500_init_data;
|
2012-05-18 01:39:04 -07:00
|
|
|
struct dbx500_regulator_info *info;
|
|
|
|
struct regulator_config config = { };
|
2019-04-11 18:54:21 -07:00
|
|
|
struct regulator_dev *rdev;
|
2019-04-11 18:54:20 -07:00
|
|
|
int err, i;
|
2012-05-18 01:39:04 -07:00
|
|
|
|
2019-04-11 18:54:20 -07:00
|
|
|
db8500_init_data = dev_get_platdata(&pdev->dev);
|
2012-05-18 01:39:06 -07:00
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE(dbx500_regulator_info); i++) {
|
2019-04-11 18:54:20 -07:00
|
|
|
/* assign per-regulator data */
|
|
|
|
info = &dbx500_regulator_info[i];
|
|
|
|
|
|
|
|
config.driver_data = info;
|
|
|
|
config.dev = &pdev->dev;
|
|
|
|
if (db8500_init_data)
|
|
|
|
config.init_data = &db8500_init_data[i];
|
|
|
|
|
2019-04-11 18:54:21 -07:00
|
|
|
rdev = devm_regulator_register(&pdev->dev, &info->desc,
|
|
|
|
&config);
|
|
|
|
if (IS_ERR(rdev)) {
|
|
|
|
err = PTR_ERR(rdev);
|
2019-04-11 18:54:20 -07:00
|
|
|
dev_err(&pdev->dev, "failed to register %s: err %i\n",
|
|
|
|
info->desc.name, err);
|
2012-05-18 01:39:06 -07:00
|
|
|
return err;
|
|
|
|
}
|
2019-04-11 18:54:20 -07:00
|
|
|
dev_dbg(&pdev->dev, "regulator-%s-probed\n", info->desc.name);
|
2011-04-01 05:43:33 -07:00
|
|
|
}
|
2012-05-18 01:39:06 -07:00
|
|
|
|
2019-04-11 18:54:20 -07:00
|
|
|
ux500_regulator_debug_init(pdev, dbx500_regulator_info,
|
|
|
|
ARRAY_SIZE(dbx500_regulator_info));
|
2012-05-18 01:39:04 -07:00
|
|
|
return 0;
|
2011-04-01 05:43:33 -07:00
|
|
|
}
|
|
|
|
|
2023-12-05 05:26:18 -07:00
|
|
|
static void db8500_regulator_remove(struct platform_device *pdev)
|
2011-04-01 05:43:33 -07:00
|
|
|
{
|
2012-01-13 08:30:31 -07:00
|
|
|
ux500_regulator_debug_exit();
|
2011-04-01 05:43:33 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static struct platform_driver db8500_regulator_driver = {
|
|
|
|
.driver = {
|
|
|
|
.name = "db8500-prcmu-regulators",
|
regulator: Set PROBE_PREFER_ASYNCHRONOUS for drivers that existed in 4.14
Probing of regulators can be a slow operation and can contribute to
slower boot times. This is especially true if a regulator is turned on
at probe time (with regulator-boot-on or regulator-always-on) and the
regulator requires delays (off-on-time, ramp time, etc).
While the overall kernel is not ready to switch to async probe by
default, as per the discussion on the mailing lists [1] it is believed
that the regulator subsystem is in good shape and we can move
regulator drivers over wholesale. There is no way to just magically
opt in all regulators (regulators are just normal drivers like
platform_driver), so we set PROBE_PREFER_ASYNCHRONOUS for all
regulators found in 'drivers/regulator' individually.
Given the number of drivers touched and the impossibility to test this
ahead of time, it wouldn't be shocking at all if this caused a
regression for someone. If there is a regression caused by this patch,
it's likely to be one of the cases talked about in [1]. As a "quick
fix", drivers involved in the regression could be fixed by changing
them to PROBE_FORCE_SYNCHRONOUS. That being said, the correct fix
would be to directly fix the problem that caused the issue with async
probe.
The approach here follows a similar approach that was used for the mmc
subsystem several years ago [2]. In fact, I ran nearly the same python
script to auto-generate the changes. The only thing I changed was to
search for "i2c_driver", "spmi_driver", and "spi_driver" in addition
to "platform_driver".
[1] https://lore.kernel.org/r/06db017f-e985-4434-8d1d-02ca2100cca0@sirena.org.uk
[2] https://lore.kernel.org/r/20200903232441.2694866-1-dianders@chromium.org/
Signed-off-by: Douglas Anderson <dianders@chromium.org>
Link: https://lore.kernel.org/r/20230316125351.1.I2a4677392a38db5758dee0788b2cea5872562a82@changeid
Signed-off-by: Mark Brown <broonie@kernel.org>
2023-03-16 12:54:38 -07:00
|
|
|
.probe_type = PROBE_PREFER_ASYNCHRONOUS,
|
2011-04-01 05:43:33 -07:00
|
|
|
},
|
|
|
|
.probe = db8500_regulator_probe,
|
2023-12-05 05:26:18 -07:00
|
|
|
.remove_new = db8500_regulator_remove,
|
2011-04-01 05:43:33 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
static int __init db8500_regulator_init(void)
|
|
|
|
{
|
2011-07-05 20:41:12 -07:00
|
|
|
return platform_driver_register(&db8500_regulator_driver);
|
2011-04-01 05:43:33 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void __exit db8500_regulator_exit(void)
|
|
|
|
{
|
|
|
|
platform_driver_unregister(&db8500_regulator_driver);
|
|
|
|
}
|
|
|
|
|
|
|
|
arch_initcall(db8500_regulator_init);
|
|
|
|
module_exit(db8500_regulator_exit);
|
|
|
|
|
|
|
|
MODULE_AUTHOR("STMicroelectronics/ST-Ericsson");
|
|
|
|
MODULE_DESCRIPTION("DB8500 regulator driver");
|
|
|
|
MODULE_LICENSE("GPL v2");
|