diff options
Diffstat (limited to 'drivers/regulator/tps65910-regulator.c')
-rw-r--r-- | drivers/regulator/tps65910-regulator.c | 108 |
1 files changed, 108 insertions, 0 deletions
diff --git a/drivers/regulator/tps65910-regulator.c b/drivers/regulator/tps65910-regulator.c index 5ee7e4bd8b58..60c95646f201 100644 --- a/drivers/regulator/tps65910-regulator.c +++ b/drivers/regulator/tps65910-regulator.c | |||
@@ -23,6 +23,7 @@ | |||
23 | #include <linux/slab.h> | 23 | #include <linux/slab.h> |
24 | #include <linux/gpio.h> | 24 | #include <linux/gpio.h> |
25 | #include <linux/mfd/tps65910.h> | 25 | #include <linux/mfd/tps65910.h> |
26 | #include <linux/regulator/of_regulator.h> | ||
26 | 27 | ||
27 | #define TPS65910_SUPPLY_STATE_ENABLED 0x1 | 28 | #define TPS65910_SUPPLY_STATE_ENABLED 0x1 |
28 | #define EXT_SLEEP_CONTROL (TPS65910_SLEEP_CONTROL_EXT_INPUT_EN1 | \ | 29 | #define EXT_SLEEP_CONTROL (TPS65910_SLEEP_CONTROL_EXT_INPUT_EN1 | \ |
@@ -1035,6 +1036,105 @@ static int tps65910_set_ext_sleep_config(struct tps65910_reg *pmic, | |||
1035 | return ret; | 1036 | return ret; |
1036 | } | 1037 | } |
1037 | 1038 | ||
1039 | #ifdef CONFIG_OF | ||
1040 | |||
1041 | static struct of_regulator_match tps65910_matches[] = { | ||
1042 | { .name = "VRTC", .driver_data = (void *) &tps65910_regs[0] }, | ||
1043 | { .name = "VIO", .driver_data = (void *) &tps65910_regs[1] }, | ||
1044 | { .name = "VDD1", .driver_data = (void *) &tps65910_regs[2] }, | ||
1045 | { .name = "VDD2", .driver_data = (void *) &tps65910_regs[3] }, | ||
1046 | { .name = "VDD3", .driver_data = (void *) &tps65910_regs[4] }, | ||
1047 | { .name = "VDIG1", .driver_data = (void *) &tps65910_regs[5] }, | ||
1048 | { .name = "VDIG2", .driver_data = (void *) &tps65910_regs[6] }, | ||
1049 | { .name = "VPLL", .driver_data = (void *) &tps65910_regs[7] }, | ||
1050 | { .name = "VDAC", .driver_data = (void *) &tps65910_regs[8] }, | ||
1051 | { .name = "VAUX1", .driver_data = (void *) &tps65910_regs[9] }, | ||
1052 | { .name = "VAUX2", .driver_data = (void *) &tps65910_regs[10] }, | ||
1053 | { .name = "VAUX33", .driver_data = (void *) &tps65910_regs[11] }, | ||
1054 | { .name = "VMMC", .driver_data = (void *) &tps65910_regs[12] }, | ||
1055 | }; | ||
1056 | |||
1057 | static struct of_regulator_match tps65911_matches[] = { | ||
1058 | { .name = "VRTC", .driver_data = (void *) &tps65911_regs[0] }, | ||
1059 | { .name = "VIO", .driver_data = (void *) &tps65911_regs[1] }, | ||
1060 | { .name = "VDD1", .driver_data = (void *) &tps65911_regs[2] }, | ||
1061 | { .name = "VDD2", .driver_data = (void *) &tps65911_regs[3] }, | ||
1062 | { .name = "VDDCTRL", .driver_data = (void *) &tps65911_regs[4] }, | ||
1063 | { .name = "LDO1", .driver_data = (void *) &tps65911_regs[5] }, | ||
1064 | { .name = "LDO2", .driver_data = (void *) &tps65911_regs[6] }, | ||
1065 | { .name = "LDO3", .driver_data = (void *) &tps65911_regs[7] }, | ||
1066 | { .name = "LDO4", .driver_data = (void *) &tps65911_regs[8] }, | ||
1067 | { .name = "LDO5", .driver_data = (void *) &tps65911_regs[9] }, | ||
1068 | { .name = "LDO6", .driver_data = (void *) &tps65911_regs[10] }, | ||
1069 | { .name = "LDO7", .driver_data = (void *) &tps65911_regs[11] }, | ||
1070 | { .name = "LDO8", .driver_data = (void *) &tps65911_regs[12] }, | ||
1071 | }; | ||
1072 | |||
1073 | static struct tps65910_board *tps65910_parse_dt_reg_data( | ||
1074 | struct platform_device *pdev) | ||
1075 | { | ||
1076 | struct tps65910_board *pmic_plat_data; | ||
1077 | struct tps65910 *tps65910 = dev_get_drvdata(pdev->dev.parent); | ||
1078 | struct device_node *np = pdev->dev.parent->of_node; | ||
1079 | struct device_node *regulators; | ||
1080 | struct of_regulator_match *matches; | ||
1081 | unsigned int prop; | ||
1082 | int idx = 0, ret, count; | ||
1083 | |||
1084 | pmic_plat_data = devm_kzalloc(&pdev->dev, sizeof(*pmic_plat_data), | ||
1085 | GFP_KERNEL); | ||
1086 | |||
1087 | if (!pmic_plat_data) { | ||
1088 | dev_err(&pdev->dev, "Failure to alloc pdata for regulators.\n"); | ||
1089 | return NULL; | ||
1090 | } | ||
1091 | |||
1092 | regulators = of_find_node_by_name(np, "regulators"); | ||
1093 | |||
1094 | switch (tps65910_chip_id(tps65910)) { | ||
1095 | case TPS65910: | ||
1096 | count = ARRAY_SIZE(tps65910_matches); | ||
1097 | matches = tps65910_matches; | ||
1098 | break; | ||
1099 | case TPS65911: | ||
1100 | count = ARRAY_SIZE(tps65911_matches); | ||
1101 | matches = tps65911_matches; | ||
1102 | break; | ||
1103 | default: | ||
1104 | pr_err("Invalid tps chip version\n"); | ||
1105 | return NULL; | ||
1106 | } | ||
1107 | |||
1108 | ret = of_regulator_match(pdev->dev.parent, regulators, matches, count); | ||
1109 | if (ret < 0) { | ||
1110 | dev_err(&pdev->dev, "Error parsing regulator init data: %d\n", | ||
1111 | ret); | ||
1112 | return NULL; | ||
1113 | } | ||
1114 | |||
1115 | for (idx = 0; idx < count; idx++) { | ||
1116 | if (!matches[idx].init_data || !matches[idx].of_node) | ||
1117 | continue; | ||
1118 | |||
1119 | pmic_plat_data->tps65910_pmic_init_data[idx] = | ||
1120 | matches[idx].init_data; | ||
1121 | |||
1122 | ret = of_property_read_u32(matches[idx].of_node, | ||
1123 | "ti,regulator-ext-sleep-control", &prop); | ||
1124 | if (!ret) | ||
1125 | pmic_plat_data->regulator_ext_sleep_control[idx] = prop; | ||
1126 | } | ||
1127 | |||
1128 | return pmic_plat_data; | ||
1129 | } | ||
1130 | #else | ||
1131 | static inline struct tps65910_board *tps65910_parse_dt_reg_data( | ||
1132 | struct platform_device *pdev) | ||
1133 | { | ||
1134 | return 0; | ||
1135 | } | ||
1136 | #endif | ||
1137 | |||
1038 | static __devinit int tps65910_probe(struct platform_device *pdev) | 1138 | static __devinit int tps65910_probe(struct platform_device *pdev) |
1039 | { | 1139 | { |
1040 | struct tps65910 *tps65910 = dev_get_drvdata(pdev->dev.parent); | 1140 | struct tps65910 *tps65910 = dev_get_drvdata(pdev->dev.parent); |
@@ -1047,6 +1147,9 @@ static __devinit int tps65910_probe(struct platform_device *pdev) | |||
1047 | int i, err; | 1147 | int i, err; |
1048 | 1148 | ||
1049 | pmic_plat_data = dev_get_platdata(tps65910->dev); | 1149 | pmic_plat_data = dev_get_platdata(tps65910->dev); |
1150 | if (!pmic_plat_data && tps65910->dev->of_node) | ||
1151 | pmic_plat_data = tps65910_parse_dt_reg_data(pdev); | ||
1152 | |||
1050 | if (!pmic_plat_data) | 1153 | if (!pmic_plat_data) |
1051 | return -EINVAL; | 1154 | return -EINVAL; |
1052 | 1155 | ||
@@ -1154,6 +1257,11 @@ static __devinit int tps65910_probe(struct platform_device *pdev) | |||
1154 | config.driver_data = pmic; | 1257 | config.driver_data = pmic; |
1155 | config.regmap = tps65910->regmap; | 1258 | config.regmap = tps65910->regmap; |
1156 | 1259 | ||
1260 | #ifdef CONFIG_OF | ||
1261 | config.of_node = of_find_node_by_name(tps65910->dev->of_node, | ||
1262 | info->name); | ||
1263 | #endif | ||
1264 | |||
1157 | rdev = regulator_register(&pmic->desc[i], &config); | 1265 | rdev = regulator_register(&pmic->desc[i], &config); |
1158 | if (IS_ERR(rdev)) { | 1266 | if (IS_ERR(rdev)) { |
1159 | dev_err(tps65910->dev, | 1267 | dev_err(tps65910->dev, |