| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622 | 
							- /*
 
-  * OMAP Voltage Controller (VC) interface
 
-  *
 
-  * Copyright (C) 2011 Texas Instruments, Inc.
 
-  *
 
-  * This file is licensed under the terms of the GNU General Public
 
-  * License version 2. This program is licensed "as is" without any
 
-  * warranty of any kind, whether express or implied.
 
-  */
 
- #include <linux/kernel.h>
 
- #include <linux/delay.h>
 
- #include <linux/init.h>
 
- #include <linux/bug.h>
 
- #include <linux/io.h>
 
- #include <asm/div64.h>
 
- #include "iomap.h"
 
- #include "soc.h"
 
- #include "voltage.h"
 
- #include "vc.h"
 
- #include "prm-regbits-34xx.h"
 
- #include "prm-regbits-44xx.h"
 
- #include "prm44xx.h"
 
- #include "pm.h"
 
- #include "scrm44xx.h"
 
- #include "control.h"
 
- /**
 
-  * struct omap_vc_channel_cfg - describe the cfg_channel bitfield
 
-  * @sa: bit for slave address
 
-  * @rav: bit for voltage configuration register
 
-  * @rac: bit for command configuration register
 
-  * @racen: enable bit for RAC
 
-  * @cmd: bit for command value set selection
 
-  *
 
-  * Channel configuration bits, common for OMAP3+
 
-  * OMAP3 register: PRM_VC_CH_CONF
 
-  * OMAP4 register: PRM_VC_CFG_CHANNEL
 
-  * OMAP5 register: PRM_VC_SMPS_<voltdm>_CONFIG
 
-  */
 
- struct omap_vc_channel_cfg {
 
- 	u8 sa;
 
- 	u8 rav;
 
- 	u8 rac;
 
- 	u8 racen;
 
- 	u8 cmd;
 
- };
 
- static struct omap_vc_channel_cfg vc_default_channel_cfg = {
 
- 	.sa    = BIT(0),
 
- 	.rav   = BIT(1),
 
- 	.rac   = BIT(2),
 
- 	.racen = BIT(3),
 
- 	.cmd   = BIT(4),
 
- };
 
- /*
 
-  * On OMAP3+, all VC channels have the above default bitfield
 
-  * configuration, except the OMAP4 MPU channel.  This appears
 
-  * to be a freak accident as every other VC channel has the
 
-  * default configuration, thus creating a mutant channel config.
 
-  */
 
- static struct omap_vc_channel_cfg vc_mutant_channel_cfg = {
 
- 	.sa    = BIT(0),
 
- 	.rav   = BIT(2),
 
- 	.rac   = BIT(3),
 
- 	.racen = BIT(4),
 
- 	.cmd   = BIT(1),
 
- };
 
- static struct omap_vc_channel_cfg *vc_cfg_bits;
 
- /* Default I2C trace length on pcb, 6.3cm. Used for capacitance calculations. */
 
- static u32 sr_i2c_pcb_length = 63;
 
- #define CFG_CHANNEL_MASK 0x1f
 
- /**
 
-  * omap_vc_config_channel - configure VC channel to PMIC mappings
 
-  * @voltdm: pointer to voltagdomain defining the desired VC channel
 
-  *
 
-  * Configures the VC channel to PMIC mappings for the following
 
-  * PMIC settings
 
-  * - i2c slave address (SA)
 
-  * - voltage configuration address (RAV)
 
-  * - command configuration address (RAC) and enable bit (RACEN)
 
-  * - command values for ON, ONLP, RET and OFF (CMD)
 
-  *
 
-  * This function currently only allows flexible configuration of the
 
-  * non-default channel.  Starting with OMAP4, there are more than 2
 
-  * channels, with one defined as the default (on OMAP4, it's MPU.)
 
-  * Only the non-default channel can be configured.
 
-  */
 
- static int omap_vc_config_channel(struct voltagedomain *voltdm)
 
- {
 
- 	struct omap_vc_channel *vc = voltdm->vc;
 
- 	/*
 
- 	 * For default channel, the only configurable bit is RACEN.
 
- 	 * All others must stay at zero (see function comment above.)
 
- 	 */
 
- 	if (vc->flags & OMAP_VC_CHANNEL_DEFAULT)
 
- 		vc->cfg_channel &= vc_cfg_bits->racen;
 
- 	voltdm->rmw(CFG_CHANNEL_MASK << vc->cfg_channel_sa_shift,
 
- 		    vc->cfg_channel << vc->cfg_channel_sa_shift,
 
- 		    vc->cfg_channel_reg);
 
- 	return 0;
 
- }
 
