blob: fcf0652a6434c0312bbc568ad0d7286113410162 [file] [log] [blame]
Laxminath Kasamf1d45c62018-02-26 20:31:02 +05301/* Copyright (c) 2015-2018, The Linux Foundation. All rights reserved.
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +05302 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 */
12
13#ifndef _SWR_WCD_CTRL_H
14#define _SWR_WCD_CTRL_H
15#include <linux/module.h>
Laxminath Kasam605b42f2017-08-01 22:02:15 +053016#include <soc/swr-wcd.h>
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +053017
18#define SWR_MAX_ROW 0 /* Rows = 48 */
19#define SWR_MAX_COL 7 /* Cols = 16 */
20#define SWR_MIN_COL 0 /* Cols = 2 */
21
22#define SWR_WCD_NAME "swr-wcd"
23
24#define SWR_MSTR_PORT_LEN 8 /* Number of master ports */
25
Laxminath Kasamf1d45c62018-02-26 20:31:02 +053026#define SWR_MAX_SLAVE_DEVICES 11
27
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +053028#define SWRM_VERSION_1_0 0x01010000
29#define SWRM_VERSION_1_2 0x01030000
30#define SWRM_VERSION_1_3 0x01040000
31
32enum {
33 SWR_MSTR_PAUSE,
34 SWR_MSTR_RESUME,
35 SWR_MSTR_UP,
36 SWR_MSTR_DOWN,
37};
38
39enum {
40 SWR_IRQ_FREE,
41 SWR_IRQ_REGISTER,
42};
43
44enum {
45 SWR_DAC_PORT,
46 SWR_COMP_PORT,
47 SWR_BOOST_PORT,
48 SWR_VISENSE_PORT,
49};
50
51struct usecase {
52 u8 num_port;
53 u8 num_ch;
54 u32 chrate;
55};
56
57struct port_params {
58 u8 si;
59 u8 off1;
60 u8 off2;
61};
62
63struct swrm_mports {
64 struct list_head list;
65 u8 id;
66};
67
68struct swr_ctrl_platform_data {
69 void *handle; /* holds priv data */
70 int (*read)(void *handle, int reg);
71 int (*write)(void *handle, int reg, int val);
72 int (*bulk_write)(void *handle, u32 *reg, u32 *val, size_t len);
73 int (*clk)(void *handle, bool enable);
74 int (*reg_irq)(void *handle, irqreturn_t(*irq_handler)(int irq,
75 void *data), void *swr_handle, int type);
76};
77
78struct swr_mstr_ctrl {
79 struct swr_master master;
80 struct device *dev;
81 struct resource *supplies;
82 struct clk *mclk;
Laxminath Kasam8f7ccc22017-08-28 17:35:04 +053083 int clk_ref_count;
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +053084 struct completion reset;
85 struct completion broadcast;
86 struct mutex mlock;
87 struct mutex reslock;
88 u8 rcmd_id;
89 u8 wcmd_id;
90 void *handle; /* SWR Master handle from client for read and writes */
91 int (*read)(void *handle, int reg);
92 int (*write)(void *handle, int reg, int val);
93 int (*bulk_write)(void *handle, u32 *reg, u32 *val, size_t len);
94 int (*clk)(void *handle, bool enable);
95 int (*reg_irq)(void *handle, irqreturn_t(*irq_handler)(int irq,
96 void *data), void *swr_handle, int type);
97 int irq;
98 int version;
Laxminath Kasamf1d45c62018-02-26 20:31:02 +053099 u32 num_dev;
Asish Bhattacharya8e2277f2017-07-20 18:31:55 +0530100 int num_enum_slaves;
101 int slave_status;
102 struct swr_mstr_port *mstr_port;
103 struct list_head mport_list;
104 int state;
105 struct platform_device *pdev;
106 int num_rx_chs;
107 u8 num_cfg_devs;
108};
109
110#endif /* _SWR_WCD_CTRL_H */