Linux Audio

Check our new training course

Loading...
v3.5.6
  1/*
  2 * linux/arch/arm/mach-s3c64xx/mach-smartq.c
  3 *
  4 * Copyright (C) 2010 Maurus Cuelenaere
  5 *
  6 * This program is free software; you can redistribute it and/or modify
  7 * it under the terms of the GNU General Public License version 2 as
  8 * published by the Free Software Foundation.
  9 *
 10 */
 11
 12#include <linux/delay.h>
 13#include <linux/fb.h>
 14#include <linux/gpio.h>
 
 15#include <linux/init.h>
 16#include <linux/platform_device.h>
 
 17#include <linux/pwm_backlight.h>
 18#include <linux/serial_core.h>
 
 19#include <linux/spi/spi_gpio.h>
 20#include <linux/usb/gpio_vbus.h>
 21#include <linux/platform_data/s3c-hsotg.h>
 22
 23#include <asm/mach-types.h>
 24#include <asm/mach/map.h>
 25
 26#include <mach/map.h>
 27#include <mach/regs-gpio.h>
 28#include <mach/regs-modem.h>
 29
 30#include <plat/clock.h>
 31#include <plat/cpu.h>
 32#include <plat/devs.h>
 33#include <plat/iic.h>
 34#include <plat/gpio-cfg.h>
 35#include <plat/hwmon.h>
 36#include <plat/regs-serial.h>
 37#include <plat/usb-control.h>
 38#include <plat/sdhci.h>
 39#include <plat/ts.h>
 40
 41#include <video/platform_lcd.h>
 
 42
 43#include "common.h"
 
 
 44
 45#define UCON S3C2410_UCON_DEFAULT
 46#define ULCON (S3C2410_LCON_CS8 | S3C2410_LCON_PNONE)
 47#define UFCON (S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE)
 48
 49static struct s3c2410_uartcfg smartq_uartcfgs[] __initdata = {
 50	[0] = {
 51		.hwport	     = 0,
 52		.flags	     = 0,
 53		.ucon	     = UCON,
 54		.ulcon	     = ULCON,
 55		.ufcon	     = UFCON,
 56	},
 57	[1] = {
 58		.hwport	     = 1,
 59		.flags	     = 0,
 60		.ucon	     = UCON,
 61		.ulcon	     = ULCON,
 62		.ufcon	     = UFCON,
 63	},
 64	[2] = {
 65		.hwport	     = 2,
 66		.flags	     = 0,
 67		.ucon	     = UCON,
 68		.ulcon	     = ULCON,
 69		.ufcon	     = UFCON,
 70	},
 71};
 72
 73static void smartq_usb_host_powercontrol(int port, int to)
 74{
 75	pr_debug("%s(%d, %d)\n", __func__, port, to);
 76
 77	if (port == 0) {
 78		gpio_set_value(S3C64XX_GPL(0), to);
 79		gpio_set_value(S3C64XX_GPL(1), to);
 80	}
 81}
 82
 83static irqreturn_t smartq_usb_host_ocirq(int irq, void *pw)
 84{
 85	struct s3c2410_hcd_info *info = pw;
 86
 87	if (gpio_get_value(S3C64XX_GPL(10)) == 0) {
 88		pr_debug("%s: over-current irq (oc detected)\n", __func__);
 89		s3c2410_usb_report_oc(info, 3);
 90	} else {
 91		pr_debug("%s: over-current irq (oc cleared)\n", __func__);
 92		s3c2410_usb_report_oc(info, 0);
 93	}
 94
 95	return IRQ_HANDLED;
 96}
 97
 98static void smartq_usb_host_enableoc(struct s3c2410_hcd_info *info, int on)
 99{
100	int ret;
101
102	/* This isn't present on a SmartQ 5 board */
103	if (machine_is_smartq5())
104		return;
105
106	if (on) {
107		ret = request_irq(gpio_to_irq(S3C64XX_GPL(10)),
108				  smartq_usb_host_ocirq, IRQF_DISABLED |
109				  IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
110				  "USB host overcurrent", info);
111		if (ret != 0)
112			pr_err("failed to request usb oc irq: %d\n", ret);
113	} else {
114		free_irq(gpio_to_irq(S3C64XX_GPL(10)), info);
115	}
116}
117
118static struct s3c2410_hcd_info smartq_usb_host_info = {
119	.port[0]	= {
120		.flags	= S3C_HCDFLG_USED
121	},
122	.port[1]	= {
123		.flags	= 0
124	},
125
126	.power_control	= smartq_usb_host_powercontrol,
127	.enable_oc	= smartq_usb_host_enableoc,
128};
129
130static struct gpio_vbus_mach_info smartq_usb_otg_vbus_pdata = {
131	.gpio_vbus		= S3C64XX_GPL(9),
132	.gpio_pullup		= -1,
133	.gpio_vbus_inverted	= true,
134};
135
136static struct platform_device smartq_usb_otg_vbus_dev = {
137	.name			= "gpio-vbus",
138	.dev.platform_data	= &smartq_usb_otg_vbus_pdata,
139};
140
 
 
 
 
 
