diff options
Diffstat (limited to 'arch/sh/boards')
-rw-r--r-- | arch/sh/boards/mach-ap325rxa/setup.c | 282 | ||||
-rw-r--r-- | arch/sh/boards/mach-kfr2r09/setup.c | 217 | ||||
-rw-r--r-- | arch/sh/boards/mach-migor/setup.c | 8 | ||||
-rw-r--r-- | arch/sh/boards/mach-se/7724/setup.c | 120 | ||||
-rw-r--r-- | arch/sh/boards/of-generic.c | 7 |
5 files changed, 269 insertions, 365 deletions
diff --git a/arch/sh/boards/mach-ap325rxa/setup.c b/arch/sh/boards/mach-ap325rxa/setup.c index de8393cb7313..8f234d0435aa 100644 --- a/arch/sh/boards/mach-ap325rxa/setup.c +++ b/arch/sh/boards/mach-ap325rxa/setup.c @@ -1,40 +1,45 @@ +// SPDX-License-Identifier: GPL-2.0 /* * Renesas - AP-325RXA * (Compatible with Algo System ., LTD. - AP-320A) * * Copyright (C) 2008 Renesas Solutions Corp. * Author : Yusuke Goda <goda.yuske@renesas.com> - * - * This file is subject to the terms and conditions of the GNU General Public - * License. See the file "COPYING" in the main directory of this archive - * for more details. */ -#include <linux/init.h> +#include <asm/clock.h> +#include <asm/io.h> +#include <asm/suspend.h> + +#include <cpu/sh7723.h> + +#include <linux/clkdev.h> +#include <linux/delay.h> #include <linux/device.h> +#include <linux/gpio.h> +#include <linux/gpio/machine.h> +#include <linux/i2c.h> +#include <linux/init.h> #include <linux/interrupt.h> -#include <linux/platform_device.h> +#include <linux/memblock.h> +#include <linux/mfd/tmio.h> #include <linux/mmc/host.h> #include <linux/mtd/physmap.h> #include <linux/mtd/sh_flctl.h> -#include <linux/mfd/tmio.h> -#include <linux/delay.h> -#include <linux/i2c.h> +#include <linux/platform_device.h> #include <linux/regulator/fixed.h> #include <linux/regulator/machine.h> +#include <linux/sh_intc.h> #include <linux/smsc911x.h> -#include <linux/gpio.h> #include <linux/videodev2.h> -#include <linux/sh_intc.h> + +#include <media/drv-intf/renesas-ceu.h> #include <media/i2c/ov772x.h> -#include <media/soc_camera.h> -#include <linux/platform_data/media/soc_camera_platform.h> -#include <media/drv-intf/sh_mobile_ceu.h> + #include <video/sh_mobile_lcdc.h> -#include <asm/io.h> -#include <asm/clock.h> -#include <asm/suspend.h> -#include <cpu/sh7723.h> + +#define CEU_BUFFER_MEMORY_SIZE (4 << 20) +static phys_addr_t ceu_dma_membase; /* Dummy supplies, where voltage doesn't matter */ static struct regulator_consumer_supply dummy_supplies[] = { @@ -253,150 +258,25 @@ static struct platform_device lcdc_device = { }, }; -static void camera_power(int val) -{ - gpio_set_value(GPIO_PTZ5, val); /* RST_CAM/RSTB */ - mdelay(10); -} - -#ifdef CONFIG_I2C -/* support for the old ncm03j camera */ -static unsigned char camera_ncm03j_magic[] = -{ - 0x87, 0x00, 0x88, 0x08, 0x89, 0x01, 0x8A, 0xE8, - 0x1D, 0x00, 0x1E, 0x8A, 0x21, 0x00, 0x33, 0x36, - 0x36, 0x60, 0x37, 0x08, 0x3B, 0x31, 0x44, 0x0F, - 0x46, 0xF0, 0x4B, 0x28, 0x4C, 0x21, 0x4D, 0x55, - 0x4E, 0x1B, 0x4F, 0xC7, 0x50, 0xFC, 0x51, 0x12, - 0x58, 0x02, 0x66, 0xC0, 0x67, 0x46, 0x6B, 0xA0, - 0x6C, 0x34, 0x7E, 0x25, 0x7F, 0x25, 0x8D, 0x0F, - 0x92, 0x40, 0x93, 0x04, 0x94, 0x26, 0x95, 0x0A, - 0x99, 0x03, 0x9A, 0xF0, 0x9B, 0x14, 0x9D, 0x7A, - 0xC5, 0x02, 0xD6, 0x07, 0x59, 0x00, 0x5A, 0x1A, - 0x5B, 0x2A, 0x5C, 0x37, 0x5D, 0x42, 0x5E, 0x56, - 0xC8, 0x00, 0xC9, 0x1A, 0xCA, 0x2A, 0xCB, 0x37, - 0xCC, 0x42, 0xCD, 0x56, 0xCE, 0x00, 0xCF, 0x1A, - 0xD0, 0x2A, 0xD1, 0x37, 0xD2, 0x42, 0xD3, 0x56, - 0x5F, 0x68, 0x60, 0x87, 0x61, 0xA3, 0x62, 0xBC, - 0x63, 0xD4, 0x64, 0xEA, 0xD6, 0x0F, -}; - -static int camera_probe(void) -{ - struct i2c_adapter *a = i2c_get_adapter(0); - struct i2c_msg msg; - int ret; - - if (!a) - return -ENODEV; - - camera_power(1); - msg.addr = 0x6e; - msg.buf = camera_ncm03j_magic; - msg.len = 2; - msg.flags = 0; - ret = i2c_transfer(a, &msg, 1); - camera_power(0); - - return ret; -} - -static int camera_set_capture(struct soc_camera_platform_info *info, - int enable) -{ - struct i2c_adapter *a = i2c_get_adapter(0); - struct i2c_msg msg; - int ret = 0; - int i; - - camera_power(0); - if (!enable) - return 0; /* no disable for now */ - - camera_power(1); - for (i = 0; i < ARRAY_SIZE(camera_ncm03j_magic); i += 2) { - u_int8_t buf[8]; - - msg.addr = 0x6e; - msg.buf = buf; - msg.len = 2; - msg.flags = 0; - - buf[0] = camera_ncm03j_magic[i]; - buf[1] = camera_ncm03j_magic[i + 1]; - - ret = (ret < 0) ? ret : i2c_transfer(a, &msg, 1); - } - - return ret; -} - -static int ap325rxa_camera_add(struct soc_camera_device *icd); -static void ap325rxa_camera_del(struct soc_camera_device *icd); - -static struct soc_camera_platform_info camera_info = { - .format_name = "UYVY", - .format_depth = 16, - .format = { - .code = MEDIA_BUS_FMT_UYVY8_2X8, - .colorspace = V4L2_COLORSPACE_SMPTE170M, - .field = V4L2_FIELD_NONE, - .width = 640, - .height = 480, +/* Powerdown/reset gpios for CEU image sensors */ +static struct gpiod_lookup_table ov7725_gpios = { + .dev_id = "0-0021", + .table = { + GPIO_LOOKUP("sh7723_pfc", GPIO_PTZ5, "reset", GPIO_ACTIVE_LOW), }, - .mbus_param = V4L2_MBUS_PCLK_SAMPLE_RISING | V4L2_MBUS_MASTER | - V4L2_MBUS_VSYNC_ACTIVE_HIGH | V4L2_MBUS_HSYNC_ACTIVE_HIGH | - V4L2_MBUS_DATA_ACTIVE_HIGH, - .mbus_type = V4L2_MBUS_PARALLEL, - .set_capture = camera_set_capture, -}; - -static struct soc_camera_link camera_link = { - .bus_id = 0, - .add_device = ap325rxa_camera_add, - .del_device = ap325rxa_camera_del, - .module_name = "soc_camera_platform", - .priv = &camera_info, }; -static struct platform_device *camera_device; - -static void ap325rxa_camera_release(struct device *dev) -{ - soc_camera_platform_release(&camera_device); -} - -static int ap325rxa_camera_add(struct soc_camera_device *icd) -{ - int ret = soc_camera_platform_add(icd, &camera_device, &camera_link, - ap325rxa_camera_release, 0); - if (ret < 0) - return ret; - - ret = camera_probe(); - if (ret < 0) - soc_camera_platform_del(icd, camera_device, &camera_link); - - return ret; -} - -static void ap325rxa_camera_del(struct soc_camera_device *icd) -{ - soc_camera_platform_del(icd, camera_device, &camera_link); -} -#endif /* CONFIG_I2C */ - -static int ov7725_power(struct device *dev, int mode) -{ - camera_power(0); - if (mode) - camera_power(1); - - return 0; -} - -static struct sh_mobile_ceu_info sh_mobile_ceu_info = { - .flags = SH_CEU_FLAG_USE_8BIT_BUS, +static struct ceu_platform_data ceu0_pdata = { + .num_subdevs = 1, + .subdevs = { + { /* [0] = ov7725 */ + .flags = 0, + .bus_width = 8, + .bus_shift = 0, + .i2c_adapter_id = 0, + .i2c_address = 0x21, + }, + }, }; static struct resource ceu_resources[] = { @@ -410,18 +290,15 @@ static struct resource ceu_resources[] = { .start = evt2irq(0x880), .flags = IORESOURCE_IRQ, }, - [2] = { - /* place holder for contiguous memory */ - }, }; -static struct platform_device ceu_device = { - .name = "sh_mobile_ceu", - .id = 0, /* "ceu0" clock */ +static struct platform_device ap325rxa_ceu_device = { + .name = "renesas-ceu", + .id = 0, /* "ceu.0" clock */ .num_resources = ARRAY_SIZE(ceu_resources), .resource = ceu_resources, .dev = { - .platform_data = &sh_mobile_ceu_info, + .platform_data = &ceu0_pdata, }, }; @@ -488,44 +365,18 @@ static struct platform_device sdhi1_cn7_device = { }, }; -static struct i2c_board_info __initdata ap325rxa_i2c_devices[] = { - { - I2C_BOARD_INFO("pcf8563", 0x51), - }, -}; - -static struct i2c_board_info ap325rxa_i2c_camera[] = { - { - I2C_BOARD_INFO("ov772x", 0x21), - }, -}; - static struct ov772x_camera_info ov7725_info = { .flags = OV772X_FLAG_VFLIP | OV772X_FLAG_HFLIP, .edgectrl = OV772X_AUTO_EDGECTRL(0xf, 0), }; -static struct soc_camera_link ov7725_link = { - .bus_id = 0, - .power = ov7725_power, - .board_info = &ap325rxa_i2c_camera[0], - .i2c_adapter_id = 0, - .priv = &ov7725_info, -}; - -static struct platform_device ap325rxa_camera[] = { +static struct i2c_board_info ap325rxa_i2c_devices[] __initdata = { { - .name = "soc-camera-pdrv", - .id = 0, - .dev = { - .platform_data = &ov7725_link, - }, - }, { - .name = "soc-camera-pdrv", - .id = 1, - .dev = { - .platform_data = &camera_link, - }, + I2C_BOARD_INFO("pcf8563", 0x51), + }, + { + I2C_BOARD_INFO("ov772x", 0x21), + .platform_data = &ov7725_info, }, }; @@ -533,12 +384,9 @@ static struct platform_device *ap325rxa_devices[] __initdata = { &smsc9118_device, &ap325rxa_nor_flash_device, &lcdc_device, - &ceu_device, &nand_flash_device, &sdhi0_cn3_device, &sdhi1_cn7_device, - &ap325rxa_camera[0], - &ap325rxa_camera[1], }; extern char ap325rxa_sdram_enter_start; @@ -649,8 +497,6 @@ static int __init ap325rxa_devices_setup(void) __raw_writew(0xFFFF, PORT_DRVCRA); __raw_writew(0xFFFF, PORT_DRVCRB); - platform_resource_setup_memory(&ceu_device, "ceu", 4 << 20); - /* SDHI0 - CN3 - SD CARD */ gpio_request(GPIO_FN_SDHI0CD_PTD, NULL); gpio_request(GPIO_FN_SDHI0WP_PTD, NULL); @@ -670,9 +516,25 @@ static int __init ap325rxa_devices_setup(void) gpio_request(GPIO_FN_SDHI1CMD, NULL); gpio_request(GPIO_FN_SDHI1CLK, NULL); + /* Add a clock alias for ov7725 xclk source. */ + clk_add_alias(NULL, "0-0021", "video_clk", NULL); + + /* Register RSTB gpio for ov7725 camera sensor. */ + gpiod_add_lookup_table(&ov7725_gpios); + i2c_register_board_info(0, ap325rxa_i2c_devices, ARRAY_SIZE(ap325rxa_i2c_devices)); + /* Initialize CEU platform device separately to map memory first */ + device_initialize(&ap325rxa_ceu_device.dev); + arch_setup_pdev_archdata(&ap325rxa_ceu_device); + dma_declare_coherent_memory(&ap325rxa_ceu_device.dev, + ceu_dma_membase, ceu_dma_membase, + ceu_dma_membase + CEU_BUFFER_MEMORY_SIZE - 1, + DMA_MEMORY_EXCLUSIVE); + + platform_device_add(&ap325rxa_ceu_device); + return platform_add_devices(ap325rxa_devices, ARRAY_SIZE(ap325rxa_devices)); } @@ -689,7 +551,21 @@ static int ap325rxa_mode_pins(void) return MODE_PIN5 | MODE_PIN8; } +/* Reserve a portion of memory for CEU buffers */ +static void __init ap325rxa_mv_mem_reserve(void) +{ + phys_addr_t phys; + phys_addr_t size = CEU_BUFFER_MEMORY_SIZE; + + phys = memblock_alloc_base(size, PAGE_SIZE, MEMBLOCK_ALLOC_ANYWHERE); + memblock_free(phys, size); + memblock_remove(phys, size); + + ceu_dma_membase = phys; +} + static struct sh_machine_vector mv_ap325rxa __initmv = { .mv_name = "AP-325RXA", .mv_mode_pins = ap325rxa_mode_pins, + .mv_mem_reserve = ap325rxa_mv_mem_reserve, }; diff --git a/arch/sh/boards/mach-kfr2r09/setup.c b/arch/sh/boards/mach-kfr2r09/setup.c index 6af7777332fc..e59c577ed871 100644 --- a/arch/sh/boards/mach-kfr2r09/setup.c +++ b/arch/sh/boards/mach-kfr2r09/setup.c @@ -1,41 +1,53 @@ +// SPDX-License-Identifier: GPL-2.0 /* * KFR2R09 board support code * * Copyright (C) 2009 Magnus Damm - * - * This file is subject to the terms and conditions of the GNU General Public - * License. See the file "COPYING" in the main directory of this archive - * for more details. */ -#include <linux/init.h> -#include <linux/platform_device.h> -#include <linux/interrupt.h> -#include <linux/mmc/host.h> -#include <linux/mfd/tmio.h> -#include <linux/mtd/physmap.h> -#include <linux/mtd/onenand.h> + +#include <asm/clock.h> +#include <asm/io.h> +#include <asm/machvec.h> +#include <asm/suspend.h> + +#include <cpu/sh7724.h> + +#include <linux/clkdev.h> #include <linux/delay.h> -#include <linux/clk.h> +#include <linux/dma-mapping.h> #include <linux/gpio.h> +#include <linux/gpio/machine.h> +#include <linux/i2c.h> +#include <linux/init.h> #include <linux/input.h> #include <linux/input/sh_keysc.h> -#include <linux/i2c.h> +#include <linux/interrupt.h> +#include <linux/memblock.h> +#include <linux/mfd/tmio.h> +#include <linux/mmc/host.h> +#include <linux/mtd/onenand.h> +#include <linux/mtd/physmap.h> #include <linux/platform_data/lv5207lp.h> +#include <linux/platform_device.h> #include <linux/regulator/fixed.h> #include <linux/regulator/machine.h> +#include <linux/sh_intc.h> #include <linux/usb/r8a66597.h> #include <linux/videodev2.h> -#include <linux/sh_intc.h> + +#include <mach/kfr2r09.h> + +#include <media/drv-intf/renesas-ceu.h> #include <media/i2c/rj54n1cb0c.h> -#include <media/soc_camera.h> -#include <media/drv-intf/sh_mobile_ceu.h> + #include <video/sh_mobile_lcdc.h> -#include <asm/suspend.h> -#include <asm/clock.h> -#include <asm/machvec.h> -#include <asm/io.h> -#include <cpu/sh7724.h> -#include <mach/kfr2r09.h> + +#define CEU_BUFFER_MEMORY_SIZE (4 << 20) +static phys_addr_t ceu_dma_membase; + +/* set VIO_CKO clock to 25MHz */ +#define CEU_MCLK_FREQ 25000000 +#define DRVCRB 0xA405018C static struct mtd_partition kfr2r09_nor_flash_partitions[] = { @@ -230,8 +242,17 @@ static struct platform_device kfr2r09_usb0_gadget_device = { .resource = kfr2r09_usb0_gadget_resources, }; -static struct sh_mobile_ceu_info sh_mobile_ceu_info = { - .flags = SH_CEU_FLAG_USE_8BIT_BUS, +static struct ceu_platform_data ceu_pdata = { + .num_subdevs = 1, + .subdevs = { + { /* [0] = rj54n1cb0c */ + .flags = 0, + .bus_width = 8, + .bus_shift = 0, + .i2c_adapter_id = 1, + .i2c_address = 0x50, + }, + }, }; static struct resource kfr2r09_ceu_resources[] = { @@ -246,109 +267,35 @@ static struct resource kfr2r09_ceu_resources[] = { .end = evt2irq(0x880), .flags = IORESOURCE_IRQ, }, - [2] = { - /* place holder for contiguous memory */ - }, }; static struct platform_device kfr2r09_ceu_device = { - .name = "sh_mobile_ceu", + .name = "renesas-ceu", .id = 0, /* "ceu0" clock */ .num_resources = ARRAY_SIZE(kfr2r09_ceu_resources), .resource = kfr2r09_ceu_resources, .dev = { - .platform_data = &sh_mobile_ceu_info, + .platform_data = &ceu_pdata, }, }; -static struct i2c_board_info kfr2r09_i2c_camera = { - I2C_BOARD_INFO("rj54n1cb0c", 0x50), -}; - -static struct clk *camera_clk; - -/* set VIO_CKO clock to 25MHz */ -#define CEU_MCLK_FREQ 25000000 - -#define DRVCRB 0xA405018C -static int camera_power(struct device *dev, int mode) -{ - int ret; - - if (mode) { - long rate; - - camera_clk = clk_get(NULL, "video_clk"); - if (IS_ERR(camera_clk)) - return PTR_ERR(camera_clk); - - rate = clk_round_rate(camera_clk, CEU_MCLK_FREQ); - ret = clk_set_rate(camera_clk, rate); - if (ret < 0) - goto eclkrate; - - /* set DRVCRB - * - * use 1.8 V for VccQ_VIO - * use 2.85V for VccQ_SR - */ - __raw_writew((__raw_readw(DRVCRB) & ~0x0003) | 0x0001, DRVCRB); - - /* reset clear */ - ret = gpio_request(GPIO_PTB4, NULL); - if (ret < 0) - goto eptb4; - ret = gpio_request(GPIO_PTB7, NULL); - if (ret < 0) - goto eptb7; - - ret = gpio_direction_output(GPIO_PTB4, 1); - if (!ret) - ret = gpio_direction_output(GPIO_PTB7, 1); - if (ret < 0) - goto egpioout; - msleep(1); - - ret = clk_enable(camera_clk); /* start VIO_CKO */ - if (ret < 0) - goto eclkon; - - return 0; - } - - ret = 0; - - clk_disable(camera_clk); -eclkon: - gpio_set_value(GPIO_PTB7, 0); -egpioout: - gpio_set_value(GPIO_PTB4, 0); - gpio_free(GPIO_PTB7); -eptb7: - gpio_free(GPIO_PTB4); -eptb4: -eclkrate: - clk_put(camera_clk); - return ret; -} - static struct rj54n1_pdata rj54n1_priv = { .mclk_freq = CEU_MCLK_FREQ, .ioctl_high = false, }; -static struct soc_camera_link rj54n1_link = { - .power = camera_power, - .board_info = &kfr2r09_i2c_camera, - .i2c_adapter_id = 1, - .priv = &rj54n1_priv, +static struct i2c_board_info kfr2r09_i2c_camera = { + I2C_BOARD_INFO("rj54n1cb0c", 0x50), + .platform_data = &rj54n1_priv, }; -static struct platform_device kfr2r09_camera = { - .name = "soc-camera-pdrv", - .id = 0, - .dev = { - .platform_data = &rj54n1_link, +static struct gpiod_lookup_table rj54n1_gpios = { + .dev_id = "1-0050", + .table = { + GPIO_LOOKUP("sh7724_pfc", GPIO_PTB4, "poweron", + GPIO_ACTIVE_HIGH), + GPIO_LOOKUP("sh7724_pfc", GPIO_PTB7, "enable", + GPIO_ACTIVE_HIGH), }, }; @@ -393,8 +340,6 @@ static struct platform_device *kfr2r09_devices[] __initdata = { &kfr2r09_nand_flash_device, &kfr2r09_sh_keysc_device, &kfr2r09_sh_lcdc_device, - &kfr2r09_ceu_device, - &kfr2r09_camera, &kfr2r09_sh_sdhi0_device, }; @@ -533,6 +478,8 @@ extern char kfr2r09_sdram_leave_end; static int __init kfr2r09_devices_setup(void) { + static struct clk *camera_clk; + /* register board specific self-refresh code */ sh_mobile_register_self_refresh(SUSP_SH_STANDBY | SUSP_SH_SF | SUSP_SH_RSTANDBY, @@ -622,8 +569,6 @@ static int __init kfr2r09_devices_setup(void) gpio_request(GPIO_FN_VIO0_D1, NULL); gpio_request(GPIO_FN_VIO0_D0, NULL); - platform_resource_setup_memory(&kfr2r09_ceu_device, "ceu", 4 << 20); - /* SDHI0 connected to yc304 */ gpio_request(GPIO_FN_SDHI0CD, NULL); gpio_request(GPIO_FN_SDHI0D3, NULL); @@ -635,6 +580,36 @@ static int __init kfr2r09_devices_setup(void) i2c_register_board_info(0, &kfr2r09_backlight_board_info, 1); + /* Set camera clock frequency and register and alias for rj54n1. */ + camera_clk = clk_get(NULL, "video_clk"); + if (!IS_ERR(camera_clk)) { + clk_set_rate(camera_clk, + clk_round_rate(camera_clk, CEU_MCLK_FREQ)); + clk_put(camera_clk); + } + clk_add_alias(NULL, "1-0050", "video_clk", NULL); + + /* set DRVCRB + * + * use 1.8 V for VccQ_VIO + * use 2.85V for VccQ_SR + */ + __raw_writew((__raw_readw(DRVCRB) & ~0x0003) | 0x0001, DRVCRB); + + gpiod_add_lookup_table(&rj54n1_gpios); + + i2c_register_board_info(1, &kfr2r09_i2c_camera, 1); + + /* Initialize CEU platform device separately to map memory first */ + device_initialize(&kfr2r09_ceu_device.dev); + arch_setup_pdev_archdata(&kfr2r09_ceu_device); + dma_declare_coherent_memory(&kfr2r09_ceu_device.dev, + ceu_dma_membase, ceu_dma_membase, + ceu_dma_membase + CEU_BUFFER_MEMORY_SIZE - 1, + DMA_MEMORY_EXCLUSIVE); + + platform_device_add(&kfr2r09_ceu_device); + return platform_add_devices(kfr2r09_devices, ARRAY_SIZE(kfr2r09_devices)); } @@ -651,10 +626,24 @@ static int kfr2r09_mode_pins(void) return MODE_PIN0 | MODE_PIN1 | MODE_PIN5 | MODE_PIN8; } +/* Reserve a portion of memory for CEU buffers */ +static void __init kfr2r09_mv_mem_reserve(void) +{ + phys_addr_t phys; + phys_addr_t size = CEU_BUFFER_MEMORY_SIZE; + + phys = memblock_alloc_base(size, PAGE_SIZE, MEMBLOCK_ALLOC_ANYWHERE); + memblock_free(phys, size); + memblock_remove(phys, size); + + ceu_dma_membase = phys; +} + /* * The Machine Vector */ static struct sh_machine_vector mv_kfr2r09 __initmv = { .mv_name = "kfr2r09", .mv_mode_pins = kfr2r09_mode_pins, + .mv_mem_reserve = kfr2r09_mv_mem_reserve, }; diff --git a/arch/sh/boards/mach-migor/setup.c b/arch/sh/boards/mach-migor/setup.c index 3d7d0046cf49..254f2c662703 100644 --- a/arch/sh/boards/mach-migor/setup.c +++ b/arch/sh/boards/mach-migor/setup.c @@ -28,7 +28,6 @@ #include <video/sh_mobile_lcdc.h> #include <media/drv-intf/renesas-ceu.h> #include <media/i2c/ov772x.h> -#include <media/soc_camera.h> #include <media/i2c/tw9910.h> #include <asm/clock.h> #include <asm/machvec.h> @@ -351,8 +350,9 @@ static struct platform_device migor_ceu_device = { static struct gpiod_lookup_table ov7725_gpios = { .dev_id = "0-0021", .table = { - GPIO_LOOKUP("sh7722_pfc", GPIO_PTT0, "pwdn", GPIO_ACTIVE_HIGH), - GPIO_LOOKUP("sh7722_pfc", GPIO_PTT3, "rstb", GPIO_ACTIVE_LOW), + GPIO_LOOKUP("sh7722_pfc", GPIO_PTT0, "powerdown", + GPIO_ACTIVE_HIGH), + GPIO_LOOKUP("sh7722_pfc", GPIO_PTT3, "reset", GPIO_ACTIVE_LOW), }, }; @@ -592,7 +592,7 @@ static int __init migor_devices_setup(void) } /* Add a clock alias for ov7725 xclk source. */ - clk_add_alias("xclk", "0-0021", "video_clk", NULL); + clk_add_alias(NULL, "0-0021", "video_clk", NULL); /* Register GPIOs for video sources. */ gpiod_add_lookup_table(&ov7725_gpios); diff --git a/arch/sh/boards/mach-se/7724/setup.c b/arch/sh/boards/mach-se/7724/setup.c index 255952555656..fdbec22ae687 100644 --- a/arch/sh/boards/mach-se/7724/setup.c +++ b/arch/sh/boards/mach-se/7724/setup.c @@ -1,43 +1,49 @@ +// SPDX-License-Identifier: GPL-2.0 /* * linux/arch/sh/boards/se/7724/setup.c * * Copyright (C) 2009 Renesas Solutions Corp. * * Kuninori Morimoto <morimoto.kuninori@renesas.com> - * - * This file is subject to the terms and conditions of the GNU General Public - * License. See the file "COPYING" in the main directory of this archive - * for more details. */ +#include <asm/clock.h> +#include <asm/heartbeat.h> +#include <asm/io.h> +#include <asm/suspend.h> -#include <linux/init.h> +#include <cpu/sh7724.h> + +#include <linux/delay.h> #include <linux/device.h> +#include <linux/gpio.h> +#include <linux/init.h> +#include <linux/input.h> +#include <linux/input/sh_keysc.h> #include <linux/interrupt.h> -#include <linux/platform_device.h> -#include <linux/mmc/host.h> +#include <linux/memblock.h> #include <linux/mfd/tmio.h> +#include <linux/mmc/host.h> #include <linux/mtd/physmap.h> -#include <linux/delay.h> +#include <linux/platform_device.h> #include <linux/regulator/fixed.h> #include <linux/regulator/machine.h> -#include <linux/smc91x.h> -#include <linux/gpio.h> -#include <linux/input.h> -#include <linux/input/sh_keysc.h> -#include <linux/usb/r8a66597.h> #include <linux/sh_eth.h> #include <linux/sh_intc.h> +#include <linux/smc91x.h> +#include <linux/usb/r8a66597.h> #include <linux/videodev2.h> -#include <video/sh_mobile_lcdc.h> -#include <media/drv-intf/sh_mobile_ceu.h> + +#include <mach-se/mach/se7724.h> +#include <media/drv-intf/renesas-ceu.h> + #include <sound/sh_fsi.h> #include <sound/simple_card.h> -#include <asm/io.h> -#include <asm/heartbeat.h> -#include <asm/clock.h> -#include <asm/suspend.h> -#include <cpu/sh7724.h> -#include <mach-se/mach/se7724.h> + +#include <video/sh_mobile_lcdc.h> + +#define CEU_BUFFER_MEMORY_SIZE (4 << 20) +static phys_addr_t ceu0_dma_membase; +static phys_addr_t ceu1_dma_membase; /* * SWx 1234 5678 @@ -216,8 +222,8 @@ static struct platform_device lcdc_device = { }; /* CEU0 */ -static struct sh_mobile_ceu_info sh_mobile_ceu0_info = { - .flags = SH_CEU_FLAG_USE_8BIT_BUS, +static struct ceu_platform_data ceu0_pdata = { + .num_subdevs = 0, }; static struct resource ceu0_resources[] = { @@ -231,24 +237,21 @@ static struct resource ceu0_resources[] = { .start = evt2irq(0x880), .flags = IORESOURCE_IRQ, }, - [2] = { - /* place holder for contiguous memory */ - }, }; static struct platform_device ceu0_device = { - .name = "sh_mobile_ceu", - .id = 0, /* "ceu0" clock */ + .name = "renesas-ceu", + .id = 0, /* "ceu.0" clock */ .num_resources = ARRAY_SIZE(ceu0_resources), .resource = ceu0_resources, .dev = { - .platform_data = &sh_mobile_ceu0_info, + .platform_data = &ceu0_pdata, }, }; /* CEU1 */ -static struct sh_mobile_ceu_info sh_mobile_ceu1_info = { - .flags = SH_CEU_FLAG_USE_8BIT_BUS, +static struct ceu_platform_data ceu1_pdata = { + .num_subdevs = 0, }; static struct resource ceu1_resources[] = { @@ -262,18 +265,15 @@ static struct resource ceu1_resources[] = { .start = evt2irq(0x9e0), .flags = IORESOURCE_IRQ, }, - [2] = { - /* place holder for contiguous memory */ - }, }; static struct platform_device ceu1_device = { - .name = "sh_mobile_ceu", - .id = 1, /* "ceu1" clock */ + .name = "renesas-ceu", + .id = 1, /* "ceu.1" clock */ .num_resources = ARRAY_SIZE(ceu1_resources), .resource = ceu1_resources, .dev = { - .platform_data = &sh_mobile_ceu1_info, + .platform_data = &ceu1_pdata, }, }; @@ -574,13 +574,16 @@ static struct platform_device vou_device = { }, }; +static struct platform_device *ms7724se_ceu_devices[] __initdata = { + &ceu0_device, + &ceu1_device, +}; + static struct platform_device *ms7724se_devices[] __initdata = { &heartbeat_device, &smc91x_eth_device, &lcdc_device, &nor_flash_device, - &ceu0_device, - &ceu1_device, &keysc_device, &sh_eth_device, &sh7724_usb0_host_device, @@ -797,7 +800,6 @@ static int __init devices_setup(void) gpio_request(GPIO_FN_VIO0_CLK, NULL); gpio_request(GPIO_FN_VIO0_FLD, NULL); gpio_request(GPIO_FN_VIO0_HD, NULL); - platform_resource_setup_memory(&ceu0_device, "ceu0", 4 << 20); /* enable CEU1 */ gpio_request(GPIO_FN_VIO1_D7, NULL); @@ -812,7 +814,6 @@ static int __init devices_setup(void) gpio_request(GPIO_FN_VIO1_HD, NULL); gpio_request(GPIO_FN_VIO1_VD, NULL); gpio_request(GPIO_FN_VIO1_CLK, NULL); - platform_resource_setup_memory(&ceu1_device, "ceu1", 4 << 20); /* KEYSC */ gpio_request(GPIO_FN_KEYOUT5_IN5, NULL); @@ -934,12 +935,49 @@ static int __init devices_setup(void) gpio_request(GPIO_FN_DV_VSYNC, NULL); gpio_request(GPIO_FN_DV_HSYNC, NULL); + /* Initialize CEU platform devices separately to map memory first */ + device_initialize(&ms7724se_ceu_devices[0]->dev); + arch_setup_pdev_archdata(ms7724se_ceu_devices[0]); + dma_declare_coherent_memory(&ms7724se_ceu_devices[0]->dev, + ceu0_dma_membase, ceu0_dma_membase, + ceu0_dma_membase + + CEU_BUFFER_MEMORY_SIZE - 1, + DMA_MEMORY_EXCLUSIVE); + platform_device_add(ms7724se_ceu_devices[0]); + + device_initialize(&ms7724se_ceu_devices[1]->dev); + arch_setup_pdev_archdata(ms7724se_ceu_devices[1]); + dma_declare_coherent_memory(&ms7724se_ceu_devices[1]->dev, + ceu1_dma_membase, ceu1_dma_membase, + ceu1_dma_membase + + CEU_BUFFER_MEMORY_SIZE - 1, + DMA_MEMORY_EXCLUSIVE); + platform_device_add(ms7724se_ceu_devices[1]); + return platform_add_devices(ms7724se_devices, ARRAY_SIZE(ms7724se_devices)); } device_initcall(devices_setup); +/* Reserve a portion of memory for CEU 0 and CEU 1 buffers */ +static void __init ms7724se_mv_mem_reserve(void) +{ + phys_addr_t phys; + phys_addr_t size = CEU_BUFFER_MEMORY_SIZE; + + phys = memblock_alloc_base(size, PAGE_SIZE, MEMBLOCK_ALLOC_ANYWHERE); + memblock_free(phys, size); + memblock_remove(phys, size); + ceu0_dma_membase = phys; + + phys = memblock_alloc_base(size, PAGE_SIZE, MEMBLOCK_ALLOC_ANYWHERE); + memblock_free(phys, size); + memblock_remove(phys, size); + ceu1_dma_membase = phys; +} + static struct sh_machine_vector mv_ms7724se __initmv = { .mv_name = "ms7724se", .mv_init_irq = init_se7724_IRQ, + .mv_mem_reserve = ms7724se_mv_mem_reserve, }; diff --git a/arch/sh/boards/of-generic.c b/arch/sh/boards/of-generic.c index 46b2481eec90..26789ad28193 100644 --- a/arch/sh/boards/of-generic.c +++ b/arch/sh/boards/of-generic.c @@ -56,15 +56,15 @@ const struct of_cpu_method __cpu_method_of_table_sentinel static void sh_of_smp_probe(void) { - struct device_node *np = 0; - const char *method = 0; + struct device_node *np; + const char *method = NULL; const struct of_cpu_method *m = __cpu_method_of_table; pr_info("SH generic board support: scanning for cpus\n"); init_cpu_possible(cpumask_of(0)); - while ((np = of_find_node_by_type(np, "cpu"))) { + for_each_node_by_type(np, "cpu") { const __be32 *cell = of_get_property(np, "reg", NULL); u64 id = -1; if (cell) id = of_read_number(cell, of_n_addr_cells(np)); @@ -80,6 +80,7 @@ static void sh_of_smp_probe(void) if (!method) { np = of_find_node_by_name(NULL, "cpus"); of_property_read_string(np, "enable-method", &method); + of_node_put(np); } pr_info("CPU enable method: %s\n", method); |