1 // SPDX-License-Identifier: GPL-2.0
3 * ALPHAPROJECT AP-SH4A-3A Support.
5 * Copyright (C) 2010 ALPHAPROJECT Co.,Ltd.
6 * Copyright (C) 2008 Yoshihiro Shimoda
7 * Copyright (C) 2009 Paul Mundt
9 #include <linux/init.h>
10 #include <linux/platform_device.h>
12 #include <linux/mtd/physmap.h>
13 #include <linux/regulator/fixed.h>
14 #include <linux/regulator/machine.h>
15 #include <linux/smsc911x.h>
16 #include <linux/irq.h>
17 #include <linux/clk.h>
18 #include <asm/machvec.h>
19 #include <linux/sizes.h>
20 #include <asm/clock.h>
22 static struct mtd_partition nor_flash_partitions[] = {
30 .offset = MTDPART_OFS_APPEND,
35 .offset = MTDPART_OFS_APPEND,
36 .size = 4 * 1024 * 1024,
40 .offset = MTDPART_OFS_APPEND,
41 .size = MTDPART_SIZ_FULL,
45 static struct physmap_flash_data nor_flash_data = {
47 .parts = nor_flash_partitions,
48 .nr_parts = ARRAY_SIZE(nor_flash_partitions),
51 static struct resource nor_flash_resources[] = {
54 .end = 0x01000000 - 1,
55 .flags = IORESOURCE_MEM,
59 static struct platform_device nor_flash_device = {
60 .name = "physmap-flash",
62 .platform_data = &nor_flash_data,
64 .num_resources = ARRAY_SIZE(nor_flash_resources),
65 .resource = nor_flash_resources,
68 /* Dummy supplies, where voltage doesn't matter */
69 static struct regulator_consumer_supply dummy_supplies[] = {
70 REGULATOR_SUPPLY("vddvario", "smsc911x"),
71 REGULATOR_SUPPLY("vdd33a", "smsc911x"),
74 static struct resource smsc911x_resources[] = {
76 .name = "smsc911x-memory",
78 .end = 0xA4000000 + SZ_256 - 1,
79 .flags = IORESOURCE_MEM,
82 .name = "smsc911x-irq",
83 .start = evt2irq(0x200),
84 .end = evt2irq(0x200),
85 .flags = IORESOURCE_IRQ,
89 static struct smsc911x_platform_config smsc911x_config = {
90 .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
91 .irq_type = SMSC911X_IRQ_TYPE_OPEN_DRAIN,
92 .flags = SMSC911X_USE_16BIT,
93 .phy_interface = PHY_INTERFACE_MODE_MII,
96 static struct platform_device smsc911x_device = {
99 .num_resources = ARRAY_SIZE(smsc911x_resources),
100 .resource = smsc911x_resources,
102 .platform_data = &smsc911x_config,
106 static struct platform_device *apsh4a3a_devices[] __initdata = {
111 static int __init apsh4a3a_devices_setup(void)
113 regulator_register_fixed(0, dummy_supplies, ARRAY_SIZE(dummy_supplies));
115 return platform_add_devices(apsh4a3a_devices,
116 ARRAY_SIZE(apsh4a3a_devices));
118 device_initcall(apsh4a3a_devices_setup);
120 static int apsh4a3a_clk_init(void)
125 clk = clk_get(NULL, "extal");
128 ret = clk_set_rate(clk, 33333000);
134 /* Initialize the board */
135 static void __init apsh4a3a_setup(char **cmdline_p)
137 printk(KERN_INFO "Alpha Project AP-SH4A-3A support:\n");
140 static void __init apsh4a3a_init_irq(void)
142 plat_irq_setup_pins(IRQ_MODE_IRQ7654);
145 /* Return the board specific boot mode pin configuration */
146 static int apsh4a3a_mode_pins(void)
150 /* These are the factory default settings of SW1 and SW2.
151 * If you change these dip switches then you will need to
152 * adjust the values below as well.
154 value &= ~MODE_PIN0; /* Clock Mode 16 */
159 value &= ~MODE_PIN5; /* 16-bit Area0 bus width */
160 value |= MODE_PIN6; /* Area 0 SRAM interface */
162 value |= MODE_PIN8; /* Little Endian */
163 value |= MODE_PIN9; /* Master Mode */
164 value |= MODE_PIN10; /* Crystal resonator */
165 value |= MODE_PIN11; /* Display Unit */
167 value &= ~MODE_PIN13; /* 29-bit address mode */
168 value |= MODE_PIN14; /* No PLL step-up */
176 static struct sh_machine_vector mv_apsh4a3a __initmv = {
177 .mv_name = "AP-SH4A-3A",
178 .mv_setup = apsh4a3a_setup,
179 .mv_clk_init = apsh4a3a_clk_init,
180 .mv_init_irq = apsh4a3a_init_irq,
181 .mv_mode_pins = apsh4a3a_mode_pins,