Merge tag 'devicetree-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
[sfrench/cifs-2.6.git] / arch / arm / mach-at91 / board-snapper9260.c
1 /*
2  * linux/arch/arm/mach-at91/board-snapper9260.c
3  *
4  *  Copyright (C) 2010 Bluewater System Ltd
5  *
6  * Author: Andre Renaud <andre@bluewatersys.com>
7  * Author: Ryan Mallon
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  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
22  *
23  */
24
25 #include <linux/init.h>
26 #include <linux/gpio.h>
27 #include <linux/platform_device.h>
28 #include <linux/spi/spi.h>
29 #include <linux/platform_data/pca953x.h>
30
31 #include <asm/mach-types.h>
32 #include <asm/mach/arch.h>
33
34 #include <mach/hardware.h>
35 #include <mach/at91sam9_smc.h>
36
37 #include "at91_aic.h"
38 #include "board.h"
39 #include "sam9_smc.h"
40 #include "generic.h"
41 #include "gpio.h"
42
43 #define SNAPPER9260_IO_EXP_GPIO(x)      (NR_BUILTIN_GPIO + (x))
44
45 static void __init snapper9260_init_early(void)
46 {
47         at91_initialize(18432000);
48 }
49
50 static struct at91_usbh_data __initdata snapper9260_usbh_data = {
51         .ports          = 2,
52         .vbus_pin       = {-EINVAL, -EINVAL},
53         .overcurrent_pin= {-EINVAL, -EINVAL},
54 };
55
56 static struct at91_udc_data __initdata snapper9260_udc_data = {
57         .vbus_pin               = SNAPPER9260_IO_EXP_GPIO(5),
58         .vbus_active_low        = 1,
59         .vbus_polled            = 1,
60         .pullup_pin             = -EINVAL,
61 };
62
63 static struct macb_platform_data snapper9260_macb_data = {
64         .phy_irq_pin    = -EINVAL,
65         .is_rmii        = 1,
66 };
67
68 static struct mtd_partition __initdata snapper9260_nand_partitions[] = {
69         {
70                 .name   = "Preboot",
71                 .offset = 0,
72                 .size   = SZ_128K,
73         },
74         {
75                 .name   = "Bootloader",
76                 .offset = MTDPART_OFS_APPEND,
77                 .size   = SZ_256K,
78         },
79         {
80                 .name   = "Environment",
81                 .offset = MTDPART_OFS_APPEND,
82                 .size   = SZ_128K,
83         },
84         {
85                 .name   = "Kernel",
86                 .offset = MTDPART_OFS_APPEND,
87                 .size   = SZ_4M,
88         },
89         {
90                 .name   = "Filesystem",
91                 .offset = MTDPART_OFS_APPEND,
92                 .size   = MTDPART_SIZ_FULL,
93         },
94 };
95
96 static struct atmel_nand_data __initdata snapper9260_nand_data = {
97         .ale            = 21,
98         .cle            = 22,
99         .rdy_pin        = AT91_PIN_PC13,
100         .parts          = snapper9260_nand_partitions,
101         .num_parts      = ARRAY_SIZE(snapper9260_nand_partitions),
102         .bus_width_16   = 0,
103         .enable_pin     = -EINVAL,
104         .det_pin        = -EINVAL,
105         .ecc_mode       = NAND_ECC_SOFT,
106 };
107
108 static struct sam9_smc_config __initdata snapper9260_nand_smc_config = {
109         .ncs_read_setup         = 0,
110         .nrd_setup              = 0,
111         .ncs_write_setup        = 0,
112         .nwe_setup              = 0,
113
114         .ncs_read_pulse         = 5,
115         .nrd_pulse              = 2,
116         .ncs_write_pulse        = 5,
117         .nwe_pulse              = 2,
118
119         .read_cycle             = 7,
120         .write_cycle            = 7,
121
122         .mode                   = (AT91_SMC_READMODE | AT91_SMC_WRITEMODE |
123                                    AT91_SMC_EXNWMODE_DISABLE),
124         .tdf_cycles             = 1,
125 };
126
127 static struct pca953x_platform_data snapper9260_io_expander_data = {
128         .gpio_base              = SNAPPER9260_IO_EXP_GPIO(0),
129 };
130
131 static struct i2c_board_info __initdata snapper9260_i2c_devices[] = {
132         {
133                 /* IO expander */
134                 I2C_BOARD_INFO("max7312", 0x28),
135                 .platform_data = &snapper9260_io_expander_data,
136         },
137         {
138                 /* Audio codec */
139                 I2C_BOARD_INFO("tlv320aic23", 0x1a),
140         },
141 };
142
143 static struct i2c_board_info __initdata snapper9260_i2c_isl1208 = {
144                 /* RTC */
145                 I2C_BOARD_INFO("isl1208", 0x6f),
146 };
147
148 static void __init snapper9260_add_device_nand(void)
149 {
150         at91_set_A_periph(AT91_PIN_PC14, 0);
151         sam9_smc_configure(0, 3, &snapper9260_nand_smc_config);
152         at91_add_device_nand(&snapper9260_nand_data);
153 }
154
155 static void __init snapper9260_board_init(void)
156 {
157         at91_register_devices();
158
159         at91_add_device_i2c(snapper9260_i2c_devices,
160                             ARRAY_SIZE(snapper9260_i2c_devices));
161
162         snapper9260_i2c_isl1208.irq = gpio_to_irq(AT91_PIN_PA31);
163         i2c_register_board_info(0, &snapper9260_i2c_isl1208, 1);
164
165         /* Debug on ttyS0 */
166         at91_register_uart(0, 0, 0);
167
168         at91_register_uart(AT91SAM9260_ID_US0, 1,
169                            ATMEL_UART_CTS | ATMEL_UART_RTS);
170         at91_register_uart(AT91SAM9260_ID_US1, 2,
171                            ATMEL_UART_CTS | ATMEL_UART_RTS);
172         at91_register_uart(AT91SAM9260_ID_US2, 3, 0);
173         at91_add_device_serial();
174         at91_add_device_usbh(&snapper9260_usbh_data);
175         at91_add_device_udc(&snapper9260_udc_data);
176         at91_add_device_eth(&snapper9260_macb_data);
177         at91_add_device_ssc(AT91SAM9260_ID_SSC, (ATMEL_SSC_TF | ATMEL_SSC_TK |
178                                                  ATMEL_SSC_TD | ATMEL_SSC_RD));
179         snapper9260_add_device_nand();
180 }
181
182 MACHINE_START(SNAPPER_9260, "Bluewater Systems Snapper 9260/9G20 module")
183         .init_time      = at91_init_time,
184         .map_io         = at91_map_io,
185         .handle_irq     = at91_aic_handle_irq,
186         .init_early     = snapper9260_init_early,
187         .init_irq       = at91_init_irq_default,
188         .init_machine   = snapper9260_board_init,
189 MACHINE_END
190
191