18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Copyright (C) ST-Ericsson SA 2010
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Authors: Sundar Iyer <sundar.iyer@stericsson.com> for ST-Ericsson
68c2ecf20Sopenharmony_ci *          Bengt Jonsson <bengt.g.jonsson@stericsson.com> for ST-Ericsson
78c2ecf20Sopenharmony_ci *
88c2ecf20Sopenharmony_ci * Power domain regulators on DB8500
98c2ecf20Sopenharmony_ci */
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci#include <linux/kernel.h>
128c2ecf20Sopenharmony_ci#include <linux/init.h>
138c2ecf20Sopenharmony_ci#include <linux/err.h>
148c2ecf20Sopenharmony_ci#include <linux/spinlock.h>
158c2ecf20Sopenharmony_ci#include <linux/platform_device.h>
168c2ecf20Sopenharmony_ci#include <linux/mfd/dbx500-prcmu.h>
178c2ecf20Sopenharmony_ci#include <linux/regulator/driver.h>
188c2ecf20Sopenharmony_ci#include <linux/regulator/machine.h>
198c2ecf20Sopenharmony_ci#include <linux/regulator/db8500-prcmu.h>
208c2ecf20Sopenharmony_ci#include <linux/regulator/of_regulator.h>
218c2ecf20Sopenharmony_ci#include <linux/of.h>
228c2ecf20Sopenharmony_ci#include <linux/module.h>
238c2ecf20Sopenharmony_ci#include "dbx500-prcmu.h"
248c2ecf20Sopenharmony_ci
258c2ecf20Sopenharmony_cistatic int db8500_regulator_enable(struct regulator_dev *rdev)
268c2ecf20Sopenharmony_ci{
278c2ecf20Sopenharmony_ci	struct dbx500_regulator_info *info = rdev_get_drvdata(rdev);
288c2ecf20Sopenharmony_ci
298c2ecf20Sopenharmony_ci	if (info == NULL)
308c2ecf20Sopenharmony_ci		return -EINVAL;
318c2ecf20Sopenharmony_ci
328c2ecf20Sopenharmony_ci	dev_vdbg(rdev_get_dev(rdev), "regulator-%s-enable\n",
338c2ecf20Sopenharmony_ci		info->desc.name);
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_ci	if (!info->is_enabled) {
368c2ecf20Sopenharmony_ci		info->is_enabled = true;
378c2ecf20Sopenharmony_ci		if (!info->exclude_from_power_state)
388c2ecf20Sopenharmony_ci			power_state_active_enable();
398c2ecf20Sopenharmony_ci	}
408c2ecf20Sopenharmony_ci
418c2ecf20Sopenharmony_ci	return 0;
428c2ecf20Sopenharmony_ci}
438c2ecf20Sopenharmony_ci
448c2ecf20Sopenharmony_cistatic int db8500_regulator_disable(struct regulator_dev *rdev)
458c2ecf20Sopenharmony_ci{
468c2ecf20Sopenharmony_ci	struct dbx500_regulator_info *info = rdev_get_drvdata(rdev);
478c2ecf20Sopenharmony_ci	int ret = 0;
488c2ecf20Sopenharmony_ci
498c2ecf20Sopenharmony_ci	if (info == NULL)
508c2ecf20Sopenharmony_ci		return -EINVAL;
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_ci	dev_vdbg(rdev_get_dev(rdev), "regulator-%s-disable\n",
538c2ecf20Sopenharmony_ci		info->desc.name);
548c2ecf20Sopenharmony_ci
558c2ecf20Sopenharmony_ci	if (info->is_enabled) {
568c2ecf20Sopenharmony_ci		info->is_enabled = false;
578c2ecf20Sopenharmony_ci		if (!info->exclude_from_power_state)
588c2ecf20Sopenharmony_ci			ret = power_state_active_disable();
598c2ecf20Sopenharmony_ci	}
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_ci	return ret;
628c2ecf20Sopenharmony_ci}
638c2ecf20Sopenharmony_ci
648c2ecf20Sopenharmony_cistatic int db8500_regulator_is_enabled(struct regulator_dev *rdev)
658c2ecf20Sopenharmony_ci{
668c2ecf20Sopenharmony_ci	struct dbx500_regulator_info *info = rdev_get_drvdata(rdev);
678c2ecf20Sopenharmony_ci
688c2ecf20Sopenharmony_ci	if (info == NULL)
698c2ecf20Sopenharmony_ci		return -EINVAL;
708c2ecf20Sopenharmony_ci
718c2ecf20Sopenharmony_ci	dev_vdbg(rdev_get_dev(rdev), "regulator-%s-is_enabled (is_enabled):"
728c2ecf20Sopenharmony_ci		" %i\n", info->desc.name, info->is_enabled);
738c2ecf20Sopenharmony_ci
748c2ecf20Sopenharmony_ci	return info->is_enabled;
758c2ecf20Sopenharmony_ci}
768c2ecf20Sopenharmony_ci
778c2ecf20Sopenharmony_ci/* db8500 regulator operations */
788c2ecf20Sopenharmony_cistatic const struct regulator_ops db8500_regulator_ops = {
798c2ecf20Sopenharmony_ci	.enable			= db8500_regulator_enable,
808c2ecf20Sopenharmony_ci	.disable		= db8500_regulator_disable,
818c2ecf20Sopenharmony_ci	.is_enabled		= db8500_regulator_is_enabled,
828c2ecf20Sopenharmony_ci};
838c2ecf20Sopenharmony_ci
848c2ecf20Sopenharmony_ci/*
858c2ecf20Sopenharmony_ci * EPOD control
868c2ecf20Sopenharmony_ci */
878c2ecf20Sopenharmony_cistatic bool epod_on[NUM_EPOD_ID];
888c2ecf20Sopenharmony_cistatic bool epod_ramret[NUM_EPOD_ID];
898c2ecf20Sopenharmony_ci
908c2ecf20Sopenharmony_cistatic int enable_epod(u16 epod_id, bool ramret)
918c2ecf20Sopenharmony_ci{
928c2ecf20Sopenharmony_ci	int ret;
938c2ecf20Sopenharmony_ci
948c2ecf20Sopenharmony_ci	if (ramret) {
958c2ecf20Sopenharmony_ci		if (!epod_on[epod_id]) {
968c2ecf20Sopenharmony_ci			ret = prcmu_set_epod(epod_id, EPOD_STATE_RAMRET);
978c2ecf20Sopenharmony_ci			if (ret < 0)
988c2ecf20Sopenharmony_ci				return ret;
998c2ecf20Sopenharmony_ci		}
1008c2ecf20Sopenharmony_ci		epod_ramret[epod_id] = true;
1018c2ecf20Sopenharmony_ci	} else {
1028c2ecf20Sopenharmony_ci		ret = prcmu_set_epod(epod_id, EPOD_STATE_ON);
1038c2ecf20Sopenharmony_ci		if (ret < 0)
1048c2ecf20Sopenharmony_ci			return ret;
1058c2ecf20Sopenharmony_ci		epod_on[epod_id] = true;
1068c2ecf20Sopenharmony_ci	}
1078c2ecf20Sopenharmony_ci
1088c2ecf20Sopenharmony_ci	return 0;
1098c2ecf20Sopenharmony_ci}
1108c2ecf20Sopenharmony_ci
1118c2ecf20Sopenharmony_cistatic int disable_epod(u16 epod_id, bool ramret)
1128c2ecf20Sopenharmony_ci{
1138c2ecf20Sopenharmony_ci	int ret;
1148c2ecf20Sopenharmony_ci
1158c2ecf20Sopenharmony_ci	if (ramret) {
1168c2ecf20Sopenharmony_ci		if (!epod_on[epod_id]) {
1178c2ecf20Sopenharmony_ci			ret = prcmu_set_epod(epod_id, EPOD_STATE_OFF);
1188c2ecf20Sopenharmony_ci			if (ret < 0)
1198c2ecf20Sopenharmony_ci				return ret;
1208c2ecf20Sopenharmony_ci		}
1218c2ecf20Sopenharmony_ci		epod_ramret[epod_id] = false;
1228c2ecf20Sopenharmony_ci	} else {
1238c2ecf20Sopenharmony_ci		if (epod_ramret[epod_id]) {
1248c2ecf20Sopenharmony_ci			ret = prcmu_set_epod(epod_id, EPOD_STATE_RAMRET);
1258c2ecf20Sopenharmony_ci			if (ret < 0)
1268c2ecf20Sopenharmony_ci				return ret;
1278c2ecf20Sopenharmony_ci		} else {
1288c2ecf20Sopenharmony_ci			ret = prcmu_set_epod(epod_id, EPOD_STATE_OFF);
1298c2ecf20Sopenharmony_ci			if (ret < 0)
1308c2ecf20Sopenharmony_ci				return ret;
1318c2ecf20Sopenharmony_ci		}
1328c2ecf20Sopenharmony_ci		epod_on[epod_id] = false;
1338c2ecf20Sopenharmony_ci	}
1348c2ecf20Sopenharmony_ci
1358c2ecf20Sopenharmony_ci	return 0;
1368c2ecf20Sopenharmony_ci}
1378c2ecf20Sopenharmony_ci
1388c2ecf20Sopenharmony_ci/*
1398c2ecf20Sopenharmony_ci * Regulator switch
1408c2ecf20Sopenharmony_ci */
1418c2ecf20Sopenharmony_cistatic int db8500_regulator_switch_enable(struct regulator_dev *rdev)
1428c2ecf20Sopenharmony_ci{
1438c2ecf20Sopenharmony_ci	struct dbx500_regulator_info *info = rdev_get_drvdata(rdev);
1448c2ecf20Sopenharmony_ci	int ret;
1458c2ecf20Sopenharmony_ci
1468c2ecf20Sopenharmony_ci	if (info == NULL)
1478c2ecf20Sopenharmony_ci		return -EINVAL;
1488c2ecf20Sopenharmony_ci
1498c2ecf20Sopenharmony_ci	dev_vdbg(rdev_get_dev(rdev), "regulator-switch-%s-enable\n",
1508c2ecf20Sopenharmony_ci		info->desc.name);
1518c2ecf20Sopenharmony_ci
1528c2ecf20Sopenharmony_ci	ret = enable_epod(info->epod_id, info->is_ramret);
1538c2ecf20Sopenharmony_ci	if (ret < 0) {
1548c2ecf20Sopenharmony_ci		dev_err(rdev_get_dev(rdev),
1558c2ecf20Sopenharmony_ci			"regulator-switch-%s-enable: prcmu call failed\n",
1568c2ecf20Sopenharmony_ci			info->desc.name);
1578c2ecf20Sopenharmony_ci		goto out;
1588c2ecf20Sopenharmony_ci	}
1598c2ecf20Sopenharmony_ci
1608c2ecf20Sopenharmony_ci	info->is_enabled = true;
1618c2ecf20Sopenharmony_ciout:
1628c2ecf20Sopenharmony_ci	return ret;
1638c2ecf20Sopenharmony_ci}
1648c2ecf20Sopenharmony_ci
1658c2ecf20Sopenharmony_cistatic int db8500_regulator_switch_disable(struct regulator_dev *rdev)
1668c2ecf20Sopenharmony_ci{
1678c2ecf20Sopenharmony_ci	struct dbx500_regulator_info *info = rdev_get_drvdata(rdev);
1688c2ecf20Sopenharmony_ci	int ret;
1698c2ecf20Sopenharmony_ci
1708c2ecf20Sopenharmony_ci	if (info == NULL)
1718c2ecf20Sopenharmony_ci		return -EINVAL;
1728c2ecf20Sopenharmony_ci
1738c2ecf20Sopenharmony_ci	dev_vdbg(rdev_get_dev(rdev), "regulator-switch-%s-disable\n",
1748c2ecf20Sopenharmony_ci		info->desc.name);
1758c2ecf20Sopenharmony_ci
1768c2ecf20Sopenharmony_ci	ret = disable_epod(info->epod_id, info->is_ramret);
1778c2ecf20Sopenharmony_ci	if (ret < 0) {
1788c2ecf20Sopenharmony_ci		dev_err(rdev_get_dev(rdev),
1798c2ecf20Sopenharmony_ci			"regulator_switch-%s-disable: prcmu call failed\n",
1808c2ecf20Sopenharmony_ci			info->desc.name);
1818c2ecf20Sopenharmony_ci		goto out;
1828c2ecf20Sopenharmony_ci	}
1838c2ecf20Sopenharmony_ci
1848c2ecf20Sopenharmony_ci	info->is_enabled = false;
1858c2ecf20Sopenharmony_ciout:
1868c2ecf20Sopenharmony_ci	return ret;
1878c2ecf20Sopenharmony_ci}
1888c2ecf20Sopenharmony_ci
1898c2ecf20Sopenharmony_cistatic int db8500_regulator_switch_is_enabled(struct regulator_dev *rdev)
1908c2ecf20Sopenharmony_ci{
1918c2ecf20Sopenharmony_ci	struct dbx500_regulator_info *info = rdev_get_drvdata(rdev);
1928c2ecf20Sopenharmony_ci
1938c2ecf20Sopenharmony_ci	if (info == NULL)
1948c2ecf20Sopenharmony_ci		return -EINVAL;
1958c2ecf20Sopenharmony_ci
1968c2ecf20Sopenharmony_ci	dev_vdbg(rdev_get_dev(rdev),
1978c2ecf20Sopenharmony_ci		"regulator-switch-%s-is_enabled (is_enabled): %i\n",
1988c2ecf20Sopenharmony_ci		info->desc.name, info->is_enabled);
1998c2ecf20Sopenharmony_ci
2008c2ecf20Sopenharmony_ci	return info->is_enabled;
2018c2ecf20Sopenharmony_ci}
2028c2ecf20Sopenharmony_ci
2038c2ecf20Sopenharmony_cistatic const struct regulator_ops db8500_regulator_switch_ops = {
2048c2ecf20Sopenharmony_ci	.enable			= db8500_regulator_switch_enable,
2058c2ecf20Sopenharmony_ci	.disable		= db8500_regulator_switch_disable,
2068c2ecf20Sopenharmony_ci	.is_enabled		= db8500_regulator_switch_is_enabled,
2078c2ecf20Sopenharmony_ci};
2088c2ecf20Sopenharmony_ci
2098c2ecf20Sopenharmony_ci/*
2108c2ecf20Sopenharmony_ci * Regulator information
2118c2ecf20Sopenharmony_ci */
2128c2ecf20Sopenharmony_cistatic struct dbx500_regulator_info
2138c2ecf20Sopenharmony_cidbx500_regulator_info[DB8500_NUM_REGULATORS] = {
2148c2ecf20Sopenharmony_ci	[DB8500_REGULATOR_VAPE] = {
2158c2ecf20Sopenharmony_ci		.desc = {
2168c2ecf20Sopenharmony_ci			.name	= "db8500-vape",
2178c2ecf20Sopenharmony_ci			.of_match = of_match_ptr("db8500_vape"),
2188c2ecf20Sopenharmony_ci			.id	= DB8500_REGULATOR_VAPE,
2198c2ecf20Sopenharmony_ci			.ops	= &db8500_regulator_ops,
2208c2ecf20Sopenharmony_ci			.type	= REGULATOR_VOLTAGE,
2218c2ecf20Sopenharmony_ci			.owner	= THIS_MODULE,
2228c2ecf20Sopenharmony_ci		},
2238c2ecf20Sopenharmony_ci	},
2248c2ecf20Sopenharmony_ci	[DB8500_REGULATOR_VARM] = {
2258c2ecf20Sopenharmony_ci		.desc = {
2268c2ecf20Sopenharmony_ci			.name	= "db8500-varm",
2278c2ecf20Sopenharmony_ci			.of_match = of_match_ptr("db8500_varm"),
2288c2ecf20Sopenharmony_ci			.id	= DB8500_REGULATOR_VARM,
2298c2ecf20Sopenharmony_ci			.ops	= &db8500_regulator_ops,
2308c2ecf20Sopenharmony_ci			.type	= REGULATOR_VOLTAGE,
2318c2ecf20Sopenharmony_ci			.owner	= THIS_MODULE,
2328c2ecf20Sopenharmony_ci		},
2338c2ecf20Sopenharmony_ci	},
2348c2ecf20Sopenharmony_ci	[DB8500_REGULATOR_VMODEM] = {
2358c2ecf20Sopenharmony_ci		.desc = {
2368c2ecf20Sopenharmony_ci			.name	= "db8500-vmodem",
2378c2ecf20Sopenharmony_ci			.of_match = of_match_ptr("db8500_vmodem"),
2388c2ecf20Sopenharmony_ci			.id	= DB8500_REGULATOR_VMODEM,
2398c2ecf20Sopenharmony_ci			.ops	= &db8500_regulator_ops,
2408c2ecf20Sopenharmony_ci			.type	= REGULATOR_VOLTAGE,
2418c2ecf20Sopenharmony_ci			.owner	= THIS_MODULE,
2428c2ecf20Sopenharmony_ci		},
2438c2ecf20Sopenharmony_ci	},
2448c2ecf20Sopenharmony_ci	[DB8500_REGULATOR_VPLL] = {
2458c2ecf20Sopenharmony_ci		.desc = {
2468c2ecf20Sopenharmony_ci			.name	= "db8500-vpll",
2478c2ecf20Sopenharmony_ci			.of_match = of_match_ptr("db8500_vpll"),
2488c2ecf20Sopenharmony_ci			.id	= DB8500_REGULATOR_VPLL,
2498c2ecf20Sopenharmony_ci			.ops	= &db8500_regulator_ops,
2508c2ecf20Sopenharmony_ci			.type	= REGULATOR_VOLTAGE,
2518c2ecf20Sopenharmony_ci			.owner	= THIS_MODULE,
2528c2ecf20Sopenharmony_ci		},
2538c2ecf20Sopenharmony_ci	},
2548c2ecf20Sopenharmony_ci	[DB8500_REGULATOR_VSMPS1] = {
2558c2ecf20Sopenharmony_ci		.desc = {
2568c2ecf20Sopenharmony_ci			.name	= "db8500-vsmps1",
2578c2ecf20Sopenharmony_ci			.of_match = of_match_ptr("db8500_vsmps1"),
2588c2ecf20Sopenharmony_ci			.id	= DB8500_REGULATOR_VSMPS1,
2598c2ecf20Sopenharmony_ci			.ops	= &db8500_regulator_ops,
2608c2ecf20Sopenharmony_ci			.type	= REGULATOR_VOLTAGE,
2618c2ecf20Sopenharmony_ci			.owner	= THIS_MODULE,
2628c2ecf20Sopenharmony_ci		},
2638c2ecf20Sopenharmony_ci	},
2648c2ecf20Sopenharmony_ci	[DB8500_REGULATOR_VSMPS2] = {
2658c2ecf20Sopenharmony_ci		.desc = {
2668c2ecf20Sopenharmony_ci			.name	= "db8500-vsmps2",
2678c2ecf20Sopenharmony_ci			.of_match = of_match_ptr("db8500_vsmps2"),
2688c2ecf20Sopenharmony_ci			.id	= DB8500_REGULATOR_VSMPS2,
2698c2ecf20Sopenharmony_ci			.ops	= &db8500_regulator_ops,
2708c2ecf20Sopenharmony_ci			.type	= REGULATOR_VOLTAGE,
2718c2ecf20Sopenharmony_ci			.owner	= THIS_MODULE,
2728c2ecf20Sopenharmony_ci			.fixed_uV = 1800000,
2738c2ecf20Sopenharmony_ci			.n_voltages = 1,
2748c2ecf20Sopenharmony_ci		},
2758c2ecf20Sopenharmony_ci		.exclude_from_power_state = true,
2768c2ecf20Sopenharmony_ci	},
2778c2ecf20Sopenharmony_ci	[DB8500_REGULATOR_VSMPS3] = {
2788c2ecf20Sopenharmony_ci		.desc = {
2798c2ecf20Sopenharmony_ci			.name	= "db8500-vsmps3",
2808c2ecf20Sopenharmony_ci			.of_match = of_match_ptr("db8500_vsmps3"),
2818c2ecf20Sopenharmony_ci			.id	= DB8500_REGULATOR_VSMPS3,
2828c2ecf20Sopenharmony_ci			.ops	= &db8500_regulator_ops,
2838c2ecf20Sopenharmony_ci			.type	= REGULATOR_VOLTAGE,
2848c2ecf20Sopenharmony_ci			.owner	= THIS_MODULE,
2858c2ecf20Sopenharmony_ci		},
2868c2ecf20Sopenharmony_ci	},
2878c2ecf20Sopenharmony_ci	[DB8500_REGULATOR_VRF1] = {
2888c2ecf20Sopenharmony_ci		.desc = {
2898c2ecf20Sopenharmony_ci			.name	= "db8500-vrf1",
2908c2ecf20Sopenharmony_ci			.of_match = of_match_ptr("db8500_vrf1"),
2918c2ecf20Sopenharmony_ci			.id	= DB8500_REGULATOR_VRF1,
2928c2ecf20Sopenharmony_ci			.ops	= &db8500_regulator_ops,
2938c2ecf20Sopenharmony_ci			.type	= REGULATOR_VOLTAGE,
2948c2ecf20Sopenharmony_ci			.owner	= THIS_MODULE,
2958c2ecf20Sopenharmony_ci		},
2968c2ecf20Sopenharmony_ci	},
2978c2ecf20Sopenharmony_ci	[DB8500_REGULATOR_SWITCH_SVAMMDSP] = {
2988c2ecf20Sopenharmony_ci		.desc = {
2998c2ecf20Sopenharmony_ci			.name	= "db8500-sva-mmdsp",
3008c2ecf20Sopenharmony_ci			.of_match = of_match_ptr("db8500_sva_mmdsp"),
3018c2ecf20Sopenharmony_ci			.id	= DB8500_REGULATOR_SWITCH_SVAMMDSP,
3028c2ecf20Sopenharmony_ci			.ops	= &db8500_regulator_switch_ops,
3038c2ecf20Sopenharmony_ci			.type	= REGULATOR_VOLTAGE,
3048c2ecf20Sopenharmony_ci			.owner	= THIS_MODULE,
3058c2ecf20Sopenharmony_ci		},
3068c2ecf20Sopenharmony_ci		.epod_id = EPOD_ID_SVAMMDSP,
3078c2ecf20Sopenharmony_ci	},
3088c2ecf20Sopenharmony_ci	[DB8500_REGULATOR_SWITCH_SVAMMDSPRET] = {
3098c2ecf20Sopenharmony_ci		.desc = {
3108c2ecf20Sopenharmony_ci			.name	= "db8500-sva-mmdsp-ret",
3118c2ecf20Sopenharmony_ci			.of_match = of_match_ptr("db8500_sva_mmdsp_ret"),
3128c2ecf20Sopenharmony_ci			.id	= DB8500_REGULATOR_SWITCH_SVAMMDSPRET,
3138c2ecf20Sopenharmony_ci			.ops	= &db8500_regulator_switch_ops,
3148c2ecf20Sopenharmony_ci			.type	= REGULATOR_VOLTAGE,
3158c2ecf20Sopenharmony_ci			.owner	= THIS_MODULE,
3168c2ecf20Sopenharmony_ci		},
3178c2ecf20Sopenharmony_ci		.epod_id = EPOD_ID_SVAMMDSP,
3188c2ecf20Sopenharmony_ci		.is_ramret = true,
3198c2ecf20Sopenharmony_ci	},
3208c2ecf20Sopenharmony_ci	[DB8500_REGULATOR_SWITCH_SVAPIPE] = {
3218c2ecf20Sopenharmony_ci		.desc = {
3228c2ecf20Sopenharmony_ci			.name	= "db8500-sva-pipe",
3238c2ecf20Sopenharmony_ci			.of_match = of_match_ptr("db8500_sva_pipe"),
3248c2ecf20Sopenharmony_ci			.id	= DB8500_REGULATOR_SWITCH_SVAPIPE,
3258c2ecf20Sopenharmony_ci			.ops	= &db8500_regulator_switch_ops,
3268c2ecf20Sopenharmony_ci			.type	= REGULATOR_VOLTAGE,
3278c2ecf20Sopenharmony_ci			.owner	= THIS_MODULE,
3288c2ecf20Sopenharmony_ci		},
3298c2ecf20Sopenharmony_ci		.epod_id = EPOD_ID_SVAPIPE,
3308c2ecf20Sopenharmony_ci	},
3318c2ecf20Sopenharmony_ci	[DB8500_REGULATOR_SWITCH_SIAMMDSP] = {
3328c2ecf20Sopenharmony_ci		.desc = {
3338c2ecf20Sopenharmony_ci			.name	= "db8500-sia-mmdsp",
3348c2ecf20Sopenharmony_ci			.of_match = of_match_ptr("db8500_sia_mmdsp"),
3358c2ecf20Sopenharmony_ci			.id	= DB8500_REGULATOR_SWITCH_SIAMMDSP,
3368c2ecf20Sopenharmony_ci			.ops	= &db8500_regulator_switch_ops,
3378c2ecf20Sopenharmony_ci			.type	= REGULATOR_VOLTAGE,
3388c2ecf20Sopenharmony_ci			.owner	= THIS_MODULE,
3398c2ecf20Sopenharmony_ci		},
3408c2ecf20Sopenharmony_ci		.epod_id = EPOD_ID_SIAMMDSP,
3418c2ecf20Sopenharmony_ci	},
3428c2ecf20Sopenharmony_ci	[DB8500_REGULATOR_SWITCH_SIAMMDSPRET] = {
3438c2ecf20Sopenharmony_ci		.desc = {
3448c2ecf20Sopenharmony_ci			.name	= "db8500-sia-mmdsp-ret",
3458c2ecf20Sopenharmony_ci			.of_match = of_match_ptr("db8500_sia_mmdsp_ret"),
3468c2ecf20Sopenharmony_ci			.id	= DB8500_REGULATOR_SWITCH_SIAMMDSPRET,
3478c2ecf20Sopenharmony_ci			.ops	= &db8500_regulator_switch_ops,
3488c2ecf20Sopenharmony_ci			.type	= REGULATOR_VOLTAGE,
3498c2ecf20Sopenharmony_ci			.owner	= THIS_MODULE,
3508c2ecf20Sopenharmony_ci		},
3518c2ecf20Sopenharmony_ci		.epod_id = EPOD_ID_SIAMMDSP,
3528c2ecf20Sopenharmony_ci		.is_ramret = true,
3538c2ecf20Sopenharmony_ci	},
3548c2ecf20Sopenharmony_ci	[DB8500_REGULATOR_SWITCH_SIAPIPE] = {
3558c2ecf20Sopenharmony_ci		.desc = {
3568c2ecf20Sopenharmony_ci			.name	= "db8500-sia-pipe",
3578c2ecf20Sopenharmony_ci			.of_match = of_match_ptr("db8500_sia_pipe"),
3588c2ecf20Sopenharmony_ci			.id	= DB8500_REGULATOR_SWITCH_SIAPIPE,
3598c2ecf20Sopenharmony_ci			.ops	= &db8500_regulator_switch_ops,
3608c2ecf20Sopenharmony_ci			.type	= REGULATOR_VOLTAGE,
3618c2ecf20Sopenharmony_ci			.owner	= THIS_MODULE,
3628c2ecf20Sopenharmony_ci		},
3638c2ecf20Sopenharmony_ci		.epod_id = EPOD_ID_SIAPIPE,
3648c2ecf20Sopenharmony_ci	},
3658c2ecf20Sopenharmony_ci	[DB8500_REGULATOR_SWITCH_SGA] = {
3668c2ecf20Sopenharmony_ci		.desc = {
3678c2ecf20Sopenharmony_ci			.name	= "db8500-sga",
3688c2ecf20Sopenharmony_ci			.of_match = of_match_ptr("db8500_sga"),
3698c2ecf20Sopenharmony_ci			.id	= DB8500_REGULATOR_SWITCH_SGA,
3708c2ecf20Sopenharmony_ci			.ops	= &db8500_regulator_switch_ops,
3718c2ecf20Sopenharmony_ci			.type	= REGULATOR_VOLTAGE,
3728c2ecf20Sopenharmony_ci			.owner	= THIS_MODULE,
3738c2ecf20Sopenharmony_ci		},
3748c2ecf20Sopenharmony_ci		.epod_id = EPOD_ID_SGA,
3758c2ecf20Sopenharmony_ci	},
3768c2ecf20Sopenharmony_ci	[DB8500_REGULATOR_SWITCH_B2R2_MCDE] = {
3778c2ecf20Sopenharmony_ci		.desc = {
3788c2ecf20Sopenharmony_ci			.name	= "db8500-b2r2-mcde",
3798c2ecf20Sopenharmony_ci			.of_match = of_match_ptr("db8500_b2r2_mcde"),
3808c2ecf20Sopenharmony_ci			.id	= DB8500_REGULATOR_SWITCH_B2R2_MCDE,
3818c2ecf20Sopenharmony_ci			.ops	= &db8500_regulator_switch_ops,
3828c2ecf20Sopenharmony_ci			.type	= REGULATOR_VOLTAGE,
3838c2ecf20Sopenharmony_ci			.owner	= THIS_MODULE,
3848c2ecf20Sopenharmony_ci		},
3858c2ecf20Sopenharmony_ci		.epod_id = EPOD_ID_B2R2_MCDE,
3868c2ecf20Sopenharmony_ci	},
3878c2ecf20Sopenharmony_ci	[DB8500_REGULATOR_SWITCH_ESRAM12] = {
3888c2ecf20Sopenharmony_ci		.desc = {
3898c2ecf20Sopenharmony_ci			.name	= "db8500-esram12",
3908c2ecf20Sopenharmony_ci			.of_match = of_match_ptr("db8500_esram12"),
3918c2ecf20Sopenharmony_ci			.id	= DB8500_REGULATOR_SWITCH_ESRAM12,
3928c2ecf20Sopenharmony_ci			.ops	= &db8500_regulator_switch_ops,
3938c2ecf20Sopenharmony_ci			.type	= REGULATOR_VOLTAGE,
3948c2ecf20Sopenharmony_ci			.owner	= THIS_MODULE,
3958c2ecf20Sopenharmony_ci		},
3968c2ecf20Sopenharmony_ci		.epod_id	= EPOD_ID_ESRAM12,
3978c2ecf20Sopenharmony_ci		.is_enabled	= true,
3988c2ecf20Sopenharmony_ci	},
3998c2ecf20Sopenharmony_ci	[DB8500_REGULATOR_SWITCH_ESRAM12RET] = {
4008c2ecf20Sopenharmony_ci		.desc = {
4018c2ecf20Sopenharmony_ci			.name	= "db8500-esram12-ret",
4028c2ecf20Sopenharmony_ci			.of_match = of_match_ptr("db8500_esram12_ret"),
4038c2ecf20Sopenharmony_ci			.id	= DB8500_REGULATOR_SWITCH_ESRAM12RET,
4048c2ecf20Sopenharmony_ci			.ops	= &db8500_regulator_switch_ops,
4058c2ecf20Sopenharmony_ci			.type	= REGULATOR_VOLTAGE,
4068c2ecf20Sopenharmony_ci			.owner	= THIS_MODULE,
4078c2ecf20Sopenharmony_ci		},
4088c2ecf20Sopenharmony_ci		.epod_id = EPOD_ID_ESRAM12,
4098c2ecf20Sopenharmony_ci		.is_ramret = true,
4108c2ecf20Sopenharmony_ci	},
4118c2ecf20Sopenharmony_ci	[DB8500_REGULATOR_SWITCH_ESRAM34] = {
4128c2ecf20Sopenharmony_ci		.desc = {
4138c2ecf20Sopenharmony_ci			.name	= "db8500-esram34",
4148c2ecf20Sopenharmony_ci			.of_match = of_match_ptr("db8500_esram34"),
4158c2ecf20Sopenharmony_ci			.id	= DB8500_REGULATOR_SWITCH_ESRAM34,
4168c2ecf20Sopenharmony_ci			.ops	= &db8500_regulator_switch_ops,
4178c2ecf20Sopenharmony_ci			.type	= REGULATOR_VOLTAGE,
4188c2ecf20Sopenharmony_ci			.owner	= THIS_MODULE,
4198c2ecf20Sopenharmony_ci		},
4208c2ecf20Sopenharmony_ci		.epod_id	= EPOD_ID_ESRAM34,
4218c2ecf20Sopenharmony_ci		.is_enabled	= true,
4228c2ecf20Sopenharmony_ci	},
4238c2ecf20Sopenharmony_ci	[DB8500_REGULATOR_SWITCH_ESRAM34RET] = {
4248c2ecf20Sopenharmony_ci		.desc = {
4258c2ecf20Sopenharmony_ci			.name	= "db8500-esram34-ret",
4268c2ecf20Sopenharmony_ci			.of_match = of_match_ptr("db8500_esram34_ret"),
4278c2ecf20Sopenharmony_ci			.id	= DB8500_REGULATOR_SWITCH_ESRAM34RET,
4288c2ecf20Sopenharmony_ci			.ops	= &db8500_regulator_switch_ops,
4298c2ecf20Sopenharmony_ci			.type	= REGULATOR_VOLTAGE,
4308c2ecf20Sopenharmony_ci			.owner	= THIS_MODULE,
4318c2ecf20Sopenharmony_ci		},
4328c2ecf20Sopenharmony_ci		.epod_id = EPOD_ID_ESRAM34,
4338c2ecf20Sopenharmony_ci		.is_ramret = true,
4348c2ecf20Sopenharmony_ci	},
4358c2ecf20Sopenharmony_ci};
4368c2ecf20Sopenharmony_ci
4378c2ecf20Sopenharmony_cistatic int db8500_regulator_probe(struct platform_device *pdev)
4388c2ecf20Sopenharmony_ci{
4398c2ecf20Sopenharmony_ci	struct regulator_init_data *db8500_init_data;
4408c2ecf20Sopenharmony_ci	struct dbx500_regulator_info *info;
4418c2ecf20Sopenharmony_ci	struct regulator_config config = { };
4428c2ecf20Sopenharmony_ci	struct regulator_dev *rdev;
4438c2ecf20Sopenharmony_ci	int err, i;
4448c2ecf20Sopenharmony_ci
4458c2ecf20Sopenharmony_ci	db8500_init_data = dev_get_platdata(&pdev->dev);
4468c2ecf20Sopenharmony_ci
4478c2ecf20Sopenharmony_ci	for (i = 0; i < ARRAY_SIZE(dbx500_regulator_info); i++) {
4488c2ecf20Sopenharmony_ci		/* assign per-regulator data */
4498c2ecf20Sopenharmony_ci		info = &dbx500_regulator_info[i];
4508c2ecf20Sopenharmony_ci
4518c2ecf20Sopenharmony_ci		config.driver_data = info;
4528c2ecf20Sopenharmony_ci		config.dev = &pdev->dev;
4538c2ecf20Sopenharmony_ci		if (db8500_init_data)
4548c2ecf20Sopenharmony_ci			config.init_data = &db8500_init_data[i];
4558c2ecf20Sopenharmony_ci
4568c2ecf20Sopenharmony_ci		rdev = devm_regulator_register(&pdev->dev, &info->desc,
4578c2ecf20Sopenharmony_ci					       &config);
4588c2ecf20Sopenharmony_ci		if (IS_ERR(rdev)) {
4598c2ecf20Sopenharmony_ci			err = PTR_ERR(rdev);
4608c2ecf20Sopenharmony_ci			dev_err(&pdev->dev, "failed to register %s: err %i\n",
4618c2ecf20Sopenharmony_ci				info->desc.name, err);
4628c2ecf20Sopenharmony_ci			return err;
4638c2ecf20Sopenharmony_ci		}
4648c2ecf20Sopenharmony_ci		dev_dbg(&pdev->dev, "regulator-%s-probed\n", info->desc.name);
4658c2ecf20Sopenharmony_ci	}
4668c2ecf20Sopenharmony_ci
4678c2ecf20Sopenharmony_ci	ux500_regulator_debug_init(pdev, dbx500_regulator_info,
4688c2ecf20Sopenharmony_ci				   ARRAY_SIZE(dbx500_regulator_info));
4698c2ecf20Sopenharmony_ci	return 0;
4708c2ecf20Sopenharmony_ci}
4718c2ecf20Sopenharmony_ci
4728c2ecf20Sopenharmony_cistatic int db8500_regulator_remove(struct platform_device *pdev)
4738c2ecf20Sopenharmony_ci{
4748c2ecf20Sopenharmony_ci	ux500_regulator_debug_exit();
4758c2ecf20Sopenharmony_ci
4768c2ecf20Sopenharmony_ci	return 0;
4778c2ecf20Sopenharmony_ci}
4788c2ecf20Sopenharmony_ci
4798c2ecf20Sopenharmony_cistatic struct platform_driver db8500_regulator_driver = {
4808c2ecf20Sopenharmony_ci	.driver = {
4818c2ecf20Sopenharmony_ci		.name = "db8500-prcmu-regulators",
4828c2ecf20Sopenharmony_ci	},
4838c2ecf20Sopenharmony_ci	.probe = db8500_regulator_probe,
4848c2ecf20Sopenharmony_ci	.remove = db8500_regulator_remove,
4858c2ecf20Sopenharmony_ci};
4868c2ecf20Sopenharmony_ci
4878c2ecf20Sopenharmony_cistatic int __init db8500_regulator_init(void)
4888c2ecf20Sopenharmony_ci{
4898c2ecf20Sopenharmony_ci	return platform_driver_register(&db8500_regulator_driver);
4908c2ecf20Sopenharmony_ci}
4918c2ecf20Sopenharmony_ci
4928c2ecf20Sopenharmony_cistatic void __exit db8500_regulator_exit(void)
4938c2ecf20Sopenharmony_ci{
4948c2ecf20Sopenharmony_ci	platform_driver_unregister(&db8500_regulator_driver);
4958c2ecf20Sopenharmony_ci}
4968c2ecf20Sopenharmony_ci
4978c2ecf20Sopenharmony_ciarch_initcall(db8500_regulator_init);
4988c2ecf20Sopenharmony_cimodule_exit(db8500_regulator_exit);
4998c2ecf20Sopenharmony_ci
5008c2ecf20Sopenharmony_ciMODULE_AUTHOR("STMicroelectronics/ST-Ericsson");
5018c2ecf20Sopenharmony_ciMODULE_DESCRIPTION("DB8500 regulator driver");
5028c2ecf20Sopenharmony_ciMODULE_LICENSE("GPL v2");
503