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