Jason Cooper | 3d468b6 | 2012-02-27 16:07:13 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2012 (C), Jason Cooper <jason@lakedaemon.net> |
| 3 | * |
| 4 | * arch/arm/mach-kirkwood/board-dt.c |
| 5 | * |
| 6 | * Marvell DreamPlug Reference Board Setup |
| 7 | * |
| 8 | * This file is licensed under the terms of the GNU General Public |
| 9 | * License version 2. This program is licensed "as is" without any |
| 10 | * warranty of any kind, whether express or implied. |
| 11 | */ |
| 12 | |
| 13 | #include <linux/kernel.h> |
| 14 | #include <linux/init.h> |
| 15 | #include <linux/platform_device.h> |
| 16 | #include <linux/mtd/partitions.h> |
| 17 | #include <linux/ata_platform.h> |
| 18 | #include <linux/mv643xx_eth.h> |
| 19 | #include <linux/of.h> |
| 20 | #include <linux/of_address.h> |
| 21 | #include <linux/of_fdt.h> |
| 22 | #include <linux/of_irq.h> |
| 23 | #include <linux/of_platform.h> |
| 24 | #include <linux/gpio.h> |
| 25 | #include <linux/leds.h> |
| 26 | #include <linux/mtd/physmap.h> |
| 27 | #include <linux/spi/flash.h> |
| 28 | #include <linux/spi/spi.h> |
| 29 | #include <linux/spi/orion_spi.h> |
| 30 | #include <asm/mach-types.h> |
| 31 | #include <asm/mach/arch.h> |
| 32 | #include <mach/kirkwood.h> |
| 33 | #include <plat/mvsdio.h> |
| 34 | #include "common.h" |
| 35 | #include "mpp.h" |
| 36 | |
| 37 | static struct of_device_id kirkwood_dt_match_table[] __initdata = { |
| 38 | { .compatible = "simple-bus", }, |
| 39 | { } |
| 40 | }; |
| 41 | |
| 42 | struct mtd_partition dreamplug_partitions[] = { |
| 43 | { |
| 44 | .name = "u-boot", |
| 45 | .size = SZ_512K, |
| 46 | .offset = 0, |
| 47 | }, |
| 48 | { |
| 49 | .name = "u-boot env", |
| 50 | .size = SZ_64K, |
| 51 | .offset = SZ_512K + SZ_512K, |
| 52 | }, |
| 53 | { |
| 54 | .name = "dtb", |
| 55 | .size = SZ_64K, |
| 56 | .offset = SZ_512K + SZ_512K + SZ_512K, |
| 57 | }, |
| 58 | }; |
| 59 | |
| 60 | static const struct flash_platform_data dreamplug_spi_slave_data = { |
| 61 | .type = "mx25l1606e", |
| 62 | .name = "spi_flash", |
| 63 | .parts = dreamplug_partitions, |
| 64 | .nr_parts = ARRAY_SIZE(dreamplug_partitions), |
| 65 | }; |
| 66 | |
| 67 | static struct spi_board_info __initdata dreamplug_spi_slave_info[] = { |
| 68 | { |
| 69 | .modalias = "m25p80", |
| 70 | .platform_data = &dreamplug_spi_slave_data, |
| 71 | .irq = -1, |
| 72 | .max_speed_hz = 50000000, |
| 73 | .bus_num = 0, |
| 74 | .chip_select = 0, |
| 75 | }, |
| 76 | }; |
| 77 | |
| 78 | static struct mv643xx_eth_platform_data dreamplug_ge00_data = { |
| 79 | .phy_addr = MV643XX_ETH_PHY_ADDR(0), |
| 80 | }; |
| 81 | |
| 82 | static struct mv643xx_eth_platform_data dreamplug_ge01_data = { |
| 83 | .phy_addr = MV643XX_ETH_PHY_ADDR(1), |
| 84 | }; |
| 85 | |
| 86 | static struct mv_sata_platform_data dreamplug_sata_data = { |
| 87 | .n_ports = 1, |
| 88 | }; |
| 89 | |
| 90 | static struct mvsdio_platform_data dreamplug_mvsdio_data = { |
| 91 | /* unfortunately the CD signal has not been connected */ |
| 92 | }; |
| 93 | |
| 94 | static struct gpio_led dreamplug_led_pins[] = { |
| 95 | { |
| 96 | .name = "dreamplug:blue:bluetooth", |
| 97 | .gpio = 47, |
| 98 | .active_low = 1, |
| 99 | }, |
| 100 | { |
| 101 | .name = "dreamplug:green:wifi", |
| 102 | .gpio = 48, |
| 103 | .active_low = 1, |
| 104 | }, |
| 105 | { |
| 106 | .name = "dreamplug:green:wifi_ap", |
| 107 | .gpio = 49, |
| 108 | .active_low = 1, |
| 109 | }, |
| 110 | }; |
| 111 | |
| 112 | static struct gpio_led_platform_data dreamplug_led_data = { |
| 113 | .leds = dreamplug_led_pins, |
| 114 | .num_leds = ARRAY_SIZE(dreamplug_led_pins), |
| 115 | }; |
| 116 | |
| 117 | static struct platform_device dreamplug_leds = { |
| 118 | .name = "leds-gpio", |
| 119 | .id = -1, |
| 120 | .dev = { |
| 121 | .platform_data = &dreamplug_led_data, |
| 122 | } |
| 123 | }; |
| 124 | |
| 125 | static unsigned int dreamplug_mpp_config[] __initdata = { |
| 126 | MPP0_SPI_SCn, |
| 127 | MPP1_SPI_MOSI, |
| 128 | MPP2_SPI_SCK, |
| 129 | MPP3_SPI_MISO, |
| 130 | MPP47_GPIO, /* Bluetooth LED */ |
| 131 | MPP48_GPIO, /* Wifi LED */ |
| 132 | MPP49_GPIO, /* Wifi AP LED */ |
| 133 | 0 |
| 134 | }; |
| 135 | |
| 136 | static void __init dreamplug_init(void) |
| 137 | { |
| 138 | /* |
| 139 | * Basic setup. Needs to be called early. |
| 140 | */ |
| 141 | kirkwood_mpp_conf(dreamplug_mpp_config); |
| 142 | |
Jason Cooper | 3d468b6 | 2012-02-27 16:07:13 +0000 | [diff] [blame] | 143 | spi_register_board_info(dreamplug_spi_slave_info, |
| 144 | ARRAY_SIZE(dreamplug_spi_slave_info)); |
| 145 | kirkwood_spi_init(); |
| 146 | |
| 147 | kirkwood_ehci_init(); |
| 148 | kirkwood_ge00_init(&dreamplug_ge00_data); |
| 149 | kirkwood_ge01_init(&dreamplug_ge01_data); |
| 150 | kirkwood_sata_init(&dreamplug_sata_data); |
| 151 | kirkwood_sdio_init(&dreamplug_mvsdio_data); |
| 152 | |
| 153 | platform_device_register(&dreamplug_leds); |
| 154 | } |
| 155 | |
| 156 | static void __init kirkwood_dt_init(void) |
| 157 | { |
| 158 | kirkwood_init(); |
| 159 | |
| 160 | if (of_machine_is_compatible("globalscale,dreamplug")) |
| 161 | dreamplug_init(); |
| 162 | |
| 163 | of_platform_populate(NULL, kirkwood_dt_match_table, NULL, NULL); |
| 164 | } |
| 165 | |
| 166 | static const char *kirkwood_dt_board_compat[] = { |
| 167 | "globalscale,dreamplug", |
| 168 | NULL |
| 169 | }; |
| 170 | |
| 171 | DT_MACHINE_START(KIRKWOOD_DT, "Marvell Kirkwood (Flattened Device Tree)") |
| 172 | /* Maintainer: Jason Cooper <jason@lakedaemon.net> */ |
| 173 | .map_io = kirkwood_map_io, |
| 174 | .init_early = kirkwood_init_early, |
| 175 | .init_irq = kirkwood_init_irq, |
| 176 | .timer = &kirkwood_timer, |
| 177 | .init_machine = kirkwood_dt_init, |
| 178 | .restart = kirkwood_restart, |
| 179 | .dt_compat = kirkwood_dt_board_compat, |
| 180 | MACHINE_END |