Lauri Hintsala | 79ce72a | 2012-02-03 16:20:34 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2011-2012 |
| 3 | * Lauri Hintsala, Bluegiga, <lauri.hintsala@bluegiga.com> |
| 4 | * Veli-Pekka Peltola, Bluegiga, <veli-pekka.peltola@bluegiga.com> |
| 5 | * |
| 6 | * based on: mach-mx28evk.c |
| 7 | * Copyright 2010 Freescale Semiconductor, Inc. All Rights Reserved. |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or modify |
| 10 | * it under the terms of the GNU General Public License as published by |
| 11 | * the Free Software Foundation; either version 2 of the License, or |
| 12 | * (at your option) any later version. |
| 13 | * |
| 14 | * This program is distributed in the hope that it will be useful, |
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | * GNU General Public License for more details. |
| 18 | */ |
| 19 | |
| 20 | #include <linux/delay.h> |
| 21 | #include <linux/platform_device.h> |
| 22 | #include <linux/gpio.h> |
| 23 | #include <linux/leds.h> |
| 24 | #include <linux/clk.h> |
| 25 | #include <linux/i2c.h> |
| 26 | #include <linux/regulator/machine.h> |
| 27 | #include <linux/regulator/fixed.h> |
| 28 | #include <linux/micrel_phy.h> |
| 29 | |
| 30 | #include <asm/mach-types.h> |
| 31 | #include <asm/mach/arch.h> |
| 32 | #include <asm/mach/time.h> |
| 33 | |
| 34 | #include <mach/common.h> |
| 35 | #include <mach/digctl.h> |
| 36 | #include <mach/iomux-mx28.h> |
| 37 | |
| 38 | #include "devices-mx28.h" |
| 39 | |
| 40 | #define APX4DEVKIT_GPIO_USERLED MXS_GPIO_NR(3, 28) |
| 41 | |
| 42 | static const iomux_cfg_t apx4devkit_pads[] __initconst = { |
| 43 | /* duart */ |
| 44 | MX28_PAD_PWM0__DUART_RX | MXS_PAD_CTRL, |
| 45 | MX28_PAD_PWM1__DUART_TX | MXS_PAD_CTRL, |
| 46 | |
| 47 | /* auart0 */ |
| 48 | MX28_PAD_AUART0_RX__AUART0_RX | MXS_PAD_CTRL, |
| 49 | MX28_PAD_AUART0_TX__AUART0_TX | MXS_PAD_CTRL, |
| 50 | MX28_PAD_AUART0_CTS__AUART0_CTS | MXS_PAD_CTRL, |
| 51 | MX28_PAD_AUART0_RTS__AUART0_RTS | MXS_PAD_CTRL, |
| 52 | |
| 53 | /* auart1 */ |
| 54 | MX28_PAD_AUART1_RX__AUART1_RX | MXS_PAD_CTRL, |
| 55 | MX28_PAD_AUART1_TX__AUART1_TX | MXS_PAD_CTRL, |
| 56 | |
| 57 | /* auart2 */ |
| 58 | MX28_PAD_SSP2_SCK__AUART2_RX | MXS_PAD_CTRL, |
| 59 | MX28_PAD_SSP2_MOSI__AUART2_TX | MXS_PAD_CTRL, |
| 60 | |
| 61 | /* auart3 */ |
| 62 | MX28_PAD_SSP2_MISO__AUART3_RX | MXS_PAD_CTRL, |
| 63 | MX28_PAD_SSP2_SS0__AUART3_TX | MXS_PAD_CTRL, |
| 64 | |
| 65 | #define MXS_PAD_FEC (MXS_PAD_8MA | MXS_PAD_3V3 | MXS_PAD_PULLUP) |
| 66 | /* fec0 */ |
| 67 | MX28_PAD_ENET0_MDC__ENET0_MDC | MXS_PAD_FEC, |
| 68 | MX28_PAD_ENET0_MDIO__ENET0_MDIO | MXS_PAD_FEC, |
| 69 | MX28_PAD_ENET0_RX_EN__ENET0_RX_EN | MXS_PAD_FEC, |
| 70 | MX28_PAD_ENET0_RXD0__ENET0_RXD0 | MXS_PAD_FEC, |
| 71 | MX28_PAD_ENET0_RXD1__ENET0_RXD1 | MXS_PAD_FEC, |
| 72 | MX28_PAD_ENET0_TX_EN__ENET0_TX_EN | MXS_PAD_FEC, |
| 73 | MX28_PAD_ENET0_TXD0__ENET0_TXD0 | MXS_PAD_FEC, |
| 74 | MX28_PAD_ENET0_TXD1__ENET0_TXD1 | MXS_PAD_FEC, |
| 75 | MX28_PAD_ENET_CLK__CLKCTRL_ENET | MXS_PAD_FEC, |
| 76 | |
| 77 | /* i2c */ |
| 78 | MX28_PAD_I2C0_SCL__I2C0_SCL, |
| 79 | MX28_PAD_I2C0_SDA__I2C0_SDA, |
| 80 | |
| 81 | /* mmc0 */ |
| 82 | MX28_PAD_SSP0_DATA0__SSP0_D0 | |
| 83 | (MXS_PAD_8MA | MXS_PAD_3V3 | MXS_PAD_PULLUP), |
| 84 | MX28_PAD_SSP0_DATA1__SSP0_D1 | |
| 85 | (MXS_PAD_8MA | MXS_PAD_3V3 | MXS_PAD_PULLUP), |
| 86 | MX28_PAD_SSP0_DATA2__SSP0_D2 | |
| 87 | (MXS_PAD_8MA | MXS_PAD_3V3 | MXS_PAD_PULLUP), |
| 88 | MX28_PAD_SSP0_DATA3__SSP0_D3 | |
| 89 | (MXS_PAD_8MA | MXS_PAD_3V3 | MXS_PAD_PULLUP), |
| 90 | MX28_PAD_SSP0_DATA4__SSP0_D4 | |
| 91 | (MXS_PAD_8MA | MXS_PAD_3V3 | MXS_PAD_PULLUP), |
| 92 | MX28_PAD_SSP0_DATA5__SSP0_D5 | |
| 93 | (MXS_PAD_8MA | MXS_PAD_3V3 | MXS_PAD_PULLUP), |
| 94 | MX28_PAD_SSP0_DATA6__SSP0_D6 | |
| 95 | (MXS_PAD_8MA | MXS_PAD_3V3 | MXS_PAD_PULLUP), |
| 96 | MX28_PAD_SSP0_DATA7__SSP0_D7 | |
| 97 | (MXS_PAD_8MA | MXS_PAD_3V3 | MXS_PAD_PULLUP), |
| 98 | MX28_PAD_SSP0_CMD__SSP0_CMD | |
| 99 | (MXS_PAD_8MA | MXS_PAD_3V3 | MXS_PAD_PULLUP), |
| 100 | MX28_PAD_SSP0_DETECT__SSP0_CARD_DETECT | |
| 101 | (MXS_PAD_8MA | MXS_PAD_3V3 | MXS_PAD_NOPULL), |
| 102 | MX28_PAD_SSP0_SCK__SSP0_SCK | |
| 103 | (MXS_PAD_12MA | MXS_PAD_3V3 | MXS_PAD_NOPULL), |
| 104 | |
| 105 | /* led */ |
| 106 | MX28_PAD_PWM3__GPIO_3_28 | MXS_PAD_CTRL, |
| 107 | |
| 108 | /* saif0 & saif1 */ |
| 109 | MX28_PAD_SAIF0_MCLK__SAIF0_MCLK | |
| 110 | (MXS_PAD_12MA | MXS_PAD_3V3 | MXS_PAD_PULLUP), |
| 111 | MX28_PAD_SAIF0_LRCLK__SAIF0_LRCLK | |
| 112 | (MXS_PAD_12MA | MXS_PAD_3V3 | MXS_PAD_PULLUP), |
| 113 | MX28_PAD_SAIF0_BITCLK__SAIF0_BITCLK | |
| 114 | (MXS_PAD_12MA | MXS_PAD_3V3 | MXS_PAD_PULLUP), |
| 115 | MX28_PAD_SAIF0_SDATA0__SAIF0_SDATA0 | |
| 116 | (MXS_PAD_12MA | MXS_PAD_3V3 | MXS_PAD_PULLUP), |
| 117 | MX28_PAD_SAIF1_SDATA0__SAIF1_SDATA0 | |
| 118 | (MXS_PAD_12MA | MXS_PAD_3V3 | MXS_PAD_PULLUP), |
| 119 | }; |
| 120 | |
| 121 | /* led */ |
| 122 | static const struct gpio_led apx4devkit_leds[] __initconst = { |
| 123 | { |
| 124 | .name = "user-led", |
| 125 | .default_trigger = "heartbeat", |
| 126 | .gpio = APX4DEVKIT_GPIO_USERLED, |
| 127 | }, |
| 128 | }; |
| 129 | |
| 130 | static const struct gpio_led_platform_data apx4devkit_led_data __initconst = { |
| 131 | .leds = apx4devkit_leds, |
| 132 | .num_leds = ARRAY_SIZE(apx4devkit_leds), |
| 133 | }; |
| 134 | |
| 135 | static const struct fec_platform_data mx28_fec_pdata __initconst = { |
| 136 | .phy = PHY_INTERFACE_MODE_RMII, |
| 137 | }; |
| 138 | |
| 139 | static const struct mxs_mmc_platform_data apx4devkit_mmc_pdata __initconst = { |
| 140 | .wp_gpio = -EINVAL, |
| 141 | .flags = SLOTF_4_BIT_CAPABLE, |
| 142 | }; |
| 143 | |
| 144 | static const struct i2c_board_info apx4devkit_i2c_boardinfo[] __initconst = { |
| 145 | { I2C_BOARD_INFO("sgtl5000", 0x0a) }, /* ASoC */ |
| 146 | { I2C_BOARD_INFO("pcf8563", 0x51) }, /* RTC */ |
| 147 | }; |
| 148 | |
| 149 | #if defined(CONFIG_REGULATOR_FIXED_VOLTAGE) || \ |
| 150 | defined(CONFIG_REGULATOR_FIXED_VOLTAGE_MODULE) |
| 151 | static struct regulator_consumer_supply apx4devkit_audio_consumer_supplies[] = { |
| 152 | REGULATOR_SUPPLY("VDDA", "0-000a"), |
| 153 | REGULATOR_SUPPLY("VDDIO", "0-000a"), |
| 154 | }; |
| 155 | |
| 156 | static struct regulator_init_data apx4devkit_vdd_reg_init_data = { |
| 157 | .constraints = { |
| 158 | .name = "3V3", |
| 159 | .always_on = 1, |
| 160 | }, |
| 161 | .consumer_supplies = apx4devkit_audio_consumer_supplies, |
| 162 | .num_consumer_supplies = ARRAY_SIZE(apx4devkit_audio_consumer_supplies), |
| 163 | }; |
| 164 | |
| 165 | static struct fixed_voltage_config apx4devkit_vdd_pdata = { |
| 166 | .supply_name = "board-3V3", |
| 167 | .microvolts = 3300000, |
| 168 | .gpio = -EINVAL, |
| 169 | .enabled_at_boot = 1, |
| 170 | .init_data = &apx4devkit_vdd_reg_init_data, |
| 171 | }; |
| 172 | |
| 173 | static struct platform_device apx4devkit_voltage_regulator = { |
| 174 | .name = "reg-fixed-voltage", |
| 175 | .id = -1, |
| 176 | .num_resources = 0, |
| 177 | .dev = { |
| 178 | .platform_data = &apx4devkit_vdd_pdata, |
| 179 | }, |
| 180 | }; |
| 181 | |
| 182 | static void __init apx4devkit_add_regulators(void) |
| 183 | { |
| 184 | platform_device_register(&apx4devkit_voltage_regulator); |
| 185 | } |
| 186 | #else |
| 187 | static void __init apx4devkit_add_regulators(void) {} |
| 188 | #endif |
| 189 | |
| 190 | static const struct mxs_saif_platform_data |
| 191 | apx4devkit_mxs_saif_pdata[] __initconst = { |
| 192 | /* working on EXTMSTR0 mode (saif0 master, saif1 slave) */ |
| 193 | { |
| 194 | .master_mode = 1, |
| 195 | .master_id = 0, |
| 196 | }, { |
| 197 | .master_mode = 0, |
| 198 | .master_id = 0, |
| 199 | }, |
| 200 | }; |
| 201 | |
| 202 | static int apx4devkit_phy_fixup(struct phy_device *phy) |
| 203 | { |
| 204 | phy->dev_flags |= MICREL_PHY_50MHZ_CLK; |
| 205 | return 0; |
| 206 | } |
| 207 | |
| 208 | static void __init apx4devkit_init(void) |
| 209 | { |
| 210 | mxs_iomux_setup_multiple_pads(apx4devkit_pads, |
| 211 | ARRAY_SIZE(apx4devkit_pads)); |
| 212 | |
| 213 | mx28_add_duart(); |
| 214 | mx28_add_auart0(); |
| 215 | mx28_add_auart1(); |
| 216 | mx28_add_auart2(); |
| 217 | mx28_add_auart3(); |
| 218 | |
| 219 | /* |
| 220 | * Register fixup for the Micrel KS8031 PHY clock |
| 221 | * (shares same ID with KS8051) |
| 222 | */ |
| 223 | phy_register_fixup_for_uid(PHY_ID_KS8051, MICREL_PHY_ID_MASK, |
| 224 | apx4devkit_phy_fixup); |
| 225 | |
| 226 | mx28_add_fec(0, &mx28_fec_pdata); |
| 227 | |
| 228 | mx28_add_mxs_mmc(0, &apx4devkit_mmc_pdata); |
| 229 | |
| 230 | gpio_led_register_device(0, &apx4devkit_led_data); |
| 231 | |
| 232 | mxs_saif_clkmux_select(MXS_DIGCTL_SAIF_CLKMUX_EXTMSTR0); |
| 233 | mx28_add_saif(0, &apx4devkit_mxs_saif_pdata[0]); |
| 234 | mx28_add_saif(1, &apx4devkit_mxs_saif_pdata[1]); |
| 235 | |
| 236 | apx4devkit_add_regulators(); |
| 237 | |
| 238 | mx28_add_mxs_i2c(0); |
| 239 | i2c_register_board_info(0, apx4devkit_i2c_boardinfo, |
| 240 | ARRAY_SIZE(apx4devkit_i2c_boardinfo)); |
| 241 | |
| 242 | mxs_add_platform_device("mxs-sgtl5000", 0, NULL, 0, NULL, 0); |
| 243 | } |
| 244 | |
| 245 | static void __init apx4devkit_timer_init(void) |
| 246 | { |
| 247 | mx28_clocks_init(); |
| 248 | } |
| 249 | |
| 250 | static struct sys_timer apx4devkit_timer = { |
| 251 | .init = apx4devkit_timer_init, |
| 252 | }; |
| 253 | |
| 254 | MACHINE_START(APX4DEVKIT, "Bluegiga APX4 Development Kit") |
| 255 | .map_io = mx28_map_io, |
| 256 | .init_irq = mx28_init_irq, |
| 257 | .timer = &apx4devkit_timer, |
| 258 | .init_machine = apx4devkit_init, |
| 259 | .restart = mxs_restart, |
| 260 | MACHINE_END |