aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-mmp
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2011-11-05 21:21:21 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-11-05 21:21:21 -0400
commitc861cd3e92d92ae946e19099f198018fcb4fd887 (patch)
treefab678a30a85cf80038c560221d6ab01812a3891 /arch/arm/mach-mmp
parent7abec10c623d9e0416dab6919a0ea22e6283516b (diff)
parentb8bc83971cc20cae3c3b65c26a804f350d74960c (diff)
Merge branch 'next/devel2' of git://git.linaro.org/people/arnd/arm-soc
* 'next/devel2' of git://git.linaro.org/people/arnd/arm-soc: (30 commits) ARM: mmp: register internal sram bank ARM: mmp: register audio sram bank ARM: mmp: add sram allocator gpio/samsung: Complain loudly if we don't know the SoC ARM: S3C64XX: Fix SoC identification for S3C64xx devices ARM: S3C2443: Remove redundant s3c_register_clocks call for init_clocks ARM: S3C24XX: Add devname for hsmmc1 pclk ARM: S3C24XX: use clk_get_rate to init fclk in common_setup_clocks ARM: S3C2443: Accommodate cpufreq frequency scheme in armdiv ARM: S3C2443: handle unset armdiv values gracefully ARM: S3C2443: Add get_rate operation for clk_armdiv ARM: S3C2416: Add comment describing the armdiv/armclk ARM: S3C2443: Move clk_arm and clk_armdiv to common code ARM: S3C24XX: Add infrastructure to transmit armdiv to common code ARM: S3C2416: Add armdiv_mask constant ARM: EXYNOS4: Add support for M-5MOLS camera on Nuri board ARM: EXYNOS4: Enable MFC on ORIGEN ARM: SAMSUNG: Add support s3c2416-adc for S3C2416/S3C2450 ARM: SAMSUNG: Add support s3c2443-adc for S3C2443 ARM: SAMSUNG: Allow overriding of adc device name for S3C24XX ...
Diffstat (limited to 'arch/arm/mach-mmp')
-rw-r--r--arch/arm/mach-mmp/Makefile2
-rw-r--r--arch/arm/mach-mmp/brownstone.c11
-rw-r--r--arch/arm/mach-mmp/include/mach/mmp2.h13
-rw-r--r--arch/arm/mach-mmp/include/mach/sram.h35
-rw-r--r--arch/arm/mach-mmp/mmp2.c3
-rw-r--r--arch/arm/mach-mmp/sram.c168
6 files changed, 231 insertions, 1 deletions
diff --git a/arch/arm/mach-mmp/Makefile b/arch/arm/mach-mmp/Makefile
index 8f948f981646..ba254a71691a 100644
--- a/arch/arm/mach-mmp/Makefile
+++ b/arch/arm/mach-mmp/Makefile
@@ -7,7 +7,7 @@ obj-y += common.o clock.o devices.o time.o
7# SoC support 7# SoC support
8obj-$(CONFIG_CPU_PXA168) += pxa168.o irq-pxa168.o 8obj-$(CONFIG_CPU_PXA168) += pxa168.o irq-pxa168.o
9obj-$(CONFIG_CPU_PXA910) += pxa910.o irq-pxa168.o 9obj-$(CONFIG_CPU_PXA910) += pxa910.o irq-pxa168.o
10obj-$(CONFIG_CPU_MMP2) += mmp2.o irq-mmp2.o 10obj-$(CONFIG_CPU_MMP2) += mmp2.o irq-mmp2.o sram.o
11 11
12# board support 12# board support
13obj-$(CONFIG_MACH_ASPENITE) += aspenite.o 13obj-$(CONFIG_MACH_ASPENITE) += aspenite.o
diff --git a/arch/arm/mach-mmp/brownstone.c b/arch/arm/mach-mmp/brownstone.c
index e411252e3d39..983cfb15fbde 100644
--- a/arch/arm/mach-mmp/brownstone.c
+++ b/arch/arm/mach-mmp/brownstone.c
@@ -185,6 +185,15 @@ static struct sdhci_pxa_platdata mmp2_sdh_platdata_mmc2 = {
185 | PXA_FLAG_SD_8_BIT_CAPABLE_SLOT, 185 | PXA_FLAG_SD_8_BIT_CAPABLE_SLOT,
186}; 186};
187 187
188static struct sram_platdata mmp2_asram_platdata = {
189 .pool_name = "asram",
190 .granularity = SRAM_GRANULARITY,
191};
192
193static struct sram_platdata mmp2_isram_platdata = {
194 .pool_name = "isram",
195 .granularity = SRAM_GRANULARITY,
196};
188 197
189static void __init brownstone_init(void) 198static void __init brownstone_init(void)
190{ 199{
@@ -196,6 +205,8 @@ static void __init brownstone_init(void)
196 mmp2_add_twsi(1, NULL, ARRAY_AND_SIZE(brownstone_twsi1_info)); 205 mmp2_add_twsi(1, NULL, ARRAY_AND_SIZE(brownstone_twsi1_info));
197 mmp2_add_sdhost(0, &mmp2_sdh_platdata_mmc0); /* SD/MMC */ 206 mmp2_add_sdhost(0, &mmp2_sdh_platdata_mmc0); /* SD/MMC */
198 mmp2_add_sdhost(2, &mmp2_sdh_platdata_mmc2); /* eMMC */ 207 mmp2_add_sdhost(2, &mmp2_sdh_platdata_mmc2); /* eMMC */
208 mmp2_add_asram(&mmp2_asram_platdata);
209 mmp2_add_isram(&mmp2_isram_platdata);
199 210
200 /* enable 5v regulator */ 211 /* enable 5v regulator */
201 platform_device_register(&brownstone_v_5vp_device); 212 platform_device_register(&brownstone_v_5vp_device);
diff --git a/arch/arm/mach-mmp/include/mach/mmp2.h b/arch/arm/mach-mmp/include/mach/mmp2.h
index de7b88826ad7..2f7b2d3c2b18 100644
--- a/arch/arm/mach-mmp/include/mach/mmp2.h
+++ b/arch/arm/mach-mmp/include/mach/mmp2.h
@@ -13,6 +13,7 @@ extern void mmp2_clear_pmic_int(void);
13#include <linux/i2c.h> 13#include <linux/i2c.h>
14#include <linux/i2c/pxa-i2c.h> 14#include <linux/i2c/pxa-i2c.h>
15#include <mach/devices.h> 15#include <mach/devices.h>
16#include <mach/sram.h>
16 17
17extern struct pxa_device_desc mmp2_device_uart1; 18extern struct pxa_device_desc mmp2_device_uart1;
18extern struct pxa_device_desc mmp2_device_uart2; 19extern struct pxa_device_desc mmp2_device_uart2;
@@ -28,6 +29,8 @@ extern struct pxa_device_desc mmp2_device_sdh0;
28extern struct pxa_device_desc mmp2_device_sdh1; 29extern struct pxa_device_desc mmp2_device_sdh1;
29extern struct pxa_device_desc mmp2_device_sdh2; 30extern struct pxa_device_desc mmp2_device_sdh2;
30extern struct pxa_device_desc mmp2_device_sdh3; 31extern struct pxa_device_desc mmp2_device_sdh3;
32extern struct pxa_device_desc mmp2_device_asram;
33extern struct pxa_device_desc mmp2_device_isram;
31 34
32static inline int mmp2_add_uart(int id) 35static inline int mmp2_add_uart(int id)
33{ 36{
@@ -85,5 +88,15 @@ static inline int mmp2_add_sdhost(int id, struct sdhci_pxa_platdata *data)
85 return pxa_register_device(d, data, sizeof(*data)); 88 return pxa_register_device(d, data, sizeof(*data));
86} 89}
87 90
91static inline int mmp2_add_asram(struct sram_platdata *data)
92{
93 return pxa_register_device(&mmp2_device_asram, data, sizeof(*data));
94}
95
96static inline int mmp2_add_isram(struct sram_platdata *data)
97{
98 return pxa_register_device(&mmp2_device_isram, data, sizeof(*data));
99}
100
88#endif /* __ASM_MACH_MMP2_H */ 101#endif /* __ASM_MACH_MMP2_H */
89 102
diff --git a/arch/arm/mach-mmp/include/mach/sram.h b/arch/arm/mach-mmp/include/mach/sram.h
new file mode 100644
index 000000000000..239e0fc1bb1f
--- /dev/null
+++ b/arch/arm/mach-mmp/include/mach/sram.h
@@ -0,0 +1,35 @@
1/*
2 * linux/arch/arm/mach-mmp/include/mach/sram.h
3 *
4 * SRAM Memory Management
5 *
6 * Copyright (c) 2011 Marvell Semiconductors Inc.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 *
12 */
13
14#ifndef __ASM_ARCH_SRAM_H
15#define __ASM_ARCH_SRAM_H
16
17#include <linux/genalloc.h>
18
19/* ARBITRARY: SRAM allocations are multiples of this 2^N size */
20#define SRAM_GRANULARITY 512
21
22enum sram_type {
23 MMP_SRAM_UNDEFINED = 0,
24 MMP_ASRAM,
25 MMP_ISRAM,
26};
27
28struct sram_platdata {
29 char *pool_name;
30 int granularity;
31};
32
33extern struct gen_pool *sram_get_gpool(char *pool_name);
34
35#endif /* __ASM_ARCH_SRAM_H */
diff --git a/arch/arm/mach-mmp/mmp2.c b/arch/arm/mach-mmp/mmp2.c
index 7a7e8e4dde41..5dd1d4a6aeb9 100644
--- a/arch/arm/mach-mmp/mmp2.c
+++ b/arch/arm/mach-mmp/mmp2.c
@@ -226,4 +226,7 @@ MMP2_DEVICE(sdh0, "sdhci-pxav3", 0, MMC, 0xd4280000, 0x120);
226MMP2_DEVICE(sdh1, "sdhci-pxav3", 1, MMC2, 0xd4280800, 0x120); 226MMP2_DEVICE(sdh1, "sdhci-pxav3", 1, MMC2, 0xd4280800, 0x120);
227MMP2_DEVICE(sdh2, "sdhci-pxav3", 2, MMC3, 0xd4281000, 0x120); 227MMP2_DEVICE(sdh2, "sdhci-pxav3", 2, MMC3, 0xd4281000, 0x120);
228MMP2_DEVICE(sdh3, "sdhci-pxav3", 3, MMC4, 0xd4281800, 0x120); 228MMP2_DEVICE(sdh3, "sdhci-pxav3", 3, MMC4, 0xd4281800, 0x120);
229MMP2_DEVICE(asram, "asram", -1, NONE, 0xe0000000, 0x4000);
230/* 0xd1000000 ~ 0xd101ffff is reserved for secure processor */
231MMP2_DEVICE(isram, "isram", -1, NONE, 0xd1020000, 0x18000);
229 232
diff --git a/arch/arm/mach-mmp/sram.c b/arch/arm/mach-mmp/sram.c
new file mode 100644
index 000000000000..4304f9519372
--- /dev/null
+++ b/arch/arm/mach-mmp/sram.c
@@ -0,0 +1,168 @@
1/*
2 * linux/arch/arm/mach-mmp/sram.c
3 *
4 * based on mach-davinci/sram.c - DaVinci simple SRAM allocator
5 *
6 * Copyright (c) 2011 Marvell Semiconductors Inc.
7 * All Rights Reserved
8 *
9 * Add for mmp sram support - Leo Yan <leoy@marvell.com>
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
14 *
15 */
16
17#include <linux/module.h>
18#include <linux/init.h>
19#include <linux/platform_device.h>
20#include <linux/io.h>
21#include <linux/err.h>
22#include <linux/slab.h>
23#include <linux/genalloc.h>
24
25#include <mach/sram.h>
26
27struct sram_bank_info {
28 char *pool_name;
29 struct gen_pool *gpool;
30 int granularity;
31
32 phys_addr_t sram_phys;
33 void __iomem *sram_virt;
34 u32 sram_size;
35
36 struct list_head node;
37};
38
39static DEFINE_MUTEX(sram_lock);
40static LIST_HEAD(sram_bank_list);
41
42struct gen_pool *sram_get_gpool(char *pool_name)
43{
44 struct sram_bank_info *info = NULL;
45
46 if (!pool_name)
47 return NULL;
48
49 mutex_lock(&sram_lock);
50
51 list_for_each_entry(info, &sram_bank_list, node)
52 if (!strcmp(pool_name, info->pool_name))
53 break;
54
55 mutex_unlock(&sram_lock);
56
57 if (&info->node == &sram_bank_list)
58 return NULL;
59
60 return info->gpool;
61}
62EXPORT_SYMBOL(sram_get_gpool);
63
64static int __devinit sram_probe(struct platform_device *pdev)
65{
66 struct sram_platdata *pdata = pdev->dev.platform_data;
67 struct sram_bank_info *info;
68 struct resource *res;
69 int ret = 0;
70
71 if (!pdata && !pdata->pool_name)
72 return -ENODEV;
73
74 info = kzalloc(sizeof(*info), GFP_KERNEL);
75 if (!info)
76 return -ENOMEM;
77
78 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
79 if (res == NULL) {
80 dev_err(&pdev->dev, "no memory resource defined\n");
81 ret = -ENODEV;
82 goto out;
83 }
84
85 if (!resource_size(res))
86 return 0;
87
88 info->sram_phys = (phys_addr_t)res->start;
89 info->sram_size = resource_size(res);
90 info->sram_virt = ioremap(info->sram_phys, info->sram_size);
91 info->pool_name = kstrdup(pdata->pool_name, GFP_KERNEL);
92 info->granularity = pdata->granularity;
93
94 info->gpool = gen_pool_create(ilog2(info->granularity), -1);
95 if (!info->gpool) {
96 dev_err(&pdev->dev, "create pool failed\n");
97 ret = -ENOMEM;
98 goto create_pool_err;
99 }
100
101 ret = gen_pool_add_virt(info->gpool, (unsigned long)info->sram_virt,
102 info->sram_phys, info->sram_size, -1);
103 if (ret < 0) {
104 dev_err(&pdev->dev, "add new chunk failed\n");
105 ret = -ENOMEM;
106 goto add_chunk_err;
107 }
108
109 mutex_lock(&sram_lock);
110 list_add(&info->node, &sram_bank_list);
111 mutex_unlock(&sram_lock);
112
113 platform_set_drvdata(pdev, info);
114
115 dev_info(&pdev->dev, "initialized\n");
116 return 0;
117
118add_chunk_err:
119 gen_pool_destroy(info->gpool);
120create_pool_err:
121 iounmap(info->sram_virt);
122 kfree(info->pool_name);
123out:
124 kfree(info);
125 return ret;
126}
127
128static int __devexit sram_remove(struct platform_device *pdev)
129{
130 struct sram_bank_info *info;
131
132 info = platform_get_drvdata(pdev);
133 if (info == NULL)
134 return -ENODEV;
135
136 mutex_lock(&sram_lock);
137 list_del(&info->node);
138 mutex_unlock(&sram_lock);
139
140 gen_pool_destroy(info->gpool);
141 iounmap(info->sram_virt);
142 kfree(info->pool_name);
143 kfree(info);
144 return 0;
145}
146
147static const struct platform_device_id sram_id_table[] = {
148 { "asram", MMP_ASRAM },
149 { "isram", MMP_ISRAM },
150 { }
151};
152
153static struct platform_driver sram_driver = {
154 .probe = sram_probe,
155 .remove = sram_remove,
156 .driver = {
157 .name = "mmp-sram",
158 },
159 .id_table = sram_id_table,
160};
161
162static int __init sram_init(void)
163{
164 return platform_driver_register(&sram_driver);
165}
166core_initcall(sram_init);
167
168MODULE_LICENSE("GPL");