1
+ // SPDX-License-Identifier: GPL-2.0
1
2
/*
2
3
* linux/arch/sh/boards/se/7724/setup.c
3
4
*
4
5
* Copyright (C) 2009 Renesas Solutions Corp.
5
6
*
6
7
* Kuninori Morimoto <morimoto.kuninori@renesas.com>
7
- *
8
- * This file is subject to the terms and conditions of the GNU General Public
9
- * License. See the file "COPYING" in the main directory of this archive
10
- * for more details.
11
8
*/
9
+ #include <asm/clock.h>
10
+ #include <asm/heartbeat.h>
11
+ #include <asm/io.h>
12
+ #include <asm/suspend.h>
12
13
13
- #include <linux/init.h>
14
+ #include <cpu/sh7724.h>
15
+
16
+ #include <linux/delay.h>
14
17
#include <linux/device.h>
18
+ #include <linux/gpio.h>
19
+ #include <linux/init.h>
20
+ #include <linux/input.h>
21
+ #include <linux/input/sh_keysc.h>
15
22
#include <linux/interrupt.h>
16
- #include <linux/platform_device.h>
17
- #include <linux/mmc/host.h>
23
+ #include <linux/memblock.h>
18
24
#include <linux/mfd/tmio.h>
25
+ #include <linux/mmc/host.h>
19
26
#include <linux/mtd/physmap.h>
20
- #include <linux/delay .h>
27
+ #include <linux/platform_device .h>
21
28
#include <linux/regulator/fixed.h>
22
29
#include <linux/regulator/machine.h>
23
- #include <linux/smc91x.h>
24
- #include <linux/gpio.h>
25
- #include <linux/input.h>
26
- #include <linux/input/sh_keysc.h>
27
- #include <linux/usb/r8a66597.h>
28
30
#include <linux/sh_eth.h>
29
31
#include <linux/sh_intc.h>
32
+ #include <linux/smc91x.h>
33
+ #include <linux/usb/r8a66597.h>
30
34
#include <linux/videodev2.h>
31
- #include <video/sh_mobile_lcdc.h>
32
- #include <media/drv-intf/sh_mobile_ceu.h>
35
+
36
+ #include <mach-se/mach/se7724.h>
37
+ #include <media/drv-intf/renesas-ceu.h>
38
+
33
39
#include <sound/sh_fsi.h>
34
40
#include <sound/simple_card.h>
35
- #include <asm/io.h>
36
- #include <asm/heartbeat .h>
37
- #include <asm/clock.h>
38
- #include <asm/suspend.h>
39
- #include <cpu/sh7724.h>
40
- #include <mach-se/mach/se7724.h>
41
+
42
+ #include <video/sh_mobile_lcdc .h>
43
+
44
+ #define CEU_BUFFER_MEMORY_SIZE (4 << 20)
45
+ static phys_addr_t ceu0_dma_membase ;
46
+ static phys_addr_t ceu1_dma_membase ;
41
47
42
48
/*
43
49
* SWx 1234 5678
@@ -216,8 +222,8 @@ static struct platform_device lcdc_device = {
216
222
};
217
223
218
224
/* CEU0 */
219
- static struct sh_mobile_ceu_info sh_mobile_ceu0_info = {
220
- .flags = SH_CEU_FLAG_USE_8BIT_BUS ,
225
+ static struct ceu_platform_data ceu0_pdata = {
226
+ .num_subdevs = 0 ,
221
227
};
222
228
223
229
static struct resource ceu0_resources [] = {
@@ -231,24 +237,21 @@ static struct resource ceu0_resources[] = {
231
237
.start = evt2irq (0x880 ),
232
238
.flags = IORESOURCE_IRQ ,
233
239
},
234
- [2 ] = {
235
- /* place holder for contiguous memory */
236
- },
237
240
};
238
241
239
242
static struct platform_device ceu0_device = {
240
- .name = "sh_mobile_ceu " ,
241
- .id = 0 , /* "ceu0 " clock */
243
+ .name = "renesas-ceu " ,
244
+ .id = 0 , /* "ceu.0 " clock */
242
245
.num_resources = ARRAY_SIZE (ceu0_resources ),
243
246
.resource = ceu0_resources ,
244
247
.dev = {
245
- .platform_data = & sh_mobile_ceu0_info ,
248
+ .platform_data = & ceu0_pdata ,
246
249
},
247
250
};
248
251
249
252
/* CEU1 */
250
- static struct sh_mobile_ceu_info sh_mobile_ceu1_info = {
251
- .flags = SH_CEU_FLAG_USE_8BIT_BUS ,
253
+ static struct ceu_platform_data ceu1_pdata = {
254
+ .num_subdevs = 0 ,
252
255
};
253
256
254
257
static struct resource ceu1_resources [] = {
@@ -262,18 +265,15 @@ static struct resource ceu1_resources[] = {
262
265
.start = evt2irq (0x9e0 ),
263
266
.flags = IORESOURCE_IRQ ,
264
267
},
265
- [2 ] = {
266
- /* place holder for contiguous memory */
267
- },
268
268
};
269
269
270
270
static struct platform_device ceu1_device = {
271
- .name = "sh_mobile_ceu " ,
272
- .id = 1 , /* "ceu1 " clock */
271
+ .name = "renesas-ceu " ,
272
+ .id = 1 , /* "ceu.1 " clock */
273
273
.num_resources = ARRAY_SIZE (ceu1_resources ),
274
274
.resource = ceu1_resources ,
275
275
.dev = {
276
- .platform_data = & sh_mobile_ceu1_info ,
276
+ .platform_data = & ceu1_pdata ,
277
277
},
278
278
};
279
279
@@ -574,13 +574,16 @@ static struct platform_device vou_device = {
574
574
},
575
575
};
576
576
577
+ static struct platform_device * ms7724se_ceu_devices [] __initdata = {
578
+ & ceu0_device ,
579
+ & ceu1_device ,
580
+ };
581
+
577
582
static struct platform_device * ms7724se_devices [] __initdata = {
578
583
& heartbeat_device ,
579
584
& smc91x_eth_device ,
580
585
& lcdc_device ,
581
586
& nor_flash_device ,
582
- & ceu0_device ,
583
- & ceu1_device ,
584
587
& keysc_device ,
585
588
& sh_eth_device ,
586
589
& sh7724_usb0_host_device ,
@@ -797,7 +800,6 @@ static int __init devices_setup(void)
797
800
gpio_request (GPIO_FN_VIO0_CLK , NULL );
798
801
gpio_request (GPIO_FN_VIO0_FLD , NULL );
799
802
gpio_request (GPIO_FN_VIO0_HD , NULL );
800
- platform_resource_setup_memory (& ceu0_device , "ceu0" , 4 << 20 );
801
803
802
804
/* enable CEU1 */
803
805
gpio_request (GPIO_FN_VIO1_D7 , NULL );
@@ -812,7 +814,6 @@ static int __init devices_setup(void)
812
814
gpio_request (GPIO_FN_VIO1_HD , NULL );
813
815
gpio_request (GPIO_FN_VIO1_VD , NULL );
814
816
gpio_request (GPIO_FN_VIO1_CLK , NULL );
815
- platform_resource_setup_memory (& ceu1_device , "ceu1" , 4 << 20 );
816
817
817
818
/* KEYSC */
818
819
gpio_request (GPIO_FN_KEYOUT5_IN5 , NULL );
@@ -934,12 +935,49 @@ static int __init devices_setup(void)
934
935
gpio_request (GPIO_FN_DV_VSYNC , NULL );
935
936
gpio_request (GPIO_FN_DV_HSYNC , NULL );
936
937
938
+ /* Initialize CEU platform devices separately to map memory first */
939
+ device_initialize (& ms7724se_ceu_devices [0 ]-> dev );
940
+ arch_setup_pdev_archdata (ms7724se_ceu_devices [0 ]);
941
+ dma_declare_coherent_memory (& ms7724se_ceu_devices [0 ]-> dev ,
942
+ ceu0_dma_membase , ceu0_dma_membase ,
943
+ ceu0_dma_membase +
944
+ CEU_BUFFER_MEMORY_SIZE - 1 ,
945
+ DMA_MEMORY_EXCLUSIVE );
946
+ platform_device_add (ms7724se_ceu_devices [0 ]);
947
+
948
+ device_initialize (& ms7724se_ceu_devices [1 ]-> dev );
949
+ arch_setup_pdev_archdata (ms7724se_ceu_devices [1 ]);
950
+ dma_declare_coherent_memory (& ms7724se_ceu_devices [1 ]-> dev ,
951
+ ceu1_dma_membase , ceu1_dma_membase ,
952
+ ceu1_dma_membase +
953
+ CEU_BUFFER_MEMORY_SIZE - 1 ,
954
+ DMA_MEMORY_EXCLUSIVE );
955
+ platform_device_add (ms7724se_ceu_devices [1 ]);
956
+
937
957
return platform_add_devices (ms7724se_devices ,
938
958
ARRAY_SIZE (ms7724se_devices ));
939
959
}
940
960
device_initcall (devices_setup );
941
961
962
+ /* Reserve a portion of memory for CEU 0 and CEU 1 buffers */
963
+ static void __init ms7724se_mv_mem_reserve (void )
964
+ {
965
+ phys_addr_t phys ;
966
+ phys_addr_t size = CEU_BUFFER_MEMORY_SIZE ;
967
+
968
+ phys = memblock_alloc_base (size , PAGE_SIZE , MEMBLOCK_ALLOC_ANYWHERE );
969
+ memblock_free (phys , size );
970
+ memblock_remove (phys , size );
971
+ ceu0_dma_membase = phys ;
972
+
973
+ phys = memblock_alloc_base (size , PAGE_SIZE , MEMBLOCK_ALLOC_ANYWHERE );
974
+ memblock_free (phys , size );
975
+ memblock_remove (phys , size );
976
+ ceu1_dma_membase = phys ;
977
+ }
978
+
942
979
static struct sh_machine_vector mv_ms7724se __initmv = {
943
980
.mv_name = "ms7724se" ,
944
981
.mv_init_irq = init_se7724_IRQ ,
982
+ .mv_mem_reserve = ms7724se_mv_mem_reserve ,
945
983
};
0 commit comments