1 /* linux/arch/arm/plat-s5p/dev-mfc.c
3 * Copyright (C) 2010-2011 Samsung Electronics Co.Ltd
5 * Base S5P MFC resource and device definitions
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
13 #include <linux/kernel.h>
14 #include <linux/interrupt.h>
15 #include <linux/platform_device.h>
16 #include <linux/dma-mapping.h>
17 #include <linux/memblock.h>
18 #include <linux/ioport.h>
21 #include <plat/devs.h>
22 #include <plat/irqs.h>
25 static struct resource s5p_mfc_resource
[] = {
28 .end
= S5P_PA_MFC
+ SZ_64K
- 1,
29 .flags
= IORESOURCE_MEM
,
34 .flags
= IORESOURCE_IRQ
,
38 struct platform_device s5p_device_mfc
= {
41 .num_resources
= ARRAY_SIZE(s5p_mfc_resource
),
42 .resource
= s5p_mfc_resource
,
46 * MFC hardware has 2 memory interfaces which are modelled as two separate
47 * platform devices to let dma-mapping distinguish between them.
49 * MFC parent device (s5p_device_mfc) must be registered before memory
50 * interface specific devices (s5p_device_mfc_l and s5p_device_mfc_r).
53 static u64 s5p_mfc_dma_mask
= DMA_BIT_MASK(32);
55 struct platform_device s5p_device_mfc_l
= {
59 .parent
= &s5p_device_mfc
.dev
,
60 .dma_mask
= &s5p_mfc_dma_mask
,
61 .coherent_dma_mask
= DMA_BIT_MASK(32),
65 struct platform_device s5p_device_mfc_r
= {
69 .parent
= &s5p_device_mfc
.dev
,
70 .dma_mask
= &s5p_mfc_dma_mask
,
71 .coherent_dma_mask
= DMA_BIT_MASK(32),
75 struct s5p_mfc_reserved_mem
{
81 static struct s5p_mfc_reserved_mem s5p_mfc_mem
[2] __initdata
;
83 void __init
s5p_mfc_reserve_mem(phys_addr_t rbase
, unsigned int rsize
,
84 phys_addr_t lbase
, unsigned int lsize
)
88 s5p_mfc_mem
[0].dev
= &s5p_device_mfc_r
.dev
;
89 s5p_mfc_mem
[0].base
= rbase
;
90 s5p_mfc_mem
[0].size
= rsize
;
92 s5p_mfc_mem
[1].dev
= &s5p_device_mfc_l
.dev
;
93 s5p_mfc_mem
[1].base
= lbase
;
94 s5p_mfc_mem
[1].size
= lsize
;
96 for (i
= 0; i
< ARRAY_SIZE(s5p_mfc_mem
); i
++) {
97 struct s5p_mfc_reserved_mem
*area
= &s5p_mfc_mem
[i
];
98 if (memblock_remove(area
->base
, area
->size
)) {
99 printk(KERN_ERR
"Failed to reserve memory for MFC device (%ld bytes at 0x%08lx)\n",
100 area
->size
, (unsigned long) area
->base
);
106 static int __init
s5p_mfc_memory_init(void)
110 for (i
= 0; i
< ARRAY_SIZE(s5p_mfc_mem
); i
++) {
111 struct s5p_mfc_reserved_mem
*area
= &s5p_mfc_mem
[i
];
115 if (dma_declare_coherent_memory(area
->dev
, area
->base
,
116 area
->base
, area
->size
,
117 DMA_MEMORY_MAP
| DMA_MEMORY_EXCLUSIVE
) == 0)
118 printk(KERN_ERR
"Failed to declare coherent memory for MFC device (%ld bytes at 0x%08lx)\n",
119 area
->size
, (unsigned long) area
->base
);
123 device_initcall(s5p_mfc_memory_init
);