From 7f798c1c0d562ef1200cbe3227cd0474b1c285f7 Mon Sep 17 00:00:00 2001 From: Kukjin Kim Date: Thu, 30 Jul 2015 01:48:17 +0900 Subject: ARM: SAMSUNG: make local dev-backlight in mach-s3c64xx This patch moves dev-backlight from plat-samsung into mach-s3c64xx because it is used for only s3c64xx no other platforms. Cc: Krzysztof Kozlowski Signed-off-by: Kukjin Kim --- arch/arm/mach-s3c64xx/Kconfig | 6 ++ arch/arm/mach-s3c64xx/Makefile | 2 + arch/arm/mach-s3c64xx/dev-backlight.c | 151 +++++++++++++++++++++++++++++++++ arch/arm/plat-samsung/Kconfig | 6 -- arch/arm/plat-samsung/Makefile | 2 - arch/arm/plat-samsung/dev-backlight.c | 152 ---------------------------------- 6 files changed, 159 insertions(+), 160 deletions(-) create mode 100644 arch/arm/mach-s3c64xx/dev-backlight.c delete mode 100644 arch/arm/plat-samsung/dev-backlight.c diff --git a/arch/arm/mach-s3c64xx/Kconfig b/arch/arm/mach-s3c64xx/Kconfig index eff95e950d81..28c7097e8506 100644 --- a/arch/arm/mach-s3c64xx/Kconfig +++ b/arch/arm/mach-s3c64xx/Kconfig @@ -34,6 +34,12 @@ config S3C64XX_DEV_ONENAND1 help Compile in platform device definition for OneNAND1 controller +config SAMSUNG_DEV_BACKLIGHT + bool + depends on SAMSUNG_DEV_PWM + help + Compile in platform device definition LCD backlight with PWM Timer + # platform specific device setup config S3C64XX_SETUP_I2C0 diff --git a/arch/arm/mach-s3c64xx/Makefile b/arch/arm/mach-s3c64xx/Makefile index 17f4b07ec763..bb233f342f31 100644 --- a/arch/arm/mach-s3c64xx/Makefile +++ b/arch/arm/mach-s3c64xx/Makefile @@ -40,6 +40,8 @@ obj-$(CONFIG_S3C64XX_SETUP_SDHCI_GPIO) += setup-sdhci-gpio.o obj-$(CONFIG_S3C64XX_SETUP_SPI) += setup-spi.o obj-$(CONFIG_S3C64XX_SETUP_USB_PHY) += setup-usb-phy.o +obj-$(CONFIG_SAMSUNG_DEV_BACKLIGHT) += dev-backlight.o + # Machine support obj-$(CONFIG_MACH_ANW6410) += mach-anw6410.o diff --git a/arch/arm/mach-s3c64xx/dev-backlight.c b/arch/arm/mach-s3c64xx/dev-backlight.c new file mode 100644 index 000000000000..62f4648830b5 --- /dev/null +++ b/arch/arm/mach-s3c64xx/dev-backlight.c @@ -0,0 +1,151 @@ +/* + * Copyright (c) 2011 Samsung Electronics Co., Ltd. + * http://www.samsung.com + * + * Common infrastructure for PWM Backlight for Samsung boards + * + * 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 +#include +#include +#include +#include + +#include +#include +#include + +struct samsung_bl_drvdata { + struct platform_pwm_backlight_data plat_data; + struct samsung_bl_gpio_info *gpio_info; +}; + +static int samsung_bl_init(struct device *dev) +{ + int ret = 0; + struct platform_pwm_backlight_data *pdata = dev->platform_data; + struct samsung_bl_drvdata *drvdata = container_of(pdata, + struct samsung_bl_drvdata, plat_data); + struct samsung_bl_gpio_info *bl_gpio_info = drvdata->gpio_info; + + ret = gpio_request(bl_gpio_info->no, "Backlight"); + if (ret) { + printk(KERN_ERR "failed to request GPIO for LCD Backlight\n"); + return ret; + } + + /* Configure GPIO pin with specific GPIO function for PWM timer */ + s3c_gpio_cfgpin(bl_gpio_info->no, bl_gpio_info->func); + + return 0; +} + +static void samsung_bl_exit(struct device *dev) +{ + struct platform_pwm_backlight_data *pdata = dev->platform_data; + struct samsung_bl_drvdata *drvdata = container_of(pdata, + struct samsung_bl_drvdata, plat_data); + struct samsung_bl_gpio_info *bl_gpio_info = drvdata->gpio_info; + + s3c_gpio_cfgpin(bl_gpio_info->no, S3C_GPIO_OUTPUT); + gpio_free(bl_gpio_info->no); +} + +/* Initialize few important fields of platform_pwm_backlight_data + * structure with default values. These fields can be overridden by + * board-specific values sent from machine file. + * For ease of operation, these fields are initialized with values + * used by most samsung boards. + * Users has the option of sending info about other parameters + * for their specific boards + */ + +static struct samsung_bl_drvdata samsung_dfl_bl_data __initdata = { + .plat_data = { + .max_brightness = 255, + .dft_brightness = 255, + .pwm_period_ns = 78770, + .enable_gpio = -1, + .init = samsung_bl_init, + .exit = samsung_bl_exit, + }, +}; + +static struct platform_device samsung_dfl_bl_device __initdata = { + .name = "pwm-backlight", +}; + +/* samsung_bl_set - Set board specific data (if any) provided by user for + * PWM Backlight control and register specific PWM and backlight device. + * @gpio_info: structure containing GPIO info for PWM timer + * @bl_data: structure containing Backlight control data + */ +void __init samsung_bl_set(struct samsung_bl_gpio_info *gpio_info, + struct platform_pwm_backlight_data *bl_data) +{ + int ret = 0; + struct platform_device *samsung_bl_device; + struct samsung_bl_drvdata *samsung_bl_drvdata; + struct platform_pwm_backlight_data *samsung_bl_data; + + samsung_bl_device = kmemdup(&samsung_dfl_bl_device, + sizeof(struct platform_device), GFP_KERNEL); + if (!samsung_bl_device) { + printk(KERN_ERR "%s: no memory for platform dev\n", __func__); + return; + } + + samsung_bl_drvdata = kmemdup(&samsung_dfl_bl_data, + sizeof(samsung_dfl_bl_data), GFP_KERNEL); + if (!samsung_bl_drvdata) { + printk(KERN_ERR "%s: no memory for platform dev\n", __func__); + goto err_data; + } + samsung_bl_device->dev.platform_data = &samsung_bl_drvdata->plat_data; + samsung_bl_drvdata->gpio_info = gpio_info; + samsung_bl_data = &samsung_bl_drvdata->plat_data; + + /* Copy board specific data provided by user */ + samsung_bl_data->pwm_id = bl_data->pwm_id; + samsung_bl_device->dev.parent = &samsung_device_pwm.dev; + + if (bl_data->max_brightness) + samsung_bl_data->max_brightness = bl_data->max_brightness; + if (bl_data->dft_brightness) + samsung_bl_data->dft_brightness = bl_data->dft_brightness; + if (bl_data->lth_brightness) + samsung_bl_data->lth_brightness = bl_data->lth_brightness; + if (bl_data->pwm_period_ns) + samsung_bl_data->pwm_period_ns = bl_data->pwm_period_ns; + if (bl_data->enable_gpio >= 0) + samsung_bl_data->enable_gpio = bl_data->enable_gpio; + if (bl_data->init) + samsung_bl_data->init = bl_data->init; + if (bl_data->notify) + samsung_bl_data->notify = bl_data->notify; + if (bl_data->notify_after) + samsung_bl_data->notify_after = bl_data->notify_after; + if (bl_data->exit) + samsung_bl_data->exit = bl_data->exit; + if (bl_data->check_fb) + samsung_bl_data->check_fb = bl_data->check_fb; + + /* Register the Backlight dev */ + ret = platform_device_register(samsung_bl_device); + if (ret) { + printk(KERN_ERR "failed to register backlight device: %d\n", ret); + goto err_plat_reg2; + } + + return; + +err_plat_reg2: + kfree(samsung_bl_data); +err_data: + kfree(samsung_bl_device); + return; +} diff --git a/arch/arm/plat-samsung/Kconfig b/arch/arm/plat-samsung/Kconfig index f115c8156758..0e1874ccf1ea 100644 --- a/arch/arm/plat-samsung/Kconfig +++ b/arch/arm/plat-samsung/Kconfig @@ -217,12 +217,6 @@ config SAMSUNG_DEV_PWM help Compile in platform device definition for PWM Timer -config SAMSUNG_DEV_BACKLIGHT - bool - depends on SAMSUNG_DEV_PWM - help - Compile in platform device definition LCD backlight with PWM Timer - config S3C24XX_PWM bool "PWM device support" select PWM diff --git a/arch/arm/plat-samsung/Makefile b/arch/arm/plat-samsung/Makefile index c48a2ccb1c62..624f5db0e39c 100644 --- a/arch/arm/plat-samsung/Makefile +++ b/arch/arm/plat-samsung/Makefile @@ -22,8 +22,6 @@ obj-$(CONFIG_SAMSUNG_ATAGS) += devs.o obj-$(CONFIG_SAMSUNG_ATAGS) += dev-uart.o obj-$(CONFIG_S5P_DEV_MFC) += s5p-dev-mfc.o -obj-$(CONFIG_SAMSUNG_DEV_BACKLIGHT) += dev-backlight.o - # PM support obj-$(CONFIG_PM_SLEEP) += pm-common.o diff --git a/arch/arm/plat-samsung/dev-backlight.c b/arch/arm/plat-samsung/dev-backlight.c deleted file mode 100644 index 2157c5b539e6..000000000000 --- a/arch/arm/plat-samsung/dev-backlight.c +++ /dev/null @@ -1,152 +0,0 @@ -/* linux/arch/arm/plat-samsung/dev-backlight.c - * - * Copyright (c) 2011 Samsung Electronics Co., Ltd. - * http://www.samsung.com - * - * Common infrastructure for PWM Backlight for Samsung boards - * - * 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 -#include -#include -#include -#include - -#include -#include -#include - -struct samsung_bl_drvdata { - struct platform_pwm_backlight_data plat_data; - struct samsung_bl_gpio_info *gpio_info; -}; - -static int samsung_bl_init(struct device *dev) -{ - int ret = 0; - struct platform_pwm_backlight_data *pdata = dev->platform_data; - struct samsung_bl_drvdata *drvdata = container_of(pdata, - struct samsung_bl_drvdata, plat_data); - struct samsung_bl_gpio_info *bl_gpio_info = drvdata->gpio_info; - - ret = gpio_request(bl_gpio_info->no, "Backlight"); - if (ret) { - printk(KERN_ERR "failed to request GPIO for LCD Backlight\n"); - return ret; - } - - /* Configure GPIO pin with specific GPIO function for PWM timer */ - s3c_gpio_cfgpin(bl_gpio_info->no, bl_gpio_info->func); - - return 0; -} - -static void samsung_bl_exit(struct device *dev) -{ - struct platform_pwm_backlight_data *pdata = dev->platform_data; - struct samsung_bl_drvdata *drvdata = container_of(pdata, - struct samsung_bl_drvdata, plat_data); - struct samsung_bl_gpio_info *bl_gpio_info = drvdata->gpio_info; - - s3c_gpio_cfgpin(bl_gpio_info->no, S3C_GPIO_OUTPUT); - gpio_free(bl_gpio_info->no); -} - -/* Initialize few important fields of platform_pwm_backlight_data - * structure with default values. These fields can be overridden by - * board-specific values sent from machine file. - * For ease of operation, these fields are initialized with values - * used by most samsung boards. - * Users has the option of sending info about other parameters - * for their specific boards - */ - -static struct samsung_bl_drvdata samsung_dfl_bl_data __initdata = { - .plat_data = { - .max_brightness = 255, - .dft_brightness = 255, - .pwm_period_ns = 78770, - .enable_gpio = -1, - .init = samsung_bl_init, - .exit = samsung_bl_exit, - }, -}; - -static struct platform_device samsung_dfl_bl_device __initdata = { - .name = "pwm-backlight", -}; - -/* samsung_bl_set - Set board specific data (if any) provided by user for - * PWM Backlight control and register specific PWM and backlight device. - * @gpio_info: structure containing GPIO info for PWM timer - * @bl_data: structure containing Backlight control data - */ -void __init samsung_bl_set(struct samsung_bl_gpio_info *gpio_info, - struct platform_pwm_backlight_data *bl_data) -{ - int ret = 0; - struct platform_device *samsung_bl_device; - struct samsung_bl_drvdata *samsung_bl_drvdata; - struct platform_pwm_backlight_data *samsung_bl_data; - - samsung_bl_device = kmemdup(&samsung_dfl_bl_device, - sizeof(struct platform_device), GFP_KERNEL); - if (!samsung_bl_device) { - printk(KERN_ERR "%s: no memory for platform dev\n", __func__); - return; - } - - samsung_bl_drvdata = kmemdup(&samsung_dfl_bl_data, - sizeof(samsung_dfl_bl_data), GFP_KERNEL); - if (!samsung_bl_drvdata) { - printk(KERN_ERR "%s: no memory for platform dev\n", __func__); - goto err_data; - } - samsung_bl_device->dev.platform_data = &samsung_bl_drvdata->plat_data; - samsung_bl_drvdata->gpio_info = gpio_info; - samsung_bl_data = &samsung_bl_drvdata->plat_data; - - /* Copy board specific data provided by user */ - samsung_bl_data->pwm_id = bl_data->pwm_id; - samsung_bl_device->dev.parent = &samsung_device_pwm.dev; - - if (bl_data->max_brightness) - samsung_bl_data->max_brightness = bl_data->max_brightness; - if (bl_data->dft_brightness) - samsung_bl_data->dft_brightness = bl_data->dft_brightness; - if (bl_data->lth_brightness) - samsung_bl_data->lth_brightness = bl_data->lth_brightness; - if (bl_data->pwm_period_ns) - samsung_bl_data->pwm_period_ns = bl_data->pwm_period_ns; - if (bl_data->enable_gpio >= 0) - samsung_bl_data->enable_gpio = bl_data->enable_gpio; - if (bl_data->init) - samsung_bl_data->init = bl_data->init; - if (bl_data->notify) - samsung_bl_data->notify = bl_data->notify; - if (bl_data->notify_after) - samsung_bl_data->notify_after = bl_data->notify_after; - if (bl_data->exit) - samsung_bl_data->exit = bl_data->exit; - if (bl_data->check_fb) - samsung_bl_data->check_fb = bl_data->check_fb; - - /* Register the Backlight dev */ - ret = platform_device_register(samsung_bl_device); - if (ret) { - printk(KERN_ERR "failed to register backlight device: %d\n", ret); - goto err_plat_reg2; - } - - return; - -err_plat_reg2: - kfree(samsung_bl_data); -err_data: - kfree(samsung_bl_device); - return; -} -- cgit v1.2.3