Kuninori Morimoto | 53e42c2 | 2013-03-21 03:03:38 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Bock-W board support |
| 3 | * |
| 4 | * Copyright (C) 2013 Renesas Solutions Corp. |
| 5 | * Copyright (C) 2013 Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> |
| 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 | |
Kuninori Morimoto | ca7bb30 | 2013-04-17 05:17:56 +0000 | [diff] [blame] | 21 | #include <linux/mfd/tmio.h> |
| 22 | #include <linux/mmc/host.h> |
Kuninori Morimoto | 111ea17 | 2013-04-12 05:38:03 +0000 | [diff] [blame] | 23 | #include <linux/pinctrl/machine.h> |
Kuninori Morimoto | 53e42c2 | 2013-03-21 03:03:38 -0700 | [diff] [blame] | 24 | #include <linux/platform_device.h> |
Kuninori Morimoto | 741440e | 2013-04-09 02:37:15 -0700 | [diff] [blame] | 25 | #include <linux/regulator/fixed.h> |
| 26 | #include <linux/regulator/machine.h> |
Kuninori Morimoto | 27d5f27 | 2013-04-01 21:20:02 -0700 | [diff] [blame] | 27 | #include <linux/smsc911x.h> |
Kuninori Morimoto | 53e42c2 | 2013-03-21 03:03:38 -0700 | [diff] [blame] | 28 | #include <mach/common.h> |
Kuninori Morimoto | 27d5f27 | 2013-04-01 21:20:02 -0700 | [diff] [blame] | 29 | #include <mach/irqs.h> |
Kuninori Morimoto | 53e42c2 | 2013-03-21 03:03:38 -0700 | [diff] [blame] | 30 | #include <mach/r8a7778.h> |
| 31 | #include <asm/mach/arch.h> |
| 32 | |
Kuninori Morimoto | d998cef | 2013-04-08 23:54:16 -0700 | [diff] [blame] | 33 | /* |
| 34 | * CN9(Upper side) SCIF/RCAN selection |
| 35 | * |
| 36 | * 1,4 3,6 |
| 37 | * SW40 SCIF RCAN |
| 38 | * SW41 SCIF RCAN |
| 39 | */ |
| 40 | |
Kuninori Morimoto | 741440e | 2013-04-09 02:37:15 -0700 | [diff] [blame] | 41 | /* Dummy supplies, where voltage doesn't matter */ |
| 42 | static struct regulator_consumer_supply dummy_supplies[] = { |
| 43 | REGULATOR_SUPPLY("vddvario", "smsc911x"), |
| 44 | REGULATOR_SUPPLY("vdd33a", "smsc911x"), |
| 45 | }; |
| 46 | |
Kuninori Morimoto | 27d5f27 | 2013-04-01 21:20:02 -0700 | [diff] [blame] | 47 | static struct smsc911x_platform_config smsc911x_data = { |
| 48 | .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW, |
| 49 | .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL, |
| 50 | .flags = SMSC911X_USE_32BIT, |
| 51 | .phy_interface = PHY_INTERFACE_MODE_MII, |
| 52 | }; |
| 53 | |
| 54 | static struct resource smsc911x_resources[] = { |
| 55 | DEFINE_RES_MEM(0x18300000, 0x1000), |
| 56 | DEFINE_RES_IRQ(irq_pin(0)), /* IRQ 0 */ |
| 57 | }; |
| 58 | |
Kuninori Morimoto | ca7bb30 | 2013-04-17 05:17:56 +0000 | [diff] [blame] | 59 | /* SDHI */ |
| 60 | static struct sh_mobile_sdhi_info sdhi0_info = { |
| 61 | .tmio_caps = MMC_CAP_SD_HIGHSPEED, |
| 62 | .tmio_ocr_mask = MMC_VDD_165_195 | MMC_VDD_32_33 | MMC_VDD_33_34, |
| 63 | .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT, |
| 64 | }; |
| 65 | |
Sergei Shtylyov | 9aa3853 | 2013-06-02 02:40:55 +0400 | [diff] [blame] | 66 | static struct sh_eth_plat_data ether_platform_data __initdata = { |
| 67 | .phy = 0x01, |
| 68 | .edmac_endian = EDMAC_LITTLE_ENDIAN, |
| 69 | .register_type = SH_ETH_REG_FAST_RCAR, |
| 70 | .phy_interface = PHY_INTERFACE_MODE_RMII, |
| 71 | /* |
| 72 | * Although the LINK signal is available on the board, it's connected to |
| 73 | * the link/activity LED output of the PHY, thus the link disappears and |
| 74 | * reappears after each packet. We'd be better off ignoring such signal |
| 75 | * and getting the link state from the PHY indirectly. |
| 76 | */ |
| 77 | .no_ether_link = 1, |
| 78 | }; |
| 79 | |
Kuninori Morimoto | ed17be9 | 2013-06-11 19:11:17 -0700 | [diff] [blame^] | 80 | /* I2C */ |
| 81 | static struct i2c_board_info i2c0_devices[] = { |
| 82 | { |
| 83 | I2C_BOARD_INFO("rx8581", 0x51), |
| 84 | }, |
| 85 | }; |
| 86 | |
Kuninori Morimoto | 111ea17 | 2013-04-12 05:38:03 +0000 | [diff] [blame] | 87 | static const struct pinctrl_map bockw_pinctrl_map[] = { |
Sergei Shtylyov | 9aa3853 | 2013-06-02 02:40:55 +0400 | [diff] [blame] | 88 | /* Ether */ |
| 89 | PIN_MAP_MUX_GROUP_DEFAULT("sh-eth", "pfc-r8a7778", |
| 90 | "ether_rmii", "ether"), |
Kuninori Morimoto | 111ea17 | 2013-04-12 05:38:03 +0000 | [diff] [blame] | 91 | /* SCIF0 */ |
| 92 | PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.0", "pfc-r8a7778", |
| 93 | "scif0_data_a", "scif0"), |
| 94 | PIN_MAP_MUX_GROUP_DEFAULT("sh-sci.0", "pfc-r8a7778", |
| 95 | "scif0_ctrl", "scif0"), |
Kuninori Morimoto | ca7bb30 | 2013-04-17 05:17:56 +0000 | [diff] [blame] | 96 | /* SDHI0 */ |
| 97 | PIN_MAP_MUX_GROUP_DEFAULT("sh_mobile_sdhi.0", "pfc-r8a7778", |
| 98 | "sdhi0", "sdhi0"), |
Kuninori Morimoto | 111ea17 | 2013-04-12 05:38:03 +0000 | [diff] [blame] | 99 | }; |
| 100 | |
Kuninori Morimoto | 44bfe68 | 2013-04-16 22:17:42 -0700 | [diff] [blame] | 101 | #define FPGA 0x18200000 |
Kuninori Morimoto | 27d5f27 | 2013-04-01 21:20:02 -0700 | [diff] [blame] | 102 | #define IRQ0MR 0x30 |
Kuninori Morimoto | ca7bb30 | 2013-04-17 05:17:56 +0000 | [diff] [blame] | 103 | #define PFC 0xfffc0000 |
| 104 | #define PUPR4 0x110 |
Kuninori Morimoto | 53e42c2 | 2013-03-21 03:03:38 -0700 | [diff] [blame] | 105 | static void __init bockw_init(void) |
| 106 | { |
Kuninori Morimoto | 44bfe68 | 2013-04-16 22:17:42 -0700 | [diff] [blame] | 107 | void __iomem *base; |
Kuninori Morimoto | 27d5f27 | 2013-04-01 21:20:02 -0700 | [diff] [blame] | 108 | |
Kuninori Morimoto | 53e42c2 | 2013-03-21 03:03:38 -0700 | [diff] [blame] | 109 | r8a7778_clock_init(); |
Kuninori Morimoto | 27d5f27 | 2013-04-01 21:20:02 -0700 | [diff] [blame] | 110 | r8a7778_init_irq_extpin(1); |
Kuninori Morimoto | 53e42c2 | 2013-03-21 03:03:38 -0700 | [diff] [blame] | 111 | r8a7778_add_standard_devices(); |
Sergei Shtylyov | 9aa3853 | 2013-06-02 02:40:55 +0400 | [diff] [blame] | 112 | r8a7778_add_ether_device(ðer_platform_data); |
Kuninori Morimoto | ed17be9 | 2013-06-11 19:11:17 -0700 | [diff] [blame^] | 113 | r8a7778_add_i2c_device(0); |
Kuninori Morimoto | 27d5f27 | 2013-04-01 21:20:02 -0700 | [diff] [blame] | 114 | |
Kuninori Morimoto | ed17be9 | 2013-06-11 19:11:17 -0700 | [diff] [blame^] | 115 | i2c_register_board_info(0, i2c0_devices, |
| 116 | ARRAY_SIZE(i2c0_devices)); |
Kuninori Morimoto | 111ea17 | 2013-04-12 05:38:03 +0000 | [diff] [blame] | 117 | pinctrl_register_mappings(bockw_pinctrl_map, |
| 118 | ARRAY_SIZE(bockw_pinctrl_map)); |
| 119 | r8a7778_pinmux_init(); |
| 120 | |
Kuninori Morimoto | ca7bb30 | 2013-04-17 05:17:56 +0000 | [diff] [blame] | 121 | /* for SMSC */ |
Kuninori Morimoto | 44bfe68 | 2013-04-16 22:17:42 -0700 | [diff] [blame] | 122 | base = ioremap_nocache(FPGA, SZ_1M); |
| 123 | if (base) { |
Kuninori Morimoto | 27d5f27 | 2013-04-01 21:20:02 -0700 | [diff] [blame] | 124 | /* |
| 125 | * CAUTION |
| 126 | * |
| 127 | * IRQ0/1 is cascaded interrupt from FPGA. |
| 128 | * it should be cared in the future |
| 129 | * Now, it is assuming IRQ0 was used only from SMSC. |
| 130 | */ |
Kuninori Morimoto | 44bfe68 | 2013-04-16 22:17:42 -0700 | [diff] [blame] | 131 | u16 val = ioread16(base + IRQ0MR); |
Kuninori Morimoto | 27d5f27 | 2013-04-01 21:20:02 -0700 | [diff] [blame] | 132 | val &= ~(1 << 4); /* enable SMSC911x */ |
Kuninori Morimoto | 44bfe68 | 2013-04-16 22:17:42 -0700 | [diff] [blame] | 133 | iowrite16(val, base + IRQ0MR); |
| 134 | iounmap(base); |
Kuninori Morimoto | 27d5f27 | 2013-04-01 21:20:02 -0700 | [diff] [blame] | 135 | |
Kuninori Morimoto | 741440e | 2013-04-09 02:37:15 -0700 | [diff] [blame] | 136 | regulator_register_fixed(0, dummy_supplies, |
| 137 | ARRAY_SIZE(dummy_supplies)); |
| 138 | |
Kuninori Morimoto | 27d5f27 | 2013-04-01 21:20:02 -0700 | [diff] [blame] | 139 | platform_device_register_resndata( |
| 140 | &platform_bus, "smsc911x", -1, |
| 141 | smsc911x_resources, ARRAY_SIZE(smsc911x_resources), |
| 142 | &smsc911x_data, sizeof(smsc911x_data)); |
| 143 | } |
Kuninori Morimoto | ca7bb30 | 2013-04-17 05:17:56 +0000 | [diff] [blame] | 144 | |
| 145 | /* for SDHI */ |
| 146 | base = ioremap_nocache(PFC, 0x200); |
| 147 | if (base) { |
| 148 | /* |
| 149 | * FIXME |
| 150 | * |
| 151 | * SDHI CD/WP pin needs pull-up |
| 152 | */ |
| 153 | iowrite32(ioread32(base + PUPR4) | (3 << 26), base + PUPR4); |
| 154 | iounmap(base); |
| 155 | |
| 156 | r8a7778_sdhi_init(0, &sdhi0_info); |
| 157 | } |
Kuninori Morimoto | 53e42c2 | 2013-03-21 03:03:38 -0700 | [diff] [blame] | 158 | } |
| 159 | |
| 160 | static const char *bockw_boards_compat_dt[] __initdata = { |
| 161 | "renesas,bockw", |
| 162 | NULL, |
| 163 | }; |
| 164 | |
| 165 | DT_MACHINE_START(BOCKW_DT, "bockw") |
| 166 | .init_early = r8a7778_init_delay, |
| 167 | .init_irq = r8a7778_init_irq_dt, |
| 168 | .init_machine = bockw_init, |
| 169 | .init_time = shmobile_timer_init, |
| 170 | .dt_compat = bockw_boards_compat_dt, |
| 171 | MACHINE_END |