- /* Voltage scale and accessory APIs */
 
- int omap_vc_pre_scale(struct voltagedomain *voltdm,
 
- 		      unsigned long target_volt,
 
- 		      u8 *target_vsel, u8 *current_vsel)
 
- {
 
- 	struct omap_vc_channel *vc = voltdm->vc;
 
- 	u32 vc_cmdval;
 
- 	/* Check if sufficient pmic info is available for this vdd */
 
- 	if (!voltdm->pmic) {
 
- 		pr_err("%s: Insufficient pmic info to scale the vdd_%s\n",
 
- 			__func__, voltdm->name);
 
- 		return -EINVAL;
 
- 	}
 
- 	if (!voltdm->pmic->uv_to_vsel) {
 
- 		pr_err("%s: PMIC function to convert voltage in uV to vsel not registered. Hence unable to scale voltage for vdd_%s\n",
 
- 		       __func__, voltdm->name);
 
- 		return -ENODATA;
 
- 	}
 
- 	if (!voltdm->read || !voltdm->write) {
 
- 		pr_err("%s: No read/write API for accessing vdd_%s regs\n",
 
- 			__func__, voltdm->name);
 
- 		return -EINVAL;
 
- 	}
 
- 	*target_vsel = voltdm->pmic->uv_to_vsel(target_volt);
 
- 	*current_vsel = voltdm->pmic->uv_to_vsel(voltdm->nominal_volt);
 
- 	/* Setting the ON voltage to the new target voltage */
 
- 	vc_cmdval = voltdm->read(vc->cmdval_reg);
 
- 	vc_cmdval &= ~vc->common->cmd_on_mask;
 
- 	vc_cmdval |= (*target_vsel << vc->common->cmd_on_shift);
 
- 	voltdm->write(vc_cmdval, vc->cmdval_reg);
 
- 	voltdm->vc_param->on = target_volt;
 
- 	omap_vp_update_errorgain(voltdm, target_volt);
 
- 	return 0;
 
- }
 
- void omap_vc_post_scale(struct voltagedomain *voltdm,
 
- 			unsigned long target_volt,
 
- 			u8 target_vsel, u8 current_vsel)
 
- {
 
- 	u32 smps_steps = 0, smps_delay = 0;
 
- 	smps_steps = abs(target_vsel - current_vsel);
 
- 	/* SMPS slew rate / step size. 2us added as buffer. */
 
- 	smps_delay = ((smps_steps * voltdm->pmic->step_size) /
 
- 			voltdm->pmic->slew_rate) + 2;
 
- 	udelay(smps_delay);
 
- }
 
- /* vc_bypass_scale - VC bypass method of voltage scaling */
 
- int omap_vc_bypass_scale(struct voltagedomain *voltdm,
 
- 			 unsigned long target_volt)
 
- {
 
- 	struct omap_vc_channel *vc = voltdm->vc;
 
- 	u32 loop_cnt = 0, retries_cnt = 0;
 
- 	u32 vc_valid, vc_bypass_val_reg, vc_bypass_value;
 
- 	u8 target_vsel, current_vsel;
 
- 	int ret;
 
- 	ret = omap_vc_pre_scale(voltdm, target_volt, &target_vsel, ¤t_vsel);
 
- 	if (ret)
 
- 		return ret;
 
- 	vc_valid = vc->common->valid;
 
- 	vc_bypass_val_reg = vc->common->bypass_val_reg;
 
- 	vc_bypass_value = (target_vsel << vc->common->data_shift) |
 
- 		(vc->volt_reg_addr << vc->common->regaddr_shift) |
 
- 		(vc->i2c_slave_addr << vc->common->slaveaddr_shift);
 
- 	voltdm->write(vc_bypass_value, vc_bypass_val_reg);
 
- 	voltdm->write(vc_bypass_value | vc_valid, vc_bypass_val_reg);
 
- 	vc_bypass_value = voltdm->read(vc_bypass_val_reg);
 
- 	/*
 
- 	 * Loop till the bypass command is acknowledged from the SMPS.
 
- 	 * NOTE: This is legacy code. The loop count and retry count needs
 
- 	 * to be revisited.
 
- 	 */
 
- 	while (!(vc_bypass_value & vc_valid)) {
 
- 		loop_cnt++;
 
- 		if (retries_cnt > 10) {
 
- 			pr_warning("%s: Retry count exceeded\n", __func__);
 
- 			return -ETIMEDOUT;
 
- 		}
 
- 		if (loop_cnt > 50) {
 
- 			retries_cnt++;
 
- 			loop_cnt = 0;
 
- 			udelay(10);
 
- 		}
 
- 		vc_bypass_value = voltdm->read(vc_bypass_val_reg);
 
- 	}
 
- 	omap_vc_post_scale(voltdm, target_volt, target_vsel, current_vsel);
 
- 	return 0;
 
- }
 
