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> |
| 23 | #include <plat/mvsdio.h> |
| 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 */ |
| 58 | }; |
| 59 | |
| 60 | static unsigned int openrd_mpp_config[] __initdata = { |
Tanmay Upadhyay | fd2ce9c | 2010-08-26 11:11:58 +0530 | [diff] [blame] | 61 | MPP12_SD_CLK, |
| 62 | MPP13_SD_CMD, |
| 63 | MPP14_SD_D0, |
| 64 | MPP15_SD_D1, |
| 65 | MPP16_SD_D2, |
| 66 | MPP17_SD_D3, |
| 67 | MPP28_GPIO, |
Alexander Clouter | b2fdb56 | 2010-01-18 23:38:19 +0000 | [diff] [blame] | 68 | MPP29_GPIO, |
Tanmay Upadhyay | fd2ce9c | 2010-08-26 11:11:58 +0530 | [diff] [blame] | 69 | MPP34_GPIO, |
| 70 | 0 |
| 71 | }; |
| 72 | |
| 73 | /* Configure MPP for UART1 */ |
| 74 | static unsigned int openrd_uart1_mpp_config[] __initdata = { |
| 75 | MPP13_UART1_TXD, |
| 76 | MPP14_UART1_RXD, |
Alexander Clouter | b2fdb56 | 2010-01-18 23:38:19 +0000 | [diff] [blame] | 77 | 0 |
| 78 | }; |
| 79 | |
apatard@mandriva.com | 492e2bf | 2010-05-31 13:49:13 +0200 | [diff] [blame] | 80 | static struct i2c_board_info i2c_board_info[] __initdata = { |
| 81 | { |
| 82 | I2C_BOARD_INFO("cs42l51", 0x4a), |
| 83 | }, |
| 84 | }; |
| 85 | |
Tanmay Upadhyay | fd2ce9c | 2010-08-26 11:11:58 +0530 | [diff] [blame] | 86 | static int __initdata uart1; |
| 87 | |
| 88 | static int __init sd_uart_selection(char *str) |
| 89 | { |
| 90 | uart1 = -EINVAL; |
| 91 | |
| 92 | /* Default is SD. Change if required, for UART */ |
| 93 | if (!str) |
| 94 | return 0; |
| 95 | |
| 96 | if (!strncmp(str, "232", 3)) { |
| 97 | uart1 = 232; |
| 98 | } else if (!strncmp(str, "485", 3)) { |
| 99 | /* OpenRD-Base doesn't have RS485. Treat is as an |
| 100 | * unknown argument & just have default setting - |
| 101 | * which is SD */ |
| 102 | if (machine_is_openrd_base()) { |
| 103 | uart1 = -ENODEV; |
| 104 | return 1; |
| 105 | } |
| 106 | |
| 107 | uart1 = 485; |
| 108 | } |
| 109 | return 1; |
| 110 | } |
| 111 | /* Parse boot_command_line string kw_openrd_init_uart1=232/485 */ |
| 112 | __setup("kw_openrd_init_uart1=", sd_uart_selection); |
| 113 | |
| 114 | static int __init uart1_mpp_config(void) |
| 115 | { |
| 116 | kirkwood_mpp_conf(openrd_uart1_mpp_config); |
| 117 | |
| 118 | if (gpio_request(34, "SD_UART1_SEL")) { |
| 119 | printk(KERN_ERR "GPIO request failed for SD/UART1 selection" |
| 120 | ", gpio: 34\n"); |
| 121 | return -EIO; |
| 122 | } |
| 123 | |
| 124 | if (gpio_request(28, "RS232_RS485_SEL")) { |
| 125 | printk(KERN_ERR "GPIO request failed for RS232/RS485 selection" |
| 126 | ", gpio# 28\n"); |
| 127 | gpio_free(34); |
| 128 | return -EIO; |
| 129 | } |
| 130 | |
| 131 | /* Select UART1 |
| 132 | * Pin # 34: 0 => UART1, 1 => SD */ |
| 133 | gpio_direction_output(34, 0); |
| 134 | |
| 135 | /* Select RS232 OR RS485 |
| 136 | * Pin # 28: 0 => RS232, 1 => RS485 */ |
| 137 | if (uart1 == 232) |
| 138 | gpio_direction_output(28, 0); |
| 139 | else |
| 140 | gpio_direction_output(28, 1); |
| 141 | |
| 142 | gpio_free(34); |
| 143 | gpio_free(28); |
| 144 | |
| 145 | return 0; |
| 146 | } |
| 147 | |
Alexander Clouter | b2fdb56 | 2010-01-18 23:38:19 +0000 | [diff] [blame] | 148 | static void __init openrd_init(void) |
| 149 | { |
| 150 | /* |
| 151 | * Basic setup. Needs to be called early. |
| 152 | */ |
| 153 | kirkwood_init(); |
| 154 | kirkwood_mpp_conf(openrd_mpp_config); |
| 155 | |
| 156 | kirkwood_uart0_init(); |
| 157 | kirkwood_nand_init(ARRAY_AND_SIZE(openrd_nand_parts), 25); |
| 158 | |
| 159 | kirkwood_ehci_init(); |
| 160 | |
Dmytro Milinevskyy | 43b5607 | 2010-06-10 22:12:55 +0300 | [diff] [blame] | 161 | if (machine_is_openrd_ultimate()) { |
| 162 | openrd_ge00_data.phy_addr = MV643XX_ETH_PHY_ADDR(0); |
| 163 | openrd_ge01_data.phy_addr = MV643XX_ETH_PHY_ADDR(1); |
| 164 | } |
| 165 | |
Alexander Clouter | b2fdb56 | 2010-01-18 23:38:19 +0000 | [diff] [blame] | 166 | kirkwood_ge00_init(&openrd_ge00_data); |
Dmytro Milinevskyy | 43b5607 | 2010-06-10 22:12:55 +0300 | [diff] [blame] | 167 | if (!machine_is_openrd_base()) |
Alexander Clouter | b2fdb56 | 2010-01-18 23:38:19 +0000 | [diff] [blame] | 168 | kirkwood_ge01_init(&openrd_ge01_data); |
Dmytro Milinevskyy | 43b5607 | 2010-06-10 22:12:55 +0300 | [diff] [blame] | 169 | |
Alexander Clouter | b2fdb56 | 2010-01-18 23:38:19 +0000 | [diff] [blame] | 170 | kirkwood_sata_init(&openrd_sata_data); |
Alexander Clouter | b2fdb56 | 2010-01-18 23:38:19 +0000 | [diff] [blame] | 171 | |
| 172 | kirkwood_i2c_init(); |
apatard@mandriva.com | 492e2bf | 2010-05-31 13:49:13 +0200 | [diff] [blame] | 173 | |
| 174 | if (machine_is_openrd_client()) { |
| 175 | i2c_register_board_info(0, i2c_board_info, |
| 176 | ARRAY_SIZE(i2c_board_info)); |
| 177 | kirkwood_audio_init(); |
| 178 | } |
Tanmay Upadhyay | fd2ce9c | 2010-08-26 11:11:58 +0530 | [diff] [blame] | 179 | |
| 180 | if (uart1 <= 0) { |
| 181 | if (uart1 < 0) |
| 182 | printk(KERN_ERR "Invalid kernel parameter to select " |
| 183 | "UART1. Defaulting to SD. ERROR CODE: %d\n", |
| 184 | uart1); |
| 185 | |
| 186 | /* Select SD |
| 187 | * Pin # 34: 0 => UART1, 1 => SD */ |
| 188 | if (gpio_request(34, "SD_UART1_SEL")) { |
| 189 | printk(KERN_ERR "GPIO request failed for SD/UART1 " |
| 190 | "selection, gpio: 34\n"); |
| 191 | } else { |
| 192 | |
| 193 | gpio_direction_output(34, 1); |
| 194 | gpio_free(34); |
| 195 | kirkwood_sdio_init(&openrd_mvsdio_data); |
| 196 | } |
| 197 | } else { |
| 198 | if (!uart1_mpp_config()) |
| 199 | kirkwood_uart1_init(); |
| 200 | } |
Alexander Clouter | b2fdb56 | 2010-01-18 23:38:19 +0000 | [diff] [blame] | 201 | } |
| 202 | |
| 203 | static int __init openrd_pci_init(void) |
| 204 | { |
Dmytro Milinevskyy | 43b5607 | 2010-06-10 22:12:55 +0300 | [diff] [blame] | 205 | if (machine_is_openrd_base() || |
| 206 | machine_is_openrd_client() || |
| 207 | machine_is_openrd_ultimate()) |
Saeed Bishara | ffd58bd | 2010-06-08 14:21:34 +0300 | [diff] [blame] | 208 | kirkwood_pcie_init(KW_PCIE0); |
Alexander Clouter | b2fdb56 | 2010-01-18 23:38:19 +0000 | [diff] [blame] | 209 | |
| 210 | return 0; |
| 211 | } |
| 212 | subsys_initcall(openrd_pci_init); |
| 213 | |
| 214 | #ifdef CONFIG_MACH_OPENRD_BASE |
| 215 | MACHINE_START(OPENRD_BASE, "Marvell OpenRD Base Board") |
| 216 | /* Maintainer: Dhaval Vasa <dhaval.vasa@einfochips.com> */ |
Alexander Clouter | b2fdb56 | 2010-01-18 23:38:19 +0000 | [diff] [blame] | 217 | .boot_params = 0x00000100, |
| 218 | .init_machine = openrd_init, |
| 219 | .map_io = kirkwood_map_io, |
| 220 | .init_irq = kirkwood_init_irq, |
| 221 | .timer = &kirkwood_timer, |
| 222 | MACHINE_END |
| 223 | #endif |
| 224 | |
| 225 | #ifdef CONFIG_MACH_OPENRD_CLIENT |
| 226 | MACHINE_START(OPENRD_CLIENT, "Marvell OpenRD Client Board") |
| 227 | /* Maintainer: Dhaval Vasa <dhaval.vasa@einfochips.com> */ |
Alexander Clouter | b2fdb56 | 2010-01-18 23:38:19 +0000 | [diff] [blame] | 228 | .boot_params = 0x00000100, |
| 229 | .init_machine = openrd_init, |
| 230 | .map_io = kirkwood_map_io, |
| 231 | .init_irq = kirkwood_init_irq, |
| 232 | .timer = &kirkwood_timer, |
| 233 | MACHINE_END |
| 234 | #endif |
Dmytro Milinevskyy | 43b5607 | 2010-06-10 22:12:55 +0300 | [diff] [blame] | 235 | |
| 236 | #ifdef CONFIG_MACH_OPENRD_ULTIMATE |
| 237 | MACHINE_START(OPENRD_ULTIMATE, "Marvell OpenRD Ultimate Board") |
| 238 | /* Maintainer: Dhaval Vasa <dhaval.vasa@einfochips.com> */ |
Dmytro Milinevskyy | 43b5607 | 2010-06-10 22:12:55 +0300 | [diff] [blame] | 239 | .boot_params = 0x00000100, |
| 240 | .init_machine = openrd_init, |
| 241 | .map_io = kirkwood_map_io, |
| 242 | .init_irq = kirkwood_init_irq, |
| 243 | .timer = &kirkwood_timer, |
| 244 | MACHINE_END |
| 245 | #endif |