aboutsummaryrefslogtreecommitdiff
path: root/drivers/misc/dummy.c
blob: b5d4db5f6fdb8845668948c8426f93696447692e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#include <linux/init.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/platform_device.h>
#include <linux/gpio.h>
#include <linux/of_gpio.h>
#include <linux/delay.h>
#include <linux/slab.h>
#include <linux/regulator/consumer.h>

struct vreg {
	const char *name;
	int minvolt;
	int maxvolt;
} vregs [8] = {
	{ "vddio", 1800000, 1800000 },
	{ "vddaon", 950000, 950000 },
	{ "vddpmu", 950000, 950000 },
	{ "vddrfa1", 950000, 950000 },
	{ "vddrfa2", 1380000, 1380000 },
	{ "vddrfa3", 2000000, 2000000 },
	{ "vddpcie1", 1350000, 1350000 },
	{ "vddpcie2", 2000000, 2000000 },
};

static int dummy_probe(struct platform_device *pdev)
{
	struct regulator_bulk_data regulators[8];
	struct device *dev = &pdev->dev;
	int i, ret;
	struct pinctrl *pinctrl;
	struct pinctrl_state *wlan_en_active;
	struct pinctrl_state *bt_en_active;

	for (i = 0; i < ARRAY_SIZE(regulators); i++)
		regulators[i].supply = vregs[i].name;
	ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(regulators), regulators);
	if (ret < 0)
		return ret;

	ret = regulator_bulk_enable(ARRAY_SIZE(regulators), regulators);
	if (ret)
		return ret;

	pinctrl = devm_pinctrl_get(dev);
	if (IS_ERR_OR_NULL(pinctrl)) {
                ret = PTR_ERR(pinctrl);
                pr_err("Failed to get pinctrl, err = %d\n", ret);
                return ret;
        }

	wlan_en_active = pinctrl_lookup_state(pinctrl, "wlan_en_active");
	if (IS_ERR_OR_NULL(wlan_en_active)) {
		ret = PTR_ERR(wlan_en_active);
		pr_err("Failed to get wlan_en_active, err = %d\n", ret);
		return ret;
	}

	bt_en_active = pinctrl_lookup_state(pinctrl, "bt_en_active");
	if (IS_ERR_OR_NULL(bt_en_active)) {
		ret = PTR_ERR(bt_en_active);
		pr_err("Failed to get bt_en_active, err = %d\n", ret);
		return ret;
	}

	ret = pinctrl_select_state(pinctrl, wlan_en_active);
	if (ret) {
		pr_err("Failed to select wlan pinctrl state");
		return ret;
	}
	udelay(1000);

	ret = pinctrl_select_state(pinctrl, bt_en_active);
	if (ret) {
		pr_err("Failed to select bt pinctrl state");
		return ret;
	}
	udelay(1000);

	return 0;
}

static int dummy_remove(struct platform_device *pdev)
{
	return 0;
}

static const struct of_device_id dummy_of_match[] = {
	{ .compatible = "qcom,dummy" },
};

static struct platform_driver dummy_driver = {
	.probe = dummy_probe,
	.remove = dummy_remove,
	.driver = {
		.name = "dummy",
		.of_match_table = dummy_of_match,
	},
};

module_platform_driver(dummy_driver);
MODULE_LICENSE("GPL v2");