Commit | Line | Data |
---|---|---|
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> | |
a09e64fb RK |
41 | #include <mach/mmc.h> |
42 | #include <mach/udc.h> | |
43 | #include <mach/gumstix.h> | |
90b8fc34 | 44 | |
a09e64fb RK |
45 | #include <mach/pxa-regs.h> |
46 | #include <mach/pxa2xx-regs.h> | |
d8ad7859 | 47 | #include <mach/mfp-pxa25x.h> |
90b8fc34 JK |
48 | |
49 | #include "generic.h" | |
50 | ||
51 | static struct resource flash_resource = { | |
52 | .start = 0x00000000, | |
53 | .end = SZ_64M - 1, | |
54 | .flags = IORESOURCE_MEM, | |
55 | }; | |
56 | ||
57 | static struct mtd_partition gumstix_partitions[] = { | |
58 | { | |
59 | .name = "Bootloader", | |
60 | .size = 0x00040000, | |
61 | .offset = 0, | |
62 | .mask_flags = MTD_WRITEABLE /* force read-only */ | |
63 | } , { | |
64 | .name = "rootfs", | |
65 | .size = MTDPART_SIZ_FULL, | |
66 | .offset = MTDPART_OFS_APPEND | |
67 | } | |
68 | }; | |
69 | ||
70 | static struct flash_platform_data gumstix_flash_data = { | |
71 | .map_name = "cfi_probe", | |
72 | .parts = gumstix_partitions, | |
73 | .nr_parts = ARRAY_SIZE(gumstix_partitions), | |
74 | .width = 2, | |
75 | }; | |
76 | ||
77 | static struct platform_device gumstix_flash_device = { | |
78 | .name = "pxa2xx-flash", | |
79 | .id = 0, | |
80 | .dev = { | |
81 | .platform_data = &gumstix_flash_data, | |
82 | }, | |
83 | .resource = &flash_resource, | |
84 | .num_resources = 1, | |
85 | }; | |
86 | ||
87 | static struct platform_device *devices[] __initdata = { | |
88 | &gumstix_flash_device, | |
89 | }; | |
90 | ||
91 | #ifdef CONFIG_MMC_PXA | |
90b8fc34 JK |
92 | static struct pxamci_platform_data gumstix_mci_platform_data = { |
93 | .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34, | |
90b8fc34 JK |
94 | }; |
95 | ||
96 | static void __init gumstix_mmc_init(void) | |
97 | { | |
98 | pxa_set_mci_info(&gumstix_mci_platform_data); | |
99 | } | |
100 | #else | |
101 | static void __init gumstix_mmc_init(void) | |
102 | { | |
d8ad7859 | 103 | pr_debug("Gumstix mmc disabled\n"); |
90b8fc34 JK |
104 | } |
105 | #endif | |
106 | ||
d8ad7859 | 107 | #ifdef CONFIG_USB_GADGET_PXA25X |
90b8fc34 JK |
108 | static struct pxa2xx_udc_mach_info gumstix_udc_info __initdata = { |
109 | .gpio_vbus = GPIO_GUMSTIX_USB_GPIOn, | |
110 | .gpio_pullup = GPIO_GUMSTIX_USB_GPIOx, | |
111 | }; | |
112 | ||
113 | static void __init gumstix_udc_init(void) | |
114 | { | |
115 | pxa_set_udc_info(&gumstix_udc_info); | |
116 | } | |
117 | #else | |
118 | static void gumstix_udc_init(void) | |
119 | { | |
d8ad7859 | 120 | pr_debug("Gumstix udc is disabled\n"); |
90b8fc34 JK |
121 | } |
122 | #endif | |
123 | ||
d8ad7859 JK |
124 | #ifdef CONFIG_BT |
125 | /* Normally, the bootloader would have enabled this 32kHz clock but many | |
126 | ** boards still have u-boot 1.1.4 so we check if it has been turned on and | |
127 | ** if not, we turn it on with a warning message. */ | |
128 | static void gumstix_setup_bt_clock(void) | |
129 | { | |
130 | int timeout = 500; | |
131 | ||
132 | if (!(OSCC & OSCC_OOK)) | |
133 | pr_warning("32kHz clock was not on. Bootloader may need to " | |
134 | "be updated\n"); | |
135 | else | |
136 | return; | |
137 | ||
138 | OSCC |= OSCC_OON; | |
139 | do { | |
140 | if (OSCC & OSCC_OOK) | |
141 | break; | |
142 | udelay(1); | |
143 | } while (--timeout); | |
144 | if (!timeout) | |
145 | pr_err("Failed to start 32kHz clock\n"); | |
146 | } | |
147 | ||
148 | static void __init gumstix_bluetooth_init(void) | |
149 | { | |
150 | int err; | |
151 | ||
152 | gumstix_setup_bt_clock(); | |
153 | ||
154 | err = gpio_request(GPIO_GUMSTIX_BTRESET, "BTRST"); | |
155 | if (err) { | |
156 | pr_err("gumstix: failed request gpio for bluetooth reset\n"); | |
157 | return; | |
158 | } | |
159 | ||
160 | err = gpio_direction_output(GPIO_GUMSTIX_BTRESET, 1); | |
161 | if (err) { | |
162 | pr_err("gumstix: can't reset bluetooth\n"); | |
163 | return; | |
164 | } | |
165 | gpio_set_value(GPIO_GUMSTIX_BTRESET, 0); | |
166 | udelay(100); | |
167 | gpio_set_value(GPIO_GUMSTIX_BTRESET, 1); | |
168 | } | |
169 | #else | |
170 | static void gumstix_bluetooth_init(void) | |
171 | { | |
172 | pr_debug("Gumstix Bluetooth is disabled\n"); | |
173 | } | |
174 | #endif | |
175 | ||
176 | static unsigned long gumstix_pin_config[] __initdata = { | |
177 | GPIO12_32KHz, | |
178 | /* BTUART */ | |
179 | GPIO42_HWUART_RXD, | |
180 | GPIO43_HWUART_TXD, | |
181 | GPIO44_HWUART_CTS, | |
182 | GPIO45_HWUART_RTS, | |
183 | /* MMC */ | |
184 | GPIO6_MMC_CLK, | |
185 | GPIO53_MMC_CLK, | |
186 | GPIO8_MMC_CS0, | |
d8ad7859 JK |
187 | }; |
188 | ||
3332b0c1 JK |
189 | int __attribute__((weak)) am200_init(void) |
190 | { | |
191 | return 0; | |
192 | } | |
193 | ||
194 | static void __init carrier_board_init(void) | |
195 | { | |
196 | /* | |
197 | * put carrier/expansion board init here if | |
198 | * they cannot be detected programatically | |
199 | */ | |
200 | am200_init(); | |
201 | } | |
202 | ||
90b8fc34 JK |
203 | static void __init gumstix_init(void) |
204 | { | |
d8ad7859 JK |
205 | pxa2xx_mfp_config(ARRAY_AND_SIZE(gumstix_pin_config)); |
206 | ||
207 | gumstix_bluetooth_init(); | |
90b8fc34 JK |
208 | gumstix_udc_init(); |
209 | gumstix_mmc_init(); | |
210 | (void) platform_add_devices(devices, ARRAY_SIZE(devices)); | |
3332b0c1 | 211 | carrier_board_init(); |
90b8fc34 JK |
212 | } |
213 | ||
214 | MACHINE_START(GUMSTIX, "Gumstix") | |
215 | .phys_io = 0x40000000, | |
216 | .boot_params = 0xa0000100, /* match u-boot bi_boot_params */ | |
217 | .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc, | |
218 | .map_io = pxa_map_io, | |
219 | .init_irq = pxa25x_init_irq, | |
220 | .timer = &pxa_timer, | |
221 | .init_machine = gumstix_init, | |
222 | MACHINE_END |