Blame view

arch/arm/mach-pxa/gumstix.c 5.05 KB
d2912cb15   Thomas Gleixner   treewide: Replace...
1
  // SPDX-License-Identifier: GPL-2.0-only
90b8fc349   Jaya Kumar   [ARM] 4867/1: Add...
2
3
4
5
6
7
8
9
10
  /*
   *  linux/arch/arm/mach-pxa/gumstix.c
   *
   *  Support for the Gumstix motherboards.
   *
   *  Original Author:	Craig Hughes
   *  Created:	Feb 14, 2008
   *  Copyright:	Craig Hughes
   *
90b8fc349   Jaya Kumar   [ARM] 4867/1: Add...
11
12
13
14
15
16
17
18
19
   *  Implemented based on lubbock.c by Nicolas Pitre and code from Craig
   *  Hughes
   */
  
  #include <linux/module.h>
  #include <linux/kernel.h>
  #include <linux/init.h>
  #include <linux/platform_device.h>
  #include <linux/interrupt.h>
d8ad7859e   Jaya Kumar   [ARM] 5197/1: gum...
20
  #include <linux/delay.h>
90b8fc349   Jaya Kumar   [ARM] 4867/1: Add...
21
22
  #include <linux/mtd/mtd.h>
  #include <linux/mtd/partitions.h>
fdabc466f   Linus Walleij   usb: phy: phy-gpi...
23
  #include <linux/gpio/machine.h>
d8ad7859e   Jaya Kumar   [ARM] 5197/1: gum...
24
25
26
  #include <linux/gpio.h>
  #include <linux/err.h>
  #include <linux/clk.h>
90b8fc349   Jaya Kumar   [ARM] 4867/1: Add...
27
28
29
30
  
  #include <asm/setup.h>
  #include <asm/memory.h>
  #include <asm/mach-types.h>
a09e64fbc   Russell King   [ARM] Move includ...
31
  #include <mach/hardware.h>
90b8fc349   Jaya Kumar   [ARM] 4867/1: Add...
32
  #include <asm/irq.h>
87dfb311b   Masahiro Yamada   treewide: replace...
33
  #include <linux/sizes.h>
90b8fc349   Jaya Kumar   [ARM] 4867/1: Add...
34
35
36
37
38
  
  #include <asm/mach/arch.h>
  #include <asm/mach/map.h>
  #include <asm/mach/irq.h>
  #include <asm/mach/flash.h>
51c62982a   Eric Miao   [ARM] pxa: introd...
39

4c25c5d29   Arnd Bergmann   ARM: pxa: make mo...
40
  #include "pxa25x.h"
293b2da1b   Arnd Bergmann   ARM: pxa: move pl...
41
  #include <linux/platform_data/mmc-pxamci.h>
4c25c5d29   Arnd Bergmann   ARM: pxa: make mo...
42
43
  #include "udc.h"
  #include "gumstix.h"
90b8fc349   Jaya Kumar   [ARM] 4867/1: Add...
44

90b8fc349   Jaya Kumar   [ARM] 4867/1: Add...
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
  #include "generic.h"
  
  static struct resource flash_resource = {
  	.start	= 0x00000000,
  	.end	= SZ_64M - 1,
  	.flags	= IORESOURCE_MEM,
  };
  
  static struct mtd_partition gumstix_partitions[] = {
  	{
  		.name =		"Bootloader",
  		.size =		0x00040000,
  		.offset =	0,
  		.mask_flags =	MTD_WRITEABLE  /* force read-only */
  	} , {
  		.name =		"rootfs",
  		.size =		MTDPART_SIZ_FULL,
  		.offset =	MTDPART_OFS_APPEND
  	}
  };
  
  static struct flash_platform_data gumstix_flash_data = {
  	.map_name	= "cfi_probe",
  	.parts		= gumstix_partitions,
  	.nr_parts	= ARRAY_SIZE(gumstix_partitions),
  	.width		= 2,
  };
  
  static struct platform_device gumstix_flash_device = {
  	.name		= "pxa2xx-flash",
  	.id		= 0,
  	.dev = {
  		.platform_data = &gumstix_flash_data,
  	},
  	.resource = &flash_resource,
  	.num_resources = 1,
  };
  
  static struct platform_device *devices[] __initdata = {
  	&gumstix_flash_device,
  };
  
  #ifdef CONFIG_MMC_PXA
