| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233 | /* * linux/arch/arm/mach-s3c64xx/mach-smartq.c * * Copyright (C) 2010 Maurus Cuelenaere * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * */#include <linux/delay.h>#include <linux/fb.h>#include <linux/gpio.h>#include <linux/init.h>#include <linux/platform_device.h>#include <linux/pwm_backlight.h>#include <linux/serial_core.h>#include <linux/spi/spi_gpio.h>#include <linux/usb/gpio_vbus.h>#include <linux/platform_data/s3c-hsotg.h>#include <asm/mach-types.h>#include <asm/mach/map.h>#include <mach/map.h>#include <mach/regs-gpio.h>#include <mach/regs-modem.h>#include <plat/clock.h>#include <plat/cpu.h>#include <plat/devs.h>#include <linux/platform_data/i2c-s3c2410.h>#include <plat/gpio-cfg.h>#include <linux/platform_data/hwmon-s3c.h>#include <plat/regs-serial.h>#include <linux/platform_data/usb-ohci-s3c2410.h>#include <plat/sdhci.h>#include <linux/platform_data/touchscreen-s3c2410.h>#include <video/platform_lcd.h>#include "common.h"#define UCON S3C2410_UCON_DEFAULT#define ULCON (S3C2410_LCON_CS8 | S3C2410_LCON_PNONE)#define UFCON (S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE)static struct s3c2410_uartcfg smartq_uartcfgs[] __initdata = {	[0] = {		.hwport	     = 0,		.flags	     = 0,		.ucon	     = UCON,		.ulcon	     = ULCON,		.ufcon	     = UFCON,	},	[1] = {		.hwport	     = 1,		.flags	     = 0,		.ucon	     = UCON,		.ulcon	     = ULCON,		.ufcon	     = UFCON,	},	[2] = {		.hwport	     = 2,		.flags	     = 0,		.ucon	     = UCON,		.ulcon	     = ULCON,		.ufcon	     = UFCON,	},};static void smartq_usb_host_powercontrol(int port, int to){	pr_debug("%s(%d, %d)\n", __func__, port, to);	if (port == 0) {		gpio_set_value(S3C64XX_GPL(0), to);		gpio_set_value(S3C64XX_GPL(1), to);	}}static irqreturn_t smartq_usb_host_ocirq(int irq, void *pw){	struct s3c2410_hcd_info *info = pw;	if (gpio_get_value(S3C64XX_GPL(10)) == 0) {		pr_debug("%s: over-current irq (oc detected)\n", __func__);		s3c2410_usb_report_oc(info, 3);	} else {		pr_debug("%s: over-current irq (oc cleared)\n", __func__);		s3c2410_usb_report_oc(info, 0);	}	return IRQ_HANDLED;}static void smartq_usb_host_enableoc(struct s3c2410_hcd_info *info, int on){	int ret;	/* This isn't present on a SmartQ 5 board */	if (machine_is_smartq5())		return;	if (on) {		ret = request_irq(gpio_to_irq(S3C64XX_GPL(10)),				  smartq_usb_host_ocirq, IRQF_DISABLED |				  IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,				  "USB host overcurrent", info);		if (ret != 0)			pr_err("failed to request usb oc irq: %d\n", ret);	} else {		free_irq(gpio_to_irq(S3C64XX_GPL(10)), info);	}}static struct s3c2410_hcd_info smartq_usb_host_info = {	.port[0]	= {		.flags	= S3C_HCDFLG_USED	},	.port[1]	= {		.flags	= 0	},	.power_control	= smartq_usb_host_powercontrol,	.enable_oc	= smartq_usb_host_enableoc,};static struct gpio_vbus_mach_info smartq_usb_otg_vbus_pdata = {	.gpio_vbus		= S3C64XX_GPL(9),	.gpio_pullup		= -1,	.gpio_vbus_inverted	= true,};static struct platform_device smartq_usb_otg_vbus_dev = {	.name			= "gpio-vbus",	.dev.platform_data	= &smartq_usb_otg_vbus_pdata,};static int smartq_bl_init(struct device *dev){    s3c_gpio_cfgpin(S3C64XX_GPF(15), S3C_GPIO_SFN(2));    return 0;}static struct platform_pwm_backlight_data smartq_backlight_data = {	.pwm_id		= 1,	.max_brightness	= 1000,	.dft_brightness	= 600,	.pwm_period_ns	= 1000000000 / (1000 * 20),	.init		= smartq_bl_init,};static struct platform_device smartq_backlight_device = {	.name		= "pwm-backlight",	.dev		= {		.parent	= &s3c_device_timer[1].dev,		.platform_data = &smartq_backlight_data,	},};static struct s3c2410_ts_mach_info smartq_touchscreen_pdata __initdata = {	.delay			= 65535,	.presc			= 99,	.oversampling_shift	= 4,};static struct s3c_sdhci_platdata smartq_internal_hsmmc_pdata = {	.max_width		= 4,	.cd_type		= S3C_SDHCI_CD_PERMANENT,};static struct s3c_hwmon_pdata smartq_hwmon_pdata __initdata = {	/* Battery voltage (?-4.2V) */	.in[0] = &(struct s3c_hwmon_chcfg) {		.name		= "smartq:battery-voltage",		.mult		= 3300,		.div		= 2048,	},	/* Reference voltage (1.2V) */	.in[1] = &(struct s3c_hwmon_chcfg) {		.name		= "smartq:reference-voltage",		.mult		= 3300,		.div		= 4096,	},};static struct s3c_hsotg_plat smartq_hsotg_pdata;static int __init smartq_lcd_setup_gpio(void){	int ret;	ret = gpio_request(S3C64XX_GPM(3), "LCD power");	if (ret < 0)		return ret;	/* turn power off */	gpio_direction_output(S3C64XX_GPM(3), 0);	return 0;}/* GPM0 -> CS */static struct spi_gpio_platform_data smartq_lcd_control = {	.sck			= S3C64XX_GPM(1),	.mosi			= S3C64XX_GPM(2),	.miso			= S3C64XX_GPM(2),};static struct platform_device smartq_lcd_control_device = {	.name			= "spi-gpio",	.id			= 1,	.dev.platform_data	= &smartq_lcd_control,};static void smartq_lcd_power_set(struct plat_lcd_data *pd, unsigned int power){	gpio_direction_output(S3C64XX_GPM(3), power);}static struct plat_lcd_data smartq_lcd_power_data = {	.set_power	= smartq_lcd_power_set,};static struct platform_device smartq_lcd_power_device = {	.name			= "platform-lcd",	.dev.parent		= &s3c_device_fb.dev,	.dev.platform_data	= &smartq_lcd_power_data,};
 |