diff options
author | Andres Salomon <dilinger@queued.net> | 2011-02-17 22:07:36 -0500 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2011-03-23 05:41:58 -0400 |
commit | 1310e6d638b302bd9cd064f8de7dcd546bb7f597 (patch) | |
tree | 381e845cded4c75a6a6430db5b2c05da7194fa05 /drivers/mfd/cs5535-mfd.c | |
parent | a9bbba996302344b1fac7773cf8198f6fee35ac1 (diff) |
mfd: Add sharing for cs5535 acpi/pms cells
This enables sharing of cs5535-mfd cells via the new mfd_shared_* API.
Hooks for enable/disble of resources are added, with refcounting of
resources being automatically handled so that cs5535_mfd_res_enable/disable
are only called when necessary.
Clients of cs5535-mfd (in this case, olpc-xo1.c) are also modified to
use the mfd_shared API. The platform drivers are also renamed to
olpc-xo1-{pms,acpi}, and resource enabling/disabling is replaced
with mfd_shared API calls.
Signed-off-by: Andres Salomon <dilinger@queued.net>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/mfd/cs5535-mfd.c')
-rw-r--r-- | drivers/mfd/cs5535-mfd.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/drivers/mfd/cs5535-mfd.c b/drivers/mfd/cs5535-mfd.c index 59ca6f151e78..886a06871065 100644 --- a/drivers/mfd/cs5535-mfd.c +++ b/drivers/mfd/cs5535-mfd.c | |||
@@ -39,6 +39,37 @@ enum cs5535_mfd_bars { | |||
39 | NR_BARS, | 39 | NR_BARS, |
40 | }; | 40 | }; |
41 | 41 | ||
42 | static int cs5535_mfd_res_enable(struct platform_device *pdev) | ||
43 | { | ||
44 | struct resource *res; | ||
45 | |||
46 | res = platform_get_resource(pdev, IORESOURCE_IO, 0); | ||
47 | if (!res) { | ||
48 | dev_err(&pdev->dev, "can't fetch device resource info\n"); | ||
49 | return -EIO; | ||
50 | } | ||
51 | |||
52 | if (!request_region(res->start, resource_size(res), DRV_NAME)) { | ||
53 | dev_err(&pdev->dev, "can't request region\n"); | ||
54 | return -EIO; | ||
55 | } | ||
56 | |||
57 | return 0; | ||
58 | } | ||
59 | |||
60 | static int cs5535_mfd_res_disable(struct platform_device *pdev) | ||
61 | { | ||
62 | struct resource *res; | ||
63 | res = platform_get_resource(pdev, IORESOURCE_IO, 0); | ||
64 | if (!res) { | ||
65 | dev_err(&pdev->dev, "can't fetch device resource info\n"); | ||
66 | return -EIO; | ||
67 | } | ||
68 | |||
69 | release_region(res->start, resource_size(res)); | ||
70 | return 0; | ||
71 | } | ||
72 | |||
42 | static __devinitdata struct resource cs5535_mfd_resources[NR_BARS]; | 73 | static __devinitdata struct resource cs5535_mfd_resources[NR_BARS]; |
43 | 74 | ||
44 | static __devinitdata struct mfd_cell cs5535_mfd_cells[] = { | 75 | static __devinitdata struct mfd_cell cs5535_mfd_cells[] = { |
@@ -65,12 +96,18 @@ static __devinitdata struct mfd_cell cs5535_mfd_cells[] = { | |||
65 | .name = "cs5535-pms", | 96 | .name = "cs5535-pms", |
66 | .num_resources = 1, | 97 | .num_resources = 1, |
67 | .resources = &cs5535_mfd_resources[PMS_BAR], | 98 | .resources = &cs5535_mfd_resources[PMS_BAR], |
99 | |||
100 | .enable = cs5535_mfd_res_enable, | ||
101 | .disable = cs5535_mfd_res_disable, | ||
68 | }, | 102 | }, |
69 | { | 103 | { |
70 | .id = ACPI_BAR, | 104 | .id = ACPI_BAR, |
71 | .name = "cs5535-acpi", | 105 | .name = "cs5535-acpi", |
72 | .num_resources = 1, | 106 | .num_resources = 1, |
73 | .resources = &cs5535_mfd_resources[ACPI_BAR], | 107 | .resources = &cs5535_mfd_resources[ACPI_BAR], |
108 | |||
109 | .enable = cs5535_mfd_res_enable, | ||
110 | .disable = cs5535_mfd_res_disable, | ||
74 | }, | 111 | }, |
75 | }; | 112 | }; |
76 | 113 | ||