blob: 7e99c3f340fc5e61c85e7023afc9e345a5a130d8 [file] [log] [blame]
Alexander Clouterb2fdb562010-01-18 23:38:19 +00001/*
2 * arch/arm/mach-kirkwood/openrd-setup.c
3 *
Dmytro Milinevskyy43b56072010-06-10 22:12:55 +03004 * Marvell OpenRD (Base|Client|Ultimate) Board Setup
Alexander Clouterb2fdb562010-01-18 23:38:19 +00005 *
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.com492e2bf2010-05-31 13:49:13 +020018#include <linux/i2c.h>
Tanmay Upadhyayfd2ce9c2010-08-26 11:11:58 +053019#include <linux/gpio.h>
Alexander Clouterb2fdb562010-01-18 23:38:19 +000020#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
27static 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
44static struct mv643xx_eth_platform_data openrd_ge00_data = {
45 .phy_addr = MV643XX_ETH_PHY_ADDR(8),
46};
47
48static struct mv643xx_eth_platform_data openrd_ge01_data = {
49 .phy_addr = MV643XX_ETH_PHY_ADDR(24),
50};
51
52static struct mv_sata_platform_data openrd_sata_data = {
53 .n_ports = 2,
54};
55
56static struct mvsdio_platform_data openrd_mvsdio_data = {
57 .gpio_card_detect = 29, /* MPP29 used as SD card detect */
58};
59
60static unsigned int openrd_mpp_config[] __initdata = {
Tanmay Upadhyayfd2ce9c2010-08-26 11:11:58 +053061 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 Clouterb2fdb562010-01-18 23:38:19 +000068 MPP29_GPIO,
Tanmay Upadhyayfd2ce9c2010-08-26 11:11:58 +053069 MPP34_GPIO,
70 0
71};
72
73/* Configure MPP for UART1 */
74static unsigned int openrd_uart1_mpp_config[] __initdata = {
75 MPP13_UART1_TXD,
76 MPP14_UART1_RXD,
Alexander Clouterb2fdb562010-01-18 23:38:19 +000077 0
78};
79
apatard@mandriva.com492e2bf2010-05-31 13:49:13 +020080static struct i2c_board_info i2c_board_info[] __initdata = {
81 {
82 I2C_BOARD_INFO("cs42l51", 0x4a),
83 },
84};
85
Axel Lin6d6761a2011-12-28 20:32:42 +080086static struct platform_device openrd_client_audio_device = {
87 .name = "openrd-client-audio",
88 .id = -1,
89};
90
Tanmay Upadhyayfd2ce9c2010-08-26 11:11:58 +053091static int __initdata uart1;
92
93static int __init sd_uart_selection(char *str)
94{
95 uart1 = -EINVAL;
96
97 /* Default is SD. Change if required, for UART */
98 if (!str)
99 return 0;
100
101 if (!strncmp(str, "232", 3)) {
102 uart1 = 232;
103 } else if (!strncmp(str, "485", 3)) {
104 /* OpenRD-Base doesn't have RS485. Treat is as an
105 * unknown argument & just have default setting -
106 * which is SD */
107 if (machine_is_openrd_base()) {
108 uart1 = -ENODEV;
109 return 1;
110 }
111
112 uart1 = 485;
113 }
114 return 1;
115}
116/* Parse boot_command_line string kw_openrd_init_uart1=232/485 */
117__setup("kw_openrd_init_uart1=", sd_uart_selection);
118
119static int __init uart1_mpp_config(void)
120{
121 kirkwood_mpp_conf(openrd_uart1_mpp_config);
122
123 if (gpio_request(34, "SD_UART1_SEL")) {
124 printk(KERN_ERR "GPIO request failed for SD/UART1 selection"
125 ", gpio: 34\n");
126 return -EIO;
127 }
128
129 if (gpio_request(28, "RS232_RS485_SEL")) {
130 printk(KERN_ERR "GPIO request failed for RS232/RS485 selection"
131 ", gpio# 28\n");
132 gpio_free(34);
133 return -EIO;
134 }
135
136 /* Select UART1
137 * Pin # 34: 0 => UART1, 1 => SD */
138 gpio_direction_output(34, 0);
139
140 /* Select RS232 OR RS485
141 * Pin # 28: 0 => RS232, 1 => RS485 */
142 if (uart1 == 232)
143 gpio_direction_output(28, 0);
144 else
145 gpio_direction_output(28, 1);
146
147 gpio_free(34);
148 gpio_free(28);
149
150 return 0;
151}
152
Alexander Clouterb2fdb562010-01-18 23:38:19 +0000153static void __init openrd_init(void)
154{
155 /*
156 * Basic setup. Needs to be called early.
157 */
158 kirkwood_init();
159 kirkwood_mpp_conf(openrd_mpp_config);
160
161 kirkwood_uart0_init();
162 kirkwood_nand_init(ARRAY_AND_SIZE(openrd_nand_parts), 25);
163
164 kirkwood_ehci_init();
165
Dmytro Milinevskyy43b56072010-06-10 22:12:55 +0300166 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 Clouterb2fdb562010-01-18 23:38:19 +0000171 kirkwood_ge00_init(&openrd_ge00_data);
Dmytro Milinevskyy43b56072010-06-10 22:12:55 +0300172 if (!machine_is_openrd_base())
Alexander Clouterb2fdb562010-01-18 23:38:19 +0000173 kirkwood_ge01_init(&openrd_ge01_data);
Dmytro Milinevskyy43b56072010-06-10 22:12:55 +0300174
Alexander Clouterb2fdb562010-01-18 23:38:19 +0000175 kirkwood_sata_init(&openrd_sata_data);
Alexander Clouterb2fdb562010-01-18 23:38:19 +0000176
177 kirkwood_i2c_init();
apatard@mandriva.com492e2bf2010-05-31 13:49:13 +0200178
Arnaud Patard (Rtp)3c9e28e2010-11-13 18:51:53 +0100179 if (machine_is_openrd_client() || machine_is_openrd_ultimate()) {
Axel Lin6d6761a2011-12-28 20:32:42 +0800180 platform_device_register(&openrd_client_audio_device);
apatard@mandriva.com492e2bf2010-05-31 13:49:13 +0200181 i2c_register_board_info(0, i2c_board_info,
182 ARRAY_SIZE(i2c_board_info));
183 kirkwood_audio_init();
184 }
Tanmay Upadhyayfd2ce9c2010-08-26 11:11:58 +0530185
186 if (uart1 <= 0) {
187 if (uart1 < 0)
188 printk(KERN_ERR "Invalid kernel parameter to select "
189 "UART1. Defaulting to SD. ERROR CODE: %d\n",
190 uart1);
191
192 /* Select SD
193 * Pin # 34: 0 => UART1, 1 => SD */
194 if (gpio_request(34, "SD_UART1_SEL")) {
195 printk(KERN_ERR "GPIO request failed for SD/UART1 "
196 "selection, gpio: 34\n");
197 } else {
198
199 gpio_direction_output(34, 1);
200 gpio_free(34);
201 kirkwood_sdio_init(&openrd_mvsdio_data);
202 }
203 } else {
204 if (!uart1_mpp_config())
205 kirkwood_uart1_init();
206 }
Alexander Clouterb2fdb562010-01-18 23:38:19 +0000207}
208
209static int __init openrd_pci_init(void)
210{
Dmytro Milinevskyy43b56072010-06-10 22:12:55 +0300211 if (machine_is_openrd_base() ||
212 machine_is_openrd_client() ||
213 machine_is_openrd_ultimate())
Saeed Bisharaffd58bd2010-06-08 14:21:34 +0300214 kirkwood_pcie_init(KW_PCIE0);
Alexander Clouterb2fdb562010-01-18 23:38:19 +0000215
216 return 0;
217}
218subsys_initcall(openrd_pci_init);
219
220#ifdef CONFIG_MACH_OPENRD_BASE
221MACHINE_START(OPENRD_BASE, "Marvell OpenRD Base Board")
222 /* Maintainer: Dhaval Vasa <dhaval.vasa@einfochips.com> */
Nicolas Pitre1b7bd282011-07-05 22:38:13 -0400223 .atag_offset = 0x100,
Alexander Clouterb2fdb562010-01-18 23:38:19 +0000224 .init_machine = openrd_init,
225 .map_io = kirkwood_map_io,
Lennert Buytenhek4ee1f6b2010-10-15 16:50:26 +0200226 .init_early = kirkwood_init_early,
Alexander Clouterb2fdb562010-01-18 23:38:19 +0000227 .init_irq = kirkwood_init_irq,
228 .timer = &kirkwood_timer,
Russell Kingcb15dff2011-11-05 10:03:47 +0000229 .restart = kirkwood_restart,
Alexander Clouterb2fdb562010-01-18 23:38:19 +0000230MACHINE_END
231#endif
232
233#ifdef CONFIG_MACH_OPENRD_CLIENT
234MACHINE_START(OPENRD_CLIENT, "Marvell OpenRD Client Board")
235 /* Maintainer: Dhaval Vasa <dhaval.vasa@einfochips.com> */
Nicolas Pitre1b7bd282011-07-05 22:38:13 -0400236 .atag_offset = 0x100,
Alexander Clouterb2fdb562010-01-18 23:38:19 +0000237 .init_machine = openrd_init,
238 .map_io = kirkwood_map_io,
Lennert Buytenhek4ee1f6b2010-10-15 16:50:26 +0200239 .init_early = kirkwood_init_early,
Alexander Clouterb2fdb562010-01-18 23:38:19 +0000240 .init_irq = kirkwood_init_irq,
241 .timer = &kirkwood_timer,
Russell Kingcb15dff2011-11-05 10:03:47 +0000242 .restart = kirkwood_restart,
Alexander Clouterb2fdb562010-01-18 23:38:19 +0000243MACHINE_END
244#endif
Dmytro Milinevskyy43b56072010-06-10 22:12:55 +0300245
246#ifdef CONFIG_MACH_OPENRD_ULTIMATE
247MACHINE_START(OPENRD_ULTIMATE, "Marvell OpenRD Ultimate Board")
248 /* Maintainer: Dhaval Vasa <dhaval.vasa@einfochips.com> */
Nicolas Pitre1b7bd282011-07-05 22:38:13 -0400249 .atag_offset = 0x100,
Dmytro Milinevskyy43b56072010-06-10 22:12:55 +0300250 .init_machine = openrd_init,
251 .map_io = kirkwood_map_io,
Lennert Buytenhek4ee1f6b2010-10-15 16:50:26 +0200252 .init_early = kirkwood_init_early,
Dmytro Milinevskyy43b56072010-06-10 22:12:55 +0300253 .init_irq = kirkwood_init_irq,
254 .timer = &kirkwood_timer,
Russell Kingcb15dff2011-11-05 10:03:47 +0000255 .restart = kirkwood_restart,
Dmytro Milinevskyy43b56072010-06-10 22:12:55 +0300256MACHINE_END
257#endif