2 * Freescale STMP378X development board support
4 * Embedded Alley Solutions, Inc <source@embeddedalley.com>
6 * Copyright 2008 Freescale Semiconductor, Inc. All Rights Reserved.
7 * Copyright 2008 Embedded Alley Solutions, Inc All Rights Reserved.
11 * The code contained herein is licensed under the GNU General Public
12 * License. You may obtain a copy of the GNU General Public License
13 * Version 2 or later at the following locations:
15 * http://www.opensource.org/licenses/gpl-license.html
16 * http://www.gnu.org/copyleft/gpl.html
18 #include <linux/kernel.h>
19 #include <linux/init.h>
21 #include <linux/platform_device.h>
22 #include <linux/delay.h>
23 #include <linux/clk.h>
24 #include <linux/err.h>
25 #include <linux/spi/spi.h>
27 #include <asm/setup.h>
28 #include <asm/mach-types.h>
29 #include <asm/mach/arch.h>
31 #include <mach/pins.h>
32 #include <mach/pinmux.h>
33 #include <mach/platform.h>
34 #include <mach/stmp3xxx.h>
36 #include <mach/gpmi.h>
40 static struct platform_device
*devices
[] = {
44 &stmp3xxx_touchscreen
,
47 &stmp3xxx_framebuffer
,
51 &stmp3xxx_dcp_bootstream
,
58 static struct pin_desc i2c_pins_desc
[] = {
59 { PINID_I2C_SCL
, PIN_FUN1
, PIN_4MA
, PIN_3_3V
, 0 },
60 { PINID_I2C_SDA
, PIN_FUN1
, PIN_4MA
, PIN_3_3V
, 0 },
63 static struct pin_group i2c_pins
= {
64 .pins
= i2c_pins_desc
,
65 .nr_pins
= ARRAY_SIZE(i2c_pins_desc
),
68 static struct pin_desc dbguart_pins_0
[] = {
69 { PINID_PWM0
, PIN_FUN3
, },
70 { PINID_PWM1
, PIN_FUN3
, },
73 static struct pin_group dbguart_pins
[] = {
75 .pins
= dbguart_pins_0
,
76 .nr_pins
= ARRAY_SIZE(dbguart_pins_0
),
80 static int dbguart_pins_control(int id
, int request
)
85 r
= stmp3xxx_request_pin_group(&dbguart_pins
[id
], "debug uart");
87 stmp3xxx_release_pin_group(&dbguart_pins
[id
], "debug uart");
91 static struct pin_desc appuart_pins_0
[] = {
92 { PINID_AUART1_CTS
, PIN_FUN1
, PIN_4MA
, PIN_1_8V
, 0, },
93 { PINID_AUART1_RTS
, PIN_FUN1
, PIN_4MA
, PIN_1_8V
, 0, },
94 { PINID_AUART1_RX
, PIN_FUN1
, PIN_4MA
, PIN_1_8V
, 0, },
95 { PINID_AUART1_TX
, PIN_FUN1
, PIN_4MA
, PIN_1_8V
, 0, },
98 static struct pin_desc appuart_pins_1
[] = {
101 static struct pin_desc mmc_pins_desc
[] = {
102 { PINID_SSP1_DATA0
, PIN_FUN1
, PIN_8MA
, PIN_3_3V
, 1 },
103 { PINID_SSP1_DATA1
, PIN_FUN1
, PIN_8MA
, PIN_3_3V
, 1 },
104 { PINID_SSP1_DATA2
, PIN_FUN1
, PIN_8MA
, PIN_3_3V
, 1 },
105 { PINID_SSP1_DATA3
, PIN_FUN1
, PIN_8MA
, PIN_3_3V
, 1 },
106 { PINID_SSP1_CMD
, PIN_FUN1
, PIN_8MA
, PIN_3_3V
, 1 },
107 { PINID_SSP1_SCK
, PIN_FUN1
, PIN_8MA
, PIN_3_3V
, 0 },
108 { PINID_SSP1_DETECT
, PIN_FUN1
, PIN_8MA
, PIN_3_3V
, 0 },
111 static struct pin_group mmc_pins
= {
112 .pins
= mmc_pins_desc
,
113 .nr_pins
= ARRAY_SIZE(mmc_pins_desc
),
116 static int stmp3xxxmmc_get_wp(void)
118 return gpio_get_value(PINID_PWM4
);
121 static int stmp3xxxmmc_hw_init_ssp1(void)
125 ret
= stmp3xxx_request_pin_group(&mmc_pins
, "mmc");
129 /* Configure write protect GPIO pin */
130 ret
= gpio_request(PINID_PWM4
, "mmc wp");
134 gpio_direction_input(PINID_PWM4
);
136 /* Configure POWER pin as gpio to drive power to MMC slot */
137 ret
= gpio_request(PINID_PWM3
, "mmc power");
141 gpio_direction_output(PINID_PWM3
, 0);
147 gpio_free(PINID_PWM4
);
149 stmp3xxx_release_pin_group(&mmc_pins
, "mmc");
154 static void stmp3xxxmmc_hw_release_ssp1(void)
156 gpio_free(PINID_PWM3
);
157 gpio_free(PINID_PWM4
);
158 stmp3xxx_release_pin_group(&mmc_pins
, "mmc");
161 static void stmp3xxxmmc_cmd_pullup_ssp1(int enable
)
163 stmp3xxx_pin_pullup(PINID_SSP1_CMD
, enable
, "mmc");
167 stmp3xxxmmc_setclock_ssp1(void __iomem
*base
, unsigned long hz
)
169 struct clk
*ssp
, *parent
;
173 ssp
= clk_get(NULL
, "ssp");
175 /* using SSP1, no timeout, clock rate 1 */
176 writel(BF(2, SSP_TIMING_CLOCK_DIVIDE
) |
177 BF(0xFFFF, SSP_TIMING_TIMEOUT
),
178 base
+ HW_SSP_TIMING
);
180 p
= (hz
> 1000000) ? "io" : "osc_24M";
181 parent
= clk_get(NULL
, p
);
182 clk_set_parent(ssp
, parent
);
183 r
= clk_set_rate(ssp
, 2 * hz
/ 1000);
190 static struct stmp3xxxmmc_platform_data mmc_data
= {
191 .hw_init
= stmp3xxxmmc_hw_init_ssp1
,
192 .hw_release
= stmp3xxxmmc_hw_release_ssp1
,
193 .get_wp
= stmp3xxxmmc_get_wp
,
194 .cmd_pullup
= stmp3xxxmmc_cmd_pullup_ssp1
,
195 .setclock
= stmp3xxxmmc_setclock_ssp1
,
199 static struct pin_group appuart_pins
[] = {
201 .pins
= appuart_pins_0
,
202 .nr_pins
= ARRAY_SIZE(appuart_pins_0
),
205 .pins
= appuart_pins_1
,
206 .nr_pins
= ARRAY_SIZE(appuart_pins_1
),
210 static struct pin_desc ssp1_pins_desc
[] = {
211 { PINID_SSP1_SCK
, PIN_FUN1
, PIN_8MA
, PIN_3_3V
, 0, },
212 { PINID_SSP1_CMD
, PIN_FUN1
, PIN_4MA
, PIN_3_3V
, 0, },
213 { PINID_SSP1_DATA0
, PIN_FUN1
, PIN_4MA
, PIN_3_3V
, 0, },
214 { PINID_SSP1_DATA3
, PIN_FUN1
, PIN_4MA
, PIN_3_3V
, 0, },
217 static struct pin_desc ssp2_pins_desc
[] = {
218 { PINID_GPMI_WRN
, PIN_FUN3
, PIN_8MA
, PIN_3_3V
, 0, },
219 { PINID_GPMI_RDY1
, PIN_FUN3
, PIN_4MA
, PIN_3_3V
, 0, },
220 { PINID_GPMI_D00
, PIN_FUN3
, PIN_4MA
, PIN_3_3V
, 0, },
221 { PINID_GPMI_D03
, PIN_FUN3
, PIN_4MA
, PIN_3_3V
, 0, },
224 static struct pin_group ssp1_pins
= {
225 .pins
= ssp1_pins_desc
,
226 .nr_pins
= ARRAY_SIZE(ssp1_pins_desc
),
229 static struct pin_group ssp2_pins
= {
230 .pins
= ssp1_pins_desc
,
231 .nr_pins
= ARRAY_SIZE(ssp2_pins_desc
),
234 static struct pin_desc gpmi_pins_desc
[] = {
235 { PINID_GPMI_CE0N
, PIN_FUN1
, PIN_4MA
, PIN_3_3V
, 0 },
236 { PINID_GPMI_CE1N
, PIN_FUN1
, PIN_4MA
, PIN_3_3V
, 0 },
237 { PINID_GMPI_CE2N
, PIN_FUN1
, PIN_4MA
, PIN_3_3V
, 0 },
238 { PINID_GPMI_CLE
, PIN_FUN1
, PIN_4MA
, PIN_3_3V
, 0 },
239 { PINID_GPMI_ALE
, PIN_FUN1
, PIN_4MA
, PIN_3_3V
, 0 },
240 { PINID_GPMI_WPN
, PIN_FUN1
, PIN_12MA
, PIN_3_3V
, 0 },
241 { PINID_GPMI_RDY1
, PIN_FUN1
, PIN_4MA
, PIN_3_3V
, 0 },
242 { PINID_GPMI_D00
, PIN_FUN1
, PIN_4MA
, PIN_3_3V
, 0 },
243 { PINID_GPMI_D01
, PIN_FUN1
, PIN_4MA
, PIN_3_3V
, 0 },
244 { PINID_GPMI_D02
, PIN_FUN1
, PIN_4MA
, PIN_3_3V
, 0 },
245 { PINID_GPMI_D03
, PIN_FUN1
, PIN_4MA
, PIN_3_3V
, 0 },
246 { PINID_GPMI_D04
, PIN_FUN1
, PIN_4MA
, PIN_3_3V
, 0 },
247 { PINID_GPMI_D05
, PIN_FUN1
, PIN_4MA
, PIN_3_3V
, 0 },
248 { PINID_GPMI_D06
, PIN_FUN1
, PIN_4MA
, PIN_3_3V
, 0 },
249 { PINID_GPMI_D07
, PIN_FUN1
, PIN_4MA
, PIN_3_3V
, 0 },
250 { PINID_GPMI_RDY0
, PIN_FUN1
, PIN_4MA
, PIN_3_3V
, 0 },
251 { PINID_GPMI_RDY2
, PIN_FUN1
, PIN_4MA
, PIN_3_3V
, 0 },
252 { PINID_GPMI_RDY3
, PIN_FUN1
, PIN_4MA
, PIN_3_3V
, 0 },
253 { PINID_GPMI_WRN
, PIN_FUN1
, PIN_12MA
, PIN_3_3V
, 0 },
254 { PINID_GPMI_RDN
, PIN_FUN1
, PIN_12MA
, PIN_3_3V
, 0 },
257 static struct pin_group gpmi_pins
= {
258 .pins
= gpmi_pins_desc
,
259 .nr_pins
= ARRAY_SIZE(gpmi_pins_desc
),
262 static struct mtd_partition gpmi_partitions
[] = {
270 .size
= MTDPART_SIZ_FULL
,
271 .offset
= MTDPART_OFS_APPEND
,
275 static struct gpmi_platform_data gpmi_data
= {
277 .nr_parts
= ARRAY_SIZE(gpmi_partitions
),
278 .parts
= gpmi_partitions
,
279 .part_types
= { "cmdline", NULL
},
282 static struct spi_board_info spi_board_info
[] __initdata
= {
283 #if defined(CONFIG_ENC28J60) || defined(CONFIG_ENC28J60_MODULE)
285 .modalias
= "enc28j60",
286 .max_speed_hz
= 6 * 1000 * 1000,
289 .platform_data
= NULL
,
294 static void __init
stmp378x_devb_init(void)
296 stmp3xxx_pinmux_init(NR_REAL_IRQS
);
298 /* init stmp3xxx platform */
301 stmp3xxx_dbguart
.dev
.platform_data
= dbguart_pins_control
;
302 stmp3xxx_appuart
.dev
.platform_data
= appuart_pins
;
303 stmp3xxx_mmc
.dev
.platform_data
= &mmc_data
;
304 stmp3xxx_gpmi
.dev
.platform_data
= &gpmi_data
;
305 stmp3xxx_spi1
.dev
.platform_data
= &ssp1_pins
;
306 stmp3xxx_spi2
.dev
.platform_data
= &ssp2_pins
;
307 stmp378x_i2c
.dev
.platform_data
= &i2c_pins
;
309 /* register spi devices */
310 spi_register_board_info(spi_board_info
, ARRAY_SIZE(spi_board_info
));
312 /* add board's devices */
313 platform_add_devices(devices
, ARRAY_SIZE(devices
));
315 /* add devices selected by command line ssp1= and ssp2= options */
316 stmp3xxx_ssp1_device_register();
317 stmp3xxx_ssp2_device_register();
320 MACHINE_START(STMP378X
, "STMP378X")
321 .phys_io
= 0x80000000,
322 .io_pg_offst
= ((0xf0000000) >> 18) & 0xfffc,
323 .boot_params
= 0x40000100,
324 .map_io
= stmp378x_map_io
,
325 .init_irq
= stmp378x_init_irq
,
326 .timer
= &stmp3xxx_timer
,
327 .init_machine
= stmp378x_devb_init
,