blob: 9378efcd586efbeaa853a4f7c8bf976de42cf519 [file] [log] [blame]
Vipin Mehta30295c82010-09-01 12:06:33 -07001//------------------------------------------------------------------------------
2//
3// Copyright (c) 2004-2010 Atheros Corporation. All rights reserved.
4//
5//
6// Permission to use, copy, modify, and/or distribute this software for any
7// purpose with or without fee is hereby granted, provided that the above
8// copyright notice and this permission notice appear in all copies.
9//
10// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17//
18//
19//------------------------------------------------------------------------------
20//
21// This file is the include file for Atheros PS and patch parser.
22// It implements APIs to parse data buffer with patch and PS information and convert it to HCI commands.
23//
24
25#ifndef __AR3KPSPARSER_H
26#define __AR3KPSPARSER_H
27
28
29
30
31#include <linux/fs.h>
32#include <linux/slab.h>
33#include "athdefs.h"
34#ifdef HCI_TRANSPORT_SDIO
35#include "a_config.h"
36#include "a_types.h"
37#include "a_osapi.h"
38#define ATH_MODULE_NAME misc
39#include "a_debug.h"
40#include "common_drv.h"
41#include "hci_transport_api.h"
42#include "ar3kconfig.h"
43#else
44#ifndef A_PRINTF
45#define A_PRINTF(args...) printk(KERN_ALERT args)
46#endif /* A_PRINTF */
47#include "debug_linux.h"
48
49/* Helper data type declaration */
50
Vipin Mehta30295c82010-09-01 12:06:33 -070051#define ATH_DEBUG_ERR (1 << 0)
52#define ATH_DEBUG_WARN (1 << 1)
53#define ATH_DEBUG_INFO (1 << 2)
54
55
56
Joe Perches1071a132011-02-02 14:05:47 -080057#define false 0
58#define true 1
Vipin Mehta30295c82010-09-01 12:06:33 -070059
60#ifndef A_MALLOC
61#define A_MALLOC(size) kmalloc((size),GFP_KERNEL)
62#endif /* A_MALLOC */
63
64
65#ifndef A_FREE
66#define A_FREE(addr) kfree((addr))
67#endif /* A_MALLOC */
68#endif /* HCI_TRANSPORT_UART */
69
70/* String manipulation APIs */
71#ifndef A_STRTOUL
72#define A_STRTOUL simple_strtoul
73#endif /* A_STRTOL */
74
75#ifndef A_STRTOL
76#define A_STRTOL simple_strtol
77#endif /* A_STRTOL */
78
79
80/* The maximum number of bytes possible in a patch entry */
81#define MAX_PATCH_SIZE 20000
82
83/* Maximum HCI packets that will be formed from the Patch file */
84#define MAX_NUM_PATCH_ENTRY (MAX_PATCH_SIZE/MAX_BYTE_LENGTH) + 1
85
86
87
88
89
90
91
Luis R. Rodrigueza5413062011-03-14 10:59:05 -070092struct ps_cmd_packet
Vipin Mehta30295c82010-09-01 12:06:33 -070093{
Luis R. Rodriguezd8cb3162011-03-10 18:55:31 -080094 u8 *Hcipacket;
Vipin Mehta30295c82010-09-01 12:06:33 -070095 int packetLen;
Luis R. Rodrigueza5413062011-03-14 10:59:05 -070096};
Vipin Mehta30295c82010-09-01 12:06:33 -070097
98/* Parses a Patch information buffer and store it in global structure */
Luis R. Rodriguezd8cb3162011-03-10 18:55:31 -080099int AthDoParsePatch(u8 *, u32 );
Vipin Mehta30295c82010-09-01 12:06:33 -0700100
101/* parses a PS information buffer and stores it in a global structure */
Luis R. Rodriguezd8cb3162011-03-10 18:55:31 -0800102int AthDoParsePS(u8 *, u32 );
Vipin Mehta30295c82010-09-01 12:06:33 -0700103
104/*
105 * Uses the output of Both AthDoParsePS and AthDoParsePatch APIs to form HCI command array with
106 * all the PS and patch commands.
107 * The list will have the below mentioned commands in order.
108 * CRC command packet
109 * Download patch command(s)
110 * Enable patch Command
111 * PS Reset Command
112 * PS Tag Command(s)
113 *
114 */
Luis R. Rodrigueza5413062011-03-14 10:59:05 -0700115int AthCreateCommandList(struct ps_cmd_packet **, u32 *);
Vipin Mehta30295c82010-09-01 12:06:33 -0700116
117/* Cleanup the dynamically allicated HCI command list */
Luis R. Rodrigueza5413062011-03-14 10:59:05 -0700118int AthFreeCommandList(struct ps_cmd_packet **HciPacketList, u32 numPackets);
Vipin Mehta30295c82010-09-01 12:06:33 -0700119#endif /* __AR3KPSPARSER_H */