blob: 8992318cdbd3577db1041a4c4a0fbbc6c0094ed3 [file] [log] [blame]
Banajit Goswamide8271c2017-01-18 00:28:59 -08001/* Copyright (c) 2015-2016, The Linux Foundation. All rights reserved.
2 *
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>
16#include <linux/soundwire/swr-wcd.h>
17
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
26enum {
27 SWR_MSTR_PAUSE,
28 SWR_MSTR_RESUME,
29 SWR_MSTR_UP,
30 SWR_MSTR_DOWN,
31};
32
33enum {
34 SWR_IRQ_FREE,
35 SWR_IRQ_REGISTER,
36};
37
38enum {
39 SWR_DAC_PORT,
40 SWR_COMP_PORT,
41 SWR_BOOST_PORT,
42 SWR_VISENSE_PORT,
43};
44
45struct usecase {
46 u8 num_port;
47 u8 num_ch;
48 u32 chrate;
49};
50
51struct port_params {
52 u8 si;
53 u8 off1;
54 u8 off2;
55};
56
57struct swrm_mports {
58 struct list_head list;
59 u8 id;
60};
61
62struct swr_ctrl_platform_data {
63 void *handle; /* holds priv data */
64 int (*read)(void *handle, int reg);
65 int (*write)(void *handle, int reg, int val);
66 int (*bulk_write)(void *handle, u32 *reg, u32 *val, size_t len);
67 int (*clk)(void *handle, bool enable);
68 int (*reg_irq)(void *handle, irqreturn_t(*irq_handler)(int irq,
69 void *data), void *swr_handle, int type);
70};
71
72struct swr_mstr_ctrl {
73 struct swr_master master;
74 struct device *dev;
75 struct resource *supplies;
76 struct clk *mclk;
77 struct completion reset;
78 struct completion broadcast;
79 struct mutex mlock;
80 struct mutex reslock;
81 u8 rcmd_id;
82 u8 wcmd_id;
83 void *handle; /* SWR Master handle from client for read and writes */
84 int (*read)(void *handle, int reg);
85 int (*write)(void *handle, int reg, int val);
86 int (*bulk_write)(void *handle, u32 *reg, u32 *val, size_t len);
87 int (*clk)(void *handle, bool enable);
88 int (*reg_irq)(void *handle, irqreturn_t(*irq_handler)(int irq,
89 void *data), void *swr_handle, int type);
90 int irq;
91 int num_enum_slaves;
92 int slave_status;
93 struct swr_mstr_port *mstr_port;
94 struct list_head mport_list;
95 int state;
96 struct platform_device *pdev;
97 int num_rx_chs;
98 u8 num_cfg_devs;
99};
100
101#endif /* _SWR_WCD_CTRL_H */