mm: make wait_on_page_writeback() wait for multiple pending writebacks
[linux/fpc-iii.git] / arch / arm / mach-pxa / gumstix.c
blob49dd618b10f7ef742fee5f996ca1ff6cc73ebf24
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3 * linux/arch/arm/mach-pxa/gumstix.c
5 * Support for the Gumstix motherboards.
7 * Original Author: Craig Hughes
8 * Created: Feb 14, 2008
9 * Copyright: Craig Hughes
11 * Implemented based on lubbock.c by Nicolas Pitre and code from Craig
12 * Hughes
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>
20 #include <linux/delay.h>
21 #include <linux/mtd/mtd.h>
22 #include <linux/mtd/partitions.h>
23 #include <linux/gpio/machine.h>
24 #include <linux/gpio.h>
25 #include <linux/err.h>
26 #include <linux/clk.h>
28 #include <asm/setup.h>
29 #include <asm/memory.h>
30 #include <asm/mach-types.h>
31 #include <mach/hardware.h>
32 #include <asm/irq.h>
33 #include <linux/sizes.h>
35 #include <asm/mach/arch.h>
36 #include <asm/mach/map.h>
37 #include <asm/mach/irq.h>
38 #include <asm/mach/flash.h>
40 #include "pxa25x.h"
41 #include <linux/platform_data/mmc-pxamci.h>
42 #include "udc.h"
43 #include "gumstix.h"
45 #include "generic.h"
47 static struct resource flash_resource = {
48 .start = 0x00000000,
49 .end = SZ_64M - 1,
50 .flags = IORESOURCE_MEM,
53 static struct mtd_partition gumstix_partitions[] = {
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
66 static 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,
73 static struct platform_device gumstix_flash_device = {
74 .name = "pxa2xx-flash",
75 .id = 0,
76 .dev = {
77 .platform_data = &gumstix_flash_data,
79 .resource = &flash_resource,
80 .num_resources = 1,
83 static struct platform_device *devices[] __initdata = {
84 &gumstix_flash_device,
87 #ifdef CONFIG_MMC_PXA
88 static struct pxamci_platform_data gumstix_mci_platform_data = {
89 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
92 static void __init gumstix_mmc_init(void)
94 pxa_set_mci_info(&gumstix_mci_platform_data);
96 #else
97 static void __init gumstix_mmc_init(void)
99 pr_debug("Gumstix mmc disabled\n");
101 #endif
103 #ifdef CONFIG_USB_PXA25X
104 static struct gpiod_lookup_table gumstix_gpio_vbus_gpiod_table = {
105 .dev_id = "gpio-vbus",
106 .table = {
107 GPIO_LOOKUP("gpio-pxa", GPIO_GUMSTIX_USB_GPIOn,
108 "vbus", GPIO_ACTIVE_HIGH),
109 GPIO_LOOKUP("gpio-pxa", GPIO_GUMSTIX_USB_GPIOx,
110 "pullup", GPIO_ACTIVE_HIGH),
111 { },
115 static struct platform_device gumstix_gpio_vbus = {
116 .name = "gpio-vbus",
117 .id = -1,
120 static void __init gumstix_udc_init(void)
122 gpiod_add_lookup_table(&gumstix_gpio_vbus_gpiod_table);
123 platform_device_register(&gumstix_gpio_vbus);
125 #else
126 static void gumstix_udc_init(void)
128 pr_debug("Gumstix udc is disabled\n");
130 #endif
132 #ifdef CONFIG_BT
133 /* Normally, the bootloader would have enabled this 32kHz clock but many
134 ** boards still have u-boot 1.1.4 so we check if it has been turned on and
135 ** if not, we turn it on with a warning message. */
136 static void gumstix_setup_bt_clock(void)
138 int timeout = 500;
140 if (!(readl(OSCC) & OSCC_OOK))
141 pr_warn("32kHz clock was not on. Bootloader may need to be updated\n");
142 else
143 return;
145 writel(readl(OSCC) | OSCC_OON, OSCC);
146 do {
147 if (readl(OSCC) & OSCC_OOK)
148 break;
149 udelay(1);
150 } while (--timeout);
151 if (!timeout)
152 pr_err("Failed to start 32kHz clock\n");
155 static void __init gumstix_bluetooth_init(void)
157 int err;
159 gumstix_setup_bt_clock();
161 err = gpio_request(GPIO_GUMSTIX_BTRESET, "BTRST");
162 if (err) {
163 pr_err("gumstix: failed request gpio for bluetooth reset\n");
164 return;
167 err = gpio_direction_output(GPIO_GUMSTIX_BTRESET, 1);
168 if (err) {
169 pr_err("gumstix: can't reset bluetooth\n");
170 return;
172 gpio_set_value(GPIO_GUMSTIX_BTRESET, 0);
173 udelay(100);
174 gpio_set_value(GPIO_GUMSTIX_BTRESET, 1);
176 #else
177 static void gumstix_bluetooth_init(void)
179 pr_debug("Gumstix Bluetooth is disabled\n");
181 #endif
183 static unsigned long gumstix_pin_config[] __initdata = {
184 GPIO12_32KHz,
185 /* BTUART */
186 GPIO42_HWUART_RXD,
187 GPIO43_HWUART_TXD,
188 GPIO44_HWUART_CTS,
189 GPIO45_HWUART_RTS,
190 /* MMC */
191 GPIO6_MMC_CLK,
192 GPIO53_MMC_CLK,
193 GPIO8_MMC_CS0,
196 int __attribute__((weak)) am200_init(void)
198 return 0;
201 int __attribute__((weak)) am300_init(void)
203 return 0;
206 static void __init carrier_board_init(void)
209 * put carrier/expansion board init here if
210 * they cannot be detected programatically
212 am200_init();
213 am300_init();
216 static void __init gumstix_init(void)
218 pxa2xx_mfp_config(ARRAY_AND_SIZE(gumstix_pin_config));
220 pxa_set_ffuart_info(NULL);
221 pxa_set_btuart_info(NULL);
222 pxa_set_stuart_info(NULL);
223 pxa_set_hwuart_info(NULL);
225 gumstix_bluetooth_init();
226 gumstix_udc_init();
227 gumstix_mmc_init();
228 (void) platform_add_devices(devices, ARRAY_SIZE(devices));
229 carrier_board_init();
232 MACHINE_START(GUMSTIX, "Gumstix")
233 .atag_offset = 0x100, /* match u-boot bi_boot_params */
234 .map_io = pxa25x_map_io,
235 .nr_irqs = PXA_NR_IRQS,
236 .init_irq = pxa25x_init_irq,
237 .handle_irq = pxa25x_handle_irq,
238 .init_time = pxa_timer_init,
239 .init_machine = gumstix_init,
240 .restart = pxa_restart,
241 MACHINE_END