141static int smartq_bl_init(struct device *dev)
142{
143    s3c_gpio_cfgpin(S3C64XX_GPF(15), S3C_GPIO_SFN(2));
144
145    return 0;
146}
147
148static struct platform_pwm_backlight_data smartq_backlight_data = {
149	.pwm_id		= 1,
150	.max_brightness	= 1000,
151	.dft_brightness	= 600,
152	.pwm_period_ns	= 1000000000 / (1000 * 20),
153	.init		= smartq_bl_init,
154};
155
156static struct platform_device smartq_backlight_device = {
157	.name		= "pwm-backlight",
158	.dev		= {
159		.parent	= &s3c_device_timer[1].dev,
160		.platform_data = &smartq_backlight_data,
161	},
162};
163
164static struct s3c2410_ts_mach_info smartq_touchscreen_pdata __initdata = {
165	.delay			= 65535,
166	.presc			= 99,
167	.oversampling_shift	= 4,
168};
169
170static struct s3c_sdhci_platdata smartq_internal_hsmmc_pdata = {
171	.max_width		= 4,
172	.cd_type		= S3C_SDHCI_CD_PERMANENT,
173};
174
175static struct s3c_hwmon_pdata smartq_hwmon_pdata __initdata = {
176	/* Battery voltage (?-4.2V) */
177	.in[0] = &(struct s3c_hwmon_chcfg) {
178		.name		= "smartq:battery-voltage",
179		.mult		= 3300,
180		.div		= 2048,
181	},
182	/* Reference voltage (1.2V) */
183	.in[1] = &(struct s3c_hwmon_chcfg) {
184		.name		= "smartq:reference-voltage",
185		.mult		= 3300,
186		.div		= 4096,
187	},
188};
189
190static struct s3c_hsotg_plat smartq_hsotg_pdata;
191
192static int __init smartq_lcd_setup_gpio(void)
193{
194	int ret;
195
196	ret = gpio_request(S3C64XX_GPM(3), "LCD power");
197	if (ret < 0)
198		return ret;
199
200	/* turn power off */
201	gpio_direction_output(S3C64XX_GPM(3), 0);
202
203	return 0;
204}
205
206/* GPM0 -> CS */
207static struct spi_gpio_platform_data smartq_lcd_control = {
208	.sck			= S3C64XX_GPM(1),
209	.mosi			= S3C64XX_GPM(2),
210	.miso			= S3C64XX_GPM(2),
211};
212
213static struct platform_device smartq_lcd_control_device = {
214	.name			= "spi-gpio",
215	.id			= 1,
216	.dev.platform_data	= &smartq_lcd_control,
217};
218
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
219static void smartq_lcd_power_set(struct plat_lcd_data *pd, unsigned int power)
220{
221	gpio_direction_output(S3C64XX_GPM(3), power);
222}
223
224static struct plat_lcd_data smartq_lcd_power_data = {
225	.set_power	= smartq_lcd_power_set,
226};
227
228static struct platform_device smartq_lcd_power_device = {
229	.name			= "platform-lcd",
230	.dev.parent		= &s3c_device_fb.dev,
231	.dev.platform_data	= &smartq_lcd_power_data,
232};
233
234static struct i2c_board_info smartq_i2c_devs[] __initdata = {
235	{ I2C_BOARD_INFO("wm8987", 0x1a), },
236};
237
238static struct platform_device *smartq_devices[] __initdata = {
239	&s3c_device_hsmmc1,	/* Init iNAND first, ... */
240	&s3c_device_hsmmc0,	/* ... then the external SD card */
241	&s3c_device_hsmmc2,
242	&s3c_device_adc,
243	&s3c_device_fb,
244	&s3c_device_hwmon,
245	&s3c_device_i2c0,
246	&s3c_device_ohci,
247	&s3c_device_rtc,
248	&s3c_device_timer[1],
249	&s3c_device_ts,
250	&s3c_device_usb_hsotg,
251	&s3c64xx_device_iis0,
252	&smartq_backlight_device,
253	&smartq_lcd_control_device,
254	&smartq_lcd_power_device,
255	&smartq_usb_otg_vbus_dev,
256};
257
258static void __init smartq_lcd_mode_set(void)
259{
260	u32 tmp;
261
262	/* set the LCD type */
263	tmp = __raw_readl(S3C64XX_SPCON);
264	tmp &= ~S3C64XX_SPCON_LCD_SEL_MASK;
265	tmp |= S3C64XX_SPCON_LCD_SEL_RGB;
266	__raw_writel(tmp, S3C64XX_SPCON);
267
268	/* remove the LCD bypass */
269	tmp = __raw_readl(S3C64XX_MODEM_MIFPCON);
270	tmp &= ~MIFPCON_LCD_BYPASS;
271	__raw_writel(tmp, S3C64XX_MODEM_MIFPCON);
272}
273
274static void smartq_power_off(void)
275{
276	gpio_direction_output(S3C64XX_GPK(15), 1);
277}
278
279static int __init smartq_power_off_init(void)
280{
281	int ret;
282
283	ret = gpio_request(S3C64XX_GPK(15), "Power control");
284	if (ret < 0) {
285		pr_err("%s: failed to get GPK15\n", __func__);
286		return ret;
287	}
288
289	/* leave power on */
290	gpio_direction_output(S3C64XX_GPK(15), 0);
291
292	pm_power_off = smartq_power_off;
293
294	return ret;
295}
296
297static int __init smartq_usb_host_init(void)
298{
299	int ret;
300
301	ret = gpio_request(S3C64XX_GPL(0), "USB power control");
302	if (ret < 0) {
303		pr_err("%s: failed to get GPL0\n", __func__);
304		return ret;
305	}
306
307	ret = gpio_request(S3C64XX_GPL(1), "USB host power control");
308	if (ret < 0) {
309		pr_err("%s: failed to get GPL1\n", __func__);
310		goto err;
311	}
312
313	if (!machine_is_smartq5()) {
314		/* This isn't present on a SmartQ 5 board */
315		ret = gpio_request(S3C64XX_GPL(10), "USB host overcurrent");
316		if (ret < 0) {
317			pr_err("%s: failed to get GPL10\n", __func__);
318			goto err2;
319		}
320	}
321
322	/* turn power off */
323	gpio_direction_output(S3C64XX_GPL(0), 0);
324	gpio_direction_output(S3C64XX_GPL(1), 0);
325	if (!machine_is_smartq5())
326		gpio_direction_input(S3C64XX_GPL(10));
327
328	s3c_device_ohci.dev.platform_data = &smartq_usb_host_info;
329
330	return 0;
331
332err2:
333	gpio_free(S3C64XX_GPL(1));
334err:
335	gpio_free(S3C64XX_GPL(0));
336	return ret;
337}
338
339static int __init smartq_usb_otg_init(void)
340{
341	clk_xusbxti.rate = 12000000;
342
343	return 0;
344}
345
346static int __init smartq_wifi_init(void)
347{
348	int ret;
349
350	ret = gpio_request(S3C64XX_GPK(1), "wifi control");
351	if (ret < 0) {
352		pr_err("%s: failed to get GPK1\n", __func__);
353		return ret;
354	}
355
356	ret = gpio_request(S3C64XX_GPK(2), "wifi reset");
357	if (ret < 0) {
358		pr_err("%s: failed to get GPK2\n", __func__);
359		gpio_free(S3C64XX_GPK(1));
360		return ret;
361	}
362
363	/* turn power on */
364	gpio_direction_output(S3C64XX_GPK(1), 1);
365
366	/* reset device */
367	gpio_direction_output(S3C64XX_GPK(2), 0);
368	mdelay(100);
369	gpio_set_value(S3C64XX_GPK(2), 1);
370	gpio_direction_input(S3C64XX_GPK(2));
371
372	return 0;
373}
374
375static struct map_desc smartq_iodesc[] __initdata = {};
376void __init smartq_map_io(void)
377{
378	s3c64xx_init_io(smartq_iodesc, ARRAY_SIZE(smartq_iodesc));
379	s3c24xx_init_clocks(12000000);
 
380	s3c24xx_init_uarts(smartq_uartcfgs, ARRAY_SIZE(smartq_uartcfgs));
 
381
382	smartq_lcd_mode_set();
383}
384
 
 
 
 
 
 
 
 
 
