~ubuntu-branches/ubuntu/precise/linux-linaro-u8500/precise

« back to all changes in this revision

Viewing changes to drivers/mfd/ab8500-sysctrl.c

  • Committer: Bazaar Package Importer
  • Author(s): John Rigby, Upstream Fixes, Andy Green, John Rigby
  • Date: 2011-04-14 12:16:06 UTC
  • Revision ID: james.westby@ubuntu.com-20110414121606-b77podkyqgr2oix7
Tags: 2.6.38-1002.3
[ Upstream Fixes ]

* MUSB: shutdown: Make sure block is awake before doing shutdown
  - LP: #745737
* Fixed gpio polarity of gpio USB-phy reset.
  - LP: #747639

[ Andy Green ]

* LINARO: SAUCE: disable CONFIG_OMAP_RESET_CLOCKS
  - LP: #752900

[ John Rigby ]

* Rebase to new upstreams:
  Linux v2.6.38.1
  linaro-linux-2.6.38-upstream-29Mar2011
  Ubuntu-2.6.38-7.35
* SAUCE: OMAP4: clock: wait for module to become accessible on
  a clk enable
  - LP: #745737
* Rebase to new upstreams:
  Linux v2.6.38.2
  linaro-linux-2.6.38-upstream-5Apr2011
  Ubuntu-2.6.38-8.41
  - LP: #732842
* Update configs for device tree, dvfs and lttng
* LINARO: add building of dtb's
* LINARO: SAUCE: Disable lowest operating freqs on omap34xx
  - LP: #732912

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) ST-Ericsson SA 2010
 
3
 * Author: Mattias Nilsson <mattias.i.nilsson@stericsson.com> for ST Ericsson.
 
4
 * License terms: GNU General Public License (GPL) version 2
 
5
 */
 
6
 
 
7
#include <linux/err.h>
 
8
#include <linux/platform_device.h>
 
9
#include <linux/mfd/ab8500.h>
 
10
#include <linux/mfd/abx500.h>
 
11
#include <linux/mfd/ab8500/sysctrl.h>
 
12
 
 
13
static struct device *sysctrl_dev;
 
14
 
 
15
static inline bool valid_bank(u8 bank)
 
16
{
 
17
        return ((bank == AB8500_SYS_CTRL1_BLOCK) ||
 
18
                (bank == AB8500_SYS_CTRL2_BLOCK));
 
19
}
 
20
 
 
21
int ab8500_sysctrl_read(u16 reg, u8 *value)
 
22
{
 
23
        u8 bank;
 
24
 
 
25
        if (sysctrl_dev == NULL)
 
26
                return -EAGAIN;
 
27
 
 
28
        bank = (reg >> 8);
 
29
        if (!valid_bank(bank))
 
30
                return -EINVAL;
 
31
 
 
32
        return abx500_get_register_interruptible(sysctrl_dev, bank,
 
33
                (u8)(reg & 0xFF), value);
 
34
}
 
35
 
 
36
int ab8500_sysctrl_write(u16 reg, u8 mask, u8 value)
 
37
{
 
38
        u8 bank;
 
39
 
 
40
        if (sysctrl_dev == NULL)
 
41
                return -EAGAIN;
 
42
 
 
43
        bank = (reg >> 8);
 
44
        if (!valid_bank(bank))
 
45
                return -EINVAL;
 
46
 
 
47
        return abx500_mask_and_set_register_interruptible(sysctrl_dev, bank,
 
48
                (u8)(reg & 0xFF), mask, value);
 
49
}
 
50
 
 
51
static int __devinit ab8500_sysctrl_probe(struct platform_device *pdev)
 
52
{
 
53
        sysctrl_dev = &pdev->dev;
 
54
        return 0;
 
55
}
 
56
 
 
57
static int __devexit ab8500_sysctrl_remove(struct platform_device *pdev)
 
58
{
 
59
        sysctrl_dev = NULL;
 
60
        return 0;
 
61
}
 
62
 
 
63
static struct platform_driver ab8500_sysctrl_driver = {
 
64
        .driver = {
 
65
                .name = "ab8500-sysctrl",
 
66
                .owner = THIS_MODULE,
 
67
        },
 
68
        .probe = ab8500_sysctrl_probe,
 
69
        .remove = __devexit_p(ab8500_sysctrl_remove),
 
70
};
 
71
 
 
72
static int __init ab8500_sysctrl_init(void)
 
73
{
 
74
        return platform_driver_register(&ab8500_sysctrl_driver);
 
75
}
 
76
subsys_initcall(ab8500_sysctrl_init);
 
77
 
 
78
MODULE_AUTHOR("Mattias Nilsson <mattias.i.nilsson@stericsson.com");
 
79
MODULE_DESCRIPTION("AB8500 system control driver");
 
80
MODULE_LICENSE("GPL v2");