]> Git Repo - J-linux.git/blob - include/linux/mfd/cs40l50.h
Merge tag 'vfs-6.13-rc7.fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs
[J-linux.git] / include / linux / mfd / cs40l50.h
1 /* SPDX-License-Identifier: GPL-2.0
2  *
3  * CS40L50 Advanced Haptic Driver with waveform memory,
4  * integrated DSP, and closed-loop algorithms
5  *
6  * Copyright 2024 Cirrus Logic, Inc.
7  *
8  * Author: James Ogletree <[email protected]>
9  */
10
11 #ifndef __MFD_CS40L50_H__
12 #define __MFD_CS40L50_H__
13
14 #include <linux/firmware/cirrus/cs_dsp.h>
15 #include <linux/gpio/consumer.h>
16 #include <linux/pm.h>
17 #include <linux/regmap.h>
18
19 /* Power Supply Configuration */
20 #define CS40L50_BLOCK_ENABLES2          0x201C
21 #define CS40L50_ERR_RLS                 0x2034
22 #define CS40L50_BST_LPMODE_SEL          0x3810
23 #define CS40L50_DCM_LOW_POWER           0x1
24 #define CS40L50_OVERTEMP_WARN           0x4000010
25
26 /* Interrupts */
27 #define CS40L50_IRQ1_INT_1              0xE010
28 #define CS40L50_IRQ1_BASE               CS40L50_IRQ1_INT_1
29 #define CS40L50_IRQ1_INT_2              0xE014
30 #define CS40L50_IRQ1_INT_8              0xE02C
31 #define CS40L50_IRQ1_INT_9              0xE030
32 #define CS40L50_IRQ1_INT_10             0xE034
33 #define CS40L50_IRQ1_INT_18             0xE054
34 #define CS40L50_IRQ1_MASK_1             0xE090
35 #define CS40L50_IRQ1_MASK_2             0xE094
36 #define CS40L50_IRQ1_MASK_20            0xE0DC
37 #define CS40L50_IRQ1_INT_1_OFFSET       (CS40L50_IRQ1_INT_1 - CS40L50_IRQ1_BASE)
38 #define CS40L50_IRQ1_INT_2_OFFSET       (CS40L50_IRQ1_INT_2 - CS40L50_IRQ1_BASE)
39 #define CS40L50_IRQ1_INT_8_OFFSET       (CS40L50_IRQ1_INT_8 - CS40L50_IRQ1_BASE)
40 #define CS40L50_IRQ1_INT_9_OFFSET       (CS40L50_IRQ1_INT_9 - CS40L50_IRQ1_BASE)
41 #define CS40L50_IRQ1_INT_10_OFFSET      (CS40L50_IRQ1_INT_10 - CS40L50_IRQ1_BASE)
42 #define CS40L50_IRQ1_INT_18_OFFSET      (CS40L50_IRQ1_INT_18 - CS40L50_IRQ1_BASE)
43 #define CS40L50_IRQ_MASK_2_OVERRIDE     0xFFDF7FFF
44 #define CS40L50_IRQ_MASK_20_OVERRIDE    0x15C01000
45 #define CS40L50_AMP_SHORT_MASK          BIT(31)
46 #define CS40L50_DSP_QUEUE_MASK          BIT(21)
47 #define CS40L50_TEMP_ERR_MASK           BIT(31)
48 #define CS40L50_BST_UVP_MASK            BIT(6)
49 #define CS40L50_BST_SHORT_MASK          BIT(7)
50 #define CS40L50_BST_ILIMIT_MASK         BIT(18)
51 #define CS40L50_UVLO_VDDBATT_MASK       BIT(16)
52 #define CS40L50_GLOBAL_ERROR_MASK       BIT(15)
53
54 enum cs40l50_irq_list {
55         CS40L50_DSP_QUEUE_IRQ,
56         CS40L50_GLOBAL_ERROR_IRQ,
57         CS40L50_UVLO_VDDBATT_IRQ,
58         CS40L50_BST_ILIMIT_IRQ,
59         CS40L50_BST_SHORT_IRQ,
60         CS40L50_BST_UVP_IRQ,
61         CS40L50_TEMP_ERR_IRQ,
62         CS40L50_AMP_SHORT_IRQ,
63 };
64
65 /* DSP */
66 #define CS40L50_XMEM_PACKED_0           0x2000000
67 #define CS40L50_XMEM_UNPACKED24_0       0x2800000
68 #define CS40L50_SYS_INFO_ID             0x25E0000
69 #define CS40L50_DSP_QUEUE_WT            0x28042C8
70 #define CS40L50_DSP_QUEUE_RD            0x28042CC
71 #define CS40L50_NUM_WAVES               0x2805C18
72 #define CS40L50_CORE_BASE               0x2B80000
73 #define CS40L50_YMEM_PACKED_0           0x2C00000
74 #define CS40L50_YMEM_UNPACKED24_0       0x3400000
75 #define CS40L50_PMEM_0                  0x3800000
76 #define CS40L50_DSP_POLL_US             1000
77 #define CS40L50_DSP_TIMEOUT_COUNT       100
78 #define CS40L50_RESET_PULSE_US          2200
79 #define CS40L50_CP_READY_US             3100
80 #define CS40L50_AUTOSUSPEND_MS          2000
81 #define CS40L50_PM_ALGO                 0x9F206
82 #define CS40L50_GLOBAL_ERR_RLS_SET      BIT(11)
83 #define CS40L50_GLOBAL_ERR_RLS_CLEAR    0
84
85 enum cs40l50_wseqs {
86         CS40L50_PWR_ON,
87         CS40L50_STANDBY,
88         CS40L50_ACTIVE,
89         CS40L50_NUM_WSEQS,
90 };
91
92 /* DSP Queue */
93 #define CS40L50_DSP_QUEUE_BASE          0x11004
94 #define CS40L50_DSP_QUEUE_END           0x1101C
95 #define CS40L50_DSP_QUEUE               0x11020
96 #define CS40L50_PREVENT_HIBER           0x2000003
97 #define CS40L50_ALLOW_HIBER             0x2000004
98 #define CS40L50_SHUTDOWN                0x2000005
99 #define CS40L50_SYSTEM_RESET            0x2000007
100 #define CS40L50_START_I2S               0x3000002
101 #define CS40L50_OWT_PUSH                0x3000008
102 #define CS40L50_STOP_PLAYBACK           0x5000000
103 #define CS40L50_OWT_DELETE              0xD000000
104
105 /* Firmware files */
106 #define CS40L50_FW                      "cs40l50.wmfw"
107 #define CS40L50_WT                      "cs40l50.bin"
108
109 /* Device */
110 #define CS40L50_DEVID                   0x0
111 #define CS40L50_REVID                   0x4
112 #define CS40L50_DEVID_A                 0x40A50
113 #define CS40L50_REVID_B0                0xB0
114
115 struct cs40l50 {
116         struct device *dev;
117         struct regmap *regmap;
118         struct mutex lock;
119         struct cs_dsp dsp;
120         struct gpio_desc *reset_gpio;
121         struct regmap_irq_chip_data *irq_data;
122         const struct firmware *fw;
123         const struct firmware *bin;
124         struct cs_dsp_wseq wseqs[CS40L50_NUM_WSEQS];
125         int irq;
126         u32 devid;
127         u32 revid;
128 };
129
130 int cs40l50_dsp_write(struct device *dev, struct regmap *regmap, u32 val);
131 int cs40l50_probe(struct cs40l50 *cs40l50);
132 int cs40l50_remove(struct cs40l50 *cs40l50);
133
134 extern const struct regmap_config cs40l50_regmap;
135 extern const struct dev_pm_ops cs40l50_pm_ops;
136
137 #endif /* __MFD_CS40L50_H__ */
This page took 0.034586 seconds and 4 git commands to generate.