385void __init smartq_machine_init(void)
386{
387	s3c_i2c0_set_platdata(NULL);
388	s3c_hsotg_set_platdata(&smartq_hsotg_pdata);
389	s3c_hwmon_set_platdata(&smartq_hwmon_pdata);
390	s3c_sdhci1_set_platdata(&smartq_internal_hsmmc_pdata);
391	s3c_sdhci2_set_platdata(&smartq_internal_hsmmc_pdata);
392	s3c24xx_ts_set_platdata(&smartq_touchscreen_pdata);
393
394	i2c_register_board_info(0, smartq_i2c_devs,
395				ARRAY_SIZE(smartq_i2c_devs));
396
397	WARN_ON(smartq_lcd_setup_gpio());
398	WARN_ON(smartq_power_off_init());
399	WARN_ON(smartq_usb_host_init());
400	WARN_ON(smartq_usb_otg_init());
401	WARN_ON(smartq_wifi_init());
402
 
 
403	platform_add_devices(smartq_devices, ARRAY_SIZE(smartq_devices));
 
 
 
404}
v5.4
  1// SPDX-License-Identifier: GPL-2.0
  2//
  3// Copyright (C) 2010 Maurus Cuelenaere
 
 
 
 
 
 
 
  4
  5#include <linux/delay.h>
  6#include <linux/fb.h>
  7#include <linux/gpio.h>
  8#include <linux/gpio/machine.h>
  9#include <linux/init.h>
 10#include <linux/platform_device.h>
 11#include <linux/pwm.h>
 12#include <linux/pwm_backlight.h>
 13#include <linux/serial_core.h>
 14#include <linux/serial_s3c.h>
 15#include <linux/spi/spi_gpio.h>
 16#include <linux/usb/gpio_vbus.h>
 17#include <linux/platform_data/s3c-hsotg.h>
 18
 19#include <asm/mach-types.h>
 20#include <asm/mach/map.h>
 21
 22#include <mach/map.h>
 23#include <mach/regs-gpio.h>
 24#include <mach/gpio-samsung.h>
 25
 
 26#include <plat/cpu.h>
 27#include <plat/devs.h>
 28#include <linux/platform_data/i2c-s3c2410.h>
 29#include <plat/gpio-cfg.h>
 30#include <linux/platform_data/hwmon-s3c.h>
 31#include <linux/platform_data/usb-ohci-s3c2410.h>
 
 32#include <plat/sdhci.h>
 33#include <linux/platform_data/touchscreen-s3c2410.h>
 34
 35#include <video/platform_lcd.h>
 36#include <plat/samsung-time.h>
 37
 38#include "common.h"
 39#include "mach-smartq.h"
 40#include "regs-modem.h"
 41
 42#define UCON S3C2410_UCON_DEFAULT
 43#define ULCON (S3C2410_LCON_CS8 | S3C2410_LCON_PNONE)
 44#define UFCON (S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE)
 45
 46static struct s3c2410_uartcfg smartq_uartcfgs[] __initdata = {
 47	[0] = {
 48		.hwport	     = 0,
 49		.flags	     = 0,
 50		.ucon	     = UCON,
 51		.ulcon	     = ULCON,
 52		.ufcon	     = UFCON,
 53	},
 54	[1] = {
 55		.hwport	     = 1,
 56		.flags	     = 0,
 57		.ucon	     = UCON,
 58		.ulcon	     = ULCON,
 59		.ufcon	     = UFCON,
 60	},
 61	[2] = {
 62		.hwport	     = 2,
 63		.flags	     = 0,
 64		.ucon	     = UCON,
 65		.ulcon	     = ULCON,
 66		.ufcon	     = UFCON,
 67	},
 68};
 69
 70static void smartq_usb_host_powercontrol(int port, int to)
 71{
 72	pr_debug("%s(%d, %d)\n", __func__, port, to);
 73
 74	if (port == 0) {
 75		gpio_set_value(S3C64XX_GPL(0), to);
 76		gpio_set_value(S3C64XX_GPL(1), to);
 77	}
 78}
 79
 80static irqreturn_t smartq_usb_host_ocirq(int irq, void *pw)
 81{
 82	struct s3c2410_hcd_info *info = pw;
 83
 84	if (gpio_get_value(S3C64XX_GPL(10)) == 0) {
 85		pr_debug("%s: over-current irq (oc detected)\n", __func__);
 86		s3c2410_usb_report_oc(info, 3);
 87	} else {
 88		pr_debug("%s: over-current irq (oc cleared)\n", __func__);
 89		s3c2410_usb_report_oc(info, 0);
 90	}
 91
 92	return IRQ_HANDLED;
 93}
 94
 95static void smartq_usb_host_enableoc(struct s3c2410_hcd_info *info, int on)
 96{
 97	int ret;
 98
 99	/* This isn't present on a SmartQ 5 board */
100	if (machine_is_smartq5())
101		return;
102
103	if (on) {
104		ret = request_irq(gpio_to_irq(S3C64XX_GPL(10)),
105				  smartq_usb_host_ocirq,
106				  IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
107				  "USB host overcurrent", info);
108		if (ret != 0)
109			pr_err("failed to request usb oc irq: %d\n", ret);
110	} else {
111		free_irq(gpio_to_irq(S3C64XX_GPL(10)), info);
112	}
113}
114
115static struct s3c2410_hcd_info smartq_usb_host_info = {
116	.port[0]	= {
117		.flags	= S3C_HCDFLG_USED
118	},
119	.port[1]	= {
120		.flags	= 0
121	},
122
123	.power_control	= smartq_usb_host_powercontrol,
124	.enable_oc	= smartq_usb_host_enableoc,
125};
126
127static struct gpio_vbus_mach_info smartq_usb_otg_vbus_pdata = {
128	.gpio_vbus		= S3C64XX_GPL(9),
129	.gpio_pullup		= -1,
130	.gpio_vbus_inverted	= true,
131};
132
133static struct platform_device smartq_usb_otg_vbus_dev = {
134	.name			= "gpio-vbus",
135	.dev.platform_data	= &smartq_usb_otg_vbus_pdata,
136};
137
138static struct pwm_lookup smartq_pwm_lookup[] = {
139	PWM_LOOKUP("samsung-pwm", 1, "pwm-backlight.0", NULL,
140		   1000000000 / (1000 * 20), PWM_POLARITY_NORMAL),
141};
142
143static int smartq_bl_init(struct device *dev)
144{
145    s3c_gpio_cfgpin(S3C64XX_GPF(15), S3C_GPIO_SFN(2));
146
147    return 0;
148}
149
150static struct platform_pwm_backlight_data smartq_backlight_data = {
 
151	.max_brightness	= 1000,
152	.dft_brightness	= 600,
153	.enable_gpio	= -1,
154	.init		= smartq_bl_init,
155};
156
157static struct platform_device smartq_backlight_device = {
158	.name		= "pwm-backlight",
159	.dev		= {
160		.parent	= &samsung_device_pwm.dev,
161		.platform_data = &smartq_backlight_data,
162	},
163};
164
165static struct s3c2410_ts_mach_info smartq_touchscreen_pdata __initdata = {
166	.delay			= 65535,
167	.presc			= 99,
168	.oversampling_shift	= 4,
169};
170
171static struct s3c_sdhci_platdata smartq_internal_hsmmc_pdata = {
172	.max_width		= 4,
173	.cd_type		= S3C_SDHCI_CD_PERMANENT,
174};
175
176static struct s3c_hwmon_pdata smartq_hwmon_pdata __initdata = {
177	/* Battery voltage (?-4.2V) */
178	.in[0] = &(struct s3c_hwmon_chcfg) {
179		.name		= "smartq:battery-voltage",
180		.mult		= 3300,
181		.div		= 2048,
182	},
183	/* Reference voltage (1.2V) */
184	.in[1] = &(struct s3c_hwmon_chcfg) {
185		.name		= "smartq:reference-voltage",
186		.mult		= 3300,
187		.div		= 4096,
188	},
189};
190
191static struct dwc2_hsotg_plat smartq_hsotg_pdata;
192
193static int __init smartq_lcd_setup_gpio(void)
194{
195	int ret;
196
197	ret = gpio_request(S3C64XX_GPM(3), "LCD power");
198	if (ret < 0)
199		return ret;
200
201	/* turn power off */
202	gpio_direction_output(S3C64XX_GPM(3), 0);
203
204	return 0;
205}
206
207/* GPM0 -> CS */
208static struct spi_gpio_platform_data smartq_lcd_control = {
209	.num_chipselect	= 1,
 
 
210};
211
212static struct platform_device smartq_lcd_control_device = {
213	.name			= "spi_gpio",
214	.id			= 1,
215	.dev.platform_data	= &smartq_lcd_control,
216};
217
218static struct gpiod_lookup_table smartq_lcd_control_gpiod_table = {
219	.dev_id         = "spi_gpio",
220	.table          = {
221		GPIO_LOOKUP("GPIOM", 1,
222			    "sck", GPIO_ACTIVE_HIGH),
223		GPIO_LOOKUP("GPIOM", 2,
224			    "mosi", GPIO_ACTIVE_HIGH),
225		GPIO_LOOKUP("GPIOM", 3,
226			    "miso", GPIO_ACTIVE_HIGH),
227		GPIO_LOOKUP("GPIOM", 0,
228			    "cs", GPIO_ACTIVE_HIGH),
229		{ },
230	},
231};
232
233static void smartq_lcd_power_set(struct plat_lcd_data *pd, unsigned int power)
234{
235	gpio_direction_output(S3C64XX_GPM(3), power);
236}
237
238static struct plat_lcd_data smartq_lcd_power_data = {
239	.set_power	= smartq_lcd_power_set,
240};
241
242static struct platform_device smartq_lcd_power_device = {
243	.name			= "platform-lcd",
244	.dev.parent		= &s3c_device_fb.dev,
245	.dev.platform_data	= &smartq_lcd_power_data,
246};
247
248static struct i2c_board_info smartq_i2c_devs[] __initdata = {
249	{ I2C_BOARD_INFO("wm8987", 0x1a), },
250};
251
252static struct platform_device *smartq_devices[] __initdata = {
253	&s3c_device_hsmmc1,	/* Init iNAND first, ... */
254	&s3c_device_hsmmc0,	/* ... then the external SD card */
255	&s3c_device_hsmmc2,
256	&s3c_device_adc,
257	&s3c_device_fb,
258	&s3c_device_hwmon,
259	&s3c_device_i2c0,
260	&s3c_device_ohci,
261	&s3c_device_rtc,
262	&samsung_device_pwm,
 
263	&s3c_device_usb_hsotg,
264	&s3c64xx_device_iis0,
265	&smartq_backlight_device,
266	&smartq_lcd_control_device,
267	&smartq_lcd_power_device,
268	&smartq_usb_otg_vbus_dev,
269};
270
271static void __init smartq_lcd_mode_set(void)
272{
273	u32 tmp;
274
275	/* set the LCD type */
276	tmp = __raw_readl(S3C64XX_SPCON);
277	tmp &= ~S3C64XX_SPCON_LCD_SEL_MASK;
278	tmp |= S3C64XX_SPCON_LCD_SEL_RGB;
279	__raw_writel(tmp, S3C64XX_SPCON);
280
281	/* remove the LCD bypass */
282	tmp = __raw_readl(S3C64XX_MODEM_MIFPCON);
283	tmp &= ~MIFPCON_LCD_BYPASS;
284	__raw_writel(tmp, S3C64XX_MODEM_MIFPCON);
285}
286
287static void smartq_power_off(void)
288{
289	gpio_direction_output(S3C64XX_GPK(15), 1);
290}
291
292static int __init smartq_power_off_init(void)
293{
294	int ret;
295
296	ret = gpio_request(S3C64XX_GPK(15), "Power control");
297	if (ret < 0) {
298		pr_err("%s: failed to get GPK15\n", __func__);
299		return ret;
300	}
301
302	/* leave power on */
303	gpio_direction_output(S3C64XX_GPK(15), 0);
304
305	pm_power_off = smartq_power_off;
306
307	return ret;
308}
309
310static int __init smartq_usb_host_init(void)
311{
312	int ret;
313
314	ret = gpio_request(S3C64XX_GPL(0), "USB power control");
315	if (ret < 0) {
316		pr_err("%s: failed to get GPL0\n", __func__);
317		return ret;
318	}
319
320	ret = gpio_request(S3C64XX_GPL(1), "USB host power control");
321	if (ret < 0) {
322		pr_err("%s: failed to get GPL1\n", __func__);
323		goto err;
324	}
325
326	if (!machine_is_smartq5()) {
327		/* This isn't present on a SmartQ 5 board */
328		ret = gpio_request(S3C64XX_GPL(10), "USB host overcurrent");
329		if (ret < 0) {
330			pr_err("%s: failed to get GPL10\n", __func__);
331			goto err2;
332		}
333	}
334
335	/* turn power off */
336	gpio_direction_output(S3C64XX_GPL(0), 0);
337	gpio_direction_output(S3C64XX_GPL(1), 0);
338	if (!machine_is_smartq5())
339		gpio_direction_input(S3C64XX_GPL(10));
340
341	s3c_device_ohci.dev.platform_data = &smartq_usb_host_info;
342
343	return 0;
344
345err2:
346	gpio_free(S3C64XX_GPL(1));
347err:
348	gpio_free(S3C64XX_GPL(0));
349	return ret;
350}
351
 
 
 
 
 
 
 
