xref: /openbmc/linux/arch/sh/boards/board-apsh4a3a.c (revision 87dfb311)
1aaf9128aSKuninori Morimoto // SPDX-License-Identifier: GPL-2.0
2bc34b085SPaul Mundt /*
3bc34b085SPaul Mundt  * ALPHAPROJECT AP-SH4A-3A Support.
4bc34b085SPaul Mundt  *
5bc34b085SPaul Mundt  * Copyright (C) 2010 ALPHAPROJECT Co.,Ltd.
6bc34b085SPaul Mundt  * Copyright (C) 2008  Yoshihiro Shimoda
7bc34b085SPaul Mundt  * Copyright (C) 2009  Paul Mundt
8bc34b085SPaul Mundt  */
9bc34b085SPaul Mundt #include <linux/init.h>
10bc34b085SPaul Mundt #include <linux/platform_device.h>
11bc34b085SPaul Mundt #include <linux/io.h>
12bc34b085SPaul Mundt #include <linux/mtd/physmap.h>
13920f5500SGuennadi Liakhovetski #include <linux/regulator/fixed.h>
14920f5500SGuennadi Liakhovetski #include <linux/regulator/machine.h>
15bc34b085SPaul Mundt #include <linux/smsc911x.h>
16bc34b085SPaul Mundt #include <linux/irq.h>
17bc34b085SPaul Mundt #include <linux/clk.h>
18bc34b085SPaul Mundt #include <asm/machvec.h>
1987dfb311SMasahiro Yamada #include <linux/sizes.h>
20bc34b085SPaul Mundt #include <asm/clock.h>
21bc34b085SPaul Mundt 
22bc34b085SPaul Mundt static struct mtd_partition nor_flash_partitions[] = {
23bc34b085SPaul Mundt 	{
24bc34b085SPaul Mundt 		.name		= "loader",
25bc34b085SPaul Mundt 		.offset		= 0x00000000,
26bc34b085SPaul Mundt 		.size		= 512 * 1024,
27bc34b085SPaul Mundt 	},
28bc34b085SPaul Mundt 	{
29bc34b085SPaul Mundt 		.name		= "bootenv",
30bc34b085SPaul Mundt 		.offset		= MTDPART_OFS_APPEND,
31bc34b085SPaul Mundt 		.size		= 512 * 1024,
32bc34b085SPaul Mundt 	},
33bc34b085SPaul Mundt 	{
34bc34b085SPaul Mundt 		.name		= "kernel",
35bc34b085SPaul Mundt 		.offset		= MTDPART_OFS_APPEND,
36bc34b085SPaul Mundt 		.size		= 4 * 1024 * 1024,
37bc34b085SPaul Mundt 	},
38bc34b085SPaul Mundt 	{
39bc34b085SPaul Mundt 		.name		= "data",
40bc34b085SPaul Mundt 		.offset		= MTDPART_OFS_APPEND,
41bc34b085SPaul Mundt 		.size		= MTDPART_SIZ_FULL,
42bc34b085SPaul Mundt 	},
43bc34b085SPaul Mundt };
44bc34b085SPaul Mundt 
45bc34b085SPaul Mundt static struct physmap_flash_data nor_flash_data = {
46bc34b085SPaul Mundt 	.width		= 4,
47bc34b085SPaul Mundt 	.parts		= nor_flash_partitions,
48bc34b085SPaul Mundt 	.nr_parts	= ARRAY_SIZE(nor_flash_partitions),
49bc34b085SPaul Mundt };
50bc34b085SPaul Mundt 
51bc34b085SPaul Mundt static struct resource nor_flash_resources[] = {
52bc34b085SPaul Mundt 	[0]	= {
53bc34b085SPaul Mundt 		.start	= 0x00000000,
54bc34b085SPaul Mundt 		.end	= 0x01000000 - 1,
55bc34b085SPaul Mundt 		.flags	= IORESOURCE_MEM,
56bc34b085SPaul Mundt 	}
57bc34b085SPaul Mundt };
58bc34b085SPaul Mundt 
59bc34b085SPaul Mundt static struct platform_device nor_flash_device = {
60bc34b085SPaul Mundt 	.name		= "physmap-flash",
61bc34b085SPaul Mundt 	.dev		= {
62bc34b085SPaul Mundt 		.platform_data	= &nor_flash_data,
63bc34b085SPaul Mundt 	},
64bc34b085SPaul Mundt 	.num_resources	= ARRAY_SIZE(nor_flash_resources),
65bc34b085SPaul Mundt 	.resource	= nor_flash_resources,
66bc34b085SPaul Mundt };
67bc34b085SPaul Mundt 
68920f5500SGuennadi Liakhovetski /* Dummy supplies, where voltage doesn't matter */
69920f5500SGuennadi Liakhovetski static struct regulator_consumer_supply dummy_supplies[] = {
70920f5500SGuennadi Liakhovetski 	REGULATOR_SUPPLY("vddvario", "smsc911x"),
71920f5500SGuennadi Liakhovetski 	REGULATOR_SUPPLY("vdd33a", "smsc911x"),
72920f5500SGuennadi Liakhovetski };
73920f5500SGuennadi Liakhovetski 
74bc34b085SPaul Mundt static struct resource smsc911x_resources[] = {
75bc34b085SPaul Mundt 	[0] = {
76bc34b085SPaul Mundt 		.name		= "smsc911x-memory",
77bc34b085SPaul Mundt 		.start		= 0xA4000000,
78bc34b085SPaul Mundt 		.end		= 0xA4000000 + SZ_256 - 1,
79bc34b085SPaul Mundt 		.flags		= IORESOURCE_MEM,
80bc34b085SPaul Mundt 	},
81bc34b085SPaul Mundt 	[1] = {
82bc34b085SPaul Mundt 		.name		= "smsc911x-irq",
83bc34b085SPaul Mundt 		.start		= evt2irq(0x200),
84bc34b085SPaul Mundt 		.end		= evt2irq(0x200),
85bc34b085SPaul Mundt 		.flags		= IORESOURCE_IRQ,
86bc34b085SPaul Mundt 	},
87bc34b085SPaul Mundt };
88bc34b085SPaul Mundt 
89bc34b085SPaul Mundt static struct smsc911x_platform_config smsc911x_config = {
90bc34b085SPaul Mundt 	.irq_polarity	= SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
91bc34b085SPaul Mundt 	.irq_type	= SMSC911X_IRQ_TYPE_OPEN_DRAIN,
92bc34b085SPaul Mundt 	.flags		= SMSC911X_USE_16BIT,
93bc34b085SPaul Mundt 	.phy_interface	= PHY_INTERFACE_MODE_MII,
94bc34b085SPaul Mundt };
95bc34b085SPaul Mundt 
96bc34b085SPaul Mundt static struct platform_device smsc911x_device = {
97bc34b085SPaul Mundt 	.name		= "smsc911x",
98bc34b085SPaul Mundt 	.id		= -1,
99bc34b085SPaul Mundt 	.num_resources	= ARRAY_SIZE(smsc911x_resources),
100bc34b085SPaul Mundt 	.resource	= smsc911x_resources,
101bc34b085SPaul Mundt 	.dev = {
102bc34b085SPaul Mundt 		.platform_data = &smsc911x_config,
103bc34b085SPaul Mundt 	},
104bc34b085SPaul Mundt };
105bc34b085SPaul Mundt 
106bc34b085SPaul Mundt static struct platform_device *apsh4a3a_devices[] __initdata = {
107bc34b085SPaul Mundt 	&nor_flash_device,
108bc34b085SPaul Mundt 	&smsc911x_device,
109bc34b085SPaul Mundt };
110bc34b085SPaul Mundt 
apsh4a3a_devices_setup(void)111bc34b085SPaul Mundt static int __init apsh4a3a_devices_setup(void)
112bc34b085SPaul Mundt {
113920f5500SGuennadi Liakhovetski 	regulator_register_fixed(0, dummy_supplies, ARRAY_SIZE(dummy_supplies));
114920f5500SGuennadi Liakhovetski 
115bc34b085SPaul Mundt 	return platform_add_devices(apsh4a3a_devices,
116bc34b085SPaul Mundt 				    ARRAY_SIZE(apsh4a3a_devices));
117bc34b085SPaul Mundt }
118bc34b085SPaul Mundt device_initcall(apsh4a3a_devices_setup);
119bc34b085SPaul Mundt 
apsh4a3a_clk_init(void)120bc34b085SPaul Mundt static int apsh4a3a_clk_init(void)
121bc34b085SPaul Mundt {
122bc34b085SPaul Mundt 	struct clk *clk;
123bc34b085SPaul Mundt 	int ret;
124bc34b085SPaul Mundt 
125bc34b085SPaul Mundt 	clk = clk_get(NULL, "extal");
1267912825dSPaul Mundt 	if (IS_ERR(clk))
127bc34b085SPaul Mundt 		return PTR_ERR(clk);
128bc34b085SPaul Mundt 	ret = clk_set_rate(clk, 33333000);
129bc34b085SPaul Mundt 	clk_put(clk);
130bc34b085SPaul Mundt 
131bc34b085SPaul Mundt 	return ret;
132bc34b085SPaul Mundt }
133bc34b085SPaul Mundt 
134bc34b085SPaul Mundt /* Initialize the board */
apsh4a3a_setup(char ** cmdline_p)135bc34b085SPaul Mundt static void __init apsh4a3a_setup(char **cmdline_p)
136bc34b085SPaul Mundt {
137bc34b085SPaul Mundt 	printk(KERN_INFO "Alpha Project AP-SH4A-3A support:\n");
138bc34b085SPaul Mundt }
139bc34b085SPaul Mundt 
apsh4a3a_init_irq(void)140bc34b085SPaul Mundt static void __init apsh4a3a_init_irq(void)
141bc34b085SPaul Mundt {
142bc34b085SPaul Mundt 	plat_irq_setup_pins(IRQ_MODE_IRQ7654);
143bc34b085SPaul Mundt }
144bc34b085SPaul Mundt 
145bc34b085SPaul Mundt /* Return the board specific boot mode pin configuration */
apsh4a3a_mode_pins(void)146bc34b085SPaul Mundt static int apsh4a3a_mode_pins(void)
147bc34b085SPaul Mundt {
148bc34b085SPaul Mundt 	int value = 0;
149bc34b085SPaul Mundt 
150bc34b085SPaul Mundt 	/* These are the factory default settings of SW1 and SW2.
151bc34b085SPaul Mundt 	 * If you change these dip switches then you will need to
152bc34b085SPaul Mundt 	 * adjust the values below as well.
153bc34b085SPaul Mundt 	 */
154bc34b085SPaul Mundt 	value &= ~MODE_PIN0;  /* Clock Mode 16 */
155bc34b085SPaul Mundt 	value &= ~MODE_PIN1;
156bc34b085SPaul Mundt 	value &= ~MODE_PIN2;
157bc34b085SPaul Mundt 	value &= ~MODE_PIN3;
158bc34b085SPaul Mundt 	value |=  MODE_PIN4;
159bc34b085SPaul Mundt 	value &= ~MODE_PIN5;  /* 16-bit Area0 bus width */
160bc34b085SPaul Mundt 	value |=  MODE_PIN6;  /* Area 0 SRAM interface */
161bc34b085SPaul Mundt 	value |=  MODE_PIN7;
162bc34b085SPaul Mundt 	value |=  MODE_PIN8;  /* Little Endian */
163bc34b085SPaul Mundt 	value |=  MODE_PIN9;  /* Master Mode */
164bc34b085SPaul Mundt 	value |=  MODE_PIN10; /* Crystal resonator */
165bc34b085SPaul Mundt 	value |=  MODE_PIN11; /* Display Unit */
166bc34b085SPaul Mundt 	value |=  MODE_PIN12;
167bc34b085SPaul Mundt 	value &= ~MODE_PIN13; /* 29-bit address mode */
168bc34b085SPaul Mundt 	value |=  MODE_PIN14; /* No PLL step-up */
169bc34b085SPaul Mundt 
170bc34b085SPaul Mundt 	return value;
171bc34b085SPaul Mundt }
172bc34b085SPaul Mundt 
173bc34b085SPaul Mundt /*
174bc34b085SPaul Mundt  * The Machine Vector
175bc34b085SPaul Mundt  */
176bc34b085SPaul Mundt static struct sh_machine_vector mv_apsh4a3a __initmv = {
177bc34b085SPaul Mundt 	.mv_name		= "AP-SH4A-3A",
178bc34b085SPaul Mundt 	.mv_setup		= apsh4a3a_setup,
179bc34b085SPaul Mundt 	.mv_clk_init		= apsh4a3a_clk_init,
180bc34b085SPaul Mundt 	.mv_init_irq		= apsh4a3a_init_irq,
181bc34b085SPaul Mundt 	.mv_mode_pins		= apsh4a3a_mode_pins,
182bc34b085SPaul Mundt };
183