blob: 1176eb9c10271036cb083513fa25abcd527e1a3d [file] [log] [blame]
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001/* arch/arm/mach-msm/qdsp6/dal.h
2 *
3 * Copyright (C) 2009 Google, Inc.
4 * Author: Brian Swetland <swetland@google.com>
5 *
6 * This software is licensed under the terms of the GNU General Public
7 * License version 2, as published by the Free Software Foundation, and
8 * may be copied, distributed, and modified under those terms.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 */
16
17#ifndef _MACH_MSM_DAL_
18#define _MACH_MSM_DAL_
19
20struct dal_client;
21
22struct dal_info {
23 uint32_t size;
24 uint32_t version;
25 char name[32];
26};
27
28typedef void (*dal_event_func_t)(void *data, int len, void *cookie);
29
30struct dal_client *dal_attach(uint32_t device_id, const char *name,
31 uint32_t cpu, dal_event_func_t func, void *cookie);
32
33int dal_detach(struct dal_client *client);
34
35int dal_call(struct dal_client *client,
36 unsigned ddi, unsigned prototype,
37 void *data, int data_len,
38 void *reply, int reply_max);
39
40void dal_trace(struct dal_client *client);
41void dal_trace_dump(struct dal_client *client);
42
43/* function to call before panic on stalled dal calls */
44void dal_set_oops(struct dal_client *client, void (*oops)(void));
45
46/* convenience wrappers */
47int dal_call_f0(struct dal_client *client, uint32_t ddi,
48 uint32_t arg1);
49int dal_call_f1(struct dal_client *client, uint32_t ddi,
50 uint32_t arg1, uint32_t arg2);
51int dal_call_f5(struct dal_client *client, uint32_t ddi,
52 void *ibuf, uint32_t ilen);
53int dal_call_f6(struct dal_client *client, uint32_t ddi,
54 uint32_t s1, void *ibuf, uint32_t ilen);
55int dal_call_f9(struct dal_client *client, uint32_t ddi,
56 void *obuf, uint32_t olen);
57int dal_call_f11(struct dal_client *client, uint32_t ddi,
58 uint32_t s1, void *obuf, uint32_t olen);
59int dal_call_f13(struct dal_client *client, uint32_t ddi, void *ibuf1,
60 uint32_t ilen1, void *ibuf2, uint32_t ilen2, void *obuf,
61 uint32_t olen);
62int dal_call_f14(struct dal_client *client, uint32_t ddi, void *ibuf,
63 uint32_t ilen, void *obuf1, uint32_t olen1, void *obuf2,
64 uint32_t olen2, uint32_t *oalen2);
65
66/* common DAL operations */
67enum {
68 DAL_OP_ATTACH = 0,
69 DAL_OP_DETACH,
70 DAL_OP_INIT,
71 DAL_OP_DEINIT,
72 DAL_OP_OPEN,
73 DAL_OP_CLOSE,
74 DAL_OP_INFO,
75 DAL_OP_POWEREVENT,
76 DAL_OP_SYSREQUEST,
77 DAL_OP_FIRST_DEVICE_API,
78};
79
80static inline int check_version(struct dal_client *client, uint32_t version)
81{
82 struct dal_info info;
83 int res;
84
85 res = dal_call_f9(client, DAL_OP_INFO, &info, sizeof(struct dal_info));
86 if (!res) {
87 if (((info.version & 0xFFFF0000) != (version & 0xFFFF0000)) ||
88 ((info.version & 0x0000FFFF) <
89 (version & 0x0000FFFF))) {
90 res = -EINVAL;
91 }
92 }
93 return res;
94}
95
96#endif