- /* Convert microsecond value to number of 32kHz clock cycles */
 
- static inline u32 omap_usec_to_32k(u32 usec)
 
- {
 
- 	return DIV_ROUND_UP_ULL(32768ULL * (u64)usec, 1000000ULL);
 
- }
 
- /* Set oscillator setup time for omap3 */
 
- static void omap3_set_clksetup(u32 usec, struct voltagedomain *voltdm)
 
- {
 
- 	voltdm->write(omap_usec_to_32k(usec), OMAP3_PRM_CLKSETUP_OFFSET);
 
- }
 
- /**
 
-  * omap3_set_i2c_timings - sets i2c sleep timings for a channel
 
-  * @voltdm: channel to configure
 
-  * @off_mode: select whether retention or off mode values used
 
-  *
 
-  * Calculates and sets up voltage controller to use I2C based
 
-  * voltage scaling for sleep modes. This can be used for either off mode
 
-  * or retention. Off mode has additionally an option to use sys_off_mode
 
-  * pad, which uses a global signal to program the whole power IC to
 
-  * off-mode.
 
-  */
 
- static void omap3_set_i2c_timings(struct voltagedomain *voltdm, bool off_mode)
 
- {
 
- 	unsigned long voltsetup1;
 
- 	u32 tgt_volt;
 
- 	/*
 
- 	 * Oscillator is shut down only if we are using sys_off_mode pad,
 
- 	 * thus we set a minimal setup time here
 
- 	 */
 
- 	omap3_set_clksetup(1, voltdm);
 
- 	if (off_mode)
 
- 		tgt_volt = voltdm->vc_param->off;
 
- 	else
 
- 		tgt_volt = voltdm->vc_param->ret;
 
- 	voltsetup1 = (voltdm->vc_param->on - tgt_volt) /
 
- 			voltdm->pmic->slew_rate;
 
- 	voltsetup1 = voltsetup1 * voltdm->sys_clk.rate / 8 / 1000000 + 1;
 
- 	voltdm->rmw(voltdm->vfsm->voltsetup_mask,
 
- 		voltsetup1 << __ffs(voltdm->vfsm->voltsetup_mask),
 
- 		voltdm->vfsm->voltsetup_reg);
 
- 	/*
 
- 	 * pmic is not controlling the voltage scaling during retention,
 
- 	 * thus set voltsetup2 to 0
 
- 	 */
 
- 	voltdm->write(0, OMAP3_PRM_VOLTSETUP2_OFFSET);
 
- }
 
- /**
 
-  * omap3_set_off_timings - sets off-mode timings for a channel
 
-  * @voltdm: channel to configure
 
-  *
 
-  * Calculates and sets up off-mode timings for a channel. Off-mode
 
-  * can use either I2C based voltage scaling, or alternatively
 
-  * sys_off_mode pad can be used to send a global command to power IC.
 
-  * This function first checks which mode is being used, and calls
 
-  * omap3_set_i2c_timings() if the system is using I2C control mode.
 
-  * sys_off_mode has the additional benefit that voltages can be
 
-  * scaled to zero volt level with TWL4030 / TWL5030, I2C can only
 
-  * scale to 600mV.
 
-  */
 
- static void omap3_set_off_timings(struct voltagedomain *voltdm)
 
