Commit 56f733ff authored by Furquan Shaikh's avatar Furquan Shaikh Committed by chrome-bot

max98927: Add option to limit boost converter input current

Valid current limit values are in the range 1000mA - 4100mA.

BUG=b:65106522
BRANCH=None
TEST=Verified that boot beep works in firmware. Read back register
0x42 to confirm correct value is programmed.

Change-Id: I6562edc6c0f1c4cad2ae8829556122ef19831e87
Signed-off-by: default avatarFurquan Shaikh <furquan@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/663953Reviewed-by: default avatarAaron Durbin <adurbin@chromium.org>
parent 3dd61046
......@@ -111,7 +111,7 @@ static int board_setup(void)
DesignwareI2c *i2c4 =
new_pci_designware_i2c(PCI_DEV(0, 0x19, 2), 400000, 120);
Max98927Codec *speaker_amp =
new_max98927_codec(&i2c4->ops, 0x39, 16, 16000, 64);
new_max98927_codec(&i2c4->ops, 0x39, 16, 16000, 64, 0);
/* Activate buffer to disconnect I2S from PCH and allow GPIO */
GpioCfg *i2s_buffer = new_skylake_gpio_output(GPP_D22, 1);
......
......@@ -122,9 +122,9 @@ static int board_setup(void)
DesignwareI2c *i2c5 =
new_pci_designware_i2c(PCI_DEV(0, 0x19, 1), 400000, 120);
Max98927Codec *speaker_amp_l =
new_max98927_codec(&i2c5->ops, 0x3a, 16, 16000, 64);
new_max98927_codec(&i2c5->ops, 0x3a, 16, 16000, 64, 2000);
Max98927Codec *speaker_amp_r =
new_max98927_codec(&i2c5->ops, 0x39, 16, 16000, 64);
new_max98927_codec(&i2c5->ops, 0x39, 16, 16000, 64, 2000);
/* Activate buffer to disconnect I2S from PCH and allow GPIO */
GpioCfg *i2s2_buffer_enable = new_skylake_gpio_output(GPP_D22, 1);
......
......@@ -26,11 +26,17 @@ enum {
REG_AMP_ENABLE = 0x003a,
REG_SPEAKER_SOURCE = 0x003b,
REG_SPEAKER_GAIN = 0x003c,
REG_BOOST_CONTROL_1 = 0x0042,
REG_MEAS_ADC_CONFIG = 0x0043,
REG_GLOBAL_ENABLE = 0x00ff,
REG_SOFT_RESET = 0x0100,
};
// REG_BOOST_CONTROL_1
enum {
BOOST_CONTROL_1_ILIM_MASK = 0x3e,
};
// REG_SPEAKER_GAIN: PCM[2:0] PDM[6:4]
enum {
SPEAKER_GAIN_MASK = 0x07,
......@@ -364,9 +370,22 @@ static int max98927_enable(SoundRouteComponentOps *me)
max98927_power(codec, 1);
}
static void max98927_set_bst_ilim(Max98927Codec *codec, uint16_t bst_ilim_ma)
{
uint16_t bst_ilim;
if ((bst_ilim_ma < 1000) || (bst_ilim_ma > 4100))
return;
bst_ilim = bst_ilim_ma / 100 - 10;
if (max98927_update(codec, REG_BOOST_CONTROL_1,
BOOST_CONTROL_1_ILIM_MASK, bst_ilim << 1))
printf("%s: ERROR: Failed to set BST_ILIM!\n", __func__);
}
Max98927Codec *new_max98927_codec(I2cOps *i2c, uint8_t chip,
int bits_per_sample, int sample_rate,
int lr_frame_size)
int lr_frame_size, uint16_t bst_ilim_ma)
{
Max98927Codec *codec = xzalloc(sizeof(*codec));
......@@ -379,5 +398,7 @@ Max98927Codec *new_max98927_codec(I2cOps *i2c, uint8_t chip,
codec->sample_rate = sample_rate;
codec->lr_frame_size = lr_frame_size;
max98927_set_bst_ilim(codec, bst_ilim_ma);
return codec;
}
......@@ -28,6 +28,6 @@ typedef struct
Max98927Codec *new_max98927_codec(I2cOps *i2c, uint8_t chip,
int bits_per_sample, int sample_rate,
int lr_frame_size);
int lr_frame_size, uint16_t bst_ilim_ma);
#endif /* __DRIVERS_SOUND_MAX98927_H__ */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment