[ARM] pxa: introduce pxa{25x,27x,300,320,930}.h for board usage
[deliverable/linux.git] / arch / arm / mach-pxa / gumstix.c
CommitLineData
90b8fc34
JK
1/*
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>
d8ad7859 23#include <linux/delay.h>
90b8fc34
JK
24#include <linux/mtd/mtd.h>
25#include <linux/mtd/partitions.h>
d8ad7859
JK
26#include <linux/gpio.h>
27#include <linux/err.h>
28#include <linux/clk.h>
90b8fc34
JK
29
30#include <asm/setup.h>
31#include <asm/memory.h>
32#include <asm/mach-types.h>
a09e64fb 33#include <mach/hardware.h>
90b8fc34
JK
34#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>
51c62982
EM
41
42#include <mach/pxa25x.h>
a09e64fb
RK
43#include <mach/mmc.h>
44#include <mach/udc.h>
45#include <mach/gumstix.h>
90b8fc34 46
90b8fc34
JK
47#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
90b8fc34
JK
90static struct pxamci_platform_data gumstix_mci_platform_data = {
91 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
90b8fc34
JK
92};
93
94static void __init gumstix_mmc_init(void)
95{
96 pxa_set_mci_info(&gumstix_mci_platform_data);
97}
98#else
99static void __init gumstix_mmc_init(void)
100{
d8ad7859 101 pr_debug("Gumstix mmc disabled\n");
90b8fc34
JK
102}
103#endif
104
d8ad7859 105#ifdef CONFIG_USB_GADGET_PXA25X
90b8fc34
JK
106static struct pxa2xx_udc_mach_info gumstix_udc_info __initdata = {
107 .gpio_vbus = GPIO_GUMSTIX_USB_GPIOn,
108 .gpio_pullup = GPIO_GUMSTIX_USB_GPIOx,
109};
110
111static void __init gumstix_udc_init(void)
112{
113 pxa_set_udc_info(&gumstix_udc_info);
114}
115#else
116static void gumstix_udc_init(void)
117{
d8ad7859 118 pr_debug("Gumstix udc is disabled\n");
90b8fc34
JK
119}
120#endif
121
d8ad7859
JK
122#ifdef CONFIG_BT
123/* Normally, the bootloader would have enabled this 32kHz clock but many
124** boards still have u-boot 1.1.4 so we check if it has been turned on and
125** if not, we turn it on with a warning message. */
126static void gumstix_setup_bt_clock(void)
127{
128 int timeout = 500;
129
130 if (!(OSCC & OSCC_OOK))
131 pr_warning("32kHz clock was not on. Bootloader may need to "
132 "be updated\n");
133 else
134 return;
135
136 OSCC |= OSCC_OON;
137 do {
138 if (OSCC & OSCC_OOK)
139 break;
140 udelay(1);
141 } while (--timeout);
142 if (!timeout)
143 pr_err("Failed to start 32kHz clock\n");
144}
145
146static void __init gumstix_bluetooth_init(void)
147{
148 int err;
149
150 gumstix_setup_bt_clock();
151
152 err = gpio_request(GPIO_GUMSTIX_BTRESET, "BTRST");
153 if (err) {
154 pr_err("gumstix: failed request gpio for bluetooth reset\n");
155 return;
156 }
157
158 err = gpio_direction_output(GPIO_GUMSTIX_BTRESET, 1);
159 if (err) {
160 pr_err("gumstix: can't reset bluetooth\n");
161 return;
162 }
163 gpio_set_value(GPIO_GUMSTIX_BTRESET, 0);
164 udelay(100);
165 gpio_set_value(GPIO_GUMSTIX_BTRESET, 1);
166}
167#else
168static void gumstix_bluetooth_init(void)
169{
170 pr_debug("Gumstix Bluetooth is disabled\n");
171}
172#endif
173
174static unsigned long gumstix_pin_config[] __initdata = {
175 GPIO12_32KHz,
176 /* BTUART */
177 GPIO42_HWUART_RXD,
178 GPIO43_HWUART_TXD,
179 GPIO44_HWUART_CTS,
180 GPIO45_HWUART_RTS,
181 /* MMC */
182 GPIO6_MMC_CLK,
183 GPIO53_MMC_CLK,
184 GPIO8_MMC_CS0,
d8ad7859
JK
185};
186
3332b0c1
JK
187int __attribute__((weak)) am200_init(void)
188{
189 return 0;
190}
191
4ce255c1
JK
192int __attribute__((weak)) am300_init(void)
193{
194 return 0;
195}
196
3332b0c1
JK
197static void __init carrier_board_init(void)
198{
199 /*
200 * put carrier/expansion board init here if
201 * they cannot be detected programatically
202 */
203 am200_init();
4ce255c1 204 am300_init();
3332b0c1
JK
205}
206
90b8fc34
JK
207static void __init gumstix_init(void)
208{
d8ad7859
JK
209 pxa2xx_mfp_config(ARRAY_AND_SIZE(gumstix_pin_config));
210
211 gumstix_bluetooth_init();
90b8fc34
JK
212 gumstix_udc_init();
213 gumstix_mmc_init();
214 (void) platform_add_devices(devices, ARRAY_SIZE(devices));
3332b0c1 215 carrier_board_init();
90b8fc34
JK
216}
217
218MACHINE_START(GUMSTIX, "Gumstix")
219 .phys_io = 0x40000000,
220 .boot_params = 0xa0000100, /* match u-boot bi_boot_params */
221 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
222 .map_io = pxa_map_io,
223 .init_irq = pxa25x_init_irq,
224 .timer = &pxa_timer,
225 .init_machine = gumstix_init,
226MACHINE_END
This page took 0.09527 seconds and 5 git commands to generate.