Debian Codegraph @

drivers/dahdi/voicebus/vpmoct.h

raw symbols SCIP
1 /*
2 * VPMOCT Driver.
3 *
4 * Written by Russ Meyerriecks <[email protected]>
5 *
6 * Copyright (C) 2010-2011 Digium, Inc.
7 *
8 * All rights reserved.
9 *
10 */
11
12 /*
13 * See http://www.asterisk.org for more information about
14 * the Asterisk project. Please do not directly contact
15 * any of the maintainers of this project for assistance;
16 * the project provides a web site, mailing lists and IRC
17 * channels for your use.
18 *
19 * This program is free software, distributed under the terms of
20 * the GNU General Public License Version 2 as published by the
21 * Free Software Foundation. See the LICENSE file included with
22 * this program for more details.
23 */
24
25 #ifndef _VPMOCT_H
26 #define _VPMOCT_H
27
28 #include <linux/list.h>
29 #include <linux/pci.h>
30 #include <linux/timer.h>
31 #include "dahdi/kernel.h"
32
33 #include <stdbool.h>
34
35 #define VPMOCT_FIRM_HEADER_LEN 32
36 #define VPMOCT_BOOT_RAM_LEN 128
37 #define VPMOCT_FLASH_BUF_SECTIONS 4
38 #define VPMOCT_MAX_CHUNK 7
39
40 /* Bootloader commands */
41 #define VPMOCT_BOOT_FLASH_ERASE 0x01
42 #define VPMOCT_BOOT_FLASH_COPY 0x02
43 #define VPMOCT_BOOT_IMAGE_VALIDATE 0x06
44 #define VPMOCT_BOOT_REBOOT 0x07
45 #define VPMOCT_BOOT_DECRYPT 0x08
46 #define VPMOCT_BOOT_FLASHLOAD 0x10
47
48 /* Dual use registers */
49 #define VPMOCT_IDENT 0x00
50 #define VPMOCT_MAJOR 0x0a
51 #define VPMOCT_MINOR 0x0b
52 #define VPMOCT_SERIAL 0x90
53 #define VPMOCT_SERIAL_SIZE 32
54
55 /* Bootloader registers */
56 #define VPMOCT_BOOT_ERROR 0x0c
57 #define VPMOCT_BOOT_STATUS 0x10
58 #define VPMOCT_BOOT_CMD 0x11
59 #define VPMOCT_BOOT_LEN 0x14
60 #define VPMOCT_BOOT_ADDRESS1 0x18
61 #define VPMOCT_BOOT_ADDRESS2 0x1c
62 #define VPMOCT_BOOT_RAM 0x20
63
64 enum vpmoct_mode { UNKNOWN = 0, APPLICATION, BOOTLOADER };
65
66 struct vpmoct {
67 struct list_head pending_list;
68 struct list_head active_list;
69 spinlock_t list_lock;
70 struct mutex mutex;
71 enum vpmoct_mode mode;
72 struct device *dev;
73 u32 companding;
74 u32 echo;
75 unsigned int preecho_enabled:1;
76 unsigned int echo_update_active:1;
77 unsigned int companding_update_active:1;
78 u8 preecho_timeslot;
79 u8 preecho_buf[8];
80 u8 major;
81 u8 minor;
82 };
83
84 struct vpmoct_cmd {
85 struct list_head node;
86 u8 address;
87 u8 data[VPMOCT_MAX_CHUNK];
88 u8 command;
89 u8 chunksize;
90 u8 txident;
91 struct completion complete;
92 };
93
94 static inline bool is_vpmoct_cmd_read(const struct vpmoct_cmd *cmd)
95 {
96 return (0x60 == (cmd->command & 0xf0));
97 }
98
99 struct vpmoct *vpmoct_alloc(void);
100 void vpmoct_free(struct vpmoct *vpm);
101 typedef void (*load_complete_func_t)(struct device *dev, bool operational);
102 int vpmoct_init(struct vpmoct *vpm, load_complete_func_t load_complete);
103 int vpmoct_echocan_create(struct vpmoct *vpm,
104 int channo,
105 int companding);
106 void vpmoct_echocan_free(struct vpmoct *vpm,
107 int channo);
108 int vpmoct_preecho_enable(struct vpmoct *vpm, int channo);
109 int vpmoct_preecho_disable(struct vpmoct *vpm, int channo);
110 #endif