- {
 
- 	unsigned long clksetup;
 
- 	unsigned long voltsetup2;
 
- 	unsigned long voltsetup2_old;
 
- 	u32 val;
 
- 	u32 tstart, tshut;
 
- 	/* check if sys_off_mode is used to control off-mode voltages */
 
- 	val = voltdm->read(OMAP3_PRM_VOLTCTRL_OFFSET);
 
- 	if (!(val & OMAP3430_SEL_OFF_MASK)) {
 
- 		/* No, omap is controlling them over I2C */
 
- 		omap3_set_i2c_timings(voltdm, true);
 
- 		return;
 
- 	}
 
- 	omap_pm_get_oscillator(&tstart, &tshut);
 
- 	omap3_set_clksetup(tstart, voltdm);
 
- 	clksetup = voltdm->read(OMAP3_PRM_CLKSETUP_OFFSET);
 
- 	/* voltsetup 2 in us */
 
- 	voltsetup2 = voltdm->vc_param->on / voltdm->pmic->slew_rate;
 
- 	/* convert to 32k clk cycles */
 
- 	voltsetup2 = DIV_ROUND_UP(voltsetup2 * 32768, 1000000);
 
- 	voltsetup2_old = voltdm->read(OMAP3_PRM_VOLTSETUP2_OFFSET);
 
- 	/*
 
- 	 * Update voltsetup2 if higher than current value (needed because
 
- 	 * we have multiple channels with different ramp times), also
 
- 	 * update voltoffset always to value recommended by TRM
 
- 	 */
 
- 	if (voltsetup2 > voltsetup2_old) {
 
- 		voltdm->write(voltsetup2, OMAP3_PRM_VOLTSETUP2_OFFSET);
 
- 		voltdm->write(clksetup - voltsetup2,
 
- 			OMAP3_PRM_VOLTOFFSET_OFFSET);
 
- 	} else
 
- 		voltdm->write(clksetup - voltsetup2_old,
 
- 			OMAP3_PRM_VOLTOFFSET_OFFSET);
 
- 	/*
 
- 	 * omap is not controlling voltage scaling during off-mode,
 
- 	 * thus set voltsetup1 to 0
 
- 	 */
 
- 	voltdm->rmw(voltdm->vfsm->voltsetup_mask, 0,
 
- 		voltdm->vfsm->voltsetup_reg);
 
- 	/* voltoffset must be clksetup minus voltsetup2 according to TRM */
 
- 	voltdm->write(clksetup - voltsetup2, OMAP3_PRM_VOLTOFFSET_OFFSET);
 
- }
 
- static void __init omap3_vc_init_channel(struct voltagedomain *voltdm)
 
- {
 
- 	omap3_set_off_timings(voltdm);
 
- }
 
- /**
 
-  * omap4_calc_volt_ramp - calculates voltage ramping delays on omap4
 
-  * @voltdm: channel to calculate values for
 
-  * @voltage_diff: voltage difference in microvolts
 
-  *
 
-  * Calculates voltage ramp prescaler + counter values for a voltage
 
-  * difference on omap4. Returns a field value suitable for writing to
 
-  * VOLTSETUP register for a channel in following format:
 
-  * bits[8:9] prescaler ... bits[0:5] counter. See OMAP4 TRM for reference.
 
-  */
 
- static u32 omap4_calc_volt_ramp(struct voltagedomain *voltdm, u32 voltage_diff)
 
- {
 
- 	u32 prescaler;
 
- 	u32 cycles;
 
- 	u32 time;
 
- 	time = voltage_diff / voltdm->pmic->slew_rate;
 
- 	cycles = voltdm->sys_clk.rate / 1000 * time / 1000;
 
- 	cycles /= 64;
 
- 	prescaler = 0;
 
- 	/* shift to next prescaler until no overflow */
 
- 	/* scale for div 256 = 64 * 4 */
 
- 	if (cycles > 63) {
 
- 		cycles /= 4;
 
- 		prescaler++;
 
- 	}
 
- 	/* scale for div 512 = 256 * 2 */
 
- 	if (cycles > 63) {
 
- 		cycles /= 2;
 
- 		prescaler++;
 
- 	}
 
- 	/* scale for div 2048 = 512 * 4 */
 
- 	if (cycles > 63) {
 
- 		cycles /= 4;
 
- 		prescaler++;
 
- 	}
 
- 	/* check for overflow => invalid ramp time */
 
- 	if (cycles > 63) {
 
- 		pr_warn("%s: invalid setuptime for vdd_%s\n", __func__,
 
- 			voltdm->name);
 
- 		return 0;
 
- 	}
 
- 	cycles++;
 
- 	return (prescaler << OMAP4430_RAMP_UP_PRESCAL_SHIFT) |
 
- 		(cycles << OMAP4430_RAMP_UP_COUNT_SHIFT);
 
- }
 
- /**
 
-  * omap4_usec_to_val_scrm - convert microsecond value to SCRM module bitfield
 
-  * @usec: microseconds
 
-  * @shift: number of bits to shift left
 
-  * @mask: bitfield mask
 
-  *
 
-  * Converts microsecond value to OMAP4 SCRM bitfield. Bitfield is
 
-  * shifted to requested position, and checked agains the mask value.
 
-  * If larger, forced to the max value of the field (i.e. the mask itself.)
 
-  * Returns the SCRM bitfield value.
 
-  */
 
