1+ // SPDX-License-Identifier: GPL-2.0
12/*
23 * linux/arch/sh/boards/se/7724/setup.c
34 *
45 * Copyright (C) 2009 Renesas Solutions Corp.
56 *
67 * 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.
118 */
9+ #include <asm/clock.h>
10+ #include <asm/heartbeat.h>
11+ #include <asm/io.h>
12+ #include <asm/suspend.h>
1213
13- #include <linux/init.h>
14+ #include <cpu/sh7724.h>
15+
16+ #include <linux/delay.h>
1417#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>
1522#include <linux/interrupt.h>
16- #include <linux/platform_device.h>
17- #include <linux/mmc/host.h>
23+ #include <linux/memblock.h>
1824#include <linux/mfd/tmio.h>
25+ #include <linux/mmc/host.h>
1926#include <linux/mtd/physmap.h>
20- #include <linux/delay .h>
27+ #include <linux/platform_device .h>
2128#include <linux/regulator/fixed.h>
2229#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>
2830#include <linux/sh_eth.h>
2931#include <linux/sh_intc.h>
32+ #include <linux/smc91x.h>
33+ #include <linux/usb/r8a66597.h>
3034#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+
3339#include <sound/sh_fsi.h>
3440#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 ;
4147
4248/*
4349 * SWx 1234 5678
@@ -216,8 +222,8 @@ static struct platform_device lcdc_device = {
216222};
217223
218224/* 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 ,
221227};
222228
223229static struct resource ceu0_resources [] = {
@@ -231,24 +237,21 @@ static struct resource ceu0_resources[] = {
231237 .start = evt2irq (0x880 ),
232238 .flags = IORESOURCE_IRQ ,
233239 },
234- [2 ] = {
235- /* place holder for contiguous memory */
236- },
237240};
238241
239242static 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 */
242245 .num_resources = ARRAY_SIZE (ceu0_resources ),
243246 .resource = ceu0_resources ,
244247 .dev = {
245- .platform_data = & sh_mobile_ceu0_info ,
248+ .platform_data = & ceu0_pdata ,
246249 },
247250};
248251
249252/* 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 ,
252255};
253256
254257static struct resource ceu1_resources [] = {
@@ -262,18 +265,15 @@ static struct resource ceu1_resources[] = {
262265 .start = evt2irq (0x9e0 ),
263266 .flags = IORESOURCE_IRQ ,
264267 },
265- [2 ] = {
266- /* place holder for contiguous memory */
267- },
268268};
269269
270270static 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 */
273273 .num_resources = ARRAY_SIZE (ceu1_resources ),
274274 .resource = ceu1_resources ,
275275 .dev = {
276- .platform_data = & sh_mobile_ceu1_info ,
276+ .platform_data = & ceu1_pdata ,
277277 },
278278};
279279
@@ -574,13 +574,16 @@ static struct platform_device vou_device = {
574574 },
575575};
576576
577+ static struct platform_device * ms7724se_ceu_devices [] __initdata = {
578+ & ceu0_device ,
579+ & ceu1_device ,
580+ };
581+
577582static struct platform_device * ms7724se_devices [] __initdata = {
578583 & heartbeat_device ,
579584 & smc91x_eth_device ,
580585 & lcdc_device ,
581586 & nor_flash_device ,
582- & ceu0_device ,
583- & ceu1_device ,
584587 & keysc_device ,
585588 & sh_eth_device ,
586589 & sh7724_usb0_host_device ,
@@ -797,7 +800,6 @@ static int __init devices_setup(void)
797800 gpio_request (GPIO_FN_VIO0_CLK , NULL );
798801 gpio_request (GPIO_FN_VIO0_FLD , NULL );
799802 gpio_request (GPIO_FN_VIO0_HD , NULL );
800- platform_resource_setup_memory (& ceu0_device , "ceu0" , 4 << 20 );
801803
802804 /* enable CEU1 */
803805 gpio_request (GPIO_FN_VIO1_D7 , NULL );
@@ -812,7 +814,6 @@ static int __init devices_setup(void)
812814 gpio_request (GPIO_FN_VIO1_HD , NULL );
813815 gpio_request (GPIO_FN_VIO1_VD , NULL );
814816 gpio_request (GPIO_FN_VIO1_CLK , NULL );
815- platform_resource_setup_memory (& ceu1_device , "ceu1" , 4 << 20 );
816817
817818 /* KEYSC */
818819 gpio_request (GPIO_FN_KEYOUT5_IN5 , NULL );
@@ -934,12 +935,49 @@ static int __init devices_setup(void)
934935 gpio_request (GPIO_FN_DV_VSYNC , NULL );
935936 gpio_request (GPIO_FN_DV_HSYNC , NULL );
936937
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+
937957 return platform_add_devices (ms7724se_devices ,
938958 ARRAY_SIZE (ms7724se_devices ));
939959}
940960device_initcall (devices_setup );
941961
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+
942979static struct sh_machine_vector mv_ms7724se __initmv = {
943980 .mv_name = "ms7724se" ,
944981 .mv_init_irq = init_se7724_IRQ ,
982+ .mv_mem_reserve = ms7724se_mv_mem_reserve ,
945983};
0 commit comments