90b8fc349   Jaya Kumar   [ARM] 4867/1: Add...
88
  static struct pxamci_platform_data gumstix_mci_platform_data = {
7a648256b   Robert Jarzmik   [ARM] pxa: factor...
89
  	.ocr_mask		= MMC_VDD_32_33|MMC_VDD_33_34,
90b8fc349   Jaya Kumar   [ARM] 4867/1: Add...
90
91
92
93
94
95
96
97
98
  };
  
  static void __init gumstix_mmc_init(void)
  {
  	pxa_set_mci_info(&gumstix_mci_platform_data);
  }
  #else
  static void __init gumstix_mmc_init(void)
  {
d8ad7859e   Jaya Kumar   [ARM] 5197/1: gum...
99
100
  	pr_debug("Gumstix mmc disabled
  ");
90b8fc349   Jaya Kumar   [ARM] 4867/1: Add...
101
102
  }
  #endif
c0a39151a   Haojian Zhuang   ARM: pxa: fix inc...
103
  #ifdef CONFIG_USB_PXA25X
fdabc466f   Linus Walleij   usb: phy: phy-gpi...
104
105
106
107
108
109
110
111
112
  static struct gpiod_lookup_table gumstix_gpio_vbus_gpiod_table = {
  	.dev_id = "gpio-vbus",
  	.table = {
  		GPIO_LOOKUP("gpio-pxa", GPIO_GUMSTIX_USB_GPIOn,
  			    "vbus", GPIO_ACTIVE_HIGH),
  		GPIO_LOOKUP("gpio-pxa", GPIO_GUMSTIX_USB_GPIOx,
  			    "pullup", GPIO_ACTIVE_HIGH),
  		{ },
  	},
90b8fc349   Jaya Kumar   [ARM] 4867/1: Add...
113
  };
d19f4cbd4   Dmitry Eremin-Solenikov   ARM: pxa/gumstix:...
114
115
116
  static struct platform_device gumstix_gpio_vbus = {
  	.name	= "gpio-vbus",
  	.id	= -1,
d19f4cbd4   Dmitry Eremin-Solenikov   ARM: pxa/gumstix:...
117
  };
90b8fc349   Jaya Kumar   [ARM] 4867/1: Add...
118
119
  static void __init gumstix_udc_init(void)
  {
fdabc466f   Linus Walleij   usb: phy: phy-gpi...
120
  	gpiod_add_lookup_table(&gumstix_gpio_vbus_gpiod_table);
d19f4cbd4   Dmitry Eremin-Solenikov   ARM: pxa/gumstix:...
121
  	platform_device_register(&gumstix_gpio_vbus);
90b8fc349   Jaya Kumar   [ARM] 4867/1: Add...
122
123
124
125
  }
  #else
  static void gumstix_udc_init(void)
  {
d8ad7859e   Jaya Kumar   [ARM] 5197/1: gum...
126
127
  	pr_debug("Gumstix udc is disabled
  ");
90b8fc349   Jaya Kumar   [ARM] 4867/1: Add...
128
129
  }
  #endif
d8ad7859e   Jaya Kumar   [ARM] 5197/1: gum...
130
131
132
133
134
135
136
  #ifdef CONFIG_BT
  /* Normally, the bootloader would have enabled this 32kHz clock but many
  ** boards still have u-boot 1.1.4 so we check if it has been turned on and
  ** if not, we turn it on with a warning message. */
  static void gumstix_setup_bt_clock(void)
  {
  	int timeout = 500;
ea7743e27   Arnd Bergmann   ARM: pxa: define ...
137
  	if (!(readl(OSCC) & OSCC_OOK))
7b472ac75   Joe Perches   arm: mach-pxa: Co...
138
139
  		pr_warn("32kHz clock was not on. Bootloader may need to be updated
  ");
d8ad7859e   Jaya Kumar   [ARM] 5197/1: gum...
140
141
  	else
  		return;
ea7743e27   Arnd Bergmann   ARM: pxa: define ...
142
  	writel(readl(OSCC) | OSCC_OON, OSCC);
d8ad7859e   Jaya Kumar   [ARM] 5197/1: gum...
143
  	do {
ea7743e27   Arnd Bergmann   ARM: pxa: define ...
144
  		if (readl(OSCC) & OSCC_OOK)
d8ad7859e   Jaya Kumar   [ARM] 5197/1: gum...
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
  			break;
  		udelay(1);
  	} while (--timeout);
  	if (!timeout)
  		pr_err("Failed to start 32kHz clock
  ");
  }
  
  static void __init gumstix_bluetooth_init(void)
  {
  	int err;
  
  	gumstix_setup_bt_clock();
  
  	err = gpio_request(GPIO_GUMSTIX_BTRESET, "BTRST");
  	if (err) {
  		pr_err("gumstix: failed request gpio for bluetooth reset
  ");
  		return;
  	}
  
  	err = gpio_direction_output(GPIO_GUMSTIX_BTRESET, 1);
  	if (err) {
  		pr_err("gumstix: can't reset bluetooth
  ");
  		return;
  	}
  	gpio_set_value(GPIO_GUMSTIX_BTRESET, 0);
  	udelay(100);
  	gpio_set_value(GPIO_GUMSTIX_BTRESET, 1);
  }
  #else
  static void gumstix_bluetooth_init(void)
  {
  	pr_debug("Gumstix Bluetooth is disabled
  ");
  }
  #endif
  
  static unsigned long gumstix_pin_config[] __initdata = {
  	GPIO12_32KHz,
  	/* BTUART */
  	GPIO42_HWUART_RXD,
  	GPIO43_HWUART_TXD,
  	GPIO44_HWUART_CTS,
  	GPIO45_HWUART_RTS,
  	/* MMC */
  	GPIO6_MMC_CLK,
  	GPIO53_MMC_CLK,
  	GPIO8_MMC_CS0,
d8ad7859e   Jaya Kumar   [ARM] 5197/1: gum...
195
  };
3332b0c17   Jaya Kumar   [ARM] pxa/gumstix...
196
197
198
199
  int __attribute__((weak)) am200_init(void)
  {
  	return 0;
  }
4ce255c14   Jaya Kumar   [ARM] 5354/1: mac...
200
201
202
203
  int __attribute__((weak)) am300_init(void)
  {
  	return 0;
  }
3332b0c17   Jaya Kumar   [ARM] pxa/gumstix...
204
205
206
207
208
209
210
  static void __init carrier_board_init(void)
  {
  	/*
  	 * put carrier/expansion board init here if
  	 * they cannot be detected programatically
  	 */
  	am200_init();
4ce255c14   Jaya Kumar   [ARM] 5354/1: mac...
211
  	am300_init();
3332b0c17   Jaya Kumar   [ARM] pxa/gumstix...
212
  }
90b8fc349   Jaya Kumar   [ARM] 4867/1: Add...
213
214
  static void __init gumstix_init(void)
  {
d8ad7859e   Jaya Kumar   [ARM] 5197/1: gum...
215
  	pxa2xx_mfp_config(ARRAY_AND_SIZE(gumstix_pin_config));
cc155c6f2   Russell King   [ARM] pxa: allow ...
216
217
218
219
  	pxa_set_ffuart_info(NULL);
  	pxa_set_btuart_info(NULL);
  	pxa_set_stuart_info(NULL);
  	pxa_set_hwuart_info(NULL);
d8ad7859e   Jaya Kumar   [ARM] 5197/1: gum...
220
  	gumstix_bluetooth_init();
90b8fc349   Jaya Kumar   [ARM] 4867/1: Add...
221
222
223
  	gumstix_udc_init();
  	gumstix_mmc_init();
  	(void) platform_add_devices(devices, ARRAY_SIZE(devices));
3332b0c17   Jaya Kumar   [ARM] pxa/gumstix...
224
  	carrier_board_init();
90b8fc349   Jaya Kumar   [ARM] 4867/1: Add...
225
226
227
  }
  
  MACHINE_START(GUMSTIX, "Gumstix")
7375aba67   Nicolas Pitre   ARM: mach-pxa: co...
228
  	.atag_offset	= 0x100, /* match u-boot bi_boot_params */
851982c1b   Marek Vasut   ARM: pxa: Introdu...
229
  	.map_io		= pxa25x_map_io,
4e611091f   Rob Herring   ARM: pxa: remove ...
230
  	.nr_irqs	= PXA_NR_IRQS,
90b8fc349   Jaya Kumar   [ARM] 4867/1: Add...
231
  	.init_irq	= pxa25x_init_irq,
8a97ae2f5   Eric Miao   ARM: pxa: enable ...
232
  	.handle_irq	= pxa25x_handle_irq,
6bb27d734   Stephen Warren   ARM: delete struc...
233
  	.init_time	= pxa_timer_init,
90b8fc349   Jaya Kumar   [ARM] 4867/1: Add...
234
  	.init_machine	= gumstix_init,
271a74fc8   Russell King   ARM: restart: pxa...
235
  	.restart	= pxa_restart,
90b8fc349   Jaya Kumar   [ARM] 4867/1: Add...
236
  MACHINE_END