1*f9f46d05SCharles Keepax // SPDX-License-Identifier: GPL-2.0 20d463d01SJames Schulman // 30d463d01SJames Schulman // cs35l45-tables.c -- CS35L45 ALSA SoC audio driver 40d463d01SJames Schulman // 50d463d01SJames Schulman // Copyright 2019-2022 Cirrus Logic, Inc. 60d463d01SJames Schulman // 70d463d01SJames Schulman // Author: James Schulman <james.schulman@cirrus.com> 80d463d01SJames Schulman 90d463d01SJames Schulman #include <linux/module.h> 100d463d01SJames Schulman #include <linux/regmap.h> 110d463d01SJames Schulman 120d463d01SJames Schulman #include "cs35l45.h" 130d463d01SJames Schulman 140d463d01SJames Schulman static const struct reg_sequence cs35l45_patch[] = { 150d463d01SJames Schulman { 0x00000040, 0x00000055 }, 160d463d01SJames Schulman { 0x00000040, 0x000000AA }, 170d463d01SJames Schulman { 0x00000044, 0x00000055 }, 180d463d01SJames Schulman { 0x00000044, 0x000000AA }, 190d463d01SJames Schulman { 0x00006480, 0x0830500A }, 200d463d01SJames Schulman { 0x00007C60, 0x1000850B }, 210d463d01SJames Schulman { CS35L45_BOOST_OV_CFG, 0x007000D0 }, 220d463d01SJames Schulman { CS35L45_LDPM_CONFIG, 0x0001B636 }, 230d463d01SJames Schulman { 0x00002C08, 0x00000009 }, 240d463d01SJames Schulman { 0x00006850, 0x0A30FFC4 }, 250d463d01SJames Schulman { 0x00003820, 0x00040100 }, 260d463d01SJames Schulman { 0x00003824, 0x00000000 }, 270d463d01SJames Schulman { 0x00007CFC, 0x62870004 }, 280d463d01SJames Schulman { 0x00007C60, 0x1001850B }, 290d463d01SJames Schulman { 0x00000040, 0x00000000 }, 300d463d01SJames Schulman { 0x00000044, 0x00000000 }, 310d463d01SJames Schulman { CS35L45_BOOST_CCM_CFG, 0xF0000003 }, 320d463d01SJames Schulman { CS35L45_BOOST_DCM_CFG, 0x08710220 }, 330d463d01SJames Schulman { CS35L45_ERROR_RELEASE, 0x00200000 }, 340d463d01SJames Schulman }; 350d463d01SJames Schulman 360d463d01SJames Schulman int cs35l45_apply_patch(struct cs35l45_private *cs35l45) 370d463d01SJames Schulman { 380d463d01SJames Schulman return regmap_register_patch(cs35l45->regmap, cs35l45_patch, 390d463d01SJames Schulman ARRAY_SIZE(cs35l45_patch)); 400d463d01SJames Schulman } 41926505cfSCharles Keepax EXPORT_SYMBOL_NS_GPL(cs35l45_apply_patch, SND_SOC_CS35L45); 420d463d01SJames Schulman 430d463d01SJames Schulman static const struct reg_default cs35l45_defaults[] = { 440d463d01SJames Schulman { CS35L45_BLOCK_ENABLES, 0x00003323 }, 450d463d01SJames Schulman { CS35L45_BLOCK_ENABLES2, 0x00000010 }, 46fa8c052bSVlad.Karpovich { CS35L45_SYNC_GPIO1, 0x00000007 }, 47fa8c052bSVlad.Karpovich { CS35L45_INTB_GPIO2_MCLK_REF, 0x00000005 }, 48fa8c052bSVlad.Karpovich { CS35L45_GPIO3, 0x00000005 }, 4974b14e28SVlad.Karpovich { CS35L45_PWRMGT_CTL, 0x00000000 }, 506c07be8fSVlad.Karpovich { CS35L45_WAKESRC_CTL, 0x00000008 }, 516c07be8fSVlad.Karpovich { CS35L45_WKI2C_CTL, 0x00000030 }, 520d463d01SJames Schulman { CS35L45_REFCLK_INPUT, 0x00000510 }, 530d463d01SJames Schulman { CS35L45_GLOBAL_SAMPLE_RATE, 0x00000003 }, 540d463d01SJames Schulman { CS35L45_ASP_ENABLES1, 0x00000000 }, 550d463d01SJames Schulman { CS35L45_ASP_CONTROL1, 0x00000028 }, 560d463d01SJames Schulman { CS35L45_ASP_CONTROL2, 0x18180200 }, 570d463d01SJames Schulman { CS35L45_ASP_CONTROL3, 0x00000002 }, 580d463d01SJames Schulman { CS35L45_ASP_FRAME_CONTROL1, 0x03020100 }, 590d463d01SJames Schulman { CS35L45_ASP_FRAME_CONTROL2, 0x00000004 }, 600d463d01SJames Schulman { CS35L45_ASP_FRAME_CONTROL5, 0x00000100 }, 610d463d01SJames Schulman { CS35L45_ASP_DATA_CONTROL1, 0x00000018 }, 620d463d01SJames Schulman { CS35L45_ASP_DATA_CONTROL5, 0x00000018 }, 630d463d01SJames Schulman { CS35L45_DACPCM1_INPUT, 0x00000008 }, 640d463d01SJames Schulman { CS35L45_ASPTX1_INPUT, 0x00000018 }, 650d463d01SJames Schulman { CS35L45_ASPTX2_INPUT, 0x00000019 }, 660d463d01SJames Schulman { CS35L45_ASPTX3_INPUT, 0x00000020 }, 670d463d01SJames Schulman { CS35L45_ASPTX4_INPUT, 0x00000028 }, 680d463d01SJames Schulman { CS35L45_ASPTX5_INPUT, 0x00000048 }, 6974b14e28SVlad.Karpovich { CS35L45_DSP1_RX1_RATE, 0x00000001 }, 7074b14e28SVlad.Karpovich { CS35L45_DSP1_RX2_RATE, 0x00000001 }, 7174b14e28SVlad.Karpovich { CS35L45_DSP1_RX3_RATE, 0x00000001 }, 7274b14e28SVlad.Karpovich { CS35L45_DSP1_RX4_RATE, 0x00000001 }, 7374b14e28SVlad.Karpovich { CS35L45_DSP1_RX5_RATE, 0x00000001 }, 7474b14e28SVlad.Karpovich { CS35L45_DSP1_RX6_RATE, 0x00000001 }, 7574b14e28SVlad.Karpovich { CS35L45_DSP1_RX7_RATE, 0x00000001 }, 7674b14e28SVlad.Karpovich { CS35L45_DSP1_RX8_RATE, 0x00000001 }, 7774b14e28SVlad.Karpovich { CS35L45_DSP1_TX1_RATE, 0x00000001 }, 7874b14e28SVlad.Karpovich { CS35L45_DSP1_TX2_RATE, 0x00000001 }, 7974b14e28SVlad.Karpovich { CS35L45_DSP1_TX3_RATE, 0x00000001 }, 8074b14e28SVlad.Karpovich { CS35L45_DSP1_TX4_RATE, 0x00000001 }, 8174b14e28SVlad.Karpovich { CS35L45_DSP1_TX5_RATE, 0x00000001 }, 8274b14e28SVlad.Karpovich { CS35L45_DSP1_TX6_RATE, 0x00000001 }, 8374b14e28SVlad.Karpovich { CS35L45_DSP1_TX7_RATE, 0x00000001 }, 8474b14e28SVlad.Karpovich { CS35L45_DSP1_TX8_RATE, 0x00000001 }, 8574b14e28SVlad.Karpovich { CS35L45_DSP1RX1_INPUT, 0x00000008 }, 8674b14e28SVlad.Karpovich { CS35L45_DSP1RX2_INPUT, 0x00000009 }, 8774b14e28SVlad.Karpovich { CS35L45_DSP1RX3_INPUT, 0x00000018 }, 8874b14e28SVlad.Karpovich { CS35L45_DSP1RX4_INPUT, 0x00000019 }, 8974b14e28SVlad.Karpovich { CS35L45_DSP1RX5_INPUT, 0x00000020 }, 9074b14e28SVlad.Karpovich { CS35L45_DSP1RX6_INPUT, 0x00000028 }, 9174b14e28SVlad.Karpovich { CS35L45_DSP1RX7_INPUT, 0x0000003A }, 9274b14e28SVlad.Karpovich { CS35L45_DSP1RX8_INPUT, 0x00000028 }, 930d463d01SJames Schulman { CS35L45_AMP_PCM_CONTROL, 0x00100000 }, 946085f9e6SVlad.Karpovich { CS35L45_IRQ1_CFG, 0x00000000 }, 956085f9e6SVlad.Karpovich { CS35L45_IRQ1_MASK_1, 0xBFEFFFBF }, 966085f9e6SVlad.Karpovich { CS35L45_IRQ1_MASK_2, 0xFFFFFFFF }, 976085f9e6SVlad.Karpovich { CS35L45_IRQ1_MASK_3, 0xFFFF87FF }, 986085f9e6SVlad.Karpovich { CS35L45_IRQ1_MASK_4, 0xF8FFFFFF }, 996085f9e6SVlad.Karpovich { CS35L45_IRQ1_MASK_5, 0x0EF80000 }, 1006085f9e6SVlad.Karpovich { CS35L45_IRQ1_MASK_6, 0x00000000 }, 1016085f9e6SVlad.Karpovich { CS35L45_IRQ1_MASK_7, 0xFFFFFF78 }, 1026085f9e6SVlad.Karpovich { CS35L45_IRQ1_MASK_8, 0x00003FFF }, 1036085f9e6SVlad.Karpovich { CS35L45_IRQ1_MASK_9, 0x00000000 }, 1046085f9e6SVlad.Karpovich { CS35L45_IRQ1_MASK_10, 0x00000000 }, 1056085f9e6SVlad.Karpovich { CS35L45_IRQ1_MASK_11, 0x00000000 }, 1066085f9e6SVlad.Karpovich { CS35L45_IRQ1_MASK_12, 0x00000000 }, 1076085f9e6SVlad.Karpovich { CS35L45_IRQ1_MASK_13, 0x00000000 }, 1086085f9e6SVlad.Karpovich { CS35L45_IRQ1_MASK_14, 0x00000001 }, 1096085f9e6SVlad.Karpovich { CS35L45_IRQ1_MASK_15, 0x00000000 }, 1106085f9e6SVlad.Karpovich { CS35L45_IRQ1_MASK_16, 0x00000000 }, 1116085f9e6SVlad.Karpovich { CS35L45_IRQ1_MASK_17, 0x00000000 }, 1126085f9e6SVlad.Karpovich { CS35L45_IRQ1_MASK_18, 0x3FE5D0FF }, 113fa8c052bSVlad.Karpovich { CS35L45_GPIO1_CTRL1, 0x81000001 }, 114fa8c052bSVlad.Karpovich { CS35L45_GPIO2_CTRL1, 0x81000001 }, 115fa8c052bSVlad.Karpovich { CS35L45_GPIO3_CTRL1, 0x81000001 }, 1160d463d01SJames Schulman }; 1170d463d01SJames Schulman 1180d463d01SJames Schulman static bool cs35l45_readable_reg(struct device *dev, unsigned int reg) 1190d463d01SJames Schulman { 1200d463d01SJames Schulman switch (reg) { 1210d463d01SJames Schulman case CS35L45_DEVID ... CS35L45_OTPID: 1220d463d01SJames Schulman case CS35L45_SFT_RESET: 1230d463d01SJames Schulman case CS35L45_GLOBAL_ENABLES: 1240d463d01SJames Schulman case CS35L45_BLOCK_ENABLES: 1250d463d01SJames Schulman case CS35L45_BLOCK_ENABLES2: 1260d463d01SJames Schulman case CS35L45_ERROR_RELEASE: 127fa8c052bSVlad.Karpovich case CS35L45_SYNC_GPIO1: 128fa8c052bSVlad.Karpovich case CS35L45_INTB_GPIO2_MCLK_REF: 129fa8c052bSVlad.Karpovich case CS35L45_GPIO3: 13074b14e28SVlad.Karpovich case CS35L45_PWRMGT_CTL: 1316c07be8fSVlad.Karpovich case CS35L45_WAKESRC_CTL: 1326c07be8fSVlad.Karpovich case CS35L45_WKI2C_CTL: 1336c07be8fSVlad.Karpovich case CS35L45_PWRMGT_STS: 1340d463d01SJames Schulman case CS35L45_REFCLK_INPUT: 1350d463d01SJames Schulman case CS35L45_GLOBAL_SAMPLE_RATE: 1360d463d01SJames Schulman case CS35L45_ASP_ENABLES1: 1370d463d01SJames Schulman case CS35L45_ASP_CONTROL1: 1380d463d01SJames Schulman case CS35L45_ASP_CONTROL2: 1390d463d01SJames Schulman case CS35L45_ASP_CONTROL3: 1400d463d01SJames Schulman case CS35L45_ASP_FRAME_CONTROL1: 1410d463d01SJames Schulman case CS35L45_ASP_FRAME_CONTROL2: 1420d463d01SJames Schulman case CS35L45_ASP_FRAME_CONTROL5: 1430d463d01SJames Schulman case CS35L45_ASP_DATA_CONTROL1: 1440d463d01SJames Schulman case CS35L45_ASP_DATA_CONTROL5: 1450d463d01SJames Schulman case CS35L45_DACPCM1_INPUT: 1460d463d01SJames Schulman case CS35L45_ASPTX1_INPUT: 1470d463d01SJames Schulman case CS35L45_ASPTX2_INPUT: 1480d463d01SJames Schulman case CS35L45_ASPTX3_INPUT: 1490d463d01SJames Schulman case CS35L45_ASPTX4_INPUT: 1500d463d01SJames Schulman case CS35L45_ASPTX5_INPUT: 15174b14e28SVlad.Karpovich case CS35L45_DSP1RX1_INPUT: 15274b14e28SVlad.Karpovich case CS35L45_DSP1RX2_INPUT: 15374b14e28SVlad.Karpovich case CS35L45_DSP1RX3_INPUT: 15474b14e28SVlad.Karpovich case CS35L45_DSP1RX4_INPUT: 15574b14e28SVlad.Karpovich case CS35L45_DSP1RX5_INPUT: 15674b14e28SVlad.Karpovich case CS35L45_DSP1RX6_INPUT: 15774b14e28SVlad.Karpovich case CS35L45_DSP1RX7_INPUT: 15874b14e28SVlad.Karpovich case CS35L45_DSP1RX8_INPUT: 1590d463d01SJames Schulman case CS35L45_AMP_PCM_CONTROL: 1600d463d01SJames Schulman case CS35L45_AMP_PCM_HPF_TST: 1616085f9e6SVlad.Karpovich case CS35L45_IRQ1_CFG: 1626085f9e6SVlad.Karpovich case CS35L45_IRQ1_STATUS: 1636085f9e6SVlad.Karpovich case CS35L45_IRQ1_EINT_1 ... CS35L45_IRQ1_EINT_18: 1646085f9e6SVlad.Karpovich case CS35L45_IRQ1_STS_1 ... CS35L45_IRQ1_STS_18: 1656085f9e6SVlad.Karpovich case CS35L45_IRQ1_MASK_1 ... CS35L45_IRQ1_MASK_18: 166fa8c052bSVlad.Karpovich case CS35L45_GPIO_STATUS1: 167fa8c052bSVlad.Karpovich case CS35L45_GPIO1_CTRL1: 168fa8c052bSVlad.Karpovich case CS35L45_GPIO2_CTRL1: 169fa8c052bSVlad.Karpovich case CS35L45_GPIO3_CTRL1: 17074b14e28SVlad.Karpovich case CS35L45_DSP_MBOX_1: 17174b14e28SVlad.Karpovich case CS35L45_DSP_MBOX_2: 17274b14e28SVlad.Karpovich case CS35L45_DSP_VIRT1_MBOX_1 ... CS35L45_DSP_VIRT1_MBOX_4: 17374b14e28SVlad.Karpovich case CS35L45_DSP_VIRT2_MBOX_1 ... CS35L45_DSP_VIRT2_MBOX_4: 17474b14e28SVlad.Karpovich case CS35L45_DSP1_SYS_ID: 17574b14e28SVlad.Karpovich case CS35L45_DSP1_CLOCK_FREQ: 17674b14e28SVlad.Karpovich case CS35L45_DSP1_RX1_RATE: 17774b14e28SVlad.Karpovich case CS35L45_DSP1_RX2_RATE: 17874b14e28SVlad.Karpovich case CS35L45_DSP1_RX3_RATE: 17974b14e28SVlad.Karpovich case CS35L45_DSP1_RX4_RATE: 18074b14e28SVlad.Karpovich case CS35L45_DSP1_RX5_RATE: 18174b14e28SVlad.Karpovich case CS35L45_DSP1_RX6_RATE: 18274b14e28SVlad.Karpovich case CS35L45_DSP1_RX7_RATE: 18374b14e28SVlad.Karpovich case CS35L45_DSP1_RX8_RATE: 18474b14e28SVlad.Karpovich case CS35L45_DSP1_TX1_RATE: 18574b14e28SVlad.Karpovich case CS35L45_DSP1_TX2_RATE: 18674b14e28SVlad.Karpovich case CS35L45_DSP1_TX3_RATE: 18774b14e28SVlad.Karpovich case CS35L45_DSP1_TX4_RATE: 18874b14e28SVlad.Karpovich case CS35L45_DSP1_TX5_RATE: 18974b14e28SVlad.Karpovich case CS35L45_DSP1_TX6_RATE: 19074b14e28SVlad.Karpovich case CS35L45_DSP1_TX7_RATE: 19174b14e28SVlad.Karpovich case CS35L45_DSP1_TX8_RATE: 19274b14e28SVlad.Karpovich case CS35L45_DSP1_SCRATCH1: 19374b14e28SVlad.Karpovich case CS35L45_DSP1_SCRATCH2: 19474b14e28SVlad.Karpovich case CS35L45_DSP1_SCRATCH3: 19574b14e28SVlad.Karpovich case CS35L45_DSP1_SCRATCH4: 19674b14e28SVlad.Karpovich case CS35L45_DSP1_CCM_CORE_CONTROL: 19774b14e28SVlad.Karpovich case CS35L45_DSP1_XMEM_PACK_0 ... CS35L45_DSP1_XMEM_PACK_4607: 19874b14e28SVlad.Karpovich case CS35L45_DSP1_XMEM_UNPACK32_0 ... CS35L45_DSP1_XMEM_UNPACK32_3071: 19974b14e28SVlad.Karpovich case CS35L45_DSP1_XMEM_UNPACK24_0 ... CS35L45_DSP1_XMEM_UNPACK24_6143: 20074b14e28SVlad.Karpovich case CS35L45_DSP1_YMEM_PACK_0 ... CS35L45_DSP1_YMEM_PACK_1532: 20174b14e28SVlad.Karpovich case CS35L45_DSP1_YMEM_UNPACK32_0 ... CS35L45_DSP1_YMEM_UNPACK32_1022: 20274b14e28SVlad.Karpovich case CS35L45_DSP1_YMEM_UNPACK24_0 ... CS35L45_DSP1_YMEM_UNPACK24_2043: 20374b14e28SVlad.Karpovich case CS35L45_DSP1_PMEM_0 ... CS35L45_DSP1_PMEM_3834: 2040d463d01SJames Schulman return true; 2050d463d01SJames Schulman default: 2060d463d01SJames Schulman return false; 2070d463d01SJames Schulman } 2080d463d01SJames Schulman } 2090d463d01SJames Schulman 2100d463d01SJames Schulman static bool cs35l45_volatile_reg(struct device *dev, unsigned int reg) 2110d463d01SJames Schulman { 2120d463d01SJames Schulman switch (reg) { 2130d463d01SJames Schulman case CS35L45_DEVID ... CS35L45_OTPID: 2140d463d01SJames Schulman case CS35L45_SFT_RESET: 2150d463d01SJames Schulman case CS35L45_GLOBAL_ENABLES: 2160d463d01SJames Schulman case CS35L45_ERROR_RELEASE: 2170d463d01SJames Schulman case CS35L45_AMP_PCM_HPF_TST: /* not cachable */ 2186c07be8fSVlad.Karpovich case CS35L45_PWRMGT_STS: 2196085f9e6SVlad.Karpovich case CS35L45_IRQ1_STATUS: 2206085f9e6SVlad.Karpovich case CS35L45_IRQ1_EINT_1 ... CS35L45_IRQ1_EINT_18: 2216085f9e6SVlad.Karpovich case CS35L45_IRQ1_STS_1 ... CS35L45_IRQ1_STS_18: 222fa8c052bSVlad.Karpovich case CS35L45_GPIO_STATUS1: 22374b14e28SVlad.Karpovich case CS35L45_DSP_MBOX_1: 22474b14e28SVlad.Karpovich case CS35L45_DSP_MBOX_2: 22574b14e28SVlad.Karpovich case CS35L45_DSP_VIRT1_MBOX_1 ... CS35L45_DSP_VIRT1_MBOX_4: 22674b14e28SVlad.Karpovich case CS35L45_DSP_VIRT2_MBOX_1 ... CS35L45_DSP_VIRT2_MBOX_4: 22774b14e28SVlad.Karpovich case CS35L45_DSP1_SYS_ID: 22874b14e28SVlad.Karpovich case CS35L45_DSP1_CLOCK_FREQ: 22974b14e28SVlad.Karpovich case CS35L45_DSP1_SCRATCH1: 23074b14e28SVlad.Karpovich case CS35L45_DSP1_SCRATCH2: 23174b14e28SVlad.Karpovich case CS35L45_DSP1_SCRATCH3: 23274b14e28SVlad.Karpovich case CS35L45_DSP1_SCRATCH4: 23374b14e28SVlad.Karpovich case CS35L45_DSP1_CCM_CORE_CONTROL: 23474b14e28SVlad.Karpovich case CS35L45_DSP1_XMEM_PACK_0 ... CS35L45_DSP1_XMEM_PACK_4607: 23574b14e28SVlad.Karpovich case CS35L45_DSP1_XMEM_UNPACK32_0 ... CS35L45_DSP1_XMEM_UNPACK32_3071: 23674b14e28SVlad.Karpovich case CS35L45_DSP1_XMEM_UNPACK24_0 ... CS35L45_DSP1_XMEM_UNPACK24_6143: 23774b14e28SVlad.Karpovich case CS35L45_DSP1_YMEM_PACK_0 ... CS35L45_DSP1_YMEM_PACK_1532: 23874b14e28SVlad.Karpovich case CS35L45_DSP1_YMEM_UNPACK32_0 ... CS35L45_DSP1_YMEM_UNPACK32_1022: 23974b14e28SVlad.Karpovich case CS35L45_DSP1_YMEM_UNPACK24_0 ... CS35L45_DSP1_YMEM_UNPACK24_2043: 24074b14e28SVlad.Karpovich case CS35L45_DSP1_PMEM_0 ... CS35L45_DSP1_PMEM_3834: 2410d463d01SJames Schulman return true; 2420d463d01SJames Schulman default: 2430d463d01SJames Schulman return false; 2440d463d01SJames Schulman } 2450d463d01SJames Schulman } 2460d463d01SJames Schulman 2470d463d01SJames Schulman const struct regmap_config cs35l45_i2c_regmap = { 2480d463d01SJames Schulman .reg_bits = 32, 2490d463d01SJames Schulman .val_bits = 32, 2500d463d01SJames Schulman .reg_stride = 4, 2510d463d01SJames Schulman .reg_format_endian = REGMAP_ENDIAN_BIG, 2520d463d01SJames Schulman .val_format_endian = REGMAP_ENDIAN_BIG, 2530d463d01SJames Schulman .max_register = CS35L45_LASTREG, 2540d463d01SJames Schulman .reg_defaults = cs35l45_defaults, 2550d463d01SJames Schulman .num_reg_defaults = ARRAY_SIZE(cs35l45_defaults), 2560d463d01SJames Schulman .volatile_reg = cs35l45_volatile_reg, 2570d463d01SJames Schulman .readable_reg = cs35l45_readable_reg, 2580d463d01SJames Schulman .cache_type = REGCACHE_RBTREE, 2590d463d01SJames Schulman }; 260926505cfSCharles Keepax EXPORT_SYMBOL_NS_GPL(cs35l45_i2c_regmap, SND_SOC_CS35L45); 2610d463d01SJames Schulman 2620d463d01SJames Schulman const struct regmap_config cs35l45_spi_regmap = { 2630d463d01SJames Schulman .reg_bits = 32, 2640d463d01SJames Schulman .val_bits = 32, 2650d463d01SJames Schulman .pad_bits = 16, 2660d463d01SJames Schulman .reg_stride = 4, 2670d463d01SJames Schulman .reg_format_endian = REGMAP_ENDIAN_BIG, 2680d463d01SJames Schulman .val_format_endian = REGMAP_ENDIAN_BIG, 2690d463d01SJames Schulman .max_register = CS35L45_LASTREG, 2700d463d01SJames Schulman .reg_defaults = cs35l45_defaults, 2710d463d01SJames Schulman .num_reg_defaults = ARRAY_SIZE(cs35l45_defaults), 2720d463d01SJames Schulman .volatile_reg = cs35l45_volatile_reg, 2730d463d01SJames Schulman .readable_reg = cs35l45_readable_reg, 2740d463d01SJames Schulman .cache_type = REGCACHE_RBTREE, 2750d463d01SJames Schulman }; 276926505cfSCharles Keepax EXPORT_SYMBOL_NS_GPL(cs35l45_spi_regmap, SND_SOC_CS35L45); 2770d463d01SJames Schulman 2780d463d01SJames Schulman static const struct { 2790d463d01SJames Schulman u8 cfg_id; 2800d463d01SJames Schulman u32 freq; 2810d463d01SJames Schulman } cs35l45_pll_refclk_freq[] = { 2820d463d01SJames Schulman { 0x0C, 128000 }, 2830d463d01SJames Schulman { 0x0F, 256000 }, 2840d463d01SJames Schulman { 0x11, 384000 }, 2850d463d01SJames Schulman { 0x12, 512000 }, 2860d463d01SJames Schulman { 0x15, 768000 }, 2870d463d01SJames Schulman { 0x17, 1024000 }, 2880d463d01SJames Schulman { 0x19, 1411200 }, 2890d463d01SJames Schulman { 0x1B, 1536000 }, 2900d463d01SJames Schulman { 0x1C, 2116800 }, 2910d463d01SJames Schulman { 0x1D, 2048000 }, 2920d463d01SJames Schulman { 0x1E, 2304000 }, 2930d463d01SJames Schulman { 0x1F, 2822400 }, 2940d463d01SJames Schulman { 0x21, 3072000 }, 2950d463d01SJames Schulman { 0x23, 4233600 }, 2960d463d01SJames Schulman { 0x24, 4096000 }, 2970d463d01SJames Schulman { 0x25, 4608000 }, 2980d463d01SJames Schulman { 0x26, 5644800 }, 2990d463d01SJames Schulman { 0x27, 6000000 }, 3000d463d01SJames Schulman { 0x28, 6144000 }, 3010d463d01SJames Schulman { 0x29, 6350400 }, 3020d463d01SJames Schulman { 0x2A, 6912000 }, 3030d463d01SJames Schulman { 0x2D, 7526400 }, 3040d463d01SJames Schulman { 0x2E, 8467200 }, 3050d463d01SJames Schulman { 0x2F, 8192000 }, 3060d463d01SJames Schulman { 0x30, 9216000 }, 3070d463d01SJames Schulman { 0x31, 11289600 }, 3080d463d01SJames Schulman { 0x33, 12288000 }, 3090d463d01SJames Schulman { 0x37, 16934400 }, 3100d463d01SJames Schulman { 0x38, 18432000 }, 3110d463d01SJames Schulman { 0x39, 22579200 }, 3120d463d01SJames Schulman { 0x3B, 24576000 }, 3130d463d01SJames Schulman }; 3140d463d01SJames Schulman 3150d463d01SJames Schulman unsigned int cs35l45_get_clk_freq_id(unsigned int freq) 3160d463d01SJames Schulman { 3170d463d01SJames Schulman int i; 3180d463d01SJames Schulman 3190d463d01SJames Schulman if (freq == 0) 3200d463d01SJames Schulman return -EINVAL; 3210d463d01SJames Schulman 3220d463d01SJames Schulman for (i = 0; i < ARRAY_SIZE(cs35l45_pll_refclk_freq); ++i) { 3230d463d01SJames Schulman if (cs35l45_pll_refclk_freq[i].freq == freq) 3240d463d01SJames Schulman return cs35l45_pll_refclk_freq[i].cfg_id; 3250d463d01SJames Schulman } 3260d463d01SJames Schulman 3270d463d01SJames Schulman return -EINVAL; 3280d463d01SJames Schulman } 329926505cfSCharles Keepax EXPORT_SYMBOL_NS_GPL(cs35l45_get_clk_freq_id, SND_SOC_CS35L45); 330