blob: 96c3451291358f74ef6fcf288dc9d489a397ef0a [file] [log] [blame]
Jaya Kumar90b8fc32008-03-15 05:11:07 +01001/*
2 * linux/arch/arm/mach-pxa/gumstix.c
3 *
4 * Support for the Gumstix motherboards.
5 *
6 * Original Author: Craig Hughes
7 * Created: Feb 14, 2008
8 * Copyright: Craig Hughes
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
13 *
14 * Implemented based on lubbock.c by Nicolas Pitre and code from Craig
15 * Hughes
16 */
17
18#include <linux/module.h>
19#include <linux/kernel.h>
20#include <linux/init.h>
21#include <linux/platform_device.h>
22#include <linux/interrupt.h>
Jaya Kumard8ad7852008-08-16 04:07:18 +010023#include <linux/delay.h>
Jaya Kumar90b8fc32008-03-15 05:11:07 +010024#include <linux/mtd/mtd.h>
25#include <linux/mtd/partitions.h>
Jaya Kumard8ad7852008-08-16 04:07:18 +010026#include <linux/gpio.h>
27#include <linux/err.h>
28#include <linux/clk.h>
Jaya Kumar90b8fc32008-03-15 05:11:07 +010029
30#include <asm/setup.h>
31#include <asm/memory.h>
32#include <asm/mach-types.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010033#include <mach/hardware.h>
Jaya Kumar90b8fc32008-03-15 05:11:07 +010034#include <asm/irq.h>
35#include <asm/sizes.h>
36
37#include <asm/mach/arch.h>
38#include <asm/mach/map.h>
39#include <asm/mach/irq.h>
40#include <asm/mach/flash.h>
Eric Miao51c62982009-01-02 23:17:22 +080041
42#include <mach/pxa25x.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010043#include <mach/mmc.h>
44#include <mach/udc.h>
45#include <mach/gumstix.h>
Jaya Kumar90b8fc32008-03-15 05:11:07 +010046
Jaya Kumar90b8fc32008-03-15 05:11:07 +010047#include "generic.h"
48
49static struct resource flash_resource = {
50 .start = 0x00000000,
51 .end = SZ_64M - 1,
52 .flags = IORESOURCE_MEM,
53};
54
55static struct mtd_partition gumstix_partitions[] = {
56 {
57 .name = "Bootloader",
58 .size = 0x00040000,
59 .offset = 0,
60 .mask_flags = MTD_WRITEABLE /* force read-only */
61 } , {
62 .name = "rootfs",
63 .size = MTDPART_SIZ_FULL,
64 .offset = MTDPART_OFS_APPEND
65 }
66};
67
68static struct flash_platform_data gumstix_flash_data = {
69 .map_name = "cfi_probe",
70 .parts = gumstix_partitions,
71 .nr_parts = ARRAY_SIZE(gumstix_partitions),
72 .width = 2,
73};
74
75static struct platform_device gumstix_flash_device = {
76 .name = "pxa2xx-flash",
77 .id = 0,
78 .dev = {
79 .platform_data = &gumstix_flash_data,
80 },
81 .resource = &flash_resource,
82 .num_resources = 1,
83};
84
85static struct platform_device *devices[] __initdata = {
86 &gumstix_flash_device,
87};
88
89#ifdef CONFIG_MMC_PXA
Jaya Kumar90b8fc32008-03-15 05:11:07 +010090static struct pxamci_platform_data gumstix_mci_platform_data = {
Robert Jarzmik7a648252009-07-06 22:16:42 +020091 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
92 .gpio_card_detect = -1,
93 .gpio_card_ro = -1,
94 .gpio_power = -1,
Jaya Kumar90b8fc32008-03-15 05:11:07 +010095};
96
97static void __init gumstix_mmc_init(void)
98{
99 pxa_set_mci_info(&gumstix_mci_platform_data);
100}
101#else
102static void __init gumstix_mmc_init(void)
103{
Jaya Kumard8ad7852008-08-16 04:07:18 +0100104 pr_debug("Gumstix mmc disabled\n");
Jaya Kumar90b8fc32008-03-15 05:11:07 +0100105}
106#endif
107
Jaya Kumard8ad7852008-08-16 04:07:18 +0100108#ifdef CONFIG_USB_GADGET_PXA25X
Jaya Kumar90b8fc32008-03-15 05:11:07 +0100109static struct pxa2xx_udc_mach_info gumstix_udc_info __initdata = {
110 .gpio_vbus = GPIO_GUMSTIX_USB_GPIOn,
111 .gpio_pullup = GPIO_GUMSTIX_USB_GPIOx,
112};
113
114static void __init gumstix_udc_init(void)
115{
116 pxa_set_udc_info(&gumstix_udc_info);
117}
118#else
119static void gumstix_udc_init(void)
120{
Jaya Kumard8ad7852008-08-16 04:07:18 +0100121 pr_debug("Gumstix udc is disabled\n");
Jaya Kumar90b8fc32008-03-15 05:11:07 +0100122}
123#endif
124
Jaya Kumard8ad7852008-08-16 04:07:18 +0100125#ifdef CONFIG_BT
126/* Normally, the bootloader would have enabled this 32kHz clock but many
127** boards still have u-boot 1.1.4 so we check if it has been turned on and
128** if not, we turn it on with a warning message. */
129static void gumstix_setup_bt_clock(void)
130{
131 int timeout = 500;
132
133 if (!(OSCC & OSCC_OOK))
134 pr_warning("32kHz clock was not on. Bootloader may need to "
135 "be updated\n");
136 else
137 return;
138
139 OSCC |= OSCC_OON;
140 do {
141 if (OSCC & OSCC_OOK)
142 break;
143 udelay(1);
144 } while (--timeout);
145 if (!timeout)
146 pr_err("Failed to start 32kHz clock\n");
147}
148
149static void __init gumstix_bluetooth_init(void)
150{
151 int err;
152
153 gumstix_setup_bt_clock();
154
155 err = gpio_request(GPIO_GUMSTIX_BTRESET, "BTRST");
156 if (err) {
157 pr_err("gumstix: failed request gpio for bluetooth reset\n");
158 return;
159 }
160
161 err = gpio_direction_output(GPIO_GUMSTIX_BTRESET, 1);
162 if (err) {
163 pr_err("gumstix: can't reset bluetooth\n");
164 return;
165 }
166 gpio_set_value(GPIO_GUMSTIX_BTRESET, 0);
167 udelay(100);
168 gpio_set_value(GPIO_GUMSTIX_BTRESET, 1);
169}
170#else
171static void gumstix_bluetooth_init(void)
172{
173 pr_debug("Gumstix Bluetooth is disabled\n");
174}
175#endif
176
177static unsigned long gumstix_pin_config[] __initdata = {
178 GPIO12_32KHz,
179 /* BTUART */
180 GPIO42_HWUART_RXD,
181 GPIO43_HWUART_TXD,
182 GPIO44_HWUART_CTS,
183 GPIO45_HWUART_RTS,
184 /* MMC */
185 GPIO6_MMC_CLK,
186 GPIO53_MMC_CLK,
187 GPIO8_MMC_CS0,
Jaya Kumard8ad7852008-08-16 04:07:18 +0100188};
189
Jaya Kumar3332b0c2008-12-09 22:14:29 +0800190int __attribute__((weak)) am200_init(void)
191{
192 return 0;
193}
194
Jaya Kumar4ce255c2009-01-01 17:51:01 +0100195int __attribute__((weak)) am300_init(void)
196{
197 return 0;
198}
199
Jaya Kumar3332b0c2008-12-09 22:14:29 +0800200static void __init carrier_board_init(void)
201{
202 /*
203 * put carrier/expansion board init here if
204 * they cannot be detected programatically
205 */
206 am200_init();
Jaya Kumar4ce255c2009-01-01 17:51:01 +0100207 am300_init();
Jaya Kumar3332b0c2008-12-09 22:14:29 +0800208}
209
Jaya Kumar90b8fc32008-03-15 05:11:07 +0100210static void __init gumstix_init(void)
211{
Jaya Kumard8ad7852008-08-16 04:07:18 +0100212 pxa2xx_mfp_config(ARRAY_AND_SIZE(gumstix_pin_config));
213
Russell Kingcc155c62009-11-09 13:34:08 +0800214 pxa_set_ffuart_info(NULL);
215 pxa_set_btuart_info(NULL);
216 pxa_set_stuart_info(NULL);
217 pxa_set_hwuart_info(NULL);
218
Jaya Kumard8ad7852008-08-16 04:07:18 +0100219 gumstix_bluetooth_init();
Jaya Kumar90b8fc32008-03-15 05:11:07 +0100220 gumstix_udc_init();
221 gumstix_mmc_init();
222 (void) platform_add_devices(devices, ARRAY_SIZE(devices));
Jaya Kumar3332b0c2008-12-09 22:14:29 +0800223 carrier_board_init();
Jaya Kumar90b8fc32008-03-15 05:11:07 +0100224}
225
226MACHINE_START(GUMSTIX, "Gumstix")
227 .phys_io = 0x40000000,
228 .boot_params = 0xa0000100, /* match u-boot bi_boot_params */
229 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
230 .map_io = pxa_map_io,
231 .init_irq = pxa25x_init_irq,
232 .timer = &pxa_timer,
233 .init_machine = gumstix_init,
234MACHINE_END