aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNishanth Menon <nm@ti.com>2014-06-30 11:57:38 -0400
committerMark Brown <broonie@linaro.org>2014-07-03 10:25:56 -0400
commit429222d00531b348076862ea4fd8cd694bf064a9 (patch)
tree6da9ac1b5d8e4d33177a9d6169f6995c028d1c5a
parent6839cd6f6487969e969ced2245bfdabaf7005f6b (diff)
regulator: palmas: Simplify code by not indexing regulator_desc unnecessarily
Palmas regulator needs to full up the regulator_desc based on PMIC and type of regulator. However, we dont need to do desc[id] every time. we can simplify by using a pointer to desc[id] and filling up the parameters. Signed-off-by: Nishanth Menon <nm@ti.com> Tested-by: Stephen Warren <swarren@nvidia.com> Tested-by: Keerthy <j-keerthy@ti.com> Signed-off-by: Mark Brown <broonie@linaro.org>
-rw-r--r--drivers/regulator/palmas-regulator.c248
1 files changed, 112 insertions, 136 deletions
diff --git a/drivers/regulator/palmas-regulator.c b/drivers/regulator/palmas-regulator.c
index d6b734f397dc..ae0f639096fb 100644
--- a/drivers/regulator/palmas-regulator.c
+++ b/drivers/regulator/palmas-regulator.c
@@ -866,6 +866,7 @@ static int palmas_ldo_registration(struct palmas_pmic *pmic,
866 struct regulator_dev *rdev; 866 struct regulator_dev *rdev;
867 struct palmas_reg_init *reg_init; 867 struct palmas_reg_init *reg_init;
868 struct palmas_regs_info *rinfo; 868 struct palmas_regs_info *rinfo;
869 struct regulator_desc *desc;
869 870
870 for (id = ddata->ldo_begin; id < ddata->max_reg; id++) { 871 for (id = ddata->ldo_begin; id < ddata->max_reg; id++) {
871 if (pdata && pdata->reg_init[id]) 872 if (pdata && pdata->reg_init[id])
@@ -879,57 +880,51 @@ static int palmas_ldo_registration(struct palmas_pmic *pmic,
879 */ 880 */
880 881
881 /* Register the regulators */ 882 /* Register the regulators */
882 pmic->desc[id].name = rinfo->name; 883 desc = &pmic->desc[id];
883 pmic->desc[id].id = id; 884 desc->name = rinfo->name;
884 pmic->desc[id].type = REGULATOR_VOLTAGE; 885 desc->id = id;
885 pmic->desc[id].owner = THIS_MODULE; 886 desc->type = REGULATOR_VOLTAGE;
887 desc->owner = THIS_MODULE;
886 888
887 if (id < PALMAS_REG_REGEN1) { 889 if (id < PALMAS_REG_REGEN1) {
888 pmic->desc[id].n_voltages = PALMAS_LDO_NUM_VOLTAGES; 890 desc->n_voltages = PALMAS_LDO_NUM_VOLTAGES;
889 if (reg_init && reg_init->roof_floor) 891 if (reg_init && reg_init->roof_floor)
890 pmic->desc[id].ops = 892 desc->ops = &palmas_ops_ext_control_ldo;
891 &palmas_ops_ext_control_ldo;
892 else 893 else
893 pmic->desc[id].ops = &palmas_ops_ldo; 894 desc->ops = &palmas_ops_ldo;
894 pmic->desc[id].min_uV = 900000; 895 desc->min_uV = 900000;
895 pmic->desc[id].uV_step = 50000; 896 desc->uV_step = 50000;
896 pmic->desc[id].linear_min_sel = 1; 897 desc->linear_min_sel = 1;
897 pmic->desc[id].enable_time = 500; 898 desc->enable_time = 500;
898 pmic->desc[id].vsel_reg = 899 desc->vsel_reg = PALMAS_BASE_TO_REG(PALMAS_LDO_BASE,
899 PALMAS_BASE_TO_REG(PALMAS_LDO_BASE, 900 rinfo->vsel_addr);
900 rinfo->vsel_addr); 901 desc->vsel_mask = PALMAS_LDO1_VOLTAGE_VSEL_MASK;
901 pmic->desc[id].vsel_mask = 902 desc->enable_reg = PALMAS_BASE_TO_REG(PALMAS_LDO_BASE,
902 PALMAS_LDO1_VOLTAGE_VSEL_MASK; 903 rinfo->ctrl_addr);
903 pmic->desc[id].enable_reg = 904 desc->enable_mask = PALMAS_LDO1_CTRL_MODE_ACTIVE;
904 PALMAS_BASE_TO_REG(PALMAS_LDO_BASE,
905 rinfo->ctrl_addr);
906 pmic->desc[id].enable_mask =
907 PALMAS_LDO1_CTRL_MODE_ACTIVE;
908 905
909 /* Check if LDO8 is in tracking mode or not */ 906 /* Check if LDO8 is in tracking mode or not */
910 if (pdata && (id == PALMAS_REG_LDO8) && 907 if (pdata && (id == PALMAS_REG_LDO8) &&
911 pdata->enable_ldo8_tracking) { 908 pdata->enable_ldo8_tracking) {
912 palmas_enable_ldo8_track(pmic->palmas); 909 palmas_enable_ldo8_track(pmic->palmas);
913 pmic->desc[id].min_uV = 450000; 910 desc->min_uV = 450000;
914 pmic->desc[id].uV_step = 25000; 911 desc->uV_step = 25000;
915 } 912 }
916 913
917 /* LOD6 in vibrator mode will have enable time 2000us */ 914 /* LOD6 in vibrator mode will have enable time 2000us */
918 if (pdata && pdata->ldo6_vibrator && 915 if (pdata && pdata->ldo6_vibrator &&
919 (id == PALMAS_REG_LDO6)) 916 (id == PALMAS_REG_LDO6))
920 pmic->desc[id].enable_time = 2000; 917 desc->enable_time = 2000;
921 } else { 918 } else {
922 pmic->desc[id].n_voltages = 1; 919 desc->n_voltages = 1;
923 if (reg_init && reg_init->roof_floor) 920 if (reg_init && reg_init->roof_floor)
924 pmic->desc[id].ops = 921 desc->ops = &palmas_ops_ext_control_extreg;
925 &palmas_ops_ext_control_extreg;
926 else 922 else
927 pmic->desc[id].ops = &palmas_ops_extreg; 923 desc->ops = &palmas_ops_extreg;
928 pmic->desc[id].enable_reg = 924 desc->enable_reg =
929 PALMAS_BASE_TO_REG(PALMAS_RESOURCE_BASE, 925 PALMAS_BASE_TO_REG(PALMAS_RESOURCE_BASE,
930 rinfo->ctrl_addr); 926 rinfo->ctrl_addr);
931 pmic->desc[id].enable_mask = 927 desc->enable_mask = PALMAS_REGEN1_CTRL_MODE_ACTIVE;
932 PALMAS_REGEN1_CTRL_MODE_ACTIVE;
933 } 928 }
934 929
935 if (pdata) 930 if (pdata)
@@ -937,11 +932,10 @@ static int palmas_ldo_registration(struct palmas_pmic *pmic,
937 else 932 else
938 config.init_data = NULL; 933 config.init_data = NULL;
939 934
940 pmic->desc[id].supply_name = rinfo->sname; 935 desc->supply_name = rinfo->sname;
941 config.of_node = ddata->palmas_matches[id].of_node; 936 config.of_node = ddata->palmas_matches[id].of_node;
942 937
943 rdev = devm_regulator_register(pmic->dev, &pmic->desc[id], 938 rdev = devm_regulator_register(pmic->dev, desc, &config);
944 &config);
945 if (IS_ERR(rdev)) { 939 if (IS_ERR(rdev)) {
946 dev_err(pmic->dev, 940 dev_err(pmic->dev,
947 "failed to register %s regulator\n", 941 "failed to register %s regulator\n",
@@ -981,6 +975,7 @@ static int tps65917_ldo_registration(struct palmas_pmic *pmic,
981 struct regulator_dev *rdev; 975 struct regulator_dev *rdev;
982 struct palmas_reg_init *reg_init; 976 struct palmas_reg_init *reg_init;
983 struct palmas_regs_info *rinfo; 977 struct palmas_regs_info *rinfo;
978 struct regulator_desc *desc;
984 979
985 for (id = ddata->ldo_begin; id < ddata->max_reg; id++) { 980 for (id = ddata->ldo_begin; id < ddata->max_reg; id++) {
986 if (pdata && pdata->reg_init[id]) 981 if (pdata && pdata->reg_init[id])
@@ -994,49 +989,43 @@ static int tps65917_ldo_registration(struct palmas_pmic *pmic,
994 rinfo = &ddata->palmas_regs_info[id]; 989 rinfo = &ddata->palmas_regs_info[id];
995 990
996 /* Register the regulators */ 991 /* Register the regulators */
997 pmic->desc[id].name = rinfo->name; 992 desc = &pmic->desc[id];
998 pmic->desc[id].id = id; 993 desc->name = rinfo->name;
999 pmic->desc[id].type = REGULATOR_VOLTAGE; 994 desc->id = id;
1000 pmic->desc[id].owner = THIS_MODULE; 995 desc->type = REGULATOR_VOLTAGE;
996 desc->owner = THIS_MODULE;
1001 997
1002 if (id < TPS65917_REG_REGEN1) { 998 if (id < TPS65917_REG_REGEN1) {
1003 pmic->desc[id].n_voltages = PALMAS_LDO_NUM_VOLTAGES; 999 desc->n_voltages = PALMAS_LDO_NUM_VOLTAGES;
1004 if (reg_init && reg_init->roof_floor) 1000 if (reg_init && reg_init->roof_floor)
1005 pmic->desc[id].ops = 1001 desc->ops = &palmas_ops_ext_control_ldo;
1006 &palmas_ops_ext_control_ldo;
1007 else 1002 else
1008 pmic->desc[id].ops = &tps65917_ops_ldo; 1003 desc->ops = &tps65917_ops_ldo;
1009 pmic->desc[id].min_uV = 900000; 1004 desc->min_uV = 900000;
1010 pmic->desc[id].uV_step = 50000; 1005 desc->uV_step = 50000;
1011 pmic->desc[id].linear_min_sel = 1; 1006 desc->linear_min_sel = 1;
1012 pmic->desc[id].enable_time = 500; 1007 desc->enable_time = 500;
1013 pmic->desc[id].vsel_reg = 1008 desc->vsel_reg = PALMAS_BASE_TO_REG(PALMAS_LDO_BASE,
1014 PALMAS_BASE_TO_REG(PALMAS_LDO_BASE, 1009 rinfo->vsel_addr);
1015 rinfo->vsel_addr); 1010 desc->vsel_mask = PALMAS_LDO1_VOLTAGE_VSEL_MASK;
1016 pmic->desc[id].vsel_mask = 1011 desc->enable_reg = PALMAS_BASE_TO_REG(PALMAS_LDO_BASE,
1017 PALMAS_LDO1_VOLTAGE_VSEL_MASK; 1012 rinfo->ctrl_addr);
1018 pmic->desc[id].enable_reg = 1013 desc->enable_mask = PALMAS_LDO1_CTRL_MODE_ACTIVE;
1019 PALMAS_BASE_TO_REG(PALMAS_LDO_BASE,
1020 rinfo->ctrl_addr);
1021 pmic->desc[id].enable_mask =
1022 PALMAS_LDO1_CTRL_MODE_ACTIVE;
1023 /* 1014 /*
1024 * To be confirmed. Discussion on going with PMIC Team. 1015 * To be confirmed. Discussion on going with PMIC Team.
1025 * It is of the order of ~60mV/uS. 1016 * It is of the order of ~60mV/uS.
1026 */ 1017 */
1027 pmic->desc[id].ramp_delay = 2500; 1018 desc->ramp_delay = 2500;
1028 } else { 1019 } else {
1029 pmic->desc[id].n_voltages = 1; 1020 desc->n_voltages = 1;
1030 if (reg_init && reg_init->roof_floor) 1021 if (reg_init && reg_init->roof_floor)
1031 pmic->desc[id].ops = 1022 desc->ops = &palmas_ops_ext_control_extreg;
1032 &palmas_ops_ext_control_extreg;
1033 else 1023 else
1034 pmic->desc[id].ops = &palmas_ops_extreg; 1024 desc->ops = &palmas_ops_extreg;
1035 pmic->desc[id].enable_reg = 1025 desc->enable_reg =
1036 PALMAS_BASE_TO_REG(PALMAS_RESOURCE_BASE, 1026 PALMAS_BASE_TO_REG(PALMAS_RESOURCE_BASE,
1037 rinfo->ctrl_addr); 1027 rinfo->ctrl_addr);
1038 pmic->desc[id].enable_mask = 1028 desc->enable_mask = PALMAS_REGEN1_CTRL_MODE_ACTIVE;
1039 PALMAS_REGEN1_CTRL_MODE_ACTIVE;
1040 } 1029 }
1041 1030
1042 if (pdata) 1031 if (pdata)
@@ -1044,11 +1033,10 @@ static int tps65917_ldo_registration(struct palmas_pmic *pmic,
1044 else 1033 else
1045 config.init_data = NULL; 1034 config.init_data = NULL;
1046 1035
1047 pmic->desc[id].supply_name = rinfo->sname; 1036 desc->supply_name = rinfo->sname;
1048 config.of_node = ddata->palmas_matches[id].of_node; 1037 config.of_node = ddata->palmas_matches[id].of_node;
1049 1038
1050 rdev = devm_regulator_register(pmic->dev, &pmic->desc[id], 1039 rdev = devm_regulator_register(pmic->dev, desc, &config);
1051 &config);
1052 if (IS_ERR(rdev)) { 1040 if (IS_ERR(rdev)) {
1053 dev_err(pmic->dev, 1041 dev_err(pmic->dev,
1054 "failed to register %s regulator\n", 1042 "failed to register %s regulator\n",
@@ -1089,6 +1077,7 @@ static int palmas_smps_registration(struct palmas_pmic *pmic,
1089 struct regulator_dev *rdev; 1077 struct regulator_dev *rdev;
1090 struct palmas_reg_init *reg_init; 1078 struct palmas_reg_init *reg_init;
1091 struct palmas_regs_info *rinfo; 1079 struct palmas_regs_info *rinfo;
1080 struct regulator_desc *desc;
1092 1081
1093 for (id = ddata->smps_start; id <= ddata->smps_end; id++) { 1082 for (id = ddata->smps_start; id <= ddata->smps_end; id++) {
1094 bool ramp_delay_support = false; 1083 bool ramp_delay_support = false;
@@ -1128,6 +1117,7 @@ static int palmas_smps_registration(struct palmas_pmic *pmic,
1128 continue; 1117 continue;
1129 } 1118 }
1130 rinfo = &ddata->palmas_regs_info[id]; 1119 rinfo = &ddata->palmas_regs_info[id];
1120 desc = &pmic->desc[id];
1131 1121
1132 if ((id == PALMAS_REG_SMPS6) || (id == PALMAS_REG_SMPS8)) 1122 if ((id == PALMAS_REG_SMPS6) || (id == PALMAS_REG_SMPS8))
1133 ramp_delay_support = true; 1123 ramp_delay_support = true;
@@ -1140,9 +1130,8 @@ static int palmas_smps_registration(struct palmas_pmic *pmic,
1140 "reading TSTEP reg failed: %d\n", ret); 1130 "reading TSTEP reg failed: %d\n", ret);
1141 return ret; 1131 return ret;
1142 } 1132 }
1143 pmic->desc[id].ramp_delay = 1133 desc->ramp_delay = palmas_smps_ramp_delay[reg & 0x3];
1144 palmas_smps_ramp_delay[reg & 0x3]; 1134 pmic->ramp_delay[id] = desc->ramp_delay;
1145 pmic->ramp_delay[id] = pmic->desc[id].ramp_delay;
1146 } 1135 }
1147 1136
1148 /* Initialise sleep/init values from platform data */ 1137 /* Initialise sleep/init values from platform data */
@@ -1156,31 +1145,28 @@ static int palmas_smps_registration(struct palmas_pmic *pmic,
1156 } 1145 }
1157 1146
1158 /* Register the regulators */ 1147 /* Register the regulators */
1159 pmic->desc[id].name = rinfo->name; 1148 desc->name = rinfo->name;
1160 pmic->desc[id].id = id; 1149 desc->id = id;
1161 1150
1162 switch (id) { 1151 switch (id) {
1163 case PALMAS_REG_SMPS10_OUT1: 1152 case PALMAS_REG_SMPS10_OUT1:
1164 case PALMAS_REG_SMPS10_OUT2: 1153 case PALMAS_REG_SMPS10_OUT2:
1165 pmic->desc[id].n_voltages = PALMAS_SMPS10_NUM_VOLTAGES; 1154 desc->n_voltages = PALMAS_SMPS10_NUM_VOLTAGES;
1166 pmic->desc[id].ops = &palmas_ops_smps10; 1155 desc->ops = &palmas_ops_smps10;
1167 pmic->desc[id].vsel_reg = 1156 desc->vsel_reg = PALMAS_BASE_TO_REG(PALMAS_SMPS_BASE,
1168 PALMAS_BASE_TO_REG(PALMAS_SMPS_BASE, 1157 PALMAS_SMPS10_CTRL);
1169 PALMAS_SMPS10_CTRL); 1158 desc->vsel_mask = SMPS10_VSEL;
1170 pmic->desc[id].vsel_mask = SMPS10_VSEL; 1159 desc->enable_reg = PALMAS_BASE_TO_REG(PALMAS_SMPS_BASE,
1171 pmic->desc[id].enable_reg = 1160 PALMAS_SMPS10_CTRL);
1172 PALMAS_BASE_TO_REG(PALMAS_SMPS_BASE,
1173 PALMAS_SMPS10_CTRL);
1174 if (id == PALMAS_REG_SMPS10_OUT1) 1161 if (id == PALMAS_REG_SMPS10_OUT1)
1175 pmic->desc[id].enable_mask = SMPS10_SWITCH_EN; 1162 desc->enable_mask = SMPS10_SWITCH_EN;
1176 else 1163 else
1177 pmic->desc[id].enable_mask = SMPS10_BOOST_EN; 1164 desc->enable_mask = SMPS10_BOOST_EN;
1178 pmic->desc[id].bypass_reg = 1165 desc->bypass_reg = PALMAS_BASE_TO_REG(PALMAS_SMPS_BASE,
1179 PALMAS_BASE_TO_REG(PALMAS_SMPS_BASE, 1166 PALMAS_SMPS10_CTRL);
1180 PALMAS_SMPS10_CTRL); 1167 desc->bypass_mask = SMPS10_BYPASS_EN;
1181 pmic->desc[id].bypass_mask = SMPS10_BYPASS_EN; 1168 desc->min_uV = 3750000;
1182 pmic->desc[id].min_uV = 3750000; 1169 desc->uV_step = 1250000;
1183 pmic->desc[id].uV_step = 1250000;
1184 break; 1170 break;
1185 default: 1171 default:
1186 /* 1172 /*
@@ -1190,7 +1176,7 @@ static int palmas_smps_registration(struct palmas_pmic *pmic,
1190 * ranges. Read the current smps mode for later use. 1176 * ranges. Read the current smps mode for later use.
1191 */ 1177 */
1192 addr = rinfo->vsel_addr; 1178 addr = rinfo->vsel_addr;
1193 pmic->desc[id].n_linear_ranges = 3; 1179 desc->n_linear_ranges = 3;
1194 1180
1195 ret = palmas_smps_read(pmic->palmas, addr, &reg); 1181 ret = palmas_smps_read(pmic->palmas, addr, &reg);
1196 if (ret) 1182 if (ret)
@@ -1198,21 +1184,18 @@ static int palmas_smps_registration(struct palmas_pmic *pmic,
1198 if (reg & PALMAS_SMPS12_VOLTAGE_RANGE) 1184 if (reg & PALMAS_SMPS12_VOLTAGE_RANGE)
1199 pmic->range[id] = 1; 1185 pmic->range[id] = 1;
1200 if (pmic->range[id]) 1186 if (pmic->range[id])
1201 pmic->desc[id].linear_ranges = smps_high_ranges; 1187 desc->linear_ranges = smps_high_ranges;
1202 else 1188 else
1203 pmic->desc[id].linear_ranges = smps_low_ranges; 1189 desc->linear_ranges = smps_low_ranges;
1204 1190
1205 if (reg_init && reg_init->roof_floor) 1191 if (reg_init && reg_init->roof_floor)
1206 pmic->desc[id].ops = 1192 desc->ops = &palmas_ops_ext_control_smps;
1207 &palmas_ops_ext_control_smps;
1208 else 1193 else
1209 pmic->desc[id].ops = &palmas_ops_smps; 1194 desc->ops = &palmas_ops_smps;
1210 pmic->desc[id].n_voltages = PALMAS_SMPS_NUM_VOLTAGES; 1195 desc->n_voltages = PALMAS_SMPS_NUM_VOLTAGES;
1211 pmic->desc[id].vsel_reg = 1196 desc->vsel_reg = PALMAS_BASE_TO_REG(PALMAS_SMPS_BASE,
1212 PALMAS_BASE_TO_REG(PALMAS_SMPS_BASE, 1197 rinfo->vsel_addr);
1213 rinfo->vsel_addr); 1198 desc->vsel_mask = PALMAS_SMPS12_VOLTAGE_VSEL_MASK;
1214 pmic->desc[id].vsel_mask =
1215 PALMAS_SMPS12_VOLTAGE_VSEL_MASK;
1216 1199
1217 /* Read the smps mode for later use. */ 1200 /* Read the smps mode for later use. */
1218 addr = rinfo->ctrl_addr; 1201 addr = rinfo->ctrl_addr;
@@ -1222,28 +1205,25 @@ static int palmas_smps_registration(struct palmas_pmic *pmic,
1222 pmic->current_reg_mode[id] = reg & 1205 pmic->current_reg_mode[id] = reg &
1223 PALMAS_SMPS12_CTRL_MODE_ACTIVE_MASK; 1206 PALMAS_SMPS12_CTRL_MODE_ACTIVE_MASK;
1224 1207
1225 pmic->desc[id].enable_reg = 1208 desc->enable_reg = PALMAS_BASE_TO_REG(PALMAS_SMPS_BASE,
1226 PALMAS_BASE_TO_REG(PALMAS_SMPS_BASE, 1209 rinfo->ctrl_addr);
1227 rinfo->ctrl_addr); 1210 desc->enable_mask = PALMAS_SMPS12_CTRL_MODE_ACTIVE_MASK;
1228 pmic->desc[id].enable_mask =
1229 PALMAS_SMPS12_CTRL_MODE_ACTIVE_MASK;
1230 /* set_mode overrides this value */ 1211 /* set_mode overrides this value */
1231 pmic->desc[id].enable_val = SMPS_CTRL_MODE_ON; 1212 desc->enable_val = SMPS_CTRL_MODE_ON;
1232 } 1213 }
1233 1214
1234 pmic->desc[id].type = REGULATOR_VOLTAGE; 1215 desc->type = REGULATOR_VOLTAGE;
1235 pmic->desc[id].owner = THIS_MODULE; 1216 desc->owner = THIS_MODULE;
1236 1217
1237 if (pdata) 1218 if (pdata)
1238 config.init_data = pdata->reg_data[id]; 1219 config.init_data = pdata->reg_data[id];
1239 else 1220 else
1240 config.init_data = NULL; 1221 config.init_data = NULL;
1241 1222
1242 pmic->desc[id].supply_name = rinfo->sname; 1223 desc->supply_name = rinfo->sname;
1243 config.of_node = ddata->palmas_matches[id].of_node; 1224 config.of_node = ddata->palmas_matches[id].of_node;
1244 1225
1245 rdev = devm_regulator_register(pmic->dev, &pmic->desc[id], 1226 rdev = devm_regulator_register(pmic->dev, desc, &config);
1246 &config);
1247 if (IS_ERR(rdev)) { 1227 if (IS_ERR(rdev)) {
1248 dev_err(pmic->dev, 1228 dev_err(pmic->dev,
1249 "failed to register %s regulator\n", 1229 "failed to register %s regulator\n",
@@ -1269,13 +1249,15 @@ static int tps65917_smps_registration(struct palmas_pmic *pmic,
1269 struct regulator_dev *rdev; 1249 struct regulator_dev *rdev;
1270 struct palmas_reg_init *reg_init; 1250 struct palmas_reg_init *reg_init;
1271 struct palmas_regs_info *rinfo; 1251 struct palmas_regs_info *rinfo;
1252 struct regulator_desc *desc;
1272 1253
1273 for (id = ddata->smps_start; id <= ddata->smps_end; id++) { 1254 for (id = ddata->smps_start; id <= ddata->smps_end; id++) {
1274 /* 1255 /*
1275 * Miss out regulators which are not available due 1256 * Miss out regulators which are not available due
1276 * to slaving configurations. 1257 * to slaving configurations.
1277 */ 1258 */
1278 pmic->desc[id].n_linear_ranges = 3; 1259 desc = &pmic->desc[id];
1260 desc->n_linear_ranges = 3;
1279 if ((id == TPS65917_REG_SMPS2) && pmic->smps12) 1261 if ((id == TPS65917_REG_SMPS2) && pmic->smps12)
1280 continue; 1262 continue;
1281 1263
@@ -1291,8 +1273,8 @@ static int tps65917_smps_registration(struct palmas_pmic *pmic,
1291 rinfo = &ddata->palmas_regs_info[id]; 1273 rinfo = &ddata->palmas_regs_info[id];
1292 1274
1293 /* Register the regulators */ 1275 /* Register the regulators */
1294 pmic->desc[id].name = rinfo->name; 1276 desc->name = rinfo->name;
1295 pmic->desc[id].id = id; 1277 desc->id = id;
1296 1278
1297 /* 1279 /*
1298 * Read and store the RANGE bit for later use 1280 * Read and store the RANGE bit for later use
@@ -1309,24 +1291,19 @@ static int tps65917_smps_registration(struct palmas_pmic *pmic,
1309 pmic->range[id] = 1; 1291 pmic->range[id] = 1;
1310 1292
1311 if (pmic->range[id]) 1293 if (pmic->range[id])
1312 pmic->desc[id].linear_ranges = smps_high_ranges; 1294 desc->linear_ranges = smps_high_ranges;
1313 else 1295 else
1314 pmic->desc[id].linear_ranges = smps_low_ranges; 1296 desc->linear_ranges = smps_low_ranges;
1315
1316 1297
1317 if (reg_init && reg_init->roof_floor) 1298 if (reg_init && reg_init->roof_floor)
1318 pmic->desc[id].ops = 1299 desc->ops = &tps65917_ops_ext_control_smps;
1319 &tps65917_ops_ext_control_smps;
1320 else 1300 else
1321 pmic->desc[id].ops = &tps65917_ops_smps; 1301 desc->ops = &tps65917_ops_smps;
1322 pmic->desc[id].n_voltages = PALMAS_SMPS_NUM_VOLTAGES; 1302 desc->n_voltages = PALMAS_SMPS_NUM_VOLTAGES;
1323 pmic->desc[id].vsel_reg = 1303 desc->vsel_reg = PALMAS_BASE_TO_REG(PALMAS_SMPS_BASE,
1324 PALMAS_BASE_TO_REG(PALMAS_SMPS_BASE, 1304 rinfo->vsel_addr);
1325 rinfo->vsel_addr); 1305 desc->vsel_mask = PALMAS_SMPS12_VOLTAGE_VSEL_MASK;
1326 pmic->desc[id].vsel_mask = 1306 desc->ramp_delay = 2500;
1327 PALMAS_SMPS12_VOLTAGE_VSEL_MASK;
1328
1329 pmic->desc[id].ramp_delay = 2500;
1330 1307
1331 /* Read the smps mode for later use. */ 1308 /* Read the smps mode for later use. */
1332 addr = rinfo->ctrl_addr; 1309 addr = rinfo->ctrl_addr;
@@ -1336,19 +1313,18 @@ static int tps65917_smps_registration(struct palmas_pmic *pmic,
1336 pmic->current_reg_mode[id] = reg & 1313 pmic->current_reg_mode[id] = reg &
1337 PALMAS_SMPS12_CTRL_MODE_ACTIVE_MASK; 1314 PALMAS_SMPS12_CTRL_MODE_ACTIVE_MASK;
1338 1315
1339 pmic->desc[id].type = REGULATOR_VOLTAGE; 1316 desc->type = REGULATOR_VOLTAGE;
1340 pmic->desc[id].owner = THIS_MODULE; 1317 desc->owner = THIS_MODULE;
1341 1318
1342 if (pdata) 1319 if (pdata)
1343 config.init_data = pdata->reg_data[id]; 1320 config.init_data = pdata->reg_data[id];
1344 else 1321 else
1345 config.init_data = NULL; 1322 config.init_data = NULL;
1346 1323
1347 pmic->desc[id].supply_name = rinfo->sname; 1324 desc->supply_name = rinfo->sname;
1348 config.of_node = ddata->palmas_matches[id].of_node; 1325 config.of_node = ddata->palmas_matches[id].of_node;
1349 1326
1350 rdev = devm_regulator_register(pmic->dev, &pmic->desc[id], 1327 rdev = devm_regulator_register(pmic->dev, desc, &config);
1351 &config);
1352 if (IS_ERR(rdev)) { 1328 if (IS_ERR(rdev)) {
1353 dev_err(pmic->dev, 1329 dev_err(pmic->dev,
1354 "failed to register %s regulator\n", 1330 "failed to register %s regulator\n",