Magnus Damm | 78ded16 | 2013-03-29 17:00:02 +0900 | [diff] [blame] | 1 | /* |
| 2 | * APE6EVM board support |
| 3 | * |
| 4 | * Copyright (C) 2013 Renesas Solutions Corp. |
| 5 | * Copyright (C) 2013 Magnus Damm |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; version 2 of the License. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software |
| 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 19 | */ |
| 20 | |
Magnus Damm | 15351a7a | 2013-03-29 17:00:21 +0900 | [diff] [blame] | 21 | #include <linux/gpio.h> |
Magnus Damm | 78ded16 | 2013-03-29 17:00:02 +0900 | [diff] [blame] | 22 | #include <linux/interrupt.h> |
Magnus Damm | 78ded16 | 2013-03-29 17:00:02 +0900 | [diff] [blame] | 23 | #include <linux/kernel.h> |
Guennadi Liakhovetski | 8711613 | 2013-07-10 10:13:08 +0200 | [diff] [blame^] | 24 | #include <linux/mmc/host.h> |
| 25 | #include <linux/mmc/sh_mmcif.h> |
Magnus Damm | 2c56055 | 2013-03-29 17:00:12 +0900 | [diff] [blame] | 26 | #include <linux/pinctrl/machine.h> |
Magnus Damm | 78ded16 | 2013-03-29 17:00:02 +0900 | [diff] [blame] | 27 | #include <linux/platform_device.h> |
Magnus Damm | 15351a7a | 2013-03-29 17:00:21 +0900 | [diff] [blame] | 28 | #include <linux/regulator/fixed.h> |
| 29 | #include <linux/regulator/machine.h> |
Kuninori Morimoto | b8568a0 | 2013-04-04 21:24:27 -0700 | [diff] [blame] | 30 | #include <linux/sh_clk.h> |
Magnus Damm | 15351a7a | 2013-03-29 17:00:21 +0900 | [diff] [blame] | 31 | #include <linux/smsc911x.h> |
Magnus Damm | 78ded16 | 2013-03-29 17:00:02 +0900 | [diff] [blame] | 32 | #include <mach/common.h> |
Magnus Damm | 15351a7a | 2013-03-29 17:00:21 +0900 | [diff] [blame] | 33 | #include <mach/irqs.h> |
Magnus Damm | 78ded16 | 2013-03-29 17:00:02 +0900 | [diff] [blame] | 34 | #include <mach/r8a73a4.h> |
| 35 | #include <asm/mach-types.h> |
| 36 | #include <asm/mach/arch.h> |
| 37 | |
Magnus Damm | 15351a7a | 2013-03-29 17:00:21 +0900 | [diff] [blame] | 38 | /* Dummy supplies, where voltage doesn't matter */ |
| 39 | static struct regulator_consumer_supply dummy_supplies[] = { |
| 40 | REGULATOR_SUPPLY("vddvario", "smsc911x"), |
| 41 | REGULATOR_SUPPLY("vdd33a", "smsc911x"), |
| 42 | }; |
| 43 | |
| 44 | /* SMSC LAN9220 */ |
| 45 | static const struct resource lan9220_res[] = { |
| 46 | DEFINE_RES_MEM(0x08000000, 0x1000), |
| 47 | { |
| 48 | .start = irq_pin(40), /* IRQ40 */ |
| 49 | .flags = IORESOURCE_IRQ | IRQF_TRIGGER_HIGH, |
| 50 | }, |
| 51 | }; |
| 52 | |
| 53 | static const struct smsc911x_platform_config lan9220_data = { |
| 54 | .flags = SMSC911X_USE_32BIT, |
| 55 | .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL, |
| 56 | .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_HIGH, |
| 57 | }; |
| 58 | |
Guennadi Liakhovetski | 8711613 | 2013-07-10 10:13:08 +0200 | [diff] [blame^] | 59 | /* |
| 60 | * On APE6EVM power is supplied to MMCIF by a tps80032 regulator. For now we |
| 61 | * model a VDD supply to MMCIF, using a fixed 3.3V regulator. |
| 62 | */ |
| 63 | static struct regulator_consumer_supply fixed3v3_power_consumers[] = |
| 64 | { |
| 65 | REGULATOR_SUPPLY("vmmc", "sh_mmcif.0"), |
| 66 | }; |
| 67 | |
| 68 | /* MMCIF */ |
| 69 | static struct sh_mmcif_plat_data mmcif0_pdata = { |
| 70 | .caps = MMC_CAP_8_BIT_DATA | MMC_CAP_NONREMOVABLE, |
| 71 | }; |
| 72 | |
| 73 | static struct resource mmcif0_resources[] = { |
| 74 | DEFINE_RES_MEM_NAMED(0xee200000, 0x100, "MMCIF0"), |
| 75 | DEFINE_RES_IRQ(gic_spi(169)), |
| 76 | }; |
| 77 | |
Magnus Damm | 2c56055 | 2013-03-29 17:00:12 +0900 | [diff] [blame] | 78 | static const struct pinctrl_map ape6evm_pinctrl_map[] = { |
| 79 | /* SCIFA0 console */ |
| 80 | PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.0", "pfc-r8a73a4", |
| 81 | "scifa0_data", "scifa0"), |
Magnus Damm | 15351a7a | 2013-03-29 17:00:21 +0900 | [diff] [blame] | 82 | /* SMSC */ |
| 83 | PIN_MAP_MUX_GROUP_DEFAULT("smsc911x", "pfc-r8a73a4", |
| 84 | "irqc_irq40", "irqc"), |
Guennadi Liakhovetski | 8711613 | 2013-07-10 10:13:08 +0200 | [diff] [blame^] | 85 | /* MMCIF0 */ |
| 86 | PIN_MAP_MUX_GROUP_DEFAULT("sh_mmcif.0", "pfc-r8a73a4", |
| 87 | "mmc0_data8", "mmc0"), |
| 88 | PIN_MAP_MUX_GROUP_DEFAULT("sh_mmcif.0", "pfc-r8a73a4", |
| 89 | "mmc0_ctrl", "mmc0"), |
Magnus Damm | 2c56055 | 2013-03-29 17:00:12 +0900 | [diff] [blame] | 90 | }; |
| 91 | |
Magnus Damm | 78ded16 | 2013-03-29 17:00:02 +0900 | [diff] [blame] | 92 | static void __init ape6evm_add_standard_devices(void) |
| 93 | { |
Kuninori Morimoto | b8568a0 | 2013-04-04 21:24:27 -0700 | [diff] [blame] | 94 | |
| 95 | struct clk *parent; |
| 96 | struct clk *mp; |
| 97 | |
Magnus Damm | 78ded16 | 2013-03-29 17:00:02 +0900 | [diff] [blame] | 98 | r8a73a4_clock_init(); |
Kuninori Morimoto | b8568a0 | 2013-04-04 21:24:27 -0700 | [diff] [blame] | 99 | |
| 100 | /* MP clock parent = extal2 */ |
| 101 | parent = clk_get(NULL, "extal2"); |
| 102 | mp = clk_get(NULL, "mp"); |
| 103 | BUG_ON(IS_ERR(parent) || IS_ERR(mp)); |
| 104 | |
| 105 | clk_set_parent(mp, parent); |
| 106 | clk_put(parent); |
| 107 | clk_put(mp); |
| 108 | |
Magnus Damm | 2c56055 | 2013-03-29 17:00:12 +0900 | [diff] [blame] | 109 | pinctrl_register_mappings(ape6evm_pinctrl_map, |
| 110 | ARRAY_SIZE(ape6evm_pinctrl_map)); |
| 111 | r8a73a4_pinmux_init(); |
Magnus Damm | 78ded16 | 2013-03-29 17:00:02 +0900 | [diff] [blame] | 112 | r8a73a4_add_standard_devices(); |
Magnus Damm | 15351a7a | 2013-03-29 17:00:21 +0900 | [diff] [blame] | 113 | |
| 114 | /* LAN9220 ethernet */ |
| 115 | gpio_request_one(270, GPIOF_OUT_INIT_HIGH, NULL); /* smsc9220 RESET */ |
| 116 | |
| 117 | regulator_register_fixed(0, dummy_supplies, ARRAY_SIZE(dummy_supplies)); |
| 118 | |
| 119 | platform_device_register_resndata(&platform_bus, "smsc911x", -1, |
| 120 | lan9220_res, ARRAY_SIZE(lan9220_res), |
| 121 | &lan9220_data, sizeof(lan9220_data)); |
Guennadi Liakhovetski | 8711613 | 2013-07-10 10:13:08 +0200 | [diff] [blame^] | 122 | regulator_register_always_on(1, "fixed-3.3V", fixed3v3_power_consumers, |
| 123 | ARRAY_SIZE(fixed3v3_power_consumers), 3300000); |
| 124 | platform_device_register_resndata(&platform_bus, "sh_mmcif", 0, |
| 125 | mmcif0_resources, ARRAY_SIZE(mmcif0_resources), |
| 126 | &mmcif0_pdata, sizeof(mmcif0_pdata)); |
Magnus Damm | 78ded16 | 2013-03-29 17:00:02 +0900 | [diff] [blame] | 127 | } |
| 128 | |
| 129 | static const char *ape6evm_boards_compat_dt[] __initdata = { |
| 130 | "renesas,ape6evm", |
| 131 | NULL, |
| 132 | }; |
| 133 | |
| 134 | DT_MACHINE_START(APE6EVM_DT, "ape6evm") |
Magnus Damm | b9a30ef | 2013-06-28 20:27:32 +0900 | [diff] [blame] | 135 | .init_early = r8a73a4_init_delay, |
Magnus Damm | 78ded16 | 2013-03-29 17:00:02 +0900 | [diff] [blame] | 136 | .init_time = shmobile_timer_init, |
| 137 | .init_machine = ape6evm_add_standard_devices, |
| 138 | .dt_compat = ape6evm_boards_compat_dt, |
| 139 | MACHINE_END |