mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-11-01 17:08:10 +00:00
0bde7294e2
Mostly bug fixes and clean up. There is a new driver, which is actually moving a custom PWM driver from drivers/misc. The majority of the patches are enhancements to the device tree support in the pwm-backlight driver. Backlights can now additionally be powered using a regulator and enabled using a GPIO in addition to just the PWM input. -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (GNU/Linux) iQIcBAABAgAGBQJSh1s7AAoJEN0jrNd/PrOhdS4P/1A/Tx05pP0ACsizhkB4Ro02 XgjIusWw/jp+3LWXrlaReVNb5H6GlahDT5+2/ApAw06o7INGvpSzyI1fuFQ2DU6K L7MgWDSifeL7jiwfUq5f3Qv4Vccjgii0z4BBQI5ZpPluIzKpo2uhz7gIjBR3wPu9 i34bc902SL/DrlvbMUsRHlYT9Ok3TpsPynk0pmw8xrUZDqRAX7DZH0EmvMkVsDo2 T1vt9gQVTFVgIwlRUBcbrjbu1GnYaV20s+piQhYm1RMSUqY+ArldWKzEzlN3tLYc XdnkaLikdHDRBA4DeNPJGbPU8LQax8wCTaZa1PgT0PqjNX/dCkg3hsc1Em0dH9Zh PKvyX8R6iPdOcakkRm4qdVIacblqE1HYM7T+lyVhu6XP7MWkUmNr05HQBFjhOMcm whv1gS/EeB4y/FcSzn7S23UAmOvxiWfGnOMlnazrOgS00FrbC4accgSB/iXi2lDC szO9MHwfbwDTp8WBLEw8iTPODpq7pnFcBCw80pzblMFqC8v1MAFyriwT7BUmKcR/ h/V75Q95VPAKq+uKsfb5Ruwa9CGKs8ACagLR0BuErT/J83Q7Q4Ezf56FUCvrGDtz 5AWpGUakotwHtJPx6TAOgI+237MFh/GpIOrlEtz+2b5SP6ftHxr8rj+wg1sxmI2y JohOUIFjHtcA4UifhlTU =CB+z -----END PGP SIGNATURE----- Merge tag 'pwm/for-3.13-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/thierry.reding/linux-pwm Pull pwm changes from Thierry Reding: "Mostly bug fixes and clean up. There is a new driver, which is actually moving a custom PWM driver from drivers/misc. The majority of the patches are enhancements to the device tree support in the pwm-backlight driver. Backlights can now additionally be powered using a regulator and enabled using a GPIO in addition to just the PWM input" * tag 'pwm/for-3.13-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/thierry.reding/linux-pwm: (30 commits) Documentation/pwm: Update supported SoC name for pwm-samsung pwm: samsung: Fix kernel warning while unexporting a channel MAINTAINERS: Move PWM subsystem tree to kernel.org Documentation/pwm: Fix trivial typos pwm-backlight: Remove unused variable pwm_backlight: avoid short blank screen while doing hibernation pwm-backlight: Fix brightness adjustment pwm: add ep93xx PWM support pwm-backlight: Allow for non-increasing brightness levels pwm-backlight: Add power supply support pwm-backlight: Use new enable_gpio field unicore32: Initialize PWM backlight enable_gpio field ARM: shmobile: Initialize PWM backlight enable_gpio field ARM: SAMSUNG: Initialize PWM backlight enable_gpio field ARM: pxa: Initialize PWM backlight enable_gpio field ARM: OMAP: Initialize PWM backlight enable_gpio field pwm-backlight: Add optional enable GPIO pwm-backlight: Track enable state pwm-backlight: Refactor backlight power on/off pwm-backlight: Improve readability ...
400 lines
9.1 KiB
C
400 lines
9.1 KiB
C
/*
|
|
* 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 <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 <plat/samsung-time.h>
|
|
|
|
#include "common.h"
|
|
#include "regs-modem.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),
|
|
.enable_gpio = -1,
|
|
.init = smartq_bl_init,
|
|
};
|
|
|
|
static struct platform_device smartq_backlight_device = {
|
|
.name = "pwm-backlight",
|
|
.dev = {
|
|
.parent = &samsung_device_pwm.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,
|
|
};
|
|
|
|
static struct i2c_board_info smartq_i2c_devs[] __initdata = {
|
|
{ I2C_BOARD_INFO("wm8987", 0x1a), },
|
|
};
|
|
|
|
static struct platform_device *smartq_devices[] __initdata = {
|
|
&s3c_device_hsmmc1, /* Init iNAND first, ... */
|
|
&s3c_device_hsmmc0, /* ... then the external SD card */
|
|
&s3c_device_hsmmc2,
|
|
&s3c_device_adc,
|
|
&s3c_device_fb,
|
|
&s3c_device_hwmon,
|
|
&s3c_device_i2c0,
|
|
&s3c_device_ohci,
|
|
&s3c_device_rtc,
|
|
&samsung_device_pwm,
|
|
&s3c_device_ts,
|
|
&s3c_device_usb_hsotg,
|
|
&s3c64xx_device_iis0,
|
|
&smartq_backlight_device,
|
|
&smartq_lcd_control_device,
|
|
&smartq_lcd_power_device,
|
|
&smartq_usb_otg_vbus_dev,
|
|
};
|
|
|
|
static void __init smartq_lcd_mode_set(void)
|
|
{
|
|
u32 tmp;
|
|
|
|
/* set the LCD type */
|
|
tmp = __raw_readl(S3C64XX_SPCON);
|
|
tmp &= ~S3C64XX_SPCON_LCD_SEL_MASK;
|
|
tmp |= S3C64XX_SPCON_LCD_SEL_RGB;
|
|
__raw_writel(tmp, S3C64XX_SPCON);
|
|
|
|
/* remove the LCD bypass */
|
|
tmp = __raw_readl(S3C64XX_MODEM_MIFPCON);
|
|
tmp &= ~MIFPCON_LCD_BYPASS;
|
|
__raw_writel(tmp, S3C64XX_MODEM_MIFPCON);
|
|
}
|
|
|
|
static void smartq_power_off(void)
|
|
{
|
|
gpio_direction_output(S3C64XX_GPK(15), 1);
|
|
}
|
|
|
|
static int __init smartq_power_off_init(void)
|
|
{
|
|
int ret;
|
|
|
|
ret = gpio_request(S3C64XX_GPK(15), "Power control");
|
|
if (ret < 0) {
|
|
pr_err("%s: failed to get GPK15\n", __func__);
|
|
return ret;
|
|
}
|
|
|
|
/* leave power on */
|
|
gpio_direction_output(S3C64XX_GPK(15), 0);
|
|
|
|
pm_power_off = smartq_power_off;
|
|
|
|
return ret;
|
|
}
|
|
|
|
static int __init smartq_usb_host_init(void)
|
|
{
|
|
int ret;
|
|
|
|
ret = gpio_request(S3C64XX_GPL(0), "USB power control");
|
|
if (ret < 0) {
|
|
pr_err("%s: failed to get GPL0\n", __func__);
|
|
return ret;
|
|
}
|
|
|
|
ret = gpio_request(S3C64XX_GPL(1), "USB host power control");
|
|
if (ret < 0) {
|
|
pr_err("%s: failed to get GPL1\n", __func__);
|
|
goto err;
|
|
}
|
|
|
|
if (!machine_is_smartq5()) {
|
|
/* This isn't present on a SmartQ 5 board */
|
|
ret = gpio_request(S3C64XX_GPL(10), "USB host overcurrent");
|
|
if (ret < 0) {
|
|
pr_err("%s: failed to get GPL10\n", __func__);
|
|
goto err2;
|
|
}
|
|
}
|
|
|
|
/* turn power off */
|
|
gpio_direction_output(S3C64XX_GPL(0), 0);
|
|
gpio_direction_output(S3C64XX_GPL(1), 0);
|
|
if (!machine_is_smartq5())
|
|
gpio_direction_input(S3C64XX_GPL(10));
|
|
|
|
s3c_device_ohci.dev.platform_data = &smartq_usb_host_info;
|
|
|
|
return 0;
|
|
|
|
err2:
|
|
gpio_free(S3C64XX_GPL(1));
|
|
err:
|
|
gpio_free(S3C64XX_GPL(0));
|
|
return ret;
|
|
}
|
|
|
|
static int __init smartq_wifi_init(void)
|
|
{
|
|
int ret;
|
|
|
|
ret = gpio_request(S3C64XX_GPK(1), "wifi control");
|
|
if (ret < 0) {
|
|
pr_err("%s: failed to get GPK1\n", __func__);
|
|
return ret;
|
|
}
|
|
|
|
ret = gpio_request(S3C64XX_GPK(2), "wifi reset");
|
|
if (ret < 0) {
|
|
pr_err("%s: failed to get GPK2\n", __func__);
|
|
gpio_free(S3C64XX_GPK(1));
|
|
return ret;
|
|
}
|
|
|
|
/* turn power on */
|
|
gpio_direction_output(S3C64XX_GPK(1), 1);
|
|
|
|
/* reset device */
|
|
gpio_direction_output(S3C64XX_GPK(2), 0);
|
|
mdelay(100);
|
|
gpio_set_value(S3C64XX_GPK(2), 1);
|
|
gpio_direction_input(S3C64XX_GPK(2));
|
|
|
|
return 0;
|
|
}
|
|
|
|
static struct map_desc smartq_iodesc[] __initdata = {};
|
|
void __init smartq_map_io(void)
|
|
{
|
|
s3c64xx_init_io(smartq_iodesc, ARRAY_SIZE(smartq_iodesc));
|
|
s3c64xx_set_xtal_freq(12000000);
|
|
s3c64xx_set_xusbxti_freq(12000000);
|
|
s3c24xx_init_uarts(smartq_uartcfgs, ARRAY_SIZE(smartq_uartcfgs));
|
|
samsung_set_timer_source(SAMSUNG_PWM3, SAMSUNG_PWM4);
|
|
|
|
smartq_lcd_mode_set();
|
|
}
|
|
|
|
void __init smartq_machine_init(void)
|
|
{
|
|
s3c_i2c0_set_platdata(NULL);
|
|
s3c_hsotg_set_platdata(&smartq_hsotg_pdata);
|
|
s3c_hwmon_set_platdata(&smartq_hwmon_pdata);
|
|
s3c_sdhci1_set_platdata(&smartq_internal_hsmmc_pdata);
|
|
s3c_sdhci2_set_platdata(&smartq_internal_hsmmc_pdata);
|
|
s3c24xx_ts_set_platdata(&smartq_touchscreen_pdata);
|
|
|
|
i2c_register_board_info(0, smartq_i2c_devs,
|
|
ARRAY_SIZE(smartq_i2c_devs));
|
|
|
|
WARN_ON(smartq_lcd_setup_gpio());
|
|
WARN_ON(smartq_power_off_init());
|
|
WARN_ON(smartq_usb_host_init());
|
|
WARN_ON(smartq_wifi_init());
|
|
|
|
platform_add_devices(smartq_devices, ARRAY_SIZE(smartq_devices));
|
|
}
|