diff options
author | Kevin Hilman <khilman@ti.com> | 2011-03-29 17:02:36 -0400 |
---|---|---|
committer | Kevin Hilman <khilman@ti.com> | 2011-09-15 15:02:55 -0400 |
commit | ba112a4e86ba8f0f9546bd953374cde064b507ca (patch) | |
tree | d35d58857d8a44d4ea501328b34fe1572ffb211b | |
parent | 4bcc475ebd06a04e1531254c27c6cf508ef8ebf9 (diff) |
OMAP3+: VC: cleanup i2c slave address configuration
- Add an i2c_slave_address field to the omap_vc_channel
- use VC/VP read/modify/write helper instead of open-coding
- remove smps_sa_shift, use __ffs(mask) for shift value
- I2C addresses 10-bit, change size to u16
Special thanks to Shweta Gulati <shweta.gulati@ti.com> for suggesting
the use of __ffs(x) instead of ffs(x) - 1.
Signed-off-by: Kevin Hilman <khilman@ti.com>
-rw-r--r-- | arch/arm/mach-omap2/vc.c | 12 | ||||
-rw-r--r-- | arch/arm/mach-omap2/vc.h | 9 | ||||
-rw-r--r-- | arch/arm/mach-omap2/vc3xxx_data.c | 2 | ||||
-rw-r--r-- | arch/arm/mach-omap2/vc44xx_data.c | 3 | ||||
-rw-r--r-- | arch/arm/mach-omap2/voltage.h | 3 |
5 files changed, 15 insertions, 14 deletions
diff --git a/arch/arm/mach-omap2/vc.c b/arch/arm/mach-omap2/vc.c index f1c73cbe3cb4..d5e792f20f16 100644 --- a/arch/arm/mach-omap2/vc.c +++ b/arch/arm/mach-omap2/vc.c | |||
@@ -241,11 +241,13 @@ void __init omap_vc_init_channel(struct voltagedomain *voltdm) | |||
241 | return; | 241 | return; |
242 | } | 242 | } |
243 | 243 | ||
244 | /* Set up the SMPS_SA(i2c slave address in VC */ | 244 | /* get PMIC/board specific settings */ |
245 | vc_val = voltdm->read(vc->common->smps_sa_reg); | 245 | vc->i2c_slave_addr = vdd->pmic_info->i2c_slave_addr; |
246 | vc_val &= ~vc->smps_sa_mask; | 246 | |
247 | vc_val |= vdd->pmic_info->i2c_slave_addr << vc->smps_sa_shift; | 247 | /* Configure the i2c slave address for this VC */ |
248 | voltdm->write(vc_val, vc->common->smps_sa_reg); | 248 | voltdm->rmw(vc->smps_sa_mask, |
249 | vc->i2c_slave_addr << __ffs(vc->smps_sa_mask), | ||
250 | vc->common->smps_sa_reg); | ||
249 | 251 | ||
250 | /* Setup the VOLRA(pmic reg addr) in VC */ | 252 | /* Setup the VOLRA(pmic reg addr) in VC */ |
251 | vc_val = voltdm->read(vc->common->smps_volra_reg); | 253 | vc_val = voltdm->read(vc->common->smps_volra_reg); |
diff --git a/arch/arm/mach-omap2/vc.h b/arch/arm/mach-omap2/vc.h index d0050f0ee6d5..69ca900aff0b 100644 --- a/arch/arm/mach-omap2/vc.h +++ b/arch/arm/mach-omap2/vc.h | |||
@@ -56,21 +56,24 @@ struct omap_vc_common { | |||
56 | 56 | ||
57 | /** | 57 | /** |
58 | * struct omap_vc_channel - VC per-instance data | 58 | * struct omap_vc_channel - VC per-instance data |
59 | * @i2c_slave_addr: I2C slave address of PMIC for this VC channel | ||
59 | * @common: pointer to VC common data for this platform | 60 | * @common: pointer to VC common data for this platform |
60 | * @smps_sa_mask: SA* bitmask in the PRM_VC_SMPS_SA register | 61 | * @smps_sa_mask: i2c slave address bitmask in the PRM_VC_SMPS_SA register |
61 | * @smps_volra_mask: VOLRA* bitmask in the PRM_VC_VOL_RA register | 62 | * @smps_volra_mask: VOLRA* bitmask in the PRM_VC_VOL_RA register |
62 | * @smps_sa_shift: SA* field shift in the PRM_VC_SMPS_SA register | ||
63 | * @smps_volra_shift: VOLRA* field shift in the PRM_VC_VOL_RA register | 63 | * @smps_volra_shift: VOLRA* field shift in the PRM_VC_VOL_RA register |
64 | * | 64 | * |
65 | * XXX It is not necessary to have both a *_mask and a *_shift - | 65 | * XXX It is not necessary to have both a *_mask and a *_shift - |
66 | * remove one | 66 | * remove one |
67 | */ | 67 | */ |
68 | struct omap_vc_channel { | 68 | struct omap_vc_channel { |
69 | /* channel state */ | ||
70 | u16 i2c_slave_addr; | ||
71 | |||
72 | /* register access data */ | ||
69 | const struct omap_vc_common *common; | 73 | const struct omap_vc_common *common; |
70 | u32 smps_sa_mask; | 74 | u32 smps_sa_mask; |
71 | u32 smps_volra_mask; | 75 | u32 smps_volra_mask; |
72 | u8 cmdval_reg; | 76 | u8 cmdval_reg; |
73 | u8 smps_sa_shift; | ||
74 | u8 smps_volra_shift; | 77 | u8 smps_volra_shift; |
75 | }; | 78 | }; |
76 | 79 | ||
diff --git a/arch/arm/mach-omap2/vc3xxx_data.c b/arch/arm/mach-omap2/vc3xxx_data.c index 6b6720301345..86be50c263ac 100644 --- a/arch/arm/mach-omap2/vc3xxx_data.c +++ b/arch/arm/mach-omap2/vc3xxx_data.c | |||
@@ -47,7 +47,6 @@ static struct omap_vc_common omap3_vc_common = { | |||
47 | struct omap_vc_channel omap3_vc_mpu = { | 47 | struct omap_vc_channel omap3_vc_mpu = { |
48 | .common = &omap3_vc_common, | 48 | .common = &omap3_vc_common, |
49 | .cmdval_reg = OMAP3_PRM_VC_CMD_VAL_0_OFFSET, | 49 | .cmdval_reg = OMAP3_PRM_VC_CMD_VAL_0_OFFSET, |
50 | .smps_sa_shift = OMAP3430_PRM_VC_SMPS_SA_SA0_SHIFT, | ||
51 | .smps_sa_mask = OMAP3430_PRM_VC_SMPS_SA_SA0_MASK, | 50 | .smps_sa_mask = OMAP3430_PRM_VC_SMPS_SA_SA0_MASK, |
52 | .smps_volra_shift = OMAP3430_VOLRA0_SHIFT, | 51 | .smps_volra_shift = OMAP3430_VOLRA0_SHIFT, |
53 | .smps_volra_mask = OMAP3430_VOLRA0_MASK, | 52 | .smps_volra_mask = OMAP3430_VOLRA0_MASK, |
@@ -56,7 +55,6 @@ struct omap_vc_channel omap3_vc_mpu = { | |||
56 | struct omap_vc_channel omap3_vc_core = { | 55 | struct omap_vc_channel omap3_vc_core = { |
57 | .common = &omap3_vc_common, | 56 | .common = &omap3_vc_common, |
58 | .cmdval_reg = OMAP3_PRM_VC_CMD_VAL_1_OFFSET, | 57 | .cmdval_reg = OMAP3_PRM_VC_CMD_VAL_1_OFFSET, |
59 | .smps_sa_shift = OMAP3430_PRM_VC_SMPS_SA_SA1_SHIFT, | ||
60 | .smps_sa_mask = OMAP3430_PRM_VC_SMPS_SA_SA1_MASK, | 58 | .smps_sa_mask = OMAP3430_PRM_VC_SMPS_SA_SA1_MASK, |
61 | .smps_volra_shift = OMAP3430_VOLRA1_SHIFT, | 59 | .smps_volra_shift = OMAP3430_VOLRA1_SHIFT, |
62 | .smps_volra_mask = OMAP3430_VOLRA1_MASK, | 60 | .smps_volra_mask = OMAP3430_VOLRA1_MASK, |
diff --git a/arch/arm/mach-omap2/vc44xx_data.c b/arch/arm/mach-omap2/vc44xx_data.c index e3125a370fa7..af922b440e96 100644 --- a/arch/arm/mach-omap2/vc44xx_data.c +++ b/arch/arm/mach-omap2/vc44xx_data.c | |||
@@ -49,7 +49,6 @@ static const struct omap_vc_common omap4_vc_common = { | |||
49 | struct omap_vc_channel omap4_vc_mpu = { | 49 | struct omap_vc_channel omap4_vc_mpu = { |
50 | .common = &omap4_vc_common, | 50 | .common = &omap4_vc_common, |
51 | .cmdval_reg = OMAP4_PRM_VC_VAL_CMD_VDD_MPU_L_OFFSET, | 51 | .cmdval_reg = OMAP4_PRM_VC_VAL_CMD_VDD_MPU_L_OFFSET, |
52 | .smps_sa_shift = OMAP4430_SA_VDD_MPU_L_PRM_VC_SMPS_SA_SHIFT, | ||
53 | .smps_sa_mask = OMAP4430_SA_VDD_MPU_L_PRM_VC_SMPS_SA_MASK, | 52 | .smps_sa_mask = OMAP4430_SA_VDD_MPU_L_PRM_VC_SMPS_SA_MASK, |
54 | .smps_volra_shift = OMAP4430_VOLRA_VDD_MPU_L_SHIFT, | 53 | .smps_volra_shift = OMAP4430_VOLRA_VDD_MPU_L_SHIFT, |
55 | .smps_volra_mask = OMAP4430_VOLRA_VDD_MPU_L_MASK, | 54 | .smps_volra_mask = OMAP4430_VOLRA_VDD_MPU_L_MASK, |
@@ -58,7 +57,6 @@ struct omap_vc_channel omap4_vc_mpu = { | |||
58 | struct omap_vc_channel omap4_vc_iva = { | 57 | struct omap_vc_channel omap4_vc_iva = { |
59 | .common = &omap4_vc_common, | 58 | .common = &omap4_vc_common, |
60 | .cmdval_reg = OMAP4_PRM_VC_VAL_CMD_VDD_IVA_L_OFFSET, | 59 | .cmdval_reg = OMAP4_PRM_VC_VAL_CMD_VDD_IVA_L_OFFSET, |
61 | .smps_sa_shift = OMAP4430_SA_VDD_IVA_L_PRM_VC_SMPS_SA_SHIFT, | ||
62 | .smps_sa_mask = OMAP4430_SA_VDD_IVA_L_PRM_VC_SMPS_SA_MASK, | 60 | .smps_sa_mask = OMAP4430_SA_VDD_IVA_L_PRM_VC_SMPS_SA_MASK, |
63 | .smps_volra_shift = OMAP4430_VOLRA_VDD_IVA_L_SHIFT, | 61 | .smps_volra_shift = OMAP4430_VOLRA_VDD_IVA_L_SHIFT, |
64 | .smps_volra_mask = OMAP4430_VOLRA_VDD_IVA_L_MASK, | 62 | .smps_volra_mask = OMAP4430_VOLRA_VDD_IVA_L_MASK, |
@@ -67,7 +65,6 @@ struct omap_vc_channel omap4_vc_iva = { | |||
67 | struct omap_vc_channel omap4_vc_core = { | 65 | struct omap_vc_channel omap4_vc_core = { |
68 | .common = &omap4_vc_common, | 66 | .common = &omap4_vc_common, |
69 | .cmdval_reg = OMAP4_PRM_VC_VAL_CMD_VDD_CORE_L_OFFSET, | 67 | .cmdval_reg = OMAP4_PRM_VC_VAL_CMD_VDD_CORE_L_OFFSET, |
70 | .smps_sa_shift = OMAP4430_SA_VDD_CORE_L_0_6_SHIFT, | ||
71 | .smps_sa_mask = OMAP4430_SA_VDD_CORE_L_0_6_MASK, | 68 | .smps_sa_mask = OMAP4430_SA_VDD_CORE_L_0_6_MASK, |
72 | .smps_volra_shift = OMAP4430_VOLRA_VDD_CORE_L_SHIFT, | 69 | .smps_volra_shift = OMAP4430_VOLRA_VDD_CORE_L_SHIFT, |
73 | .smps_volra_mask = OMAP4430_VOLRA_VDD_CORE_L_MASK, | 70 | .smps_volra_mask = OMAP4430_VOLRA_VDD_CORE_L_MASK, |
diff --git a/arch/arm/mach-omap2/voltage.h b/arch/arm/mach-omap2/voltage.h index 6a19cf39118b..590384978279 100644 --- a/arch/arm/mach-omap2/voltage.h +++ b/arch/arm/mach-omap2/voltage.h | |||
@@ -102,6 +102,7 @@ struct omap_volt_data { | |||
102 | * struct omap_volt_pmic_info - PMIC specific data required by voltage driver. | 102 | * struct omap_volt_pmic_info - PMIC specific data required by voltage driver. |
103 | * @slew_rate: PMIC slew rate (in uv/us) | 103 | * @slew_rate: PMIC slew rate (in uv/us) |
104 | * @step_size: PMIC voltage step size (in uv) | 104 | * @step_size: PMIC voltage step size (in uv) |
105 | * @i2c_slave_addr: I2C slave address of PMIC | ||
105 | * @vsel_to_uv: PMIC API to convert vsel value to actual voltage in uV. | 106 | * @vsel_to_uv: PMIC API to convert vsel value to actual voltage in uV. |
106 | * @uv_to_vsel: PMIC API to convert voltage in uV to vsel value. | 107 | * @uv_to_vsel: PMIC API to convert voltage in uV to vsel value. |
107 | * @volt_reg_addr: voltage configuration register address | 108 | * @volt_reg_addr: voltage configuration register address |
@@ -115,13 +116,13 @@ struct omap_volt_pmic_info { | |||
115 | u32 ret_volt; | 116 | u32 ret_volt; |
116 | u32 off_volt; | 117 | u32 off_volt; |
117 | u16 volt_setup_time; | 118 | u16 volt_setup_time; |
119 | u16 i2c_slave_addr; | ||
118 | u8 vp_erroroffset; | 120 | u8 vp_erroroffset; |
119 | u8 vp_vstepmin; | 121 | u8 vp_vstepmin; |
120 | u8 vp_vstepmax; | 122 | u8 vp_vstepmax; |
121 | u8 vp_vddmin; | 123 | u8 vp_vddmin; |
122 | u8 vp_vddmax; | 124 | u8 vp_vddmax; |
123 | u8 vp_timeout_us; | 125 | u8 vp_timeout_us; |
124 | u8 i2c_slave_addr; | ||
125 | u8 volt_reg_addr; | 126 | u8 volt_reg_addr; |
126 | u8 cmd_reg_addr; | 127 | u8 cmd_reg_addr; |
127 | unsigned long (*vsel_to_uv) (const u8 vsel); | 128 | unsigned long (*vsel_to_uv) (const u8 vsel); |