summaryrefslogtreecommitdiff
path: root/drivers/staging/cg2900/devices-cg2900-u5500.c
blob: 5b8c5fb8064f30a4387fcd02d27ed8a08212549d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*
 * arch/arm/mach-ux500/devices-cg2900-u5500.c
 *
 * Copyright (C) ST-Ericsson SA 2010
 * Authors:
 * Par-Gunnar Hjalmdahl (par-gunnar.p.hjalmdahl@stericsson.com) for ST-Ericsson.
 * Henrik Possung (henrik.possung@stericsson.com) for ST-Ericsson.
 * Josef Kindberg (josef.kindberg@stericsson.com) for ST-Ericsson.
 * Dariusz Szymszak (dariusz.xd.szymczak@stericsson.com) for ST-Ericsson.
 * Kjell Andersson (kjell.k.andersson@stericsson.com) for ST-Ericsson.
 * License terms:  GNU General Public License (GPL), version 2
 *
 * Board specific device support for the Linux Bluetooth HCI H:4 Driver
 * for ST-Ericsson connectivity controller.
 */

#include <linux/delay.h>
#include <linux/kernel.h>
#include <linux/sched.h>
#include <linux/clk.h>
#include <linux/types.h>
#include <linux/mfd/abx500/ab5500.h>

#include <mach/prcmu-db5500.h>

#include "devices-cg2900.h"

/* prcmu resout1 pin is used for CG2900 reset*/
void dcg2900_enable_chip(struct cg2900_chip_dev *dev)
{
	struct dcg2900_info *info = dev->b_data;

	clk_enable(info->lpoclk);
	/*
	 * Due to a bug in CG2900 we cannot just set GPIO high to enable
	 * the chip. We must wait more than 100 msecs before enbling the
	 * chip.
	 * - Set PDB to low.
	 * - Wait for 100 msecs
	 * - Set PDB to high.
	 */
	prcmu_resetout(1, 0);
	schedule_timeout_uninterruptible(msecs_to_jiffies(
					CHIP_ENABLE_PDB_LOW_TIMEOUT));
	prcmu_resetout(1, 1);
}

void dcg2900_disable_chip(struct cg2900_chip_dev *dev)
{
	struct dcg2900_info *info = dev->b_data;

	prcmu_resetout(1, 0);
	clk_disable(info->lpoclk);
}

int dcg2900_setup(struct cg2900_chip_dev *dev,
				struct dcg2900_info *info)
{
	info->lpoclk = clk_get(dev->dev, "lpoclk");
	if (IS_ERR(info->lpoclk))
		return PTR_ERR(info->lpoclk);

	return 0;
}