- static u32 omap4_usec_to_val_scrm(u32 usec, int shift, u32 mask)
 
- {
 
- 	u32 val;
 
- 	val = omap_usec_to_32k(usec) << shift;
 
- 	/* Check for overflow, if yes, force to max value */
 
- 	if (val > mask)
 
- 		val = mask;
 
- 	return val;
 
- }
 
- /**
 
-  * omap4_set_timings - set voltage ramp timings for a channel
 
-  * @voltdm: channel to configure
 
-  * @off_mode: whether off-mode values are used
 
-  *
 
-  * Calculates and sets the voltage ramp up / down values for a channel.
 
-  */
 
- static void omap4_set_timings(struct voltagedomain *voltdm, bool off_mode)
 
- {
 
- 	u32 val;
 
- 	u32 ramp;
 
- 	int offset;
 
- 	u32 tstart, tshut;
 
- 	if (off_mode) {
 
- 		ramp = omap4_calc_volt_ramp(voltdm,
 
- 			voltdm->vc_param->on - voltdm->vc_param->off);
 
- 		offset = voltdm->vfsm->voltsetup_off_reg;
 
- 	} else {
 
- 		ramp = omap4_calc_volt_ramp(voltdm,
 
- 			voltdm->vc_param->on - voltdm->vc_param->ret);
 
- 		offset = voltdm->vfsm->voltsetup_reg;
 
- 	}
 
- 	if (!ramp)
 
- 		return;
 
- 	val = voltdm->read(offset);
 
- 	val |= ramp << OMAP4430_RAMP_DOWN_COUNT_SHIFT;
 
- 	val |= ramp << OMAP4430_RAMP_UP_COUNT_SHIFT;
 
- 	voltdm->write(val, offset);
 
- 	omap_pm_get_oscillator(&tstart, &tshut);
 
- 	val = omap4_usec_to_val_scrm(tstart, OMAP4_SETUPTIME_SHIFT,
 
- 		OMAP4_SETUPTIME_MASK);
 
- 	val |= omap4_usec_to_val_scrm(tshut, OMAP4_DOWNTIME_SHIFT,
 
- 		OMAP4_DOWNTIME_MASK);
 
- 	__raw_writel(val, OMAP4_SCRM_CLKSETUPTIME);
 
- }
 
- /* OMAP4 specific voltage init functions */
 
- static void __init omap4_vc_init_channel(struct voltagedomain *voltdm)
 
- {
 
- 	omap4_set_timings(voltdm, true);
 
- 	omap4_set_timings(voltdm, false);
 
- }
 
- struct i2c_init_data {
 
- 	u8 loadbits;
 
- 	u8 load;
 
- 	u8 hsscll_38_4;
 
- 	u8 hsscll_26;
 
- 	u8 hsscll_19_2;
 
- 	u8 hsscll_16_8;
 
- 	u8 hsscll_12;
 
- };
 
- static const __initdata struct i2c_init_data omap4_i2c_timing_data[] = {
 
- 	{
 
- 		.load = 50,
 
- 		.loadbits = 0x3,
 
- 		.hsscll_38_4 = 13,
 
- 		.hsscll_26 = 11,
 
- 		.hsscll_19_2 = 9,
 
- 		.hsscll_16_8 = 9,
 
- 		.hsscll_12 = 8,
 
- 	},
 
- 	{
 
- 		.load = 25,
 
- 		.loadbits = 0x2,
 
- 		.hsscll_38_4 = 13,
 
- 		.hsscll_26 = 11,
 
- 		.hsscll_19_2 = 9,
 
- 		.hsscll_16_8 = 9,
 
- 		.hsscll_12 = 8,
 
- 	},
 
- 	{
 
- 		.load = 12,
 
- 		.loadbits = 0x1,
 
- 		.hsscll_38_4 = 11,
 
- 		.hsscll_26 = 10,
 
- 		.hsscll_19_2 = 9,
 
- 		.hsscll_16_8 = 9,
 
- 		.hsscll_12 = 8,
 
- 	},
 
- 	{
 
- 		.load = 0,
 
- 		.loadbits = 0x0,
 
- 		.hsscll_38_4 = 12,
 
- 		.hsscll_26 = 10,
 
- 		.hsscll_19_2 = 9,
 
- 		.hsscll_16_8 = 8,
 
- 		.hsscll_12 = 8,
 
- 	},
 
- };
 