352static int __init smartq_wifi_init(void)
353{
354	int ret;
355
356	ret = gpio_request(S3C64XX_GPK(1), "wifi control");
357	if (ret < 0) {
358		pr_err("%s: failed to get GPK1\n", __func__);
359		return ret;
360	}
361
362	ret = gpio_request(S3C64XX_GPK(2), "wifi reset");
363	if (ret < 0) {
364		pr_err("%s: failed to get GPK2\n", __func__);
365		gpio_free(S3C64XX_GPK(1));
366		return ret;
367	}
368
369	/* turn power on */
370	gpio_direction_output(S3C64XX_GPK(1), 1);
371
372	/* reset device */
373	gpio_direction_output(S3C64XX_GPK(2), 0);
374	mdelay(100);
375	gpio_set_value(S3C64XX_GPK(2), 1);
376	gpio_direction_input(S3C64XX_GPK(2));
377
378	return 0;
379}
380
381static struct map_desc smartq_iodesc[] __initdata = {};
382void __init smartq_map_io(void)
383{
384	s3c64xx_init_io(smartq_iodesc, ARRAY_SIZE(smartq_iodesc));
385	s3c64xx_set_xtal_freq(12000000);
386	s3c64xx_set_xusbxti_freq(12000000);
387	s3c24xx_init_uarts(smartq_uartcfgs, ARRAY_SIZE(smartq_uartcfgs));
388	samsung_set_timer_source(SAMSUNG_PWM3, SAMSUNG_PWM4);
389
390	smartq_lcd_mode_set();
391}
392
393static struct gpiod_lookup_table smartq_audio_gpios = {
394	.dev_id = "smartq-audio",
395	.table = {
396		GPIO_LOOKUP("GPL", 12, "headphone detect", 0),
397		GPIO_LOOKUP("GPK", 12, "amplifiers shutdown", 0),
398		{ },
399	},
400};
401
402void __init smartq_machine_init(void)
403{
404	s3c_i2c0_set_platdata(NULL);
405	dwc2_hsotg_set_platdata(&smartq_hsotg_pdata);
406	s3c_hwmon_set_platdata(&smartq_hwmon_pdata);
407	s3c_sdhci1_set_platdata(&smartq_internal_hsmmc_pdata);
408	s3c_sdhci2_set_platdata(&smartq_internal_hsmmc_pdata);
409	s3c64xx_ts_set_platdata(&smartq_touchscreen_pdata);
410
411	i2c_register_board_info(0, smartq_i2c_devs,
412				ARRAY_SIZE(smartq_i2c_devs));
413
414	WARN_ON(smartq_lcd_setup_gpio());
415	WARN_ON(smartq_power_off_init());
416	WARN_ON(smartq_usb_host_init());
 
417	WARN_ON(smartq_wifi_init());
418
419	pwm_add_table(smartq_pwm_lookup, ARRAY_SIZE(smartq_pwm_lookup));
420	gpiod_add_lookup_table(&smartq_lcd_control_gpiod_table);
421	platform_add_devices(smartq_devices, ARRAY_SIZE(smartq_devices));
422
423	gpiod_add_lookup_table(&smartq_audio_gpios);
424	platform_device_register_simple("smartq-audio", -1, NULL, 0);
425}