Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ASoC: cs35l35: Add Boost Inductor Calculation

Add the Boost Inductor parameters based off the size of the inductor
on the HW setup

Signed-off-by: Brian Austin <brian.austin@cirrus.com>
Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Brian Austin and committed by
Mark Brown
b7c752d6 2ea659a9

+90
+2
include/sound/cs35l35.h
··· 99 99 bool shared_bst; 100 100 /* Specifies this amp is using an external boost supply */ 101 101 bool ext_bst; 102 + /* Inductor Value */ 103 + int boost_ind; 102 104 /* ClassH Algorithm */ 103 105 struct classh_cfg classh_algo; 104 106 /* Monitor Config */
+82
sound/soc/codecs/cs35l35.c
··· 756 756 return ret; 757 757 } 758 758 759 + static int cs35l35_boost_inductor(struct cs35l35_private *cs35l35, 760 + int inductor) 761 + { 762 + struct regmap *regmap = cs35l35->regmap; 763 + unsigned int bst_ipk = 0; 764 + 765 + /* 766 + * Digital Boost Converter Configuration for feedback, 767 + * ramping, switching frequency, and estimation block seeding. 768 + */ 769 + 770 + regmap_update_bits(regmap, CS35L35_BST_CONV_SW_FREQ, 771 + CS35L35_BST_CONV_SWFREQ_MASK, 0x00); 772 + 773 + regmap_read(regmap, CS35L35_BST_PEAK_I, &bst_ipk); 774 + bst_ipk &= CS35L35_BST_IPK_MASK; 775 + 776 + switch (inductor) { 777 + case 1000: /* 1 uH */ 778 + regmap_write(regmap, CS35L35_BST_CONV_COEF_1, 0x24); 779 + regmap_write(regmap, CS35L35_BST_CONV_COEF_2, 0x24); 780 + regmap_update_bits(regmap, CS35L35_BST_CONV_SW_FREQ, 781 + CS35L35_BST_CONV_LBST_MASK, 0x00); 782 + 783 + if (bst_ipk < 0x04) 784 + regmap_write(regmap, CS35L35_BST_CONV_SLOPE_COMP, 0x1B); 785 + else 786 + regmap_write(regmap, CS35L35_BST_CONV_SLOPE_COMP, 0x4E); 787 + break; 788 + case 1200: /* 1.2 uH */ 789 + regmap_write(regmap, CS35L35_BST_CONV_COEF_1, 0x20); 790 + regmap_write(regmap, CS35L35_BST_CONV_COEF_2, 0x20); 791 + regmap_update_bits(regmap, CS35L35_BST_CONV_SW_FREQ, 792 + CS35L35_BST_CONV_LBST_MASK, 0x01); 793 + 794 + if (bst_ipk < 0x04) 795 + regmap_write(regmap, CS35L35_BST_CONV_SLOPE_COMP, 0x1B); 796 + else 797 + regmap_write(regmap, CS35L35_BST_CONV_SLOPE_COMP, 0x47); 798 + break; 799 + case 1500: /* 1.5uH */ 800 + regmap_write(regmap, CS35L35_BST_CONV_COEF_1, 0x20); 801 + regmap_write(regmap, CS35L35_BST_CONV_COEF_2, 0x20); 802 + regmap_update_bits(regmap, CS35L35_BST_CONV_SW_FREQ, 803 + CS35L35_BST_CONV_LBST_MASK, 0x02); 804 + 805 + if (bst_ipk < 0x04) 806 + regmap_write(regmap, CS35L35_BST_CONV_SLOPE_COMP, 0x1B); 807 + else 808 + regmap_write(regmap, CS35L35_BST_CONV_SLOPE_COMP, 0x3C); 809 + break; 810 + case 2200: /* 2.2uH */ 811 + regmap_write(regmap, CS35L35_BST_CONV_COEF_1, 0x19); 812 + regmap_write(regmap, CS35L35_BST_CONV_COEF_2, 0x25); 813 + regmap_update_bits(regmap, CS35L35_BST_CONV_SW_FREQ, 814 + CS35L35_BST_CONV_LBST_MASK, 0x03); 815 + 816 + if (bst_ipk < 0x04) 817 + regmap_write(regmap, CS35L35_BST_CONV_SLOPE_COMP, 0x1B); 818 + else 819 + regmap_write(regmap, CS35L35_BST_CONV_SLOPE_COMP, 0x23); 820 + break; 821 + default: 822 + dev_err(cs35l35->dev, "Invalid Inductor Value %d uH\n", 823 + inductor); 824 + return -EINVAL; 825 + } 826 + return 0; 827 + } 828 + 759 829 static int cs35l35_codec_probe(struct snd_soc_codec *codec) 760 830 { 761 831 struct cs35l35_private *cs35l35 = snd_soc_codec_get_drvdata(codec); ··· 844 774 CS35L35_BST_IPK_MASK, 845 775 cs35l35->pdata.bst_ipk << 846 776 CS35L35_BST_IPK_SHIFT); 777 + 778 + ret = cs35l35_boost_inductor(cs35l35, cs35l35->pdata.boost_ind); 779 + if (ret) 780 + return ret; 847 781 848 782 if (cs35l35->pdata.gain_zc) 849 783 regmap_update_bits(cs35l35->regmap, CS35L35_PROTECT_CTL, ··· 1270 1196 } 1271 1197 1272 1198 pdata->bst_ipk = (val32 - 1680) / 110; 1199 + } 1200 + 1201 + ret = of_property_read_u32(np, "cirrus,boost-ind-nanohenry", &val32); 1202 + if (ret >= 0) { 1203 + pdata->boost_ind = val32; 1204 + } else { 1205 + dev_err(&i2c_client->dev, "Inductor not specified.\n"); 1206 + return -EINVAL; 1273 1207 } 1274 1208 1275 1209 if (of_property_read_u32(np, "cirrus,sp-drv-strength", &val32) >= 0)
+6
sound/soc/codecs/cs35l35.h
··· 200 200 #define CS35L35_SP_I2S_DRV_MASK 0x03 201 201 #define CS35L35_SP_I2S_DRV_SHIFT 0 202 202 203 + /* Boost Converter Config */ 204 + #define CS35L35_BST_CONV_COEFF_MASK 0xFF 205 + #define CS35L35_BST_CONV_SLOPE_MASK 0xFF 206 + #define CS35L35_BST_CONV_LBST_MASK 0x03 207 + #define CS35L35_BST_CONV_SWFREQ_MASK 0xF0 208 + 203 209 /* Class H Algorithm Control */ 204 210 #define CS35L35_CH_STEREO_MASK 0x40 205 211 #define CS35L35_CH_STEREO_SHIFT 6