- /**
 
-  * omap4_vc_i2c_timing_init - sets up board I2C timing parameters
 
-  * @voltdm: voltagedomain pointer to get data from
 
-  *
 
-  * Use PMIC + board supplied settings for calculating the total I2C
 
-  * channel capacitance and set the timing parameters based on this.
 
-  * Pre-calculated values are provided in data tables, as it is not
 
-  * too straightforward to calculate these runtime.
 
-  */
 
- static void __init omap4_vc_i2c_timing_init(struct voltagedomain *voltdm)
 
- {
 
- 	u32 capacitance;
 
- 	u32 val;
 
- 	u16 hsscll;
 
- 	const struct i2c_init_data *i2c_data;
 
- 	if (!voltdm->pmic->i2c_high_speed) {
 
- 		pr_warn("%s: only high speed supported!\n", __func__);
 
- 		return;
 
- 	}
 
- 	/* PCB trace capacitance, 0.125pF / mm => mm / 8 */
 
- 	capacitance = DIV_ROUND_UP(sr_i2c_pcb_length, 8);
 
- 	/* OMAP pad capacitance */
 
- 	capacitance += 4;
 
- 	/* PMIC pad capacitance */
 
- 	capacitance += voltdm->pmic->i2c_pad_load;
 
- 	/* Search for capacitance match in the table */
 
- 	i2c_data = omap4_i2c_timing_data;
 
- 	while (i2c_data->load > capacitance)
 
- 		i2c_data++;
 
- 	/* Select proper values based on sysclk frequency */
 
- 	switch (voltdm->sys_clk.rate) {
 
- 	case 38400000:
 
- 		hsscll = i2c_data->hsscll_38_4;
 
- 		break;
 
- 	case 26000000:
 
- 		hsscll = i2c_data->hsscll_26;
 
- 		break;
 
- 	case 19200000:
 
- 		hsscll = i2c_data->hsscll_19_2;
 
- 		break;
 
- 	case 16800000:
 
- 		hsscll = i2c_data->hsscll_16_8;
 
- 		break;
 
- 	case 12000000:
 
- 		hsscll = i2c_data->hsscll_12;
 
- 		break;
 
- 	default:
 
- 		pr_warn("%s: unsupported sysclk rate: %d!\n", __func__,
 
- 			voltdm->sys_clk.rate);
 
- 		return;
 
- 	}
 
- 	/* Loadbits define pull setup for the I2C channels */
 
- 	val = i2c_data->loadbits << 25 | i2c_data->loadbits << 29;
 
- 	/* Write to SYSCTRL_PADCONF_WKUP_CTRL_I2C_2 to setup I2C pull */
 
- 	__raw_writel(val, OMAP2_L4_IO_ADDRESS(OMAP4_CTRL_MODULE_PAD_WKUP +
 
- 				OMAP4_CTRL_MODULE_PAD_WKUP_CONTROL_I2C_2));
 
- 	/* HSSCLH can always be zero */
 
- 	val = hsscll << OMAP4430_HSSCLL_SHIFT;
 
- 	val |= (0x28 << OMAP4430_SCLL_SHIFT | 0x2c << OMAP4430_SCLH_SHIFT);
 
- 	/* Write setup times to I2C config register */
 
- 	voltdm->write(val, OMAP4_PRM_VC_CFG_I2C_CLK_OFFSET);
 
- }
 
- /**
 
-  * omap_vc_i2c_init - initialize I2C interface to PMIC
 
-  * @voltdm: voltage domain containing VC data
 
-  *
 
-  * Use PMIC supplied settings for I2C high-speed mode and
 
-  * master code (if set) and program the VC I2C configuration
 
-  * register.
 
-  *
 
-  * The VC I2C configuration is common to all VC channels,
 
-  * so this function only configures I2C for the first VC
 
-  * channel registers.  All other VC channels will use the
 
-  * same configuration.
 
-  */
 
- static void __init omap_vc_i2c_init(struct voltagedomain *voltdm)
 
- {
 
- 	struct omap_vc_channel *vc = voltdm->vc;
 
- 	static bool initialized;
 
- 	static bool i2c_high_speed;
 
- 	u8 mcode;
 
- 	if (initialized) {
 
- 		if (voltdm->pmic->i2c_high_speed != i2c_high_speed)
 
- 			pr_warn("%s: I2C config for vdd_%s does not match other channels (%u).\n",
 
 
  |