162306a36Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * arch/sh/boards/superh/microdev/setup.c
462306a36Sopenharmony_ci *
562306a36Sopenharmony_ci * Copyright (C) 2003 Sean McGoogan (Sean.McGoogan@superh.com)
662306a36Sopenharmony_ci * Copyright (C) 2003, 2004 SuperH, Inc.
762306a36Sopenharmony_ci * Copyright (C) 2004, 2005 Paul Mundt
862306a36Sopenharmony_ci *
962306a36Sopenharmony_ci * SuperH SH4-202 MicroDev board support.
1062306a36Sopenharmony_ci */
1162306a36Sopenharmony_ci#include <linux/init.h>
1262306a36Sopenharmony_ci#include <linux/platform_device.h>
1362306a36Sopenharmony_ci#include <linux/ioport.h>
1462306a36Sopenharmony_ci#include <video/s1d13xxxfb.h>
1562306a36Sopenharmony_ci#include <mach/microdev.h>
1662306a36Sopenharmony_ci#include <asm/io.h>
1762306a36Sopenharmony_ci#include <asm/machvec.h>
1862306a36Sopenharmony_ci#include <linux/sizes.h>
1962306a36Sopenharmony_ci
2062306a36Sopenharmony_cistatic struct resource smc91x_resources[] = {
2162306a36Sopenharmony_ci	[0] = {
2262306a36Sopenharmony_ci		.start		= 0x300,
2362306a36Sopenharmony_ci		.end		= 0x300 + SZ_4K - 1,
2462306a36Sopenharmony_ci		.flags		= IORESOURCE_MEM,
2562306a36Sopenharmony_ci	},
2662306a36Sopenharmony_ci	[1] = {
2762306a36Sopenharmony_ci		.start		= MICRODEV_LINUX_IRQ_ETHERNET,
2862306a36Sopenharmony_ci		.end		= MICRODEV_LINUX_IRQ_ETHERNET,
2962306a36Sopenharmony_ci		.flags		= IORESOURCE_IRQ,
3062306a36Sopenharmony_ci	},
3162306a36Sopenharmony_ci};
3262306a36Sopenharmony_ci
3362306a36Sopenharmony_cistatic struct platform_device smc91x_device = {
3462306a36Sopenharmony_ci	.name		= "smc91x",
3562306a36Sopenharmony_ci	.id		= -1,
3662306a36Sopenharmony_ci	.num_resources	= ARRAY_SIZE(smc91x_resources),
3762306a36Sopenharmony_ci	.resource	= smc91x_resources,
3862306a36Sopenharmony_ci};
3962306a36Sopenharmony_ci
4062306a36Sopenharmony_cistatic struct s1d13xxxfb_regval s1d13806_initregs[] = {
4162306a36Sopenharmony_ci	{ S1DREG_MISC,			0x00 },
4262306a36Sopenharmony_ci	{ S1DREG_COM_DISP_MODE,		0x00 },
4362306a36Sopenharmony_ci	{ S1DREG_GPIO_CNF0,		0x00 },
4462306a36Sopenharmony_ci	{ S1DREG_GPIO_CNF1,		0x00 },
4562306a36Sopenharmony_ci	{ S1DREG_GPIO_CTL0,		0x00 },
4662306a36Sopenharmony_ci	{ S1DREG_GPIO_CTL1,		0x00 },
4762306a36Sopenharmony_ci	{ S1DREG_CLK_CNF,		0x02 },
4862306a36Sopenharmony_ci	{ S1DREG_LCD_CLK_CNF,		0x01 },
4962306a36Sopenharmony_ci	{ S1DREG_CRT_CLK_CNF,		0x03 },
5062306a36Sopenharmony_ci	{ S1DREG_MPLUG_CLK_CNF,		0x03 },
5162306a36Sopenharmony_ci	{ S1DREG_CPU2MEM_WST_SEL,	0x02 },
5262306a36Sopenharmony_ci	{ S1DREG_SDRAM_REF_RATE,	0x03 },
5362306a36Sopenharmony_ci	{ S1DREG_SDRAM_TC0,		0x00 },
5462306a36Sopenharmony_ci	{ S1DREG_SDRAM_TC1,		0x01 },
5562306a36Sopenharmony_ci	{ S1DREG_MEM_CNF,		0x80 },
5662306a36Sopenharmony_ci	{ S1DREG_PANEL_TYPE,		0x25 },
5762306a36Sopenharmony_ci	{ S1DREG_MOD_RATE,		0x00 },
5862306a36Sopenharmony_ci	{ S1DREG_LCD_DISP_HWIDTH,	0x63 },
5962306a36Sopenharmony_ci	{ S1DREG_LCD_NDISP_HPER,	0x1e },
6062306a36Sopenharmony_ci	{ S1DREG_TFT_FPLINE_START,	0x06 },
6162306a36Sopenharmony_ci	{ S1DREG_TFT_FPLINE_PWIDTH,	0x03 },
6262306a36Sopenharmony_ci	{ S1DREG_LCD_DISP_VHEIGHT0,	0x57 },
6362306a36Sopenharmony_ci	{ S1DREG_LCD_DISP_VHEIGHT1,	0x02 },
6462306a36Sopenharmony_ci	{ S1DREG_LCD_NDISP_VPER,	0x00 },
6562306a36Sopenharmony_ci	{ S1DREG_TFT_FPFRAME_START,	0x0a },
6662306a36Sopenharmony_ci	{ S1DREG_TFT_FPFRAME_PWIDTH,	0x81 },
6762306a36Sopenharmony_ci	{ S1DREG_LCD_DISP_MODE,		0x03 },
6862306a36Sopenharmony_ci	{ S1DREG_LCD_MISC,		0x00 },
6962306a36Sopenharmony_ci	{ S1DREG_LCD_DISP_START0,	0x00 },
7062306a36Sopenharmony_ci	{ S1DREG_LCD_DISP_START1,	0x00 },
7162306a36Sopenharmony_ci	{ S1DREG_LCD_DISP_START2,	0x00 },
7262306a36Sopenharmony_ci	{ S1DREG_LCD_MEM_OFF0,		0x90 },
7362306a36Sopenharmony_ci	{ S1DREG_LCD_MEM_OFF1,		0x01 },
7462306a36Sopenharmony_ci	{ S1DREG_LCD_PIX_PAN,		0x00 },
7562306a36Sopenharmony_ci	{ S1DREG_LCD_DISP_FIFO_HTC,	0x00 },
7662306a36Sopenharmony_ci	{ S1DREG_LCD_DISP_FIFO_LTC,	0x00 },
7762306a36Sopenharmony_ci	{ S1DREG_CRT_DISP_HWIDTH,	0x63 },
7862306a36Sopenharmony_ci	{ S1DREG_CRT_NDISP_HPER,	0x1f },
7962306a36Sopenharmony_ci	{ S1DREG_CRT_HRTC_START,	0x04 },
8062306a36Sopenharmony_ci	{ S1DREG_CRT_HRTC_PWIDTH,	0x8f },
8162306a36Sopenharmony_ci	{ S1DREG_CRT_DISP_VHEIGHT0,	0x57 },
8262306a36Sopenharmony_ci	{ S1DREG_CRT_DISP_VHEIGHT1,	0x02 },
8362306a36Sopenharmony_ci	{ S1DREG_CRT_NDISP_VPER,	0x1b },
8462306a36Sopenharmony_ci	{ S1DREG_CRT_VRTC_START,	0x00 },
8562306a36Sopenharmony_ci	{ S1DREG_CRT_VRTC_PWIDTH,	0x83 },
8662306a36Sopenharmony_ci	{ S1DREG_TV_OUT_CTL,		0x10 },
8762306a36Sopenharmony_ci	{ S1DREG_CRT_DISP_MODE,		0x05 },
8862306a36Sopenharmony_ci	{ S1DREG_CRT_DISP_START0,	0x00 },
8962306a36Sopenharmony_ci	{ S1DREG_CRT_DISP_START1,	0x00 },
9062306a36Sopenharmony_ci	{ S1DREG_CRT_DISP_START2,	0x00 },
9162306a36Sopenharmony_ci	{ S1DREG_CRT_MEM_OFF0,		0x20 },
9262306a36Sopenharmony_ci	{ S1DREG_CRT_MEM_OFF1,		0x03 },
9362306a36Sopenharmony_ci	{ S1DREG_CRT_PIX_PAN,		0x00 },
9462306a36Sopenharmony_ci	{ S1DREG_CRT_DISP_FIFO_HTC,	0x00 },
9562306a36Sopenharmony_ci	{ S1DREG_CRT_DISP_FIFO_LTC,	0x00 },
9662306a36Sopenharmony_ci	{ S1DREG_LCD_CUR_CTL,		0x00 },
9762306a36Sopenharmony_ci	{ S1DREG_LCD_CUR_START,		0x01 },
9862306a36Sopenharmony_ci	{ S1DREG_LCD_CUR_XPOS0,		0x00 },
9962306a36Sopenharmony_ci	{ S1DREG_LCD_CUR_XPOS1,		0x00 },
10062306a36Sopenharmony_ci	{ S1DREG_LCD_CUR_YPOS0,		0x00 },
10162306a36Sopenharmony_ci	{ S1DREG_LCD_CUR_YPOS1,		0x00 },
10262306a36Sopenharmony_ci	{ S1DREG_LCD_CUR_BCTL0,		0x00 },
10362306a36Sopenharmony_ci	{ S1DREG_LCD_CUR_GCTL0,		0x00 },
10462306a36Sopenharmony_ci	{ S1DREG_LCD_CUR_RCTL0,		0x00 },
10562306a36Sopenharmony_ci	{ S1DREG_LCD_CUR_BCTL1,		0x1f },
10662306a36Sopenharmony_ci	{ S1DREG_LCD_CUR_GCTL1,		0x3f },
10762306a36Sopenharmony_ci	{ S1DREG_LCD_CUR_RCTL1,		0x1f },
10862306a36Sopenharmony_ci	{ S1DREG_LCD_CUR_FIFO_HTC,	0x00 },
10962306a36Sopenharmony_ci	{ S1DREG_CRT_CUR_CTL,		0x00 },
11062306a36Sopenharmony_ci	{ S1DREG_CRT_CUR_START,		0x01 },
11162306a36Sopenharmony_ci	{ S1DREG_CRT_CUR_XPOS0,		0x00 },
11262306a36Sopenharmony_ci	{ S1DREG_CRT_CUR_XPOS1,		0x00 },
11362306a36Sopenharmony_ci	{ S1DREG_CRT_CUR_YPOS0,		0x00 },
11462306a36Sopenharmony_ci	{ S1DREG_CRT_CUR_YPOS1,		0x00 },
11562306a36Sopenharmony_ci	{ S1DREG_CRT_CUR_BCTL0,		0x00 },
11662306a36Sopenharmony_ci	{ S1DREG_CRT_CUR_GCTL0,		0x00 },
11762306a36Sopenharmony_ci	{ S1DREG_CRT_CUR_RCTL0,		0x00 },
11862306a36Sopenharmony_ci	{ S1DREG_CRT_CUR_BCTL1,		0x1f },
11962306a36Sopenharmony_ci	{ S1DREG_CRT_CUR_GCTL1,		0x3f },
12062306a36Sopenharmony_ci	{ S1DREG_CRT_CUR_RCTL1,		0x1f },
12162306a36Sopenharmony_ci	{ S1DREG_CRT_CUR_FIFO_HTC,	0x00 },
12262306a36Sopenharmony_ci	{ S1DREG_BBLT_CTL0,		0x00 },
12362306a36Sopenharmony_ci	{ S1DREG_BBLT_CTL1,		0x00 },
12462306a36Sopenharmony_ci	{ S1DREG_BBLT_CC_EXP,		0x00 },
12562306a36Sopenharmony_ci	{ S1DREG_BBLT_OP,		0x00 },
12662306a36Sopenharmony_ci	{ S1DREG_BBLT_SRC_START0,	0x00 },
12762306a36Sopenharmony_ci	{ S1DREG_BBLT_SRC_START1,	0x00 },
12862306a36Sopenharmony_ci	{ S1DREG_BBLT_SRC_START2,	0x00 },
12962306a36Sopenharmony_ci	{ S1DREG_BBLT_DST_START0,	0x00 },
13062306a36Sopenharmony_ci	{ S1DREG_BBLT_DST_START1,	0x00 },
13162306a36Sopenharmony_ci	{ S1DREG_BBLT_DST_START2,	0x00 },
13262306a36Sopenharmony_ci	{ S1DREG_BBLT_MEM_OFF0,		0x00 },
13362306a36Sopenharmony_ci	{ S1DREG_BBLT_MEM_OFF1,		0x00 },
13462306a36Sopenharmony_ci	{ S1DREG_BBLT_WIDTH0,		0x00 },
13562306a36Sopenharmony_ci	{ S1DREG_BBLT_WIDTH1,		0x00 },
13662306a36Sopenharmony_ci	{ S1DREG_BBLT_HEIGHT0,		0x00 },
13762306a36Sopenharmony_ci	{ S1DREG_BBLT_HEIGHT1,		0x00 },
13862306a36Sopenharmony_ci	{ S1DREG_BBLT_BGC0,		0x00 },
13962306a36Sopenharmony_ci	{ S1DREG_BBLT_BGC1,		0x00 },
14062306a36Sopenharmony_ci	{ S1DREG_BBLT_FGC0,		0x00 },
14162306a36Sopenharmony_ci	{ S1DREG_BBLT_FGC1,		0x00 },
14262306a36Sopenharmony_ci	{ S1DREG_LKUP_MODE,		0x00 },
14362306a36Sopenharmony_ci	{ S1DREG_LKUP_ADDR,		0x00 },
14462306a36Sopenharmony_ci	{ S1DREG_PS_CNF,		0x10 },
14562306a36Sopenharmony_ci	{ S1DREG_PS_STATUS,		0x00 },
14662306a36Sopenharmony_ci	{ S1DREG_CPU2MEM_WDOGT,		0x00 },
14762306a36Sopenharmony_ci	{ S1DREG_COM_DISP_MODE,		0x02 },
14862306a36Sopenharmony_ci};
14962306a36Sopenharmony_ci
15062306a36Sopenharmony_cistatic struct s1d13xxxfb_pdata s1d13806_platform_data = {
15162306a36Sopenharmony_ci	.initregs	= s1d13806_initregs,
15262306a36Sopenharmony_ci	.initregssize	= ARRAY_SIZE(s1d13806_initregs),
15362306a36Sopenharmony_ci};
15462306a36Sopenharmony_ci
15562306a36Sopenharmony_cistatic struct resource s1d13806_resources[] = {
15662306a36Sopenharmony_ci	[0] = {
15762306a36Sopenharmony_ci		.start		= 0x07200000,
15862306a36Sopenharmony_ci		.end		= 0x07200000 + SZ_2M - 1,
15962306a36Sopenharmony_ci		.flags		= IORESOURCE_MEM,
16062306a36Sopenharmony_ci	},
16162306a36Sopenharmony_ci	[1] = {
16262306a36Sopenharmony_ci		.start		= 0x07000000,
16362306a36Sopenharmony_ci		.end		= 0x07000000 + SZ_2M - 1,
16462306a36Sopenharmony_ci		.flags		= IORESOURCE_MEM,
16562306a36Sopenharmony_ci	},
16662306a36Sopenharmony_ci};
16762306a36Sopenharmony_ci
16862306a36Sopenharmony_cistatic struct platform_device s1d13806_device = {
16962306a36Sopenharmony_ci	.name		= "s1d13806fb",
17062306a36Sopenharmony_ci	.id		= -1,
17162306a36Sopenharmony_ci	.num_resources	= ARRAY_SIZE(s1d13806_resources),
17262306a36Sopenharmony_ci	.resource	= s1d13806_resources,
17362306a36Sopenharmony_ci
17462306a36Sopenharmony_ci	.dev = {
17562306a36Sopenharmony_ci		.platform_data	= &s1d13806_platform_data,
17662306a36Sopenharmony_ci	},
17762306a36Sopenharmony_ci};
17862306a36Sopenharmony_ci
17962306a36Sopenharmony_cistatic struct platform_device *microdev_devices[] __initdata = {
18062306a36Sopenharmony_ci	&smc91x_device,
18162306a36Sopenharmony_ci	&s1d13806_device,
18262306a36Sopenharmony_ci};
18362306a36Sopenharmony_ci
18462306a36Sopenharmony_cistatic int __init microdev_devices_setup(void)
18562306a36Sopenharmony_ci{
18662306a36Sopenharmony_ci	return platform_add_devices(microdev_devices, ARRAY_SIZE(microdev_devices));
18762306a36Sopenharmony_ci}
18862306a36Sopenharmony_cidevice_initcall(microdev_devices_setup);
18962306a36Sopenharmony_ci
19062306a36Sopenharmony_ci/*
19162306a36Sopenharmony_ci * The Machine Vector
19262306a36Sopenharmony_ci */
19362306a36Sopenharmony_cistatic struct sh_machine_vector mv_sh4202_microdev __initmv = {
19462306a36Sopenharmony_ci	.mv_name		= "SH4-202 MicroDev",
19562306a36Sopenharmony_ci	.mv_ioport_map		= microdev_ioport_map,
19662306a36Sopenharmony_ci	.mv_init_irq		= init_microdev_irq,
19762306a36Sopenharmony_ci};
198