aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator/vexpress.c
diff options
context:
space:
mode:
authorPawel Moll <pawel.moll@arm.com>2014-04-30 11:46:29 -0400
committerPawel Moll <pawel.moll@arm.com>2014-05-15 12:02:18 -0400
commit3b9334ac835bb431e2186645230c9f1eb94b5d49 (patch)
tree631e00349363927a6e49c6810332d92295103446 /drivers/regulator/vexpress.c
parentc6e126de43e7d4abfd6cf796b40589db3a046167 (diff)
mfd: vexpress: Convert custom func API to regmap
Components of the Versatile Express platform (configuration microcontrollers on motherboard and daughterboards in particular) talk to each other over a custom configuration bus. They provide miscellaneous functions (from clock generator control to energy sensors) which are represented as platform devices (and Device Tree nodes). The transactions on the bus can be generated by different "bridges" in the system, some of which are universal for the whole platform (for the price of high transfer latencies), others restricted to a subsystem (but much faster). Until now drivers for such functions were using custom "func" API, which is being replaced in this patch by regmap calls. This required: * a rework (and move to drivers/bus directory, as suggested by Samuel and Arnd) of the config bus core, which is much simpler now and uses device model infrastructure (class) to keep track of the bridges; non-DT case (soon to be retired anyway) is simply covered by a special device registration function * the new config-bus driver also takes over device population, so there is no need for special matching table for of_platform_populate nor "simple-bus" hack in the arm64 model dtsi file (relevant bindings documentation has been updated); this allows all the vexpress devices fit into normal device model, making it possible to remove plenty of early inits and other hacks in the near future * adaptation of the syscfg bridge implementation in the sysreg driver, again making it much simpler; there is a special case of the "energy" function spanning two registers, where they should be both defined in the tree now, but backward compatibility is maintained in the code * modification of the relevant drivers: * hwmon - just a straight-forward API change * power/reset driver - API change * regulator - API change plus error handling simplification * osc clock driver - this one required larger rework in order to turn in into a standard platform driver Signed-off-by: Pawel Moll <pawel.moll@arm.com> Acked-by: Mark Brown <broonie@linaro.org> Acked-by: Lee Jones <lee.jones@linaro.org> Acked-by: Guenter Roeck <linux@roeck-us.net> Acked-by: Mike Turquette <mturquette@linaro.org>
Diffstat (limited to 'drivers/regulator/vexpress.c')
-rw-r--r--drivers/regulator/vexpress.c50
1 files changed, 12 insertions, 38 deletions
diff --git a/drivers/regulator/vexpress.c b/drivers/regulator/vexpress.c
index f3ae28a7e663..2863428813e4 100644
--- a/drivers/regulator/vexpress.c
+++ b/drivers/regulator/vexpress.c
@@ -26,14 +26,14 @@
26struct vexpress_regulator { 26struct vexpress_regulator {
27 struct regulator_desc desc; 27 struct regulator_desc desc;
28 struct regulator_dev *regdev; 28 struct regulator_dev *regdev;
29 struct vexpress_config_func *func; 29 struct regmap *regmap;
30}; 30};
31 31
32static int vexpress_regulator_get_voltage(struct regulator_dev *regdev) 32static int vexpress_regulator_get_voltage(struct regulator_dev *regdev)
33{ 33{
34 struct vexpress_regulator *reg = rdev_get_drvdata(regdev); 34 struct vexpress_regulator *reg = rdev_get_drvdata(regdev);
35 u32 uV; 35 u32 uV;
36 int err = vexpress_config_read(reg->func, 0, &uV); 36 int err = regmap_read(reg->regmap, 0, &uV);
37 37
38 return err ? err : uV; 38 return err ? err : uV;
39} 39}
@@ -43,7 +43,7 @@ static int vexpress_regulator_set_voltage(struct regulator_dev *regdev,
43{ 43{
44 struct vexpress_regulator *reg = rdev_get_drvdata(regdev); 44 struct vexpress_regulator *reg = rdev_get_drvdata(regdev);
45 45
46 return vexpress_config_write(reg->func, 0, min_uV); 46 return regmap_write(reg->regmap, 0, min_uV);
47} 47}
48 48
49static struct regulator_ops vexpress_regulator_ops_ro = { 49static struct regulator_ops vexpress_regulator_ops_ro = {
@@ -57,22 +57,17 @@ static struct regulator_ops vexpress_regulator_ops = {
57 57
58static int vexpress_regulator_probe(struct platform_device *pdev) 58static int vexpress_regulator_probe(struct platform_device *pdev)
59{ 59{
60 int err;
61 struct vexpress_regulator *reg; 60 struct vexpress_regulator *reg;
62 struct regulator_init_data *init_data; 61 struct regulator_init_data *init_data;
63 struct regulator_config config = { }; 62 struct regulator_config config = { };
64 63
65 reg = devm_kzalloc(&pdev->dev, sizeof(*reg), GFP_KERNEL); 64 reg = devm_kzalloc(&pdev->dev, sizeof(*reg), GFP_KERNEL);
66 if (!reg) { 65 if (!reg)
67 err = -ENOMEM; 66 return -ENOMEM;
68 goto error_kzalloc;
69 }
70 67
71 reg->func = vexpress_config_func_get_by_dev(&pdev->dev); 68 reg->regmap = devm_regmap_init_vexpress_config(&pdev->dev);
72 if (!reg->func) { 69 if (IS_ERR(reg->regmap))
73 err = -ENXIO; 70 return PTR_ERR(reg->regmap);
74 goto error_get_func;
75 }
76 71
77 reg->desc.name = dev_name(&pdev->dev); 72 reg->desc.name = dev_name(&pdev->dev);
78 reg->desc.type = REGULATOR_VOLTAGE; 73 reg->desc.type = REGULATOR_VOLTAGE;
@@ -80,10 +75,8 @@ static int vexpress_regulator_probe(struct platform_device *pdev)
80 reg->desc.continuous_voltage_range = true; 75 reg->desc.continuous_voltage_range = true;
81 76
82 init_data = of_get_regulator_init_data(&pdev->dev, pdev->dev.of_node); 77 init_data = of_get_regulator_init_data(&pdev->dev, pdev->dev.of_node);
83 if (!init_data) { 78 if (!init_data)
84 err = -EINVAL; 79 return -EINVAL;
85 goto error_get_regulator_init_data;
86 }
87 80
88 init_data->constraints.apply_uV = 0; 81 init_data->constraints.apply_uV = 0;
89 if (init_data->constraints.min_uV && init_data->constraints.max_uV) 82 if (init_data->constraints.min_uV && init_data->constraints.max_uV)
@@ -97,30 +90,12 @@ static int vexpress_regulator_probe(struct platform_device *pdev)
97 config.of_node = pdev->dev.of_node; 90 config.of_node = pdev->dev.of_node;
98 91
99 reg->regdev = devm_regulator_register(&pdev->dev, &reg->desc, &config); 92 reg->regdev = devm_regulator_register(&pdev->dev, &reg->desc, &config);
100 if (IS_ERR(reg->regdev)) { 93 if (IS_ERR(reg->regdev))
101 err = PTR_ERR(reg->regdev); 94 return PTR_ERR(reg->regdev);
102 goto error_regulator_register;
103 }
104 95
105 platform_set_drvdata(pdev, reg); 96 platform_set_drvdata(pdev, reg);
106 97
107 return 0; 98 return 0;
108
109error_regulator_register:
110error_get_regulator_init_data:
111 vexpress_config_func_put(reg->func);
112error_get_func:
113error_kzalloc:
114 return err;
115}
116
117static int vexpress_regulator_remove(struct platform_device *pdev)
118{
119 struct vexpress_regulator *reg = platform_get_drvdata(pdev);
120
121 vexpress_config_func_put(reg->func);
122
123 return 0;
124} 99}
125 100
126static struct of_device_id vexpress_regulator_of_match[] = { 101static struct of_device_id vexpress_regulator_of_match[] = {
@@ -130,7 +105,6 @@ static struct of_device_id vexpress_regulator_of_match[] = {
130 105
131static struct platform_driver vexpress_regulator_driver = { 106static struct platform_driver vexpress_regulator_driver = {
132 .probe = vexpress_regulator_probe, 107 .probe = vexpress_regulator_probe,
133 .remove = vexpress_regulator_remove,
134 .driver = { 108 .driver = {
135 .name = DRVNAME, 109 .name = DRVNAME,
136 .owner = THIS_MODULE, 110 .owner = THIS_MODULE,