aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mfd/stmpe.c
diff options
context:
space:
mode:
authorLee Jones <lee.jones@linaro.org>2012-11-05 10:10:33 -0500
committerSamuel Ortiz <sameo@linux.intel.com>2012-11-11 17:35:03 -0500
commit909582caae384418723ccdb00e848f4140257195 (patch)
tree0e6afb4f420f202e7ccc777bce3bd9798f238e14 /drivers/mfd/stmpe.c
parent5204e51d30ceb9715e3d690efe84c50e2e9d557d (diff)
mfd: Enable the STMPE MFD for Device Tree
This patch allows the STMPE Multi-Functional Device to be correctly initialised when booting with Device Tree support enabled. Its children are specified by the addition of subordinate devices to the STMPE node in the Device Tree file. Acked-by: Arnd Bergmann <arnd@arndb.de> Acked-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Lee Jones <lee.jones@linaro.org> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/mfd/stmpe.c')
-rw-r--r--drivers/mfd/stmpe.c48
1 files changed, 42 insertions, 6 deletions
diff --git a/drivers/mfd/stmpe.c b/drivers/mfd/stmpe.c
index e50ebdfeed0f..ba157d45192d 100644
--- a/drivers/mfd/stmpe.c
+++ b/drivers/mfd/stmpe.c
@@ -885,18 +885,19 @@ static struct irq_domain_ops stmpe_irq_ops = {
885 .xlate = irq_domain_xlate_twocell, 885 .xlate = irq_domain_xlate_twocell,
886}; 886};
887 887
888static int __devinit stmpe_irq_init(struct stmpe *stmpe) 888static int __devinit stmpe_irq_init(struct stmpe *stmpe,
889 struct device_node *np)
889{ 890{
890 int base = stmpe->irq_base; 891 int base = stmpe->irq_base;
891 int num_irqs = stmpe->variant->num_irqs; 892 int num_irqs = stmpe->variant->num_irqs;
892 893
893 if (base) { 894 if (base) {
894 stmpe->domain = irq_domain_add_legacy( 895 stmpe->domain = irq_domain_add_legacy(
895 NULL, num_irqs, base, 0, &stmpe_irq_ops, stmpe); 896 np, num_irqs, base, 0, &stmpe_irq_ops, stmpe);
896 } 897 }
897 else { 898 else {
898 stmpe->domain = irq_domain_add_linear( 899 stmpe->domain = irq_domain_add_linear(
899 NULL, num_irqs, &stmpe_irq_ops, stmpe); 900 np, num_irqs, &stmpe_irq_ops, stmpe);
900 } 901 }
901 902
902 if (!stmpe->domain) { 903 if (!stmpe->domain) {
@@ -1016,15 +1017,50 @@ static int __devinit stmpe_devices_init(struct stmpe *stmpe)
1016 return ret; 1017 return ret;
1017} 1018}
1018 1019
1020void __devinit stmpe_of_probe(struct stmpe_platform_data *pdata,
1021 struct device_node *np)
1022{
1023 struct device_node *child;
1024
1025 of_property_read_u32(np, "st,autosleep-timeout",
1026 &pdata->autosleep_timeout);
1027
1028 pdata->autosleep = (pdata->autosleep_timeout) ? true : false;
1029
1030 for_each_child_of_node(np, child) {
1031 if (!strcmp(child->name, "stmpe_gpio")) {
1032 pdata->blocks |= STMPE_BLOCK_GPIO;
1033 }
1034 if (!strcmp(child->name, "stmpe_keypad")) {
1035 pdata->blocks |= STMPE_BLOCK_KEYPAD;
1036 }
1037 if (!strcmp(child->name, "stmpe_touchscreen")) {
1038 pdata->blocks |= STMPE_BLOCK_TOUCHSCREEN;
1039 }
1040 if (!strcmp(child->name, "stmpe_adc")) {
1041 pdata->blocks |= STMPE_BLOCK_ADC;
1042 }
1043 }
1044}
1045
1019/* Called from client specific probe routines */ 1046/* Called from client specific probe routines */
1020int __devinit stmpe_probe(struct stmpe_client_info *ci, int partnum) 1047int __devinit stmpe_probe(struct stmpe_client_info *ci, int partnum)
1021{ 1048{
1022 struct stmpe_platform_data *pdata = dev_get_platdata(ci->dev); 1049 struct stmpe_platform_data *pdata = dev_get_platdata(ci->dev);
1050 struct device_node *np = ci->dev->of_node;
1023 struct stmpe *stmpe; 1051 struct stmpe *stmpe;
1024 int ret; 1052 int ret;
1025 1053
1026 if (!pdata) 1054 if (!pdata) {
1027 return -EINVAL; 1055 if (np) {
1056 pdata = kzalloc(sizeof(*pdata), GFP_KERNEL);
1057 if (!pdata)
1058 return -ENOMEM;
1059
1060 stmpe_of_probe(pdata, np);
1061 } else
1062 return -EINVAL;
1063 }
1028 1064
1029 stmpe = kzalloc(sizeof(struct stmpe), GFP_KERNEL); 1065 stmpe = kzalloc(sizeof(struct stmpe), GFP_KERNEL);
1030 if (!stmpe) 1066 if (!stmpe)
@@ -1080,7 +1116,7 @@ int __devinit stmpe_probe(struct stmpe_client_info *ci, int partnum)
1080 goto free_gpio; 1116 goto free_gpio;
1081 1117
1082 if (stmpe->irq >= 0) { 1118 if (stmpe->irq >= 0) {
1083 ret = stmpe_irq_init(stmpe); 1119 ret = stmpe_irq_init(stmpe, np);
1084 if (ret) 1120 if (ret)
1085 goto free_gpio; 1121 goto free_gpio;
1086 1122