Alexander Clouter | b2fdb56 | 2010-01-18 23:38:19 +0000 | [diff] [blame] | 1 | /* |
| 2 | * arch/arm/mach-kirkwood/openrd-setup.c |
| 3 | * |
Dmytro Milinevskyy | 43b5607 | 2010-06-10 22:12:55 +0300 | [diff] [blame] | 4 | * Marvell OpenRD (Base|Client|Ultimate) Board Setup |
Alexander Clouter | b2fdb56 | 2010-01-18 23:38:19 +0000 | [diff] [blame] | 5 | * |
| 6 | * This file is licensed under the terms of the GNU General Public |
| 7 | * License version 2. This program is licensed "as is" without any |
| 8 | * warranty of any kind, whether express or implied. |
| 9 | */ |
| 10 | |
| 11 | #include <linux/kernel.h> |
| 12 | #include <linux/init.h> |
| 13 | #include <linux/platform_device.h> |
| 14 | #include <linux/mtd/nand.h> |
| 15 | #include <linux/mtd/partitions.h> |
| 16 | #include <linux/ata_platform.h> |
| 17 | #include <linux/mv643xx_eth.h> |
apatard@mandriva.com | 492e2bf | 2010-05-31 13:49:13 +0200 | [diff] [blame] | 18 | #include <linux/i2c.h> |
Tanmay Upadhyay | fd2ce9c | 2010-08-26 11:11:58 +0530 | [diff] [blame] | 19 | #include <linux/gpio.h> |
Alexander Clouter | b2fdb56 | 2010-01-18 23:38:19 +0000 | [diff] [blame] | 20 | #include <asm/mach-types.h> |
| 21 | #include <asm/mach/arch.h> |
| 22 | #include <mach/kirkwood.h> |
Arnd Bergmann | c02cecb | 2012-08-24 15:21:54 +0200 | [diff] [blame] | 23 | #include <linux/platform_data/mmc-mvsdio.h> |
Alexander Clouter | b2fdb56 | 2010-01-18 23:38:19 +0000 | [diff] [blame] | 24 | #include "common.h" |
| 25 | #include "mpp.h" |
| 26 | |
| 27 | static struct mtd_partition openrd_nand_parts[] = { |
| 28 | { |
| 29 | .name = "u-boot", |
| 30 | .offset = 0, |
| 31 | .size = SZ_1M, |
| 32 | .mask_flags = MTD_WRITEABLE |
| 33 | }, { |
| 34 | .name = "uImage", |
| 35 | .offset = MTDPART_OFS_NXTBLK, |
| 36 | .size = SZ_4M |
| 37 | }, { |
| 38 | .name = "root", |
| 39 | .offset = MTDPART_OFS_NXTBLK, |
| 40 | .size = MTDPART_SIZ_FULL |
| 41 | }, |
| 42 | }; |
| 43 | |
| 44 | static struct mv643xx_eth_platform_data openrd_ge00_data = { |
| 45 | .phy_addr = MV643XX_ETH_PHY_ADDR(8), |
| 46 | }; |
| 47 | |
| 48 | static struct mv643xx_eth_platform_data openrd_ge01_data = { |
| 49 | .phy_addr = MV643XX_ETH_PHY_ADDR(24), |
| 50 | }; |
| 51 | |
| 52 | static struct mv_sata_platform_data openrd_sata_data = { |
| 53 | .n_ports = 2, |
| 54 | }; |
| 55 | |
| 56 | static struct mvsdio_platform_data openrd_mvsdio_data = { |
| 57 | .gpio_card_detect = 29, /* MPP29 used as SD card detect */ |
Sebastian Hesselbarth | 0d0644e | 2013-03-23 13:56:58 +0100 | [diff] [blame] | 58 | .gpio_write_protect = -1, |
Alexander Clouter | b2fdb56 | 2010-01-18 23:38:19 +0000 | [diff] [blame] | 59 | }; |
| 60 | |
| 61 | static unsigned int openrd_mpp_config[] __initdata = { |
Tanmay Upadhyay | fd2ce9c | 2010-08-26 11:11:58 +0530 | [diff] [blame] | 62 | MPP12_SD_CLK, |
| 63 | MPP13_SD_CMD, |
| 64 | MPP14_SD_D0, |
| 65 | MPP15_SD_D1, |
| 66 | MPP16_SD_D2, |
| 67 | MPP17_SD_D3, |
| 68 | MPP28_GPIO, |
Alexander Clouter | b2fdb56 | 2010-01-18 23:38:19 +0000 | [diff] [blame] | 69 | MPP29_GPIO, |
Tanmay Upadhyay | fd2ce9c | 2010-08-26 11:11:58 +0530 | [diff] [blame] | 70 | MPP34_GPIO, |
| 71 | 0 |
| 72 | }; |
| 73 | |
| 74 | /* Configure MPP for UART1 */ |
| 75 | static unsigned int openrd_uart1_mpp_config[] __initdata = { |
| 76 | MPP13_UART1_TXD, |
| 77 | MPP14_UART1_RXD, |
Alexander Clouter | b2fdb56 | 2010-01-18 23:38:19 +0000 | [diff] [blame] | 78 | 0 |
| 79 | }; |
| 80 | |
apatard@mandriva.com | 492e2bf | 2010-05-31 13:49:13 +0200 | [diff] [blame] | 81 | static struct i2c_board_info i2c_board_info[] __initdata = { |
| 82 | { |
| 83 | I2C_BOARD_INFO("cs42l51", 0x4a), |
| 84 | }, |
| 85 | }; |
| 86 | |
Axel Lin | 6d6761a | 2011-12-28 20:32:42 +0800 | [diff] [blame] | 87 | static struct platform_device openrd_client_audio_device = { |
| 88 | .name = "openrd-client-audio", |
| 89 | .id = -1, |
| 90 | }; |
| 91 | |
Tanmay Upadhyay | fd2ce9c | 2010-08-26 11:11:58 +0530 | [diff] [blame] | 92 | static int __initdata uart1; |
| 93 | |
| 94 | static int __init sd_uart_selection(char *str) |
| 95 | { |
| 96 | uart1 = -EINVAL; |
| 97 | |
| 98 | /* Default is SD. Change if required, for UART */ |
| 99 | if (!str) |
| 100 | return 0; |
| 101 | |
| 102 | if (!strncmp(str, "232", 3)) { |
| 103 | uart1 = 232; |
| 104 | } else if (!strncmp(str, "485", 3)) { |
| 105 | /* OpenRD-Base doesn't have RS485. Treat is as an |
| 106 | * unknown argument & just have default setting - |
| 107 | * which is SD */ |
| 108 | if (machine_is_openrd_base()) { |
| 109 | uart1 = -ENODEV; |
| 110 | return 1; |
| 111 | } |
| 112 | |
| 113 | uart1 = 485; |
| 114 | } |
| 115 | return 1; |
| 116 | } |
| 117 | /* Parse boot_command_line string kw_openrd_init_uart1=232/485 */ |
| 118 | __setup("kw_openrd_init_uart1=", sd_uart_selection); |
| 119 | |
| 120 | static int __init uart1_mpp_config(void) |
| 121 | { |
| 122 | kirkwood_mpp_conf(openrd_uart1_mpp_config); |
| 123 | |
| 124 | if (gpio_request(34, "SD_UART1_SEL")) { |
Andrew Lunn | 98adf93 | 2012-10-20 13:23:16 +0200 | [diff] [blame] | 125 | pr_err("GPIO request 34 failed for SD/UART1 selection\n"); |
Tanmay Upadhyay | fd2ce9c | 2010-08-26 11:11:58 +0530 | [diff] [blame] | 126 | return -EIO; |
| 127 | } |
| 128 | |
| 129 | if (gpio_request(28, "RS232_RS485_SEL")) { |
Andrew Lunn | 98adf93 | 2012-10-20 13:23:16 +0200 | [diff] [blame] | 130 | pr_err("GPIO request 28 failed for RS232/RS485 selection\n"); |
Tanmay Upadhyay | fd2ce9c | 2010-08-26 11:11:58 +0530 | [diff] [blame] | 131 | gpio_free(34); |
| 132 | return -EIO; |
| 133 | } |
| 134 | |
| 135 | /* Select UART1 |
| 136 | * Pin # 34: 0 => UART1, 1 => SD */ |
| 137 | gpio_direction_output(34, 0); |
| 138 | |
| 139 | /* Select RS232 OR RS485 |
| 140 | * Pin # 28: 0 => RS232, 1 => RS485 */ |
| 141 | if (uart1 == 232) |
| 142 | gpio_direction_output(28, 0); |
| 143 | else |
| 144 | gpio_direction_output(28, 1); |
| 145 | |
| 146 | gpio_free(34); |
| 147 | gpio_free(28); |
| 148 | |
| 149 | return 0; |
| 150 | } |
| 151 | |
Alexander Clouter | b2fdb56 | 2010-01-18 23:38:19 +0000 | [diff] [blame] | 152 | static void __init openrd_init(void) |
| 153 | { |
| 154 | /* |
| 155 | * Basic setup. Needs to be called early. |
| 156 | */ |
| 157 | kirkwood_init(); |
| 158 | kirkwood_mpp_conf(openrd_mpp_config); |
| 159 | |
| 160 | kirkwood_uart0_init(); |
Julia Lawall | f4ada24 | 2013-08-11 18:51:56 +0200 | [diff] [blame] | 161 | kirkwood_nand_init(openrd_nand_parts, ARRAY_SIZE(openrd_nand_parts), |
| 162 | 25); |
Alexander Clouter | b2fdb56 | 2010-01-18 23:38:19 +0000 | [diff] [blame] | 163 | |
| 164 | kirkwood_ehci_init(); |
| 165 | |
Dmytro Milinevskyy | 43b5607 | 2010-06-10 22:12:55 +0300 | [diff] [blame] | 166 | if (machine_is_openrd_ultimate()) { |
| 167 | openrd_ge00_data.phy_addr = MV643XX_ETH_PHY_ADDR(0); |
| 168 | openrd_ge01_data.phy_addr = MV643XX_ETH_PHY_ADDR(1); |
| 169 | } |
| 170 | |
Alexander Clouter | b2fdb56 | 2010-01-18 23:38:19 +0000 | [diff] [blame] | 171 | kirkwood_ge00_init(&openrd_ge00_data); |
Dmytro Milinevskyy | 43b5607 | 2010-06-10 22:12:55 +0300 | [diff] [blame] | 172 | if (!machine_is_openrd_base()) |
Alexander Clouter | b2fdb56 | 2010-01-18 23:38:19 +0000 | [diff] [blame] | 173 | kirkwood_ge01_init(&openrd_ge01_data); |
Dmytro Milinevskyy | 43b5607 | 2010-06-10 22:12:55 +0300 | [diff] [blame] | 174 | |
Alexander Clouter | b2fdb56 | 2010-01-18 23:38:19 +0000 | [diff] [blame] | 175 | kirkwood_sata_init(&openrd_sata_data); |
Alexander Clouter | b2fdb56 | 2010-01-18 23:38:19 +0000 | [diff] [blame] | 176 | |
| 177 | kirkwood_i2c_init(); |
apatard@mandriva.com | 492e2bf | 2010-05-31 13:49:13 +0200 | [diff] [blame] | 178 | |
Arnaud Patard (Rtp) | 3c9e28e | 2010-11-13 18:51:53 +0100 | [diff] [blame] | 179 | if (machine_is_openrd_client() || machine_is_openrd_ultimate()) { |
Axel Lin | 6d6761a | 2011-12-28 20:32:42 +0800 | [diff] [blame] | 180 | platform_device_register(&openrd_client_audio_device); |
apatard@mandriva.com | 492e2bf | 2010-05-31 13:49:13 +0200 | [diff] [blame] | 181 | i2c_register_board_info(0, i2c_board_info, |
| 182 | ARRAY_SIZE(i2c_board_info)); |
| 183 | kirkwood_audio_init(); |
| 184 | } |
Tanmay Upadhyay | fd2ce9c | 2010-08-26 11:11:58 +0530 | [diff] [blame] | 185 | |
| 186 | if (uart1 <= 0) { |
| 187 | if (uart1 < 0) |
Andrew Lunn | 98adf93 | 2012-10-20 13:23:16 +0200 | [diff] [blame] | 188 | pr_err("Invalid kernel parameter to select UART1. Defaulting to SD. ERROR CODE: %d\n", |
| 189 | uart1); |
Tanmay Upadhyay | fd2ce9c | 2010-08-26 11:11:58 +0530 | [diff] [blame] | 190 | |
| 191 | /* Select SD |
| 192 | * Pin # 34: 0 => UART1, 1 => SD */ |
| 193 | if (gpio_request(34, "SD_UART1_SEL")) { |
Andrew Lunn | 98adf93 | 2012-10-20 13:23:16 +0200 | [diff] [blame] | 194 | pr_err("GPIO request 34 failed for SD/UART1 selection\n"); |
Tanmay Upadhyay | fd2ce9c | 2010-08-26 11:11:58 +0530 | [diff] [blame] | 195 | } else { |
| 196 | |
| 197 | gpio_direction_output(34, 1); |
| 198 | gpio_free(34); |
| 199 | kirkwood_sdio_init(&openrd_mvsdio_data); |
| 200 | } |
| 201 | } else { |
| 202 | if (!uart1_mpp_config()) |
| 203 | kirkwood_uart1_init(); |
| 204 | } |
Alexander Clouter | b2fdb56 | 2010-01-18 23:38:19 +0000 | [diff] [blame] | 205 | } |
| 206 | |
| 207 | static int __init openrd_pci_init(void) |
| 208 | { |
Dmytro Milinevskyy | 43b5607 | 2010-06-10 22:12:55 +0300 | [diff] [blame] | 209 | if (machine_is_openrd_base() || |
| 210 | machine_is_openrd_client() || |
| 211 | machine_is_openrd_ultimate()) |
Saeed Bishara | ffd58bd | 2010-06-08 14:21:34 +0300 | [diff] [blame] | 212 | kirkwood_pcie_init(KW_PCIE0); |
Alexander Clouter | b2fdb56 | 2010-01-18 23:38:19 +0000 | [diff] [blame] | 213 | |
| 214 | return 0; |
| 215 | } |
| 216 | subsys_initcall(openrd_pci_init); |
| 217 | |
| 218 | #ifdef CONFIG_MACH_OPENRD_BASE |
| 219 | MACHINE_START(OPENRD_BASE, "Marvell OpenRD Base Board") |
| 220 | /* Maintainer: Dhaval Vasa <dhaval.vasa@einfochips.com> */ |
Nicolas Pitre | 1b7bd28c | 2011-07-05 22:38:13 -0400 | [diff] [blame] | 221 | .atag_offset = 0x100, |
Alexander Clouter | b2fdb56 | 2010-01-18 23:38:19 +0000 | [diff] [blame] | 222 | .init_machine = openrd_init, |
| 223 | .map_io = kirkwood_map_io, |
Lennert Buytenhek | 4ee1f6b | 2010-10-15 16:50:26 +0200 | [diff] [blame] | 224 | .init_early = kirkwood_init_early, |
Alexander Clouter | b2fdb56 | 2010-01-18 23:38:19 +0000 | [diff] [blame] | 225 | .init_irq = kirkwood_init_irq, |
Stephen Warren | 6bb27d7 | 2012-11-08 12:40:59 -0700 | [diff] [blame] | 226 | .init_time = kirkwood_timer_init, |
Russell King | cb15dff | 2011-11-05 10:03:47 +0000 | [diff] [blame] | 227 | .restart = kirkwood_restart, |
Alexander Clouter | b2fdb56 | 2010-01-18 23:38:19 +0000 | [diff] [blame] | 228 | MACHINE_END |
| 229 | #endif |
| 230 | |
| 231 | #ifdef CONFIG_MACH_OPENRD_CLIENT |
| 232 | MACHINE_START(OPENRD_CLIENT, "Marvell OpenRD Client Board") |
| 233 | /* Maintainer: Dhaval Vasa <dhaval.vasa@einfochips.com> */ |
Nicolas Pitre | 1b7bd28c | 2011-07-05 22:38:13 -0400 | [diff] [blame] | 234 | .atag_offset = 0x100, |
Alexander Clouter | b2fdb56 | 2010-01-18 23:38:19 +0000 | [diff] [blame] | 235 | .init_machine = openrd_init, |
| 236 | .map_io = kirkwood_map_io, |
Lennert Buytenhek | 4ee1f6b | 2010-10-15 16:50:26 +0200 | [diff] [blame] | 237 | .init_early = kirkwood_init_early, |
Alexander Clouter | b2fdb56 | 2010-01-18 23:38:19 +0000 | [diff] [blame] | 238 | .init_irq = kirkwood_init_irq, |
Stephen Warren | 6bb27d7 | 2012-11-08 12:40:59 -0700 | [diff] [blame] | 239 | .init_time = kirkwood_timer_init, |
Russell King | cb15dff | 2011-11-05 10:03:47 +0000 | [diff] [blame] | 240 | .restart = kirkwood_restart, |
Alexander Clouter | b2fdb56 | 2010-01-18 23:38:19 +0000 | [diff] [blame] | 241 | MACHINE_END |
| 242 | #endif |
Dmytro Milinevskyy | 43b5607 | 2010-06-10 22:12:55 +0300 | [diff] [blame] | 243 | |
| 244 | #ifdef CONFIG_MACH_OPENRD_ULTIMATE |
| 245 | MACHINE_START(OPENRD_ULTIMATE, "Marvell OpenRD Ultimate Board") |
| 246 | /* Maintainer: Dhaval Vasa <dhaval.vasa@einfochips.com> */ |
Nicolas Pitre | 1b7bd28c | 2011-07-05 22:38:13 -0400 | [diff] [blame] | 247 | .atag_offset = 0x100, |
Dmytro Milinevskyy | 43b5607 | 2010-06-10 22:12:55 +0300 | [diff] [blame] | 248 | .init_machine = openrd_init, |
| 249 | .map_io = kirkwood_map_io, |
Lennert Buytenhek | 4ee1f6b | 2010-10-15 16:50:26 +0200 | [diff] [blame] | 250 | .init_early = kirkwood_init_early, |
Dmytro Milinevskyy | 43b5607 | 2010-06-10 22:12:55 +0300 | [diff] [blame] | 251 | .init_irq = kirkwood_init_irq, |
Stephen Warren | 6bb27d7 | 2012-11-08 12:40:59 -0700 | [diff] [blame] | 252 | .init_time = kirkwood_timer_init, |
Russell King | cb15dff | 2011-11-05 10:03:47 +0000 | [diff] [blame] | 253 | .restart = kirkwood_restart, |
Dmytro Milinevskyy | 43b5607 | 2010-06-10 22:12:55 +0300 | [diff] [blame] | 254 | MACHINE_END |
| 255 | #endif |