vc.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624
  1. /*
  2. * OMAP Voltage Controller (VC) interface
  3. *
  4. * Copyright (C) 2011 Texas Instruments, Inc.
  5. *
  6. * This file is licensed under the terms of the GNU General Public
  7. * License version 2. This program is licensed "as is" without any
  8. * warranty of any kind, whether express or implied.
  9. */
  10. #include <linux/kernel.h>
  11. #include <linux/delay.h>
  12. #include <linux/init.h>
  13. #include <linux/bug.h>
  14. #include <linux/io.h>
  15. #include <asm/div64.h>
  16. #include "iomap.h"
  17. #include "soc.h"
  18. #include "voltage.h"
  19. #include "vc.h"
  20. #include "prm-regbits-34xx.h"
  21. #include "prm-regbits-44xx.h"
  22. #include "prm44xx.h"
  23. #include "pm.h"
  24. #include "scrm44xx.h"
  25. /**
  26. * struct omap_vc_channel_cfg - describe the cfg_channel bitfield
  27. * @sa: bit for slave address
  28. * @rav: bit for voltage configuration register
  29. * @rac: bit for command configuration register
  30. * @racen: enable bit for RAC
  31. * @cmd: bit for command value set selection
  32. *
  33. * Channel configuration bits, common for OMAP3+
  34. * OMAP3 register: PRM_VC_CH_CONF
  35. * OMAP4 register: PRM_VC_CFG_CHANNEL
  36. * OMAP5 register: PRM_VC_SMPS_<voltdm>_CONFIG
  37. */
  38. struct omap_vc_channel_cfg {
  39. u8 sa;
  40. u8 rav;
  41. u8 rac;
  42. u8 racen;
  43. u8 cmd;
  44. };
  45. static struct omap_vc_channel_cfg vc_default_channel_cfg = {
  46. .sa = BIT(0),
  47. .rav = BIT(1),
  48. .rac = BIT(2),
  49. .racen = BIT(3),
  50. .cmd = BIT(4),
  51. };
  52. /*
  53. * On OMAP3+, all VC channels have the above default bitfield
  54. * configuration, except the OMAP4 MPU channel. This appears
  55. * to be a freak accident as every other VC channel has the
  56. * default configuration, thus creating a mutant channel config.
  57. */
  58. static struct omap_vc_channel_cfg vc_mutant_channel_cfg = {
  59. .sa = BIT(0),
  60. .rav = BIT(2),
  61. .rac = BIT(3),
  62. .racen = BIT(4),
  63. .cmd = BIT(1),
  64. };
  65. static struct omap_vc_channel_cfg *vc_cfg_bits;
  66. #define CFG_CHANNEL_MASK 0x1f
  67. /**
  68. * omap_vc_config_channel - configure VC channel to PMIC mappings
  69. * @voltdm: pointer to voltagdomain defining the desired VC channel
  70. *
  71. * Configures the VC channel to PMIC mappings for the following
  72. * PMIC settings
  73. * - i2c slave address (SA)
  74. * - voltage configuration address (RAV)
  75. * - command configuration address (RAC) and enable bit (RACEN)
  76. * - command values for ON, ONLP, RET and OFF (CMD)
  77. *
  78. * This function currently only allows flexible configuration of the
  79. * non-default channel. Starting with OMAP4, there are more than 2
  80. * channels, with one defined as the default (on OMAP4, it's MPU.)
  81. * Only the non-default channel can be configured.
  82. */
  83. static int omap_vc_config_channel(struct voltagedomain *voltdm)
  84. {
  85. struct omap_vc_channel *vc = voltdm->vc;
  86. /*
  87. * For default channel, the only configurable bit is RACEN.
  88. * All others must stay at zero (see function comment above.)
  89. */
  90. if (vc->flags & OMAP_VC_CHANNEL_DEFAULT)
  91. vc->cfg_channel &= vc_cfg_bits->racen;
  92. voltdm->rmw(CFG_CHANNEL_MASK << vc->cfg_channel_sa_shift,
  93. vc->cfg_channel << vc->cfg_channel_sa_shift,
  94. vc->cfg_channel_reg);
  95. return 0;
  96. }
  97. /* Voltage scale and accessory APIs */
  98. int omap_vc_pre_scale(struct voltagedomain *voltdm,
  99. unsigned long target_volt,
  100. u8 *target_vsel, u8 *current_vsel)
  101. {
  102. struct omap_vc_channel *vc = voltdm->vc;
  103. u32 vc_cmdval;
  104. /* Check if sufficient pmic info is available for this vdd */
  105. if (!voltdm->pmic) {
  106. pr_err("%s: Insufficient pmic info to scale the vdd_%s\n",
  107. __func__, voltdm->name);
  108. return -EINVAL;
  109. }
  110. if (!voltdm->pmic->uv_to_vsel) {
  111. pr_err("%s: PMIC function to convert voltage in uV to vsel not registered. Hence unable to scale voltage for vdd_%s\n",
  112. __func__, voltdm->name);
  113. return -ENODATA;
  114. }
  115. if (!voltdm->read || !voltdm->write) {
  116. pr_err("%s: No read/write API for accessing vdd_%s regs\n",
  117. __func__, voltdm->name);
  118. return -EINVAL;
  119. }
  120. *target_vsel = voltdm->pmic->uv_to_vsel(target_volt);
  121. *current_vsel = voltdm->pmic->uv_to_vsel(voltdm->nominal_volt);
  122. /* Setting the ON voltage to the new target voltage */
  123. vc_cmdval = voltdm->read(vc->cmdval_reg);
  124. vc_cmdval &= ~vc->common->cmd_on_mask;
  125. vc_cmdval |= (*target_vsel << vc->common->cmd_on_shift);
  126. voltdm->write(vc_cmdval, vc->cmdval_reg);
  127. voltdm->vc_param->on = target_volt;
  128. omap_vp_update_errorgain(voltdm, target_volt);
  129. return 0;
  130. }
  131. void omap_vc_post_scale(struct voltagedomain *voltdm,
  132. unsigned long target_volt,
  133. u8 target_vsel, u8 current_vsel)
  134. {
  135. u32 smps_steps = 0, smps_delay = 0;
  136. smps_steps = abs(target_vsel - current_vsel);
  137. /* SMPS slew rate / step size. 2us added as buffer. */
  138. smps_delay = ((smps_steps * voltdm->pmic->step_size) /
  139. voltdm->pmic->slew_rate) + 2;
  140. udelay(smps_delay);
  141. }
  142. /* vc_bypass_scale - VC bypass method of voltage scaling */
  143. int omap_vc_bypass_scale(struct voltagedomain *voltdm,
  144. unsigned long target_volt)
  145. {
  146. struct omap_vc_channel *vc = voltdm->vc;
  147. u32 loop_cnt = 0, retries_cnt = 0;
  148. u32 vc_valid, vc_bypass_val_reg, vc_bypass_value;
  149. u8 target_vsel, current_vsel;
  150. int ret;
  151. ret = omap_vc_pre_scale(voltdm, target_volt, &target_vsel, &current_vsel);
  152. if (ret)
  153. return ret;
  154. vc_valid = vc->common->valid;
  155. vc_bypass_val_reg = vc->common->bypass_val_reg;
  156. vc_bypass_value = (target_vsel << vc->common->data_shift) |
  157. (vc->volt_reg_addr << vc->common->regaddr_shift) |
  158. (vc->i2c_slave_addr << vc->common->slaveaddr_shift);
  159. voltdm->write(vc_bypass_value, vc_bypass_val_reg);
  160. voltdm->write(vc_bypass_value | vc_valid, vc_bypass_val_reg);
  161. vc_bypass_value = voltdm->read(vc_bypass_val_reg);
  162. /*
  163. * Loop till the bypass command is acknowledged from the SMPS.
  164. * NOTE: This is legacy code. The loop count and retry count needs
  165. * to be revisited.
  166. */
  167. while (!(vc_bypass_value & vc_valid)) {
  168. loop_cnt++;
  169. if (retries_cnt > 10) {
  170. pr_warning("%s: Retry count exceeded\n", __func__);
  171. return -ETIMEDOUT;
  172. }
  173. if (loop_cnt > 50) {
  174. retries_cnt++;
  175. loop_cnt = 0;
  176. udelay(10);
  177. }
  178. vc_bypass_value = voltdm->read(vc_bypass_val_reg);
  179. }
  180. omap_vc_post_scale(voltdm, target_volt, target_vsel, current_vsel);
  181. return 0;
  182. }
  183. /* Convert microsecond value to number of 32kHz clock cycles */
  184. static inline u32 omap_usec_to_32k(u32 usec)
  185. {
  186. return DIV_ROUND_UP_ULL(32768ULL * (u64)usec, 1000000ULL);
  187. }
  188. /* Set oscillator setup time for omap3 */
  189. static void omap3_set_clksetup(u32 usec, struct voltagedomain *voltdm)
  190. {
  191. voltdm->write(omap_usec_to_32k(usec), OMAP3_PRM_CLKSETUP_OFFSET);
  192. }
  193. /**
  194. * omap3_set_i2c_timings - sets i2c sleep timings for a channel
  195. * @voltdm: channel to configure
  196. * @off_mode: select whether retention or off mode values used
  197. *
  198. * Calculates and sets up voltage controller to use I2C based
  199. * voltage scaling for sleep modes. This can be used for either off mode
  200. * or retention. Off mode has additionally an option to use sys_off_mode
  201. * pad, which uses a global signal to program the whole power IC to
  202. * off-mode.
  203. */
  204. static void omap3_set_i2c_timings(struct voltagedomain *voltdm, bool off_mode)
  205. {
  206. unsigned long voltsetup1;
  207. u32 tgt_volt;
  208. /*
  209. * Oscillator is shut down only if we are using sys_off_mode pad,
  210. * thus we set a minimal setup time here
  211. */
  212. omap3_set_clksetup(1, voltdm);
  213. if (off_mode)
  214. tgt_volt = voltdm->vc_param->off;
  215. else
  216. tgt_volt = voltdm->vc_param->ret;
  217. voltsetup1 = (voltdm->vc_param->on - tgt_volt) /
  218. voltdm->pmic->slew_rate;
  219. voltsetup1 = voltsetup1 * voltdm->sys_clk.rate / 8 / 1000000 + 1;
  220. voltdm->rmw(voltdm->vfsm->voltsetup_mask,
  221. voltsetup1 << __ffs(voltdm->vfsm->voltsetup_mask),
  222. voltdm->vfsm->voltsetup_reg);
  223. /*
  224. * pmic is not controlling the voltage scaling during retention,
  225. * thus set voltsetup2 to 0
  226. */
  227. voltdm->write(0, OMAP3_PRM_VOLTSETUP2_OFFSET);
  228. }
  229. /**
  230. * omap3_set_off_timings - sets off-mode timings for a channel
  231. * @voltdm: channel to configure
  232. *
  233. * Calculates and sets up off-mode timings for a channel. Off-mode
  234. * can use either I2C based voltage scaling, or alternatively
  235. * sys_off_mode pad can be used to send a global command to power IC.
  236. * This function first checks which mode is being used, and calls
  237. * omap3_set_i2c_timings() if the system is using I2C control mode.
  238. * sys_off_mode has the additional benefit that voltages can be
  239. * scaled to zero volt level with TWL4030 / TWL5030, I2C can only
  240. * scale to 600mV.
  241. */
  242. static void omap3_set_off_timings(struct voltagedomain *voltdm)
  243. {
  244. unsigned long clksetup;
  245. unsigned long voltsetup2;
  246. unsigned long voltsetup2_old;
  247. u32 val;
  248. u32 tstart, tshut;
  249. /* check if sys_off_mode is used to control off-mode voltages */
  250. val = voltdm->read(OMAP3_PRM_VOLTCTRL_OFFSET);
  251. if (!(val & OMAP3430_SEL_OFF_MASK)) {
  252. /* No, omap is controlling them over I2C */
  253. omap3_set_i2c_timings(voltdm, true);
  254. return;
  255. }
  256. omap_pm_get_oscillator(&tstart, &tshut);
  257. omap3_set_clksetup(tstart, voltdm);
  258. clksetup = voltdm->read(OMAP3_PRM_CLKSETUP_OFFSET);
  259. /* voltsetup 2 in us */
  260. voltsetup2 = voltdm->vc_param->on / voltdm->pmic->slew_rate;
  261. /* convert to 32k clk cycles */
  262. voltsetup2 = DIV_ROUND_UP(voltsetup2 * 32768, 1000000);
  263. voltsetup2_old = voltdm->read(OMAP3_PRM_VOLTSETUP2_OFFSET);
  264. /*
  265. * Update voltsetup2 if higher than current value (needed because
  266. * we have multiple channels with different ramp times), also
  267. * update voltoffset always to value recommended by TRM
  268. */
  269. if (voltsetup2 > voltsetup2_old) {
  270. voltdm->write(voltsetup2, OMAP3_PRM_VOLTSETUP2_OFFSET);
  271. voltdm->write(clksetup - voltsetup2,
  272. OMAP3_PRM_VOLTOFFSET_OFFSET);
  273. } else
  274. voltdm->write(clksetup - voltsetup2_old,
  275. OMAP3_PRM_VOLTOFFSET_OFFSET);
  276. /*
  277. * omap is not controlling voltage scaling during off-mode,
  278. * thus set voltsetup1 to 0
  279. */
  280. voltdm->rmw(voltdm->vfsm->voltsetup_mask, 0,
  281. voltdm->vfsm->voltsetup_reg);
  282. /* voltoffset must be clksetup minus voltsetup2 according to TRM */
  283. voltdm->write(clksetup - voltsetup2, OMAP3_PRM_VOLTOFFSET_OFFSET);
  284. }
  285. static void __init omap3_vc_init_channel(struct voltagedomain *voltdm)
  286. {
  287. omap3_set_off_timings(voltdm);
  288. }
  289. /**
  290. * omap4_calc_volt_ramp - calculates voltage ramping delays on omap4
  291. * @voltdm: channel to calculate values for
  292. * @voltage_diff: voltage difference in microvolts
  293. *
  294. * Calculates voltage ramp prescaler + counter values for a voltage
  295. * difference on omap4. Returns a field value suitable for writing to
  296. * VOLTSETUP register for a channel in following format:
  297. * bits[8:9] prescaler ... bits[0:5] counter. See OMAP4 TRM for reference.
  298. */
  299. static u32 omap4_calc_volt_ramp(struct voltagedomain *voltdm, u32 voltage_diff)
  300. {
  301. u32 prescaler;
  302. u32 cycles;
  303. u32 time;
  304. time = voltage_diff / voltdm->pmic->slew_rate;
  305. cycles = voltdm->sys_clk.rate / 1000 * time / 1000;
  306. cycles /= 64;
  307. prescaler = 0;
  308. /* shift to next prescaler until no overflow */
  309. /* scale for div 256 = 64 * 4 */
  310. if (cycles > 63) {
  311. cycles /= 4;
  312. prescaler++;
  313. }
  314. /* scale for div 512 = 256 * 2 */
  315. if (cycles > 63) {
  316. cycles /= 2;
  317. prescaler++;
  318. }
  319. /* scale for div 2048 = 512 * 4 */
  320. if (cycles > 63) {
  321. cycles /= 4;
  322. prescaler++;
  323. }
  324. /* check for overflow => invalid ramp time */
  325. if (cycles > 63) {
  326. pr_warn("%s: invalid setuptime for vdd_%s\n", __func__,
  327. voltdm->name);
  328. return 0;
  329. }
  330. cycles++;
  331. return (prescaler << OMAP4430_RAMP_UP_PRESCAL_SHIFT) |
  332. (cycles << OMAP4430_RAMP_UP_COUNT_SHIFT);
  333. }
  334. /**
  335. * omap4_usec_to_val_scrm - convert microsecond value to SCRM module bitfield
  336. * @usec: microseconds
  337. * @shift: number of bits to shift left
  338. * @mask: bitfield mask
  339. *
  340. * Converts microsecond value to OMAP4 SCRM bitfield. Bitfield is
  341. * shifted to requested position, and checked agains the mask value.
  342. * If larger, forced to the max value of the field (i.e. the mask itself.)
  343. * Returns the SCRM bitfield value.
  344. */
  345. static u32 omap4_usec_to_val_scrm(u32 usec, int shift, u32 mask)
  346. {
  347. u32 val;
  348. val = omap_usec_to_32k(usec) << shift;
  349. /* Check for overflow, if yes, force to max value */
  350. if (val > mask)
  351. val = mask;
  352. return val;
  353. }
  354. /**
  355. * omap4_set_timings - set voltage ramp timings for a channel
  356. * @voltdm: channel to configure
  357. * @off_mode: whether off-mode values are used
  358. *
  359. * Calculates and sets the voltage ramp up / down values for a channel.
  360. */
  361. static void omap4_set_timings(struct voltagedomain *voltdm, bool off_mode)
  362. {
  363. u32 val;
  364. u32 ramp;
  365. int offset;
  366. u32 tstart, tshut;
  367. if (off_mode) {
  368. ramp = omap4_calc_volt_ramp(voltdm,
  369. voltdm->vc_param->on - voltdm->vc_param->off);
  370. offset = voltdm->vfsm->voltsetup_off_reg;
  371. } else {
  372. ramp = omap4_calc_volt_ramp(voltdm,
  373. voltdm->vc_param->on - voltdm->vc_param->ret);
  374. offset = voltdm->vfsm->voltsetup_reg;
  375. }
  376. if (!ramp)
  377. return;
  378. val = voltdm->read(offset);
  379. val |= ramp << OMAP4430_RAMP_DOWN_COUNT_SHIFT;
  380. val |= ramp << OMAP4430_RAMP_UP_COUNT_SHIFT;
  381. voltdm->write(val, offset);
  382. omap_pm_get_oscillator(&tstart, &tshut);
  383. val = omap4_usec_to_val_scrm(tstart, OMAP4_SETUPTIME_SHIFT,
  384. OMAP4_SETUPTIME_MASK);
  385. val |= omap4_usec_to_val_scrm(tshut, OMAP4_DOWNTIME_SHIFT,
  386. OMAP4_DOWNTIME_MASK);
  387. __raw_writel(val, OMAP4_SCRM_CLKSETUPTIME);
  388. }
  389. /* OMAP4 specific voltage init functions */
  390. static void __init omap4_vc_init_channel(struct voltagedomain *voltdm)
  391. {
  392. static bool is_initialized;
  393. u32 vc_val;
  394. omap4_set_timings(voltdm, true);
  395. omap4_set_timings(voltdm, false);
  396. if (is_initialized)
  397. return;
  398. /* XXX These are magic numbers and do not belong! */
  399. vc_val = (0x60 << OMAP4430_SCLL_SHIFT | 0x26 << OMAP4430_SCLH_SHIFT);
  400. voltdm->write(vc_val, OMAP4_PRM_VC_CFG_I2C_CLK_OFFSET);
  401. is_initialized = true;
  402. }
  403. /**
  404. * omap_vc_i2c_init - initialize I2C interface to PMIC
  405. * @voltdm: voltage domain containing VC data
  406. *
  407. * Use PMIC supplied settings for I2C high-speed mode and
  408. * master code (if set) and program the VC I2C configuration
  409. * register.
  410. *
  411. * The VC I2C configuration is common to all VC channels,
  412. * so this function only configures I2C for the first VC
  413. * channel registers. All other VC channels will use the
  414. * same configuration.
  415. */
  416. static void __init omap_vc_i2c_init(struct voltagedomain *voltdm)
  417. {
  418. struct omap_vc_channel *vc = voltdm->vc;
  419. static bool initialized;
  420. static bool i2c_high_speed;
  421. u8 mcode;
  422. if (initialized) {
  423. if (voltdm->pmic->i2c_high_speed != i2c_high_speed)
  424. pr_warn("%s: I2C config for vdd_%s does not match other channels (%u).",
  425. __func__, voltdm->name, i2c_high_speed);
  426. return;
  427. }
  428. i2c_high_speed = voltdm->pmic->i2c_high_speed;
  429. if (i2c_high_speed)
  430. voltdm->rmw(vc->common->i2c_cfg_hsen_mask,
  431. vc->common->i2c_cfg_hsen_mask,
  432. vc->common->i2c_cfg_reg);
  433. mcode = voltdm->pmic->i2c_mcode;
  434. if (mcode)
  435. voltdm->rmw(vc->common->i2c_mcode_mask,
  436. mcode << __ffs(vc->common->i2c_mcode_mask),
  437. vc->common->i2c_cfg_reg);
  438. initialized = true;
  439. }
  440. /**
  441. * omap_vc_calc_vsel - calculate vsel value for a channel
  442. * @voltdm: channel to calculate value for
  443. * @uvolt: microvolt value to convert to vsel
  444. *
  445. * Converts a microvolt value to vsel value for the used PMIC.
  446. * This checks whether the microvolt value is out of bounds, and
  447. * adjusts the value accordingly. If unsupported value detected,
  448. * warning is thrown.
  449. */
  450. static u8 omap_vc_calc_vsel(struct voltagedomain *voltdm, u32 uvolt)
  451. {
  452. if (voltdm->pmic->vddmin > uvolt)
  453. uvolt = voltdm->pmic->vddmin;
  454. if (voltdm->pmic->vddmax < uvolt) {
  455. WARN(1, "%s: voltage not supported by pmic: %u vs max %u\n",
  456. __func__, uvolt, voltdm->pmic->vddmax);
  457. /* Lets try maximum value anyway */
  458. uvolt = voltdm->pmic->vddmax;
  459. }
  460. return voltdm->pmic->uv_to_vsel(uvolt);
  461. }
  462. void __init omap_vc_init_channel(struct voltagedomain *voltdm)
  463. {
  464. struct omap_vc_channel *vc = voltdm->vc;
  465. u8 on_vsel, onlp_vsel, ret_vsel, off_vsel;
  466. u32 val;
  467. if (!voltdm->pmic || !voltdm->pmic->uv_to_vsel) {
  468. pr_err("%s: No PMIC info for vdd_%s\n", __func__, voltdm->name);
  469. return;
  470. }
  471. if (!voltdm->read || !voltdm->write) {
  472. pr_err("%s: No read/write API for accessing vdd_%s regs\n",
  473. __func__, voltdm->name);
  474. return;
  475. }
  476. vc->cfg_channel = 0;
  477. if (vc->flags & OMAP_VC_CHANNEL_CFG_MUTANT)
  478. vc_cfg_bits = &vc_mutant_channel_cfg;
  479. else
  480. vc_cfg_bits = &vc_default_channel_cfg;
  481. /* get PMIC/board specific settings */
  482. vc->i2c_slave_addr = voltdm->pmic->i2c_slave_addr;
  483. vc->volt_reg_addr = voltdm->pmic->volt_reg_addr;
  484. vc->cmd_reg_addr = voltdm->pmic->cmd_reg_addr;
  485. /* Configure the i2c slave address for this VC */
  486. voltdm->rmw(vc->smps_sa_mask,
  487. vc->i2c_slave_addr << __ffs(vc->smps_sa_mask),
  488. vc->smps_sa_reg);
  489. vc->cfg_channel |= vc_cfg_bits->sa;
  490. /*
  491. * Configure the PMIC register addresses.
  492. */
  493. voltdm->rmw(vc->smps_volra_mask,
  494. vc->volt_reg_addr << __ffs(vc->smps_volra_mask),
  495. vc->smps_volra_reg);
  496. vc->cfg_channel |= vc_cfg_bits->rav;
  497. if (vc->cmd_reg_addr) {
  498. voltdm->rmw(vc->smps_cmdra_mask,
  499. vc->cmd_reg_addr << __ffs(vc->smps_cmdra_mask),
  500. vc->smps_cmdra_reg);
  501. vc->cfg_channel |= vc_cfg_bits->rac;
  502. }
  503. if (vc->cmd_reg_addr == vc->volt_reg_addr)
  504. vc->cfg_channel |= vc_cfg_bits->racen;
  505. /* Set up the on, inactive, retention and off voltage */
  506. on_vsel = omap_vc_calc_vsel(voltdm, voltdm->vc_param->on);
  507. onlp_vsel = omap_vc_calc_vsel(voltdm, voltdm->vc_param->onlp);
  508. ret_vsel = omap_vc_calc_vsel(voltdm, voltdm->vc_param->ret);
  509. off_vsel = omap_vc_calc_vsel(voltdm, voltdm->vc_param->off);
  510. val = ((on_vsel << vc->common->cmd_on_shift) |
  511. (onlp_vsel << vc->common->cmd_onlp_shift) |
  512. (ret_vsel << vc->common->cmd_ret_shift) |
  513. (off_vsel << vc->common->cmd_off_shift));
  514. voltdm->write(val, vc->cmdval_reg);
  515. vc->cfg_channel |= vc_cfg_bits->cmd;
  516. /* Channel configuration */
  517. omap_vc_config_channel(voltdm);
  518. omap_vc_i2c_init(voltdm);
  519. if (cpu_is_omap34xx())
  520. omap3_vc_init_channel(voltdm);
  521. else if (cpu_is_omap44xx())
  522. omap4_vc_init_channel(voltdm);
  523. }