2018-05-28 12:37:10 -04:00
// SPDX-License-Identifier: GPL-2.0
2009-05-26 07:04:52 +00:00
/*
* linux / arch / sh / boards / se / 7724 / setup . c
*
* Copyright ( C ) 2009 Renesas Solutions Corp .
*
* Kuninori Morimoto < morimoto . kuninori @ renesas . com >
*/
2018-05-28 12:37:10 -04:00
# include <asm/clock.h>
# include <asm/heartbeat.h>
# include <asm/io.h>
# include <asm/suspend.h>
2009-05-26 07:04:52 +00:00
2018-05-28 12:37:10 -04:00
# include <cpu/sh7724.h>
# include <linux/delay.h>
2009-05-26 07:04:52 +00:00
# include <linux/device.h>
2018-05-28 12:37:10 -04:00
# include <linux/gpio.h>
# include <linux/init.h>
# include <linux/input.h>
# include <linux/input/sh_keysc.h>
2009-05-26 07:04:52 +00:00
# include <linux/interrupt.h>
2018-05-28 12:37:10 -04:00
# include <linux/memblock.h>
2015-02-24 02:07:07 +00:00
# include <linux/mfd/tmio.h>
2018-05-28 12:37:10 -04:00
# include <linux/mmc/host.h>
2009-05-26 07:04:52 +00:00
# include <linux/mtd/physmap.h>
2018-05-28 12:37:10 -04:00
# include <linux/platform_device.h>
2012-06-27 00:50:09 +02:00
# include <linux/regulator/fixed.h>
# include <linux/regulator/machine.h>
2011-09-28 16:49:14 +09:00
# include <linux/sh_eth.h>
2012-05-18 15:34:49 +09:00
# include <linux/sh_intc.h>
2018-05-28 12:37:10 -04:00
# include <linux/smc91x.h>
# include <linux/usb/r8a66597.h>
2012-01-25 22:07:05 +01:00
# include <linux/videodev2.h>
2020-09-22 15:31:03 +02:00
# include <linux/dma-map-ops.h>
2018-05-28 12:37:10 -04:00
# include <mach-se/mach/se7724.h>
# include <media/drv-intf/renesas-ceu.h>
2009-08-21 01:24:54 +00:00
# include <sound/sh_fsi.h>
2012-04-08 21:18:28 -07:00
# include <sound/simple_card.h>
2018-05-28 12:37:10 -04:00
# 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 ;
2009-05-26 07:04:52 +00:00
/*
* SWx 1234 5678
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
* SW31 : 1001 1100 : default
* SW32 : 0111 1111 : use on board flash
*
* SW41 : abxx xxxx - > a = 0 : Analog monitor
* 1 : Digital monitor
* b = 0 : VGA
2009-08-03 04:52:03 +00:00
* 1 : 720 p
*/
/*
* about 720 p
*
* When you use 1280 x 720 lcdc output ,
* you should change OSC6 lcdc clock from 25.175 MHz to 74.25 MHz ,
* and change SW41 to use 720 p
2009-05-26 07:04:52 +00:00
*/
2010-03-16 02:01:53 +00:00
/*
* about sound
*
* This setup . c supports FSI slave mode .
* Please change J20 , J21 , J22 pin to 1 - 2 connection .
*/
2009-05-26 07:04:52 +00:00
/* Heartbeat */
2010-01-15 12:24:34 +09:00
static struct resource heartbeat_resource = {
. start = PA_LED ,
. end = PA_LED ,
. flags = IORESOURCE_MEM | IORESOURCE_MEM_16BIT ,
2009-05-26 07:04:52 +00:00
} ;
static struct platform_device heartbeat_device = {
. name = " heartbeat " ,
. id = - 1 ,
2010-01-15 12:24:34 +09:00
. num_resources = 1 ,
. resource = & heartbeat_resource ,
2009-05-26 07:04:52 +00:00
} ;
/* LAN91C111 */
static struct smc91x_platdata smc91x_info = {
. flags = SMC91X_USE_16BIT | SMC91X_NOWAIT ,
} ;
static struct resource smc91x_eth_resources [ ] = {
[ 0 ] = {
. name = " SMC91C111 " ,
. start = 0x1a300300 ,
. end = 0x1a30030f ,
. flags = IORESOURCE_MEM ,
} ,
[ 1 ] = {
. start = IRQ0_SMC ,
. flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL ,
} ,
} ;
static struct platform_device smc91x_eth_device = {
. name = " smc91x " ,
. num_resources = ARRAY_SIZE ( smc91x_eth_resources ) ,
. resource = smc91x_eth_resources ,
. dev = {
. platform_data = & smc91x_info ,
} ,
} ;
/* MTD */
static struct mtd_partition nor_flash_partitions [ ] = {
{
. name = " uboot " ,
. offset = 0 ,
. size = ( 1 * 1024 * 1024 ) ,
. mask_flags = MTD_WRITEABLE , /* Read-only */
} , {
. name = " kernel " ,
. offset = MTDPART_OFS_APPEND ,
. size = ( 2 * 1024 * 1024 ) ,
} , {
. name = " free-area " ,
. offset = MTDPART_OFS_APPEND ,
. size = MTDPART_SIZ_FULL ,
} ,
} ;
static struct physmap_flash_data nor_flash_data = {
. width = 2 ,
. parts = nor_flash_partitions ,
. nr_parts = ARRAY_SIZE ( nor_flash_partitions ) ,
} ;
static struct resource nor_flash_resources [ ] = {
[ 0 ] = {
. name = " NOR Flash " ,
. start = 0x00000000 ,
. end = 0x01ffffff ,
. flags = IORESOURCE_MEM ,
}
} ;
static struct platform_device nor_flash_device = {
. name = " physmap-flash " ,
. resource = nor_flash_resources ,
. num_resources = ARRAY_SIZE ( nor_flash_resources ) ,
. dev = {
. platform_data = & nor_flash_data ,
} ,
} ;
/* LCDC */
2011-07-09 23:16:22 +02:00
static const struct fb_videomode lcdc_720p_modes [ ] = {
2010-09-03 07:20:04 +00:00
{
. name = " LB070WV1 " ,
. sync = 0 , /* hsync and vsync are active low */
2010-10-03 04:24:42 +00:00
. xres = 1280 ,
. yres = 720 ,
. left_margin = 220 ,
. right_margin = 110 ,
. hsync_len = 40 ,
. upper_margin = 20 ,
. lower_margin = 5 ,
. vsync_len = 5 ,
2010-09-03 07:20:04 +00:00
} ,
} ;
2011-07-09 23:16:22 +02:00
static const struct fb_videomode lcdc_vga_modes [ ] = {
2010-09-03 07:20:04 +00:00
{
. name = " LB070WV1 " ,
. sync = 0 , /* hsync and vsync are active low */
2010-10-03 04:24:42 +00:00
. xres = 640 ,
. yres = 480 ,
. left_margin = 105 ,
. right_margin = 50 ,
. hsync_len = 96 ,
. upper_margin = 33 ,
. lower_margin = 10 ,
. vsync_len = 2 ,
2010-09-03 07:20:04 +00:00
} ,
} ;
2009-05-26 07:04:52 +00:00
static struct sh_mobile_lcdc_info lcdc_info = {
. clock_source = LCDC_CLK_EXTERNAL ,
. ch [ 0 ] = {
. chan = LCDC_CHAN_MAINLCD ,
2011-12-13 14:02:28 +01:00
. fourcc = V4L2_PIX_FMT_RGB565 ,
2009-05-26 07:04:52 +00:00
. clock_divider = 1 ,
2011-09-11 22:59:04 +02:00
. panel_cfg = { /* 7.0 inch */
2009-05-26 07:04:52 +00:00
. width = 152 ,
. height = 91 ,
} ,
}
} ;
static struct resource lcdc_resources [ ] = {
[ 0 ] = {
. name = " LCDC " ,
. start = 0xfe940000 ,
2009-09-15 12:00:30 +00:00
. end = 0xfe942fff ,
2009-05-26 07:04:52 +00:00
. flags = IORESOURCE_MEM ,
} ,
[ 1 ] = {
2012-05-18 15:34:49 +09:00
. start = evt2irq ( 0xf40 ) ,
2009-05-26 07:04:52 +00:00
. flags = IORESOURCE_IRQ ,
} ,
} ;
static struct platform_device lcdc_device = {
. name = " sh_mobile_lcdc_fb " ,
. num_resources = ARRAY_SIZE ( lcdc_resources ) ,
. resource = lcdc_resources ,
. dev = {
. platform_data = & lcdc_info ,
} ,
} ;
/* CEU0 */
2018-05-28 12:37:10 -04:00
static struct ceu_platform_data ceu0_pdata = {
. num_subdevs = 0 ,
2009-05-26 07:04:52 +00:00
} ;
static struct resource ceu0_resources [ ] = {
[ 0 ] = {
. name = " CEU0 " ,
. start = 0xfe910000 ,
. end = 0xfe91009f ,
. flags = IORESOURCE_MEM ,
} ,
[ 1 ] = {
2012-05-18 15:34:49 +09:00
. start = evt2irq ( 0x880 ) ,
2009-05-26 07:04:52 +00:00
. flags = IORESOURCE_IRQ ,
} ,
} ;
static struct platform_device ceu0_device = {
2018-05-28 12:37:10 -04:00
. name = " renesas-ceu " ,
. id = 0 , /* "ceu.0" clock */
2009-05-26 07:04:52 +00:00
. num_resources = ARRAY_SIZE ( ceu0_resources ) ,
. resource = ceu0_resources ,
. dev = {
2018-05-28 12:37:10 -04:00
. platform_data = & ceu0_pdata ,
2009-05-26 07:04:52 +00:00
} ,
} ;
/* CEU1 */
2018-05-28 12:37:10 -04:00
static struct ceu_platform_data ceu1_pdata = {
. num_subdevs = 0 ,
2009-05-26 07:04:52 +00:00
} ;
static struct resource ceu1_resources [ ] = {
[ 0 ] = {
. name = " CEU1 " ,
. start = 0xfe914000 ,
. end = 0xfe91409f ,
. flags = IORESOURCE_MEM ,
} ,
[ 1 ] = {
2012-05-18 15:34:49 +09:00
. start = evt2irq ( 0x9e0 ) ,
2009-05-26 07:04:52 +00:00
. flags = IORESOURCE_IRQ ,
} ,
} ;
static struct platform_device ceu1_device = {
2018-05-28 12:37:10 -04:00
. name = " renesas-ceu " ,
. id = 1 , /* "ceu.1" clock */
2009-05-26 07:04:52 +00:00
. num_resources = ARRAY_SIZE ( ceu1_resources ) ,
. resource = ceu1_resources ,
. dev = {
2018-05-28 12:37:10 -04:00
. platform_data = & ceu1_pdata ,
2009-05-26 07:04:52 +00:00
} ,
} ;
2009-08-21 01:24:54 +00:00
/* FSI */
2010-03-16 02:01:53 +00:00
/* change J20, J21, J22 pin to 1-2 connection to use slave mode */
2009-08-21 01:24:54 +00:00
static struct resource fsi_resources [ ] = {
[ 0 ] = {
. name = " FSI " ,
. start = 0xFE3C0000 ,
. end = 0xFE3C021d ,
. flags = IORESOURCE_MEM ,
} ,
[ 1 ] = {
2012-05-18 15:34:49 +09:00
. start = evt2irq ( 0xf80 ) ,
2009-08-21 01:24:54 +00:00
. flags = IORESOURCE_IRQ ,
} ,
} ;
static struct platform_device fsi_device = {
. name = " sh_fsi " ,
. id = 0 ,
. num_resources = ARRAY_SIZE ( fsi_resources ) ,
. resource = fsi_resources ,
} ;
2012-04-08 21:18:28 -07:00
static struct asoc_simple_card_info fsi_ak4642_info = {
2011-11-23 16:55:34 -08:00
. name = " AK4642 " ,
. card = " FSIA-AK4642 " ,
. codec = " ak4642-codec.0-0012 " ,
. platform = " sh_fsi.0 " ,
2021-09-15 18:23:02 +01:00
. daifmt = SND_SOC_DAIFMT_LEFT_J | SND_SOC_DAIFMT_CBP_CFP ,
2013-01-10 16:49:11 -08:00
. cpu_dai = {
. name = " fsia-dai " ,
} ,
. codec_dai = {
. name = " ak4642-hifi " ,
. sysclk = 11289600 ,
} ,
2011-11-23 16:55:34 -08:00
} ;
2010-11-30 11:32:04 +09:00
static struct platform_device fsi_ak4642_device = {
2012-04-08 21:18:28 -07:00
. name = " asoc-simple-card " ,
2011-11-23 16:55:34 -08:00
. dev = {
. platform_data = & fsi_ak4642_info ,
} ,
2010-11-30 11:32:04 +09:00
} ;
2009-08-15 02:53:34 +00:00
/* KEYSC in SoC (Needs SW33-2 set to ON) */
2009-05-26 07:04:52 +00:00
static struct sh_keysc_info keysc_info = {
. mode = SH_KEYSC_MODE_1 ,
2010-02-24 00:16:47 +00:00
. scan_timing = 3 ,
2009-05-26 07:04:52 +00:00
. delay = 50 ,
. keycodes = {
KEY_1 , KEY_2 , KEY_3 , KEY_4 , KEY_5 ,
KEY_6 , KEY_7 , KEY_8 , KEY_9 , KEY_A ,
KEY_B , KEY_C , KEY_D , KEY_E , KEY_F ,
KEY_G , KEY_H , KEY_I , KEY_K , KEY_L ,
KEY_M , KEY_N , KEY_O , KEY_P , KEY_Q ,
KEY_R , KEY_S , KEY_T , KEY_U , KEY_V ,
} ,
} ;
static struct resource keysc_resources [ ] = {
[ 0 ] = {
2009-08-15 02:53:34 +00:00
. name = " KEYSC " ,
. start = 0x044b0000 ,
. end = 0x044b000f ,
2009-05-26 07:04:52 +00:00
. flags = IORESOURCE_MEM ,
} ,
[ 1 ] = {
2012-05-18 15:34:49 +09:00
. start = evt2irq ( 0xbe0 ) ,
2009-05-26 07:04:52 +00:00
. flags = IORESOURCE_IRQ ,
} ,
} ;
static struct platform_device keysc_device = {
. name = " sh_keysc " ,
. id = 0 , /* "keysc0" clock */
. num_resources = ARRAY_SIZE ( keysc_resources ) ,
. resource = keysc_resources ,
. dev = {
. platform_data = & keysc_info ,
} ,
} ;
2009-06-26 07:05:39 +00:00
/* SH Eth */
static struct resource sh_eth_resources [ ] = {
[ 0 ] = {
. start = SH_ETH_ADDR ,
2013-08-18 02:19:09 +04:00
. end = SH_ETH_ADDR + 0x1FC - 1 ,
2009-06-26 07:05:39 +00:00
. flags = IORESOURCE_MEM ,
} ,
[ 1 ] = {
2012-05-18 15:34:49 +09:00
. start = evt2irq ( 0xd60 ) ,
2009-06-26 07:05:39 +00:00
. flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL ,
} ,
} ;
2010-06-02 00:27:38 +00:00
static struct sh_eth_plat_data sh_eth_plat = {
2009-06-26 07:05:39 +00:00
. phy = 0x1f , /* SMSC LAN8187 */
2013-08-22 02:18:30 +04:00
. phy_interface = PHY_INTERFACE_MODE_MII ,
2009-06-26 07:05:39 +00:00
} ;
static struct platform_device sh_eth_device = {
2013-06-07 14:03:37 +00:00
. name = " sh7724-ether " ,
. id = 0 ,
2009-06-26 07:05:39 +00:00
. dev = {
. platform_data = & sh_eth_plat ,
} ,
. num_resources = ARRAY_SIZE ( sh_eth_resources ) ,
. resource = sh_eth_resources ,
} ;
2009-07-03 09:40:03 +00:00
static struct r8a66597_platdata sh7724_usb0_host_data = {
2009-07-17 14:59:55 +00:00
. on_chip = 1 ,
2009-07-03 09:40:03 +00:00
} ;
static struct resource sh7724_usb0_host_resources [ ] = {
[ 0 ] = {
. start = 0xa4d80000 ,
2009-08-19 00:12:15 +00:00
. end = 0xa4d80124 - 1 ,
2009-07-03 09:40:03 +00:00
. flags = IORESOURCE_MEM ,
} ,
[ 1 ] = {
2012-05-18 15:34:49 +09:00
. start = evt2irq ( 0xa20 ) ,
. end = evt2irq ( 0xa20 ) ,
2009-07-03 09:40:03 +00:00
. flags = IORESOURCE_IRQ | IRQF_TRIGGER_LOW ,
} ,
} ;
static struct platform_device sh7724_usb0_host_device = {
. name = " r8a66597_hcd " ,
. id = 0 ,
. dev = {
. dma_mask = NULL , /* not use dma */
. coherent_dma_mask = 0xffffffff ,
. platform_data = & sh7724_usb0_host_data ,
} ,
. num_resources = ARRAY_SIZE ( sh7724_usb0_host_resources ) ,
. resource = sh7724_usb0_host_resources ,
} ;
2009-08-19 09:52:02 +00:00
static struct r8a66597_platdata sh7724_usb1_gadget_data = {
. on_chip = 1 ,
} ;
static struct resource sh7724_usb1_gadget_resources [ ] = {
[ 0 ] = {
. start = 0xa4d90000 ,
. end = 0xa4d90123 ,
. flags = IORESOURCE_MEM ,
} ,
[ 1 ] = {
2012-05-18 15:34:49 +09:00
. start = evt2irq ( 0xa40 ) ,
. end = evt2irq ( 0xa40 ) ,
2009-08-19 09:52:02 +00:00
. flags = IORESOURCE_IRQ | IRQF_TRIGGER_LOW ,
} ,
} ;
static struct platform_device sh7724_usb1_gadget_device = {
. name = " r8a66597_udc " ,
. id = 1 , /* USB1 */
. dev = {
. dma_mask = NULL , /* not use dma */
. coherent_dma_mask = 0xffffffff ,
. platform_data = & sh7724_usb1_gadget_data ,
} ,
. num_resources = ARRAY_SIZE ( sh7724_usb1_gadget_resources ) ,
. resource = sh7724_usb1_gadget_resources ,
} ;
2012-06-27 00:50:09 +02:00
/* Fixed 3.3V regulator to be used by SDHI0, SDHI1 */
static struct regulator_consumer_supply fixed3v3_power_consumers [ ] =
{
REGULATOR_SUPPLY ( " vmmc " , " sh_mobile_sdhi.0 " ) ,
REGULATOR_SUPPLY ( " vqmmc " , " sh_mobile_sdhi.0 " ) ,
REGULATOR_SUPPLY ( " vmmc " , " sh_mobile_sdhi.1 " ) ,
REGULATOR_SUPPLY ( " vqmmc " , " sh_mobile_sdhi.1 " ) ,
} ;
2009-10-02 02:23:07 +00:00
static struct resource sdhi0_cn7_resources [ ] = {
[ 0 ] = {
. name = " SDHI0 " ,
. start = 0x04ce0000 ,
2011-03-09 13:42:42 +01:00
. end = 0x04ce00ff ,
2009-10-02 02:23:07 +00:00
. flags = IORESOURCE_MEM ,
} ,
[ 1 ] = {
2012-05-18 15:34:49 +09:00
. start = evt2irq ( 0xe80 ) ,
2009-10-02 02:23:07 +00:00
. flags = IORESOURCE_IRQ ,
} ,
} ;
2015-02-24 02:07:07 +00:00
static struct tmio_mmc_data sh7724_sdhi0_data = {
. chan_priv_tx = ( void * ) SHDMA_SLAVE_SDHI0_TX ,
. chan_priv_rx = ( void * ) SHDMA_SLAVE_SDHI0_RX ,
. capabilities = MMC_CAP_SDIO_IRQ ,
2010-05-19 18:34:32 +00:00
} ;
2009-10-02 02:23:07 +00:00
static struct platform_device sdhi0_cn7_device = {
. name = " sh_mobile_sdhi " ,
2009-10-27 10:49:55 +00:00
. id = 0 ,
2009-10-02 02:23:07 +00:00
. num_resources = ARRAY_SIZE ( sdhi0_cn7_resources ) ,
. resource = sdhi0_cn7_resources ,
2010-05-19 18:34:32 +00:00
. dev = {
. platform_data = & sh7724_sdhi0_data ,
} ,
2009-10-02 02:23:07 +00:00
} ;
2009-10-27 10:49:55 +00:00
static struct resource sdhi1_cn8_resources [ ] = {
[ 0 ] = {
. name = " SDHI1 " ,
. start = 0x04cf0000 ,
2011-03-09 13:42:42 +01:00
. end = 0x04cf00ff ,
2009-10-27 10:49:55 +00:00
. flags = IORESOURCE_MEM ,
} ,
[ 1 ] = {
2012-05-18 15:34:49 +09:00
. start = evt2irq ( 0x4e0 ) ,
2009-10-27 10:49:55 +00:00
. flags = IORESOURCE_IRQ ,
} ,
} ;
2015-02-24 02:07:07 +00:00
static struct tmio_mmc_data sh7724_sdhi1_data = {
. chan_priv_tx = ( void * ) SHDMA_SLAVE_SDHI1_TX ,
. chan_priv_rx = ( void * ) SHDMA_SLAVE_SDHI1_RX ,
. capabilities = MMC_CAP_SDIO_IRQ ,
2010-05-19 18:34:32 +00:00
} ;
2009-10-27 10:49:55 +00:00
static struct platform_device sdhi1_cn8_device = {
. name = " sh_mobile_sdhi " ,
. id = 1 ,
. num_resources = ARRAY_SIZE ( sdhi1_cn8_resources ) ,
. resource = sdhi1_cn8_resources ,
2010-05-19 18:34:32 +00:00
. dev = {
. platform_data = & sh7724_sdhi1_data ,
} ,
2009-10-27 10:49:55 +00:00
} ;
2010-02-23 08:19:14 +00:00
/* IrDA */
static struct resource irda_resources [ ] = {
[ 0 ] = {
. name = " IrDA " ,
. start = 0xA45D0000 ,
. end = 0xA45D0049 ,
. flags = IORESOURCE_MEM ,
} ,
[ 1 ] = {
2012-05-18 15:34:49 +09:00
. start = evt2irq ( 0x480 ) ,
2010-02-23 08:19:14 +00:00
. flags = IORESOURCE_IRQ ,
} ,
} ;
static struct platform_device irda_device = {
. name = " sh_sir " ,
. num_resources = ARRAY_SIZE ( irda_resources ) ,
. resource = irda_resources ,
} ;
2015-11-10 12:01:44 -02:00
# include <media/i2c/ak881x.h>
2015-11-13 19:40:07 -02:00
# include <media/drv-intf/sh_vou.h>
2010-03-29 07:45:28 +00:00
2010-06-02 00:27:38 +00:00
static struct ak881x_pdata ak881x_pdata = {
2010-03-29 07:45:28 +00:00
. flags = AK881X_IF_MODE_SLAVE ,
} ;
static struct i2c_board_info ak8813 = {
/* With open J18 jumper address is 0x21 */
I2C_BOARD_INFO ( " ak8813 " , 0x20 ) ,
. platform_data = & ak881x_pdata ,
} ;
2010-06-02 00:27:38 +00:00
static struct sh_vou_pdata sh_vou_pdata = {
2010-03-29 07:45:28 +00:00
. bus_fmt = SH_VOU_BUS_8BIT ,
. flags = SH_VOU_HSYNC_LOW | SH_VOU_VSYNC_LOW ,
. board_info = & ak8813 ,
. i2c_adap = 0 ,
} ;
static struct resource sh_vou_resources [ ] = {
[ 0 ] = {
. start = 0xfe960000 ,
. end = 0xfe962043 ,
. flags = IORESOURCE_MEM ,
} ,
[ 1 ] = {
2012-05-18 15:34:49 +09:00
. start = evt2irq ( 0x8e0 ) ,
2010-03-29 07:45:28 +00:00
. flags = IORESOURCE_IRQ ,
} ,
} ;
static struct platform_device vou_device = {
. name = " sh-vou " ,
. id = - 1 ,
. num_resources = ARRAY_SIZE ( sh_vou_resources ) ,
. resource = sh_vou_resources ,
. dev = {
. platform_data = & sh_vou_pdata ,
} ,
} ;
2018-05-28 12:37:10 -04:00
static struct platform_device * ms7724se_ceu_devices [ ] __initdata = {
& ceu0_device ,
& ceu1_device ,
} ;
2009-05-26 07:04:52 +00:00
static struct platform_device * ms7724se_devices [ ] __initdata = {
& heartbeat_device ,
& smc91x_eth_device ,
& lcdc_device ,
& nor_flash_device ,
& keysc_device ,
2009-06-26 07:05:39 +00:00
& sh_eth_device ,
2009-07-03 09:40:03 +00:00
& sh7724_usb0_host_device ,
2009-08-19 09:52:02 +00:00
& sh7724_usb1_gadget_device ,
2009-08-21 01:24:54 +00:00
& fsi_device ,
2010-11-30 11:32:04 +09:00
& fsi_ak4642_device ,
2009-10-02 02:23:07 +00:00
& sdhi0_cn7_device ,
2009-10-27 10:49:55 +00:00
& sdhi1_cn8_device ,
2010-02-23 08:19:14 +00:00
& irda_device ,
2010-03-29 07:45:28 +00:00
& vou_device ,
2009-05-26 07:04:52 +00:00
} ;
2009-12-15 00:27:57 +00:00
/* I2C device */
static struct i2c_board_info i2c0_devices [ ] = {
{
I2C_BOARD_INFO ( " ak4642 " , 0x12 ) ,
} ,
} ;
2009-06-26 07:05:39 +00:00
# define EEPROM_OP 0xBA206000
# define EEPROM_ADR 0xBA206004
# define EEPROM_DATA 0xBA20600C
# define EEPROM_STAT 0xBA206010
# define EEPROM_STRT 0xBA206014
2012-05-18 15:34:49 +09:00
2009-06-26 07:05:39 +00:00
static int __init sh_eth_is_eeprom_ready ( void )
{
int t = 10000 ;
while ( t - - ) {
2010-01-26 12:58:40 +09:00
if ( ! __raw_readw ( EEPROM_STAT ) )
2009-06-26 07:05:39 +00:00
return 1 ;
2009-12-24 08:31:44 +00:00
udelay ( 1 ) ;
2009-06-26 07:05:39 +00:00
}
printk ( KERN_ERR " ms7724se can not access to eeprom \n " ) ;
return 0 ;
}
static void __init sh_eth_init ( void )
{
int i ;
2009-10-27 10:47:34 +00:00
u16 mac ;
2009-06-26 07:05:39 +00:00
/* check EEPROM status */
if ( ! sh_eth_is_eeprom_ready ( ) )
return ;
/* read MAC addr from EEPROM */
for ( i = 0 ; i < 3 ; i + + ) {
2010-01-26 12:58:40 +09:00
__raw_writew ( 0x0 , EEPROM_OP ) ; /* read */
__raw_writew ( i * 2 , EEPROM_ADR ) ;
__raw_writew ( 0x1 , EEPROM_STRT ) ;
2009-06-26 07:05:39 +00:00
if ( ! sh_eth_is_eeprom_ready ( ) )
return ;
2010-01-26 12:58:40 +09:00
mac = __raw_readw ( EEPROM_DATA ) ;
2009-10-27 10:47:34 +00:00
sh_eth_plat . mac_addr [ i < < 1 ] = mac & 0xff ;
sh_eth_plat . mac_addr [ ( i < < 1 ) + 1 ] = mac > > 8 ;
2009-06-26 07:05:39 +00:00
}
}
2009-05-26 07:04:52 +00:00
# define SW4140 0xBA201000
# define FPGA_OUT 0xBA200400
# define PORT_HIZA 0xA4050158
2009-07-03 09:40:03 +00:00
# define PORT_MSELCRB 0xA4050182
2009-05-26 07:04:52 +00:00
# define SW41_A 0x0100
# define SW41_B 0x0200
# define SW41_C 0x0400
# define SW41_D 0x0800
# define SW41_E 0x1000
# define SW41_F 0x2000
# define SW41_G 0x4000
# define SW41_H 0x8000
2009-07-03 09:40:03 +00:00
2009-10-29 10:52:23 +00:00
extern char ms7724se_sdram_enter_start ;
extern char ms7724se_sdram_enter_end ;
extern char ms7724se_sdram_leave_start ;
extern char ms7724se_sdram_leave_end ;
2009-12-15 00:27:57 +00:00
static int __init arch_setup ( void )
{
/* enable I2C device */
i2c_register_board_info ( 0 , i2c0_devices ,
ARRAY_SIZE ( i2c0_devices ) ) ;
return 0 ;
}
arch_initcall ( arch_setup ) ;
2009-05-26 07:04:52 +00:00
static int __init devices_setup ( void )
{
2010-01-26 12:58:40 +09:00
u16 sw = __raw_readw ( SW4140 ) ; /* select camera, monitor */
2010-02-22 05:18:10 +00:00
struct clk * clk ;
2010-03-29 07:45:28 +00:00
u16 fpga_out ;
2009-05-26 07:04:52 +00:00
2009-10-29 10:52:23 +00:00
/* register board specific self-refresh code */
2010-02-25 11:06:02 +00:00
sh_mobile_register_self_refresh ( SUSP_SH_STANDBY | SUSP_SH_SF |
SUSP_SH_RSTANDBY ,
2009-10-29 10:52:23 +00:00
& ms7724se_sdram_enter_start ,
& ms7724se_sdram_enter_end ,
& ms7724se_sdram_leave_start ,
& ms7724se_sdram_leave_end ) ;
2012-06-27 00:50:09 +02:00
regulator_register_always_on ( 0 , " fixed-3.3V " , fixed3v3_power_consumers ,
ARRAY_SIZE ( fixed3v3_power_consumers ) , 3300000 ) ;
2009-05-26 07:04:52 +00:00
/* Reset Release */
2010-03-29 07:45:28 +00:00
fpga_out = __raw_readw ( FPGA_OUT ) ;
/* bit4: NTSC_PDN, bit5: NTSC_RESET */
fpga_out & = ~ ( ( 1 < < 1 ) | /* LAN */
( 1 < < 4 ) | /* AK8813 PDN */
( 1 < < 5 ) | /* AK8813 RESET */
( 1 < < 6 ) | /* VIDEO DAC */
( 1 < < 7 ) | /* AK4643 */
( 1 < < 8 ) | /* IrDA */
( 1 < < 12 ) | /* USB0 */
( 1 < < 14 ) ) ; /* RMII */
__raw_writew ( fpga_out | ( 1 < < 4 ) , FPGA_OUT ) ;
udelay ( 10 ) ;
/* AK8813 RESET */
__raw_writew ( fpga_out | ( 1 < < 5 ) , FPGA_OUT ) ;
udelay ( 10 ) ;
__raw_writew ( fpga_out , FPGA_OUT ) ;
2009-05-26 07:04:52 +00:00
2009-07-03 09:40:03 +00:00
/* turn on USB clocks, use external clock */
2010-01-26 12:58:40 +09:00
__raw_writew ( ( __raw_readw ( PORT_MSELCRB ) & ~ 0xc000 ) | 0x8000 , PORT_MSELCRB ) ;
2009-07-03 09:40:03 +00:00
2009-08-06 15:03:43 +00:00
/* Let LED9 show STATUS2 */
gpio_request ( GPIO_FN_STATUS2 , NULL ) ;
/* Lit LED10 show STATUS0 */
gpio_request ( GPIO_FN_STATUS0 , NULL ) ;
/* Lit LED11 show PDSTATUS */
gpio_request ( GPIO_FN_PDSTATUS , NULL ) ;
2009-07-03 09:40:03 +00:00
/* enable USB0 port */
2010-01-26 12:58:40 +09:00
__raw_writew ( 0x0600 , 0xa40501d4 ) ;
2009-07-03 09:40:03 +00:00
2009-08-19 09:52:02 +00:00
/* enable USB1 port */
2010-01-26 12:58:40 +09:00
__raw_writew ( 0x0600 , 0xa4050192 ) ;
2009-08-19 09:52:02 +00:00
2009-05-26 07:04:52 +00:00
/* enable IRQ 0,1,2 */
gpio_request ( GPIO_FN_INTC_IRQ0 , NULL ) ;
gpio_request ( GPIO_FN_INTC_IRQ1 , NULL ) ;
gpio_request ( GPIO_FN_INTC_IRQ2 , NULL ) ;
/* enable SCIFA3 */
gpio_request ( GPIO_FN_SCIF3_I_SCK , NULL ) ;
gpio_request ( GPIO_FN_SCIF3_I_RXD , NULL ) ;
gpio_request ( GPIO_FN_SCIF3_I_TXD , NULL ) ;
gpio_request ( GPIO_FN_SCIF3_I_CTS , NULL ) ;
gpio_request ( GPIO_FN_SCIF3_I_RTS , NULL ) ;
/* enable LCDC */
gpio_request ( GPIO_FN_LCDD23 , NULL ) ;
gpio_request ( GPIO_FN_LCDD22 , NULL ) ;
gpio_request ( GPIO_FN_LCDD21 , NULL ) ;
gpio_request ( GPIO_FN_LCDD20 , NULL ) ;
gpio_request ( GPIO_FN_LCDD19 , NULL ) ;
gpio_request ( GPIO_FN_LCDD18 , NULL ) ;
gpio_request ( GPIO_FN_LCDD17 , NULL ) ;
gpio_request ( GPIO_FN_LCDD16 , NULL ) ;
gpio_request ( GPIO_FN_LCDD15 , NULL ) ;
gpio_request ( GPIO_FN_LCDD14 , NULL ) ;
gpio_request ( GPIO_FN_LCDD13 , NULL ) ;
gpio_request ( GPIO_FN_LCDD12 , NULL ) ;
gpio_request ( GPIO_FN_LCDD11 , NULL ) ;
gpio_request ( GPIO_FN_LCDD10 , NULL ) ;
gpio_request ( GPIO_FN_LCDD9 , NULL ) ;
gpio_request ( GPIO_FN_LCDD8 , NULL ) ;
gpio_request ( GPIO_FN_LCDD7 , NULL ) ;
gpio_request ( GPIO_FN_LCDD6 , NULL ) ;
gpio_request ( GPIO_FN_LCDD5 , NULL ) ;
gpio_request ( GPIO_FN_LCDD4 , NULL ) ;
gpio_request ( GPIO_FN_LCDD3 , NULL ) ;
gpio_request ( GPIO_FN_LCDD2 , NULL ) ;
gpio_request ( GPIO_FN_LCDD1 , NULL ) ;
gpio_request ( GPIO_FN_LCDD0 , NULL ) ;
gpio_request ( GPIO_FN_LCDDISP , NULL ) ;
gpio_request ( GPIO_FN_LCDHSYN , NULL ) ;
gpio_request ( GPIO_FN_LCDDCK , NULL ) ;
gpio_request ( GPIO_FN_LCDVSYN , NULL ) ;
gpio_request ( GPIO_FN_LCDDON , NULL ) ;
gpio_request ( GPIO_FN_LCDVEPWC , NULL ) ;
gpio_request ( GPIO_FN_LCDVCPWC , NULL ) ;
gpio_request ( GPIO_FN_LCDRD , NULL ) ;
gpio_request ( GPIO_FN_LCDLCLK , NULL ) ;
2010-01-26 12:58:40 +09:00
__raw_writew ( ( __raw_readw ( PORT_HIZA ) & ~ 0x0001 ) , PORT_HIZA ) ;
2009-05-26 07:04:52 +00:00
/* enable CEU0 */
gpio_request ( GPIO_FN_VIO0_D15 , NULL ) ;
gpio_request ( GPIO_FN_VIO0_D14 , NULL ) ;
gpio_request ( GPIO_FN_VIO0_D13 , NULL ) ;
gpio_request ( GPIO_FN_VIO0_D12 , NULL ) ;
gpio_request ( GPIO_FN_VIO0_D11 , NULL ) ;
gpio_request ( GPIO_FN_VIO0_D10 , NULL ) ;
gpio_request ( GPIO_FN_VIO0_D9 , NULL ) ;
gpio_request ( GPIO_FN_VIO0_D8 , NULL ) ;
gpio_request ( GPIO_FN_VIO0_D7 , NULL ) ;
gpio_request ( GPIO_FN_VIO0_D6 , NULL ) ;
gpio_request ( GPIO_FN_VIO0_D5 , NULL ) ;
gpio_request ( GPIO_FN_VIO0_D4 , NULL ) ;
gpio_request ( GPIO_FN_VIO0_D3 , NULL ) ;
gpio_request ( GPIO_FN_VIO0_D2 , NULL ) ;
gpio_request ( GPIO_FN_VIO0_D1 , NULL ) ;
gpio_request ( GPIO_FN_VIO0_D0 , NULL ) ;
gpio_request ( GPIO_FN_VIO0_VD , NULL ) ;
gpio_request ( GPIO_FN_VIO0_CLK , NULL ) ;
gpio_request ( GPIO_FN_VIO0_FLD , NULL ) ;
gpio_request ( GPIO_FN_VIO0_HD , NULL ) ;
/* enable CEU1 */
gpio_request ( GPIO_FN_VIO1_D7 , NULL ) ;
gpio_request ( GPIO_FN_VIO1_D6 , NULL ) ;
gpio_request ( GPIO_FN_VIO1_D5 , NULL ) ;
gpio_request ( GPIO_FN_VIO1_D4 , NULL ) ;
gpio_request ( GPIO_FN_VIO1_D3 , NULL ) ;
gpio_request ( GPIO_FN_VIO1_D2 , NULL ) ;
gpio_request ( GPIO_FN_VIO1_D1 , NULL ) ;
gpio_request ( GPIO_FN_VIO1_D0 , NULL ) ;
gpio_request ( GPIO_FN_VIO1_FLD , NULL ) ;
gpio_request ( GPIO_FN_VIO1_HD , NULL ) ;
gpio_request ( GPIO_FN_VIO1_VD , NULL ) ;
gpio_request ( GPIO_FN_VIO1_CLK , NULL ) ;
/* KEYSC */
gpio_request ( GPIO_FN_KEYOUT5_IN5 , NULL ) ;
gpio_request ( GPIO_FN_KEYOUT4_IN6 , NULL ) ;
gpio_request ( GPIO_FN_KEYIN4 , NULL ) ;
gpio_request ( GPIO_FN_KEYIN3 , NULL ) ;
gpio_request ( GPIO_FN_KEYIN2 , NULL ) ;
gpio_request ( GPIO_FN_KEYIN1 , NULL ) ;
gpio_request ( GPIO_FN_KEYIN0 , NULL ) ;
gpio_request ( GPIO_FN_KEYOUT3 , NULL ) ;
gpio_request ( GPIO_FN_KEYOUT2 , NULL ) ;
gpio_request ( GPIO_FN_KEYOUT1 , NULL ) ;
gpio_request ( GPIO_FN_KEYOUT0 , NULL ) ;
2009-08-21 01:24:54 +00:00
/* enable FSI */
gpio_request ( GPIO_FN_FSIMCKA , NULL ) ;
2010-12-03 05:37:54 +00:00
gpio_request ( GPIO_FN_FSIIASD , NULL ) ;
2009-08-21 01:24:54 +00:00
gpio_request ( GPIO_FN_FSIOASD , NULL ) ;
gpio_request ( GPIO_FN_FSIIABCK , NULL ) ;
gpio_request ( GPIO_FN_FSIIALRCK , NULL ) ;
gpio_request ( GPIO_FN_FSIOABCK , NULL ) ;
gpio_request ( GPIO_FN_FSIOALRCK , NULL ) ;
gpio_request ( GPIO_FN_CLKAUDIOAO , NULL ) ;
2010-02-22 05:18:10 +00:00
/* set SPU2 clock to 83.4 MHz */
clk = clk_get ( NULL , " spu_clk " ) ;
2010-11-26 17:06:28 +00:00
if ( ! IS_ERR ( clk ) ) {
2010-05-13 01:08:37 +00:00
clk_set_rate ( clk , clk_round_rate ( clk , 83333333 ) ) ;
clk_put ( clk ) ;
}
2010-02-22 05:18:10 +00:00
2009-08-21 01:24:54 +00:00
/* change parent of FSI A */
2010-02-22 05:18:10 +00:00
clk = clk_get ( NULL , " fsia_clk " ) ;
2010-11-26 17:06:28 +00:00
if ( ! IS_ERR ( clk ) ) {
2010-12-03 05:37:53 +00:00
/* 48kHz dummy clock was used to make sure 1/1 divide */
clk_set_rate ( & sh7724_fsimcka_clk , 48000 ) ;
clk_set_parent ( clk , & sh7724_fsimcka_clk ) ;
clk_set_rate ( clk , 48000 ) ;
2010-05-13 01:08:37 +00:00
clk_put ( clk ) ;
}
2009-08-21 01:24:54 +00:00
2009-10-02 02:23:07 +00:00
/* SDHI0 connected to cn7 */
gpio_request ( GPIO_FN_SDHI0CD , NULL ) ;
gpio_request ( GPIO_FN_SDHI0WP , NULL ) ;
gpio_request ( GPIO_FN_SDHI0D3 , NULL ) ;
gpio_request ( GPIO_FN_SDHI0D2 , NULL ) ;
gpio_request ( GPIO_FN_SDHI0D1 , NULL ) ;
gpio_request ( GPIO_FN_SDHI0D0 , NULL ) ;
gpio_request ( GPIO_FN_SDHI0CMD , NULL ) ;
gpio_request ( GPIO_FN_SDHI0CLK , NULL ) ;
2009-10-27 10:49:55 +00:00
/* SDHI1 connected to cn8 */
gpio_request ( GPIO_FN_SDHI1CD , NULL ) ;
gpio_request ( GPIO_FN_SDHI1WP , NULL ) ;
gpio_request ( GPIO_FN_SDHI1D3 , NULL ) ;
gpio_request ( GPIO_FN_SDHI1D2 , NULL ) ;
gpio_request ( GPIO_FN_SDHI1D1 , NULL ) ;
gpio_request ( GPIO_FN_SDHI1D0 , NULL ) ;
gpio_request ( GPIO_FN_SDHI1CMD , NULL ) ;
gpio_request ( GPIO_FN_SDHI1CLK , NULL ) ;
2010-02-23 08:19:14 +00:00
/* enable IrDA */
gpio_request ( GPIO_FN_IRDA_OUT , NULL ) ;
gpio_request ( GPIO_FN_IRDA_IN , NULL ) ;
2009-06-26 07:05:39 +00:00
/*
* enable SH - Eth
*
* please remove J33 pin from your board ! !
*
* ms7724 board should not use GPIO_FN_LNKSTA pin
* So , This time PTX5 is set to input pin
*/
gpio_request ( GPIO_FN_RMII_RXD0 , NULL ) ;
gpio_request ( GPIO_FN_RMII_RXD1 , NULL ) ;
gpio_request ( GPIO_FN_RMII_TXD0 , NULL ) ;
gpio_request ( GPIO_FN_RMII_TXD1 , NULL ) ;
gpio_request ( GPIO_FN_RMII_REF_CLK , NULL ) ;
gpio_request ( GPIO_FN_RMII_TX_EN , NULL ) ;
gpio_request ( GPIO_FN_RMII_RX_ER , NULL ) ;
gpio_request ( GPIO_FN_RMII_CRS_DV , NULL ) ;
gpio_request ( GPIO_FN_MDIO , NULL ) ;
gpio_request ( GPIO_FN_MDC , NULL ) ;
gpio_request ( GPIO_PTX5 , NULL ) ;
gpio_direction_input ( GPIO_PTX5 ) ;
sh_eth_init ( ) ;
2009-05-26 07:04:52 +00:00
if ( sw & SW41_B ) {
2009-08-03 04:52:03 +00:00
/* 720p */
2011-11-29 14:33:41 +01:00
lcdc_info . ch [ 0 ] . lcd_modes = lcdc_720p_modes ;
lcdc_info . ch [ 0 ] . num_modes = ARRAY_SIZE ( lcdc_720p_modes ) ;
2009-05-26 07:04:52 +00:00
} else {
/* VGA */
2011-11-29 14:33:41 +01:00
lcdc_info . ch [ 0 ] . lcd_modes = lcdc_vga_modes ;
lcdc_info . ch [ 0 ] . num_modes = ARRAY_SIZE ( lcdc_vga_modes ) ;
2009-05-26 07:04:52 +00:00
}
if ( sw & SW41_A ) {
/* Digital monitor */
lcdc_info . ch [ 0 ] . interface_type = RGB18 ;
lcdc_info . ch [ 0 ] . flags = 0 ;
} else {
/* Analog monitor */
lcdc_info . ch [ 0 ] . interface_type = RGB24 ;
lcdc_info . ch [ 0 ] . flags = LCDC_FLAGS_DWPOL ;
}
2010-03-29 07:45:28 +00:00
/* VOU */
gpio_request ( GPIO_FN_DV_D15 , NULL ) ;
gpio_request ( GPIO_FN_DV_D14 , NULL ) ;
gpio_request ( GPIO_FN_DV_D13 , NULL ) ;
gpio_request ( GPIO_FN_DV_D12 , NULL ) ;
gpio_request ( GPIO_FN_DV_D11 , NULL ) ;
gpio_request ( GPIO_FN_DV_D10 , NULL ) ;
gpio_request ( GPIO_FN_DV_D9 , NULL ) ;
gpio_request ( GPIO_FN_DV_D8 , NULL ) ;
gpio_request ( GPIO_FN_DV_CLKI , NULL ) ;
gpio_request ( GPIO_FN_DV_CLK , NULL ) ;
gpio_request ( GPIO_FN_DV_VSYNC , NULL ) ;
gpio_request ( GPIO_FN_DV_HSYNC , NULL ) ;
2018-05-28 12:37:10 -04:00
/* Initialize CEU platform devices separately to map memory first */
device_initialize ( & ms7724se_ceu_devices [ 0 ] - > dev ) ;
dma_declare_coherent_memory ( & ms7724se_ceu_devices [ 0 ] - > dev ,
ceu0_dma_membase , ceu0_dma_membase ,
ceu0_dma_membase +
2018-12-25 13:29:54 +01:00
CEU_BUFFER_MEMORY_SIZE - 1 ) ;
2018-05-28 12:37:10 -04:00
platform_device_add ( ms7724se_ceu_devices [ 0 ] ) ;
device_initialize ( & ms7724se_ceu_devices [ 1 ] - > dev ) ;
dma_declare_coherent_memory ( & ms7724se_ceu_devices [ 1 ] - > dev ,
ceu1_dma_membase , ceu1_dma_membase ,
ceu1_dma_membase +
2018-12-25 13:29:54 +01:00
CEU_BUFFER_MEMORY_SIZE - 1 ) ;
2018-05-28 12:37:10 -04:00
platform_device_add ( ms7724se_ceu_devices [ 1 ] ) ;
2009-05-26 07:04:52 +00:00
return platform_add_devices ( ms7724se_devices ,
2009-06-26 07:05:39 +00:00
ARRAY_SIZE ( ms7724se_devices ) ) ;
2009-05-26 07:04:52 +00:00
}
device_initcall ( devices_setup ) ;
2018-05-28 12:37:10 -04:00
/* 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 ;
2019-03-11 23:29:06 -07:00
phys = memblock_phys_alloc ( size , PAGE_SIZE ) ;
2019-03-11 23:29:26 -07:00
if ( ! phys )
panic ( " Failed to allocate CEU0 memory \n " ) ;
2021-11-05 13:43:19 -07:00
memblock_phys_free ( phys , size ) ;
2018-05-28 12:37:10 -04:00
memblock_remove ( phys , size ) ;
ceu0_dma_membase = phys ;
2019-03-11 23:29:06 -07:00
phys = memblock_phys_alloc ( size , PAGE_SIZE ) ;
2019-03-11 23:29:26 -07:00
if ( ! phys )
panic ( " Failed to allocate CEU1 memory \n " ) ;
2021-11-05 13:43:19 -07:00
memblock_phys_free ( phys , size ) ;
2018-05-28 12:37:10 -04:00
memblock_remove ( phys , size ) ;
ceu1_dma_membase = phys ;
}
2009-05-26 07:04:52 +00:00
static struct sh_machine_vector mv_ms7724se __initmv = {
. mv_name = " ms7724se " ,
. mv_init_irq = init_se7724_IRQ ,
2018-05-28 12:37:10 -04:00
. mv_mem_reserve = ms7724se_mv_mem_reserve ,
2009-05-26 07:04:52 +00:00
} ;