Merge branch 'siginfo-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ebieder...
[linux-2.6-block.git] / arch / arm / mach-pxa / gumstix.c
CommitLineData
d2912cb1 1// SPDX-License-Identifier: GPL-2.0-only
90b8fc34
JK
2/*
3 * linux/arch/arm/mach-pxa/gumstix.c
4 *
5 * Support for the Gumstix motherboards.
6 *
7 * Original Author: Craig Hughes
8 * Created: Feb 14, 2008
9 * Copyright: Craig Hughes
10 *
90b8fc34
JK
11 * Implemented based on lubbock.c by Nicolas Pitre and code from Craig
12 * Hughes
13 */
14
15#include <linux/module.h>
16#include <linux/kernel.h>
17#include <linux/init.h>
18#include <linux/platform_device.h>
19#include <linux/interrupt.h>
d8ad7859 20#include <linux/delay.h>
90b8fc34
JK
21#include <linux/mtd/mtd.h>
22#include <linux/mtd/partitions.h>
d8ad7859
JK
23#include <linux/gpio.h>
24#include <linux/err.h>
25#include <linux/clk.h>
d19f4cbd 26#include <linux/usb/gpio_vbus.h>
90b8fc34
JK
27
28#include <asm/setup.h>
29#include <asm/memory.h>
30#include <asm/mach-types.h>
a09e64fb 31#include <mach/hardware.h>
90b8fc34 32#include <asm/irq.h>
87dfb311 33#include <linux/sizes.h>
90b8fc34
JK
34
35#include <asm/mach/arch.h>
36#include <asm/mach/map.h>
37#include <asm/mach/irq.h>
38#include <asm/mach/flash.h>
51c62982 39
4c25c5d2 40#include "pxa25x.h"
293b2da1 41#include <linux/platform_data/mmc-pxamci.h>
4c25c5d2
AB
42#include "udc.h"
43#include "gumstix.h"
90b8fc34 44
90b8fc34
JK
45#include "generic.h"
46
47static struct resource flash_resource = {
48 .start = 0x00000000,
49 .end = SZ_64M - 1,
50 .flags = IORESOURCE_MEM,
51};
52
53static struct mtd_partition gumstix_partitions[] = {
54 {
55 .name = "Bootloader",
56 .size = 0x00040000,
57 .offset = 0,
58 .mask_flags = MTD_WRITEABLE /* force read-only */
59 } , {
60 .name = "rootfs",
61 .size = MTDPART_SIZ_FULL,
62 .offset = MTDPART_OFS_APPEND
63 }
64};
65
66static struct flash_platform_data gumstix_flash_data = {
67 .map_name = "cfi_probe",
68 .parts = gumstix_partitions,
69 .nr_parts = ARRAY_SIZE(gumstix_partitions),
70 .width = 2,
71};
72
73static struct platform_device gumstix_flash_device = {
74 .name = "pxa2xx-flash",
75 .id = 0,
76 .dev = {
77 .platform_data = &gumstix_flash_data,
78 },
79 .resource = &flash_resource,
80 .num_resources = 1,
81};
82
83static struct platform_device *devices[] __initdata = {
84 &gumstix_flash_device,
85};
86
87#ifdef CONFIG_MMC_PXA
90b8fc34 88static struct pxamci_platform_data gumstix_mci_platform_data = {
7a648256 89 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
90b8fc34
JK
90};
91
92static void __init gumstix_mmc_init(void)
93{
94 pxa_set_mci_info(&gumstix_mci_platform_data);
95}
96#else
97static void __init gumstix_mmc_init(void)
98{
d8ad7859 99 pr_debug("Gumstix mmc disabled\n");
90b8fc34
JK
100}
101#endif
102
c0a39151 103#ifdef CONFIG_USB_PXA25X
d19f4cbd 104static struct gpio_vbus_mach_info gumstix_udc_info = {
90b8fc34
JK
105 .gpio_vbus = GPIO_GUMSTIX_USB_GPIOn,
106 .gpio_pullup = GPIO_GUMSTIX_USB_GPIOx,
107};
108
d19f4cbd
DES
109static struct platform_device gumstix_gpio_vbus = {
110 .name = "gpio-vbus",
111 .id = -1,
112 .dev = {
113 .platform_data = &gumstix_udc_info,
114 },
115};
116
90b8fc34
JK
117static void __init gumstix_udc_init(void)
118{
d19f4cbd 119 platform_device_register(&gumstix_gpio_vbus);
90b8fc34
JK
120}
121#else
122static void gumstix_udc_init(void)
123{
d8ad7859 124 pr_debug("Gumstix udc is disabled\n");
90b8fc34
JK
125}
126#endif
127
d8ad7859
JK
128#ifdef CONFIG_BT
129/* Normally, the bootloader would have enabled this 32kHz clock but many
130** boards still have u-boot 1.1.4 so we check if it has been turned on and
131** if not, we turn it on with a warning message. */
132static void gumstix_setup_bt_clock(void)
133{
134 int timeout = 500;
135
ea7743e2 136 if (!(readl(OSCC) & OSCC_OOK))
7b472ac7 137 pr_warn("32kHz clock was not on. Bootloader may need to be updated\n");
d8ad7859
JK
138 else
139 return;
140
ea7743e2 141 writel(readl(OSCC) | OSCC_OON, OSCC);
d8ad7859 142 do {
ea7743e2 143 if (readl(OSCC) & OSCC_OOK)
d8ad7859
JK
144 break;
145 udelay(1);
146 } while (--timeout);
147 if (!timeout)
148 pr_err("Failed to start 32kHz clock\n");
149}
150
151static void __init gumstix_bluetooth_init(void)
152{
153 int err;
154
155 gumstix_setup_bt_clock();
156
157 err = gpio_request(GPIO_GUMSTIX_BTRESET, "BTRST");
158 if (err) {
159 pr_err("gumstix: failed request gpio for bluetooth reset\n");
160 return;
161 }
162
163 err = gpio_direction_output(GPIO_GUMSTIX_BTRESET, 1);
164 if (err) {
165 pr_err("gumstix: can't reset bluetooth\n");
166 return;
167 }
168 gpio_set_value(GPIO_GUMSTIX_BTRESET, 0);
169 udelay(100);
170 gpio_set_value(GPIO_GUMSTIX_BTRESET, 1);
171}
172#else
173static void gumstix_bluetooth_init(void)
174{
175 pr_debug("Gumstix Bluetooth is disabled\n");
176}
177#endif
178
179static unsigned long gumstix_pin_config[] __initdata = {
180 GPIO12_32KHz,
181 /* BTUART */
182 GPIO42_HWUART_RXD,
183 GPIO43_HWUART_TXD,
184 GPIO44_HWUART_CTS,
185 GPIO45_HWUART_RTS,
186 /* MMC */
187 GPIO6_MMC_CLK,
188 GPIO53_MMC_CLK,
189 GPIO8_MMC_CS0,
d8ad7859
JK
190};
191
3332b0c1
JK
192int __attribute__((weak)) am200_init(void)
193{
194 return 0;
195}
196
4ce255c1
JK
197int __attribute__((weak)) am300_init(void)
198{
199 return 0;
200}
201
3332b0c1
JK
202static void __init carrier_board_init(void)
203{
204 /*
205 * put carrier/expansion board init here if
206 * they cannot be detected programatically
207 */
208 am200_init();
4ce255c1 209 am300_init();
3332b0c1
JK
210}
211
90b8fc34
JK
212static void __init gumstix_init(void)
213{
d8ad7859
JK
214 pxa2xx_mfp_config(ARRAY_AND_SIZE(gumstix_pin_config));
215
cc155c6f
RK
216 pxa_set_ffuart_info(NULL);
217 pxa_set_btuart_info(NULL);
218 pxa_set_stuart_info(NULL);
219 pxa_set_hwuart_info(NULL);
220
d8ad7859 221 gumstix_bluetooth_init();
90b8fc34
JK
222 gumstix_udc_init();
223 gumstix_mmc_init();
224 (void) platform_add_devices(devices, ARRAY_SIZE(devices));
3332b0c1 225 carrier_board_init();
90b8fc34
JK
226}
227
228MACHINE_START(GUMSTIX, "Gumstix")
7375aba6 229 .atag_offset = 0x100, /* match u-boot bi_boot_params */
851982c1 230 .map_io = pxa25x_map_io,
4e611091 231 .nr_irqs = PXA_NR_IRQS,
90b8fc34 232 .init_irq = pxa25x_init_irq,
8a97ae2f 233 .handle_irq = pxa25x_handle_irq,
6bb27d73 234 .init_time = pxa_timer_init,
90b8fc34 235 .init_machine = gumstix_init,
271a74fc 236 .restart = pxa_restart,
90b8fc34 237MACHINE_END