blob: 943083fe0fbe857b6e081e9fda9e9c5bcbeb2de7 [file] [log] [blame]
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07001/* arch/arm/mach-msm/htc_akm_cal.c
2 *
3 * Code to extract compass calibration information from ATAG set up
4 * by the bootloader.
5 *
6 * Copyright (C) 2007-2008 HTC Corporation
7 * Author: Farmer Tseng <farmer_tseng@htc.com>
8 *
9 * This software is licensed under the terms of the GNU General Public
10 * License version 2, as published by the Free Software Foundation, and
11 * may be copied, distributed, and modified under those terms.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 */
19
20#include <linux/kernel.h>
21#include <linux/init.h>
22#include <linux/platform_device.h>
23
24#include <asm/setup.h>
25
26/* configuration tags specific to AKM8976 */
27#define ATAG_AKM8976 0x89768976 /* AKM8976 */
28
29#define MAX_CALI_SIZE 0x1000U
30
31static char akm_cal_ram[MAX_CALI_SIZE];
32
33char *get_akm_cal_ram(void)
34{
35 return(akm_cal_ram);
36}
37EXPORT_SYMBOL(get_akm_cal_ram);
38
39static int __init parse_tag_akm(const struct tag *tag)
40{
41 unsigned char *dptr = (unsigned char *)(&tag->u);
42 unsigned size;
43
44 size = min((tag->hdr.size - 2) * sizeof(__u32), MAX_CALI_SIZE);
45
46 printk(KERN_INFO "AKM Data size = %d , 0x%x, size = %d\n",
47 tag->hdr.size, tag->hdr.tag, size);
48
49#ifdef ATAG_COMPASS_DEBUG
50 unsigned i;
51 unsigned char *ptr;
52
53 ptr = dptr;
54 printk(KERN_INFO
55 "AKM Data size = %d , 0x%x\n",
56 tag->hdr.size, tag->hdr.tag);
57 for (i = 0; i < size; i++)
58 printk(KERN_INFO "%02x ", *ptr++);
59#endif
60 memcpy((void *)akm_cal_ram, (void *)dptr, size);
61 return 0;
62}
63
64__tagtable(ATAG_AKM8976, parse_tag_akm);