blob: eb03283ccdeec454b4330d396cae7772f00fb7eb [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>
Dmitry Eremin-Solenikovd19f4cb2011-02-14 15:33:17 +030029#include <linux/usb/gpio_vbus.h>
Jaya Kumar90b8fc32008-03-15 05:11:07 +010030
31#include <asm/setup.h>
32#include <asm/memory.h>
33#include <asm/mach-types.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010034#include <mach/hardware.h>
Jaya Kumar90b8fc32008-03-15 05:11:07 +010035#include <asm/irq.h>
Masahiro Yamada87dfb312019-05-14 15:46:51 -070036#include <linux/sizes.h>
Jaya Kumar90b8fc32008-03-15 05:11:07 +010037
38#include <asm/mach/arch.h>
39#include <asm/mach/map.h>
40#include <asm/mach/irq.h>
41#include <asm/mach/flash.h>
Eric Miao51c62982009-01-02 23:17:22 +080042
Arnd Bergmann4c25c5d2015-01-30 10:45:33 +010043#include "pxa25x.h"
Arnd Bergmann293b2da2012-08-24 15:16:48 +020044#include <linux/platform_data/mmc-pxamci.h>
Arnd Bergmann4c25c5d2015-01-30 10:45:33 +010045#include "udc.h"
46#include "gumstix.h"
Jaya Kumar90b8fc32008-03-15 05:11:07 +010047
Jaya Kumar90b8fc32008-03-15 05:11:07 +010048#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
Jaya Kumar90b8fc32008-03-15 05:11:07 +010091static struct pxamci_platform_data gumstix_mci_platform_data = {
Robert Jarzmik7a648252009-07-06 22:16:42 +020092 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
Jaya Kumar90b8fc32008-03-15 05:11:07 +010093};
94
95static void __init gumstix_mmc_init(void)
96{
97 pxa_set_mci_info(&gumstix_mci_platform_data);
98}
99#else
100static void __init gumstix_mmc_init(void)
101{
Jaya Kumard8ad7852008-08-16 04:07:18 +0100102 pr_debug("Gumstix mmc disabled\n");
Jaya Kumar90b8fc32008-03-15 05:11:07 +0100103}
104#endif
105
Haojian Zhuangc0a39152011-11-10 07:13:07 +0800106#ifdef CONFIG_USB_PXA25X
Dmitry Eremin-Solenikovd19f4cb2011-02-14 15:33:17 +0300107static struct gpio_vbus_mach_info gumstix_udc_info = {
Jaya Kumar90b8fc32008-03-15 05:11:07 +0100108 .gpio_vbus = GPIO_GUMSTIX_USB_GPIOn,
109 .gpio_pullup = GPIO_GUMSTIX_USB_GPIOx,
110};
111
Dmitry Eremin-Solenikovd19f4cb2011-02-14 15:33:17 +0300112static struct platform_device gumstix_gpio_vbus = {
113 .name = "gpio-vbus",
114 .id = -1,
115 .dev = {
116 .platform_data = &gumstix_udc_info,
117 },
118};
119
Jaya Kumar90b8fc32008-03-15 05:11:07 +0100120static void __init gumstix_udc_init(void)
121{
Dmitry Eremin-Solenikovd19f4cb2011-02-14 15:33:17 +0300122 platform_device_register(&gumstix_gpio_vbus);
Jaya Kumar90b8fc32008-03-15 05:11:07 +0100123}
124#else
125static void gumstix_udc_init(void)
126{
Jaya Kumard8ad7852008-08-16 04:07:18 +0100127 pr_debug("Gumstix udc is disabled\n");
Jaya Kumar90b8fc32008-03-15 05:11:07 +0100128}
129#endif
130
Jaya Kumard8ad7852008-08-16 04:07:18 +0100131#ifdef CONFIG_BT
132/* Normally, the bootloader would have enabled this 32kHz clock but many
133** boards still have u-boot 1.1.4 so we check if it has been turned on and
134** if not, we turn it on with a warning message. */
135static void gumstix_setup_bt_clock(void)
136{
137 int timeout = 500;
138
Arnd Bergmannea7743e2016-01-29 15:06:25 +0100139 if (!(readl(OSCC) & OSCC_OOK))
Joe Perches7b472ac2014-09-13 11:31:18 -0700140 pr_warn("32kHz clock was not on. Bootloader may need to be updated\n");
Jaya Kumard8ad7852008-08-16 04:07:18 +0100141 else
142 return;
143
Arnd Bergmannea7743e2016-01-29 15:06:25 +0100144 writel(readl(OSCC) | OSCC_OON, OSCC);
Jaya Kumard8ad7852008-08-16 04:07:18 +0100145 do {
Arnd Bergmannea7743e2016-01-29 15:06:25 +0100146 if (readl(OSCC) & OSCC_OOK)
Jaya Kumard8ad7852008-08-16 04:07:18 +0100147 break;
148 udelay(1);
149 } while (--timeout);
150 if (!timeout)
151 pr_err("Failed to start 32kHz clock\n");
152}
153
154static void __init gumstix_bluetooth_init(void)
155{
156 int err;
157
158 gumstix_setup_bt_clock();
159
160 err = gpio_request(GPIO_GUMSTIX_BTRESET, "BTRST");
161 if (err) {
162 pr_err("gumstix: failed request gpio for bluetooth reset\n");
163 return;
164 }
165
166 err = gpio_direction_output(GPIO_GUMSTIX_BTRESET, 1);
167 if (err) {
168 pr_err("gumstix: can't reset bluetooth\n");
169 return;
170 }
171 gpio_set_value(GPIO_GUMSTIX_BTRESET, 0);
172 udelay(100);
173 gpio_set_value(GPIO_GUMSTIX_BTRESET, 1);
174}
175#else
176static void gumstix_bluetooth_init(void)
177{
178 pr_debug("Gumstix Bluetooth is disabled\n");
179}
180#endif
181
182static unsigned long gumstix_pin_config[] __initdata = {
183 GPIO12_32KHz,
184 /* BTUART */
185 GPIO42_HWUART_RXD,
186 GPIO43_HWUART_TXD,
187 GPIO44_HWUART_CTS,
188 GPIO45_HWUART_RTS,
189 /* MMC */
190 GPIO6_MMC_CLK,
191 GPIO53_MMC_CLK,
192 GPIO8_MMC_CS0,
Jaya Kumard8ad7852008-08-16 04:07:18 +0100193};
194
Jaya Kumar3332b0c2008-12-09 22:14:29 +0800195int __attribute__((weak)) am200_init(void)
196{
197 return 0;
198}
199
Jaya Kumar4ce255c2009-01-01 17:51:01 +0100200int __attribute__((weak)) am300_init(void)
201{
202 return 0;
203}
204
Jaya Kumar3332b0c2008-12-09 22:14:29 +0800205static void __init carrier_board_init(void)
206{
207 /*
208 * put carrier/expansion board init here if
209 * they cannot be detected programatically
210 */
211 am200_init();
Jaya Kumar4ce255c2009-01-01 17:51:01 +0100212 am300_init();
Jaya Kumar3332b0c2008-12-09 22:14:29 +0800213}
214
Jaya Kumar90b8fc32008-03-15 05:11:07 +0100215static void __init gumstix_init(void)
216{
Jaya Kumard8ad7852008-08-16 04:07:18 +0100217 pxa2xx_mfp_config(ARRAY_AND_SIZE(gumstix_pin_config));
218
Russell Kingcc155c62009-11-09 13:34:08 +0800219 pxa_set_ffuart_info(NULL);
220 pxa_set_btuart_info(NULL);
221 pxa_set_stuart_info(NULL);
222 pxa_set_hwuart_info(NULL);
223
Jaya Kumard8ad7852008-08-16 04:07:18 +0100224 gumstix_bluetooth_init();
Jaya Kumar90b8fc32008-03-15 05:11:07 +0100225 gumstix_udc_init();
226 gumstix_mmc_init();
227 (void) platform_add_devices(devices, ARRAY_SIZE(devices));
Jaya Kumar3332b0c2008-12-09 22:14:29 +0800228 carrier_board_init();
Jaya Kumar90b8fc32008-03-15 05:11:07 +0100229}
230
231MACHINE_START(GUMSTIX, "Gumstix")
Nicolas Pitre7375aba2011-07-05 22:38:15 -0400232 .atag_offset = 0x100, /* match u-boot bi_boot_params */
Marek Vasut851982c2010-10-11 02:20:19 +0200233 .map_io = pxa25x_map_io,
Rob Herring4e611092012-01-03 16:53:48 -0600234 .nr_irqs = PXA_NR_IRQS,
Jaya Kumar90b8fc32008-03-15 05:11:07 +0100235 .init_irq = pxa25x_init_irq,
Eric Miao8a97ae22011-05-18 21:30:04 +0800236 .handle_irq = pxa25x_handle_irq,
Stephen Warren6bb27d72012-11-08 12:40:59 -0700237 .init_time = pxa_timer_init,
Jaya Kumar90b8fc32008-03-15 05:11:07 +0100238 .init_machine = gumstix_init,
Russell King271a74f2011-11-04 14:15:53 +0000239 .restart = pxa_restart,
Jaya Kumar90b8fc32008-03-15 05:11:07 +0100240MACHINE_END