[PATCH 5/5] [media] s5p-tvout: Add HPD driver for S5P TVOUT

2011-02-25 Thread Abhilash Kesavan
This patch adds support HPD(Hot-Plug Detection) driver for
S5P TVOUT driver.

HPD driver generates event and send it to application when
user connects/disconnects HDMI cable to/from source and sink
device.

[based on work originally written by Sangpil Moon sangpil.m...@samsung.com]
Cc: Kukjin Kim kgene@samsung.com
Acked-by: KyungHwan Kim kh.k@samsung.com
Signed-off-by: Jiun Yu jiun...@samsung.com
Signed-off-by: Abhilash Kesavan a.kesa...@samsung.com
---
 drivers/media/video/s5p-tvout/s5p_tvout_hpd.c |  405 +
 1 files changed, 405 insertions(+), 0 deletions(-)
 create mode 100644 drivers/media/video/s5p-tvout/s5p_tvout_hpd.c

diff --git a/drivers/media/video/s5p-tvout/s5p_tvout_hpd.c 
b/drivers/media/video/s5p-tvout/s5p_tvout_hpd.c
new file mode 100644
index 000..f307286
--- /dev/null
+++ b/drivers/media/video/s5p-tvout/s5p_tvout_hpd.c
@@ -0,0 +1,405 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd.
+ * http://www.samsung.com
+ *
+ * HPD(Hot-Plug Detection) Interface for Samsung S5P TVOUT driver
+ *
+ * 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/miscdevice.h
+#include linux/io.h
+#include linux/irq.h
+#include linux/poll.h
+
+#include plat/tvout.h
+
+#include hw_if/hw_if.h
+#include s5p_tvout_common_lib.h
+
+#undef tvout_dbg
+
+#ifdef CONFIG_HPD_DEBUG
+#define tvout_dbg(fmt, ...)\
+   printk(KERN_INFO \t[HPD] %s():  fmt,  \
+   __func__, ##__VA_ARGS__)
+#else
+#define tvout_dbg(fmt, ...)
+#endif
+
+/* /dev/hpd (Major 10, Minor 243) */
+#define HPD_MINOR  243
+
+#define HPD_LO 0
+#define HPD_HI 1
+
+#define HDMI_ON1
+#define HDMI_OFF   0
+
+struct hpd_struct {
+   spinlock_t lock;
+   wait_queue_head_t waitq;
+   atomic_t state;
+   void (*int_src_hdmi_hpd)(void);
+   void (*int_src_ext_hpd)(void);
+   int (*read_gpio)(void);
+   int irq_n;
+};
+
+static struct hpd_struct hpd_struct;
+
+static int last_hpd_state;
+atomic_t hdmi_status;
+atomic_t poll_state;
+
+static struct kobject *hpd_tvout_kobj, *hpd_video_kobj;
+
+static void s5p_hpd_kobject_uevent(void)
+{
+   int hpd_state = atomic_read(hpd_struct.state);
+
+   if (hpd_state) {
+   tvout_err(Event] Send UEvent = %d\n, hpd_state);
+   kobject_uevent(hpd_tvout_kobj, KOBJ_ONLINE);
+   kobject_uevent(hpd_video_kobj, KOBJ_ONLINE);
+   } else {
+   tvout_err(Event] Send UEvent = %d\n, hpd_state);
+   kobject_uevent(hpd_tvout_kobj, KOBJ_OFFLINE);
+   kobject_uevent(hpd_video_kobj, KOBJ_OFFLINE);
+   }
+}
+
+static DECLARE_WORK(hpd_work, (void *)s5p_hpd_kobject_uevent);
+
+void s5p_hpd_set_kobj(struct kobject *tvout_kobj, struct kobject *video_kobj)
+{
+   hpd_tvout_kobj = tvout_kobj;
+   hpd_video_kobj = video_kobj;
+}
+
+static int s5p_hpd_open(struct inode *inode, struct file *file)
+{
+   atomic_set(poll_state, 1);
+
+   return 0;
+}
+
+static int s5p_hpd_release(struct inode *inode, struct file *file)
+{
+   return 0;
+}
+
+static ssize_t s5p_hpd_read(struct file *file, char __user *buffer,
+   size_t count, loff_t *ppos)
+{
+   ssize_t retval;
+
+   spin_lock_irq(hpd_struct.lock);
+
+   retval = put_user(atomic_read(hpd_struct.state),
+   (unsigned int __user *) buffer);
+
+   atomic_set(poll_state, -1);
+
+   spin_unlock_irq(hpd_struct.lock);
+
+   return retval;
+}
+
+static unsigned int s5p_hpd_poll(struct file *file, poll_table *wait)
+{
+   poll_wait(file, hpd_struct.waitq, wait);
+
+   if (atomic_read(poll_state) != -1)
+   return POLLIN | POLLRDNORM;
+
+   return 0;
+}
+
+static const struct file_operations hpd_fops = {
+   .owner  = THIS_MODULE,
+   .open   = s5p_hpd_open,
+   .release= s5p_hpd_release,
+   .read   = s5p_hpd_read,
+   .poll   = s5p_hpd_poll,
+};
+
+static struct miscdevice hpd_misc_device = {
+   .minor  = HPD_MINOR,
+   .name   = HPD,
+   .fops   = hpd_fops,
+};
+
+int s5p_hpd_set_hdmiint(void)
+{
+   /* EINT - HDMI */
+
+   set_irq_type(hpd_struct.irq_n, IRQ_TYPE_NONE);
+
+   if (last_hpd_state)
+   s5p_hdmi_reg_intc_enable(HDMI_IRQ_HPD_UNPLUG, 0);
+   else
+   s5p_hdmi_reg_intc_enable(HDMI_IRQ_HPD_PLUG, 0);
+
+   atomic_set(hdmi_status, HDMI_ON);
+
+   hpd_struct.int_src_hdmi_hpd();
+
+   s5p_hdmi_reg_hpd_gen();
+
+   if (s5p_hdmi_reg_get_hpd_status())
+   s5p_hdmi_reg_intc_enable(HDMI_IRQ_HPD_UNPLUG, 1);
+   else
+   s5p_hdmi_reg_intc_enable(HDMI_IRQ_HPD_PLUG, 1);
+
+   return 0;
+}
+
+int s5p_hpd_set_eint(void)

[PATCH/RFC 0/5] [media] s5p-tvout: Add S5P TVOUT driver

2011-02-25 Thread Abhilash Kesavan
This patch-set adds support for TV-OUT interface in the EXYNOS4 series of SoCs.
TVOUT includes the HDMI interface, analog TV interface, mixer and video
processor. This is a full-featured driver providing the following:

1) HDMI Support
2) Analog Support
3) Mixer Support
4) Video Processor Support
5) Hotplug Detect Support
6) HDCP Support
7) CEC Support
8) I2S/SPDIF Support

The driver is under development and needs major modifications, as mentioned
later in the TODO section, to conform to open source standards. Please have
a look at the driver design and offer any suggestions/comments.


I) HARDWARE

Video processor is responsible for video scaling, de-interlacing, and video post
processing of TVOUT data path. It reads reconstructed YCbCr video sequences from
DRAM, processes the sequence, and sends it to mixer on-the-fly. Input to VP is
NV12 and NV21 (Linear and tiled) format while the output to the mixer is YUV444.

Mixer overlaps or blends input data such as graphic, video, background and sends
the resulting data to the HDMI or analog TV interface. Along with the YUV444 in-
put from VP interface, the mixer can receive two RGB inputs. It allows for  
layer
blending, alpha blending, chroma key, scaling etc.

HDMI interface supports 1.3 Tx subsystem V1.0 comprising an HDMI Tx core with
I2S input interface, CEC block, and HDCP key block. It receives YUV444 or RGB888
data from the mixer and converts it into HDMI packets. Supports a variety of
video formats varying from 480p to 1080p.

Analog TV interface supports ITU-R BT 470 and EIA-770 compliant analog TV
signals with 1 channel 10bit DAC. Supports PAL-m@60Hz, PAL-60@60Hz, NTSC@60Hz,
NTSC-443@60Hz, PAL@50Hz, PAL-n@50Hz and (M)NTSC@60Hz formats for composite
output.


II) S/W DESIGN

===
---
VFS
---
KERNEL   |   |
 V   V
--   --
V4L2 STACK   FB STACKLinux Driver Model
--   --
 |   ||
=+===++
 |   ||
 |   |  +-|
 |   |  | |
 V   V  V |
  +---+---+
  |   |   |
  |   |   |
  | -   ---   |   |
  |  Video Ctrl  -- Graphics Ctrl -- TVOUT I/F|   |
  | -   ---   V   |
  |  |   | ||__   --- |
  |  |   | |   |   HPD Driver |
  |  V   V V   V(GPIO)|
  | --- ---   ---   ---   --- |
  | VP I/F   Mixer I/F Analog I/FHDMI I/F |
  | --- ---   ---   ---   |
  |  |   |   | |   |  |
DEVICE|  |   |   | |   |___   |
DRIVER|  |   |   | |   |   |  |
  |  |   |   | |   V   V  |
  |  |   |   | | -  --|
  |  |   |   | |  CECHDCP |
  |  |   |   | | -  --|
  |  |   |   | |___|___|  |
  |  |   |   ||
  +--+---+---++
 |   |   | |
 |   |   | |
=+===+===+=
 |   |   | |
 V   V   V |
--- --- ---| 
VP    Mixer   

[PATCH 4/5] [media] s5p-tvout: Add CEC driver for S5P TVOUT

2011-02-25 Thread Abhilash Kesavan
From: KyungHwan Kim kh.k@samsung.com

This patch adds support CEC(Consumer Electronic Control) driver
for S5P TVOUT driver.

It allows source device to command and control CEC-enabled sink
devices in case of HDMI. For example, it can send signals like
turning on/off from source device to digital TV.

[based on work originally written by Sangpil Moon sangpil.m...@samsung.com]
Cc: Kukjin Kim kgene@samsung.com
Signed-off-by: Jiun Yu jiun...@samsung.com
Signed-off-by: KyungHwan Kim kh.k@samsung.com
Signed-off-by: Abhilash Kesavan a.kesa...@samsung.com
---
 drivers/media/video/s5p-tvout/hw_if/cec.c |  239 
 drivers/media/video/s5p-tvout/hw_if/hdcp.c|2 +-
 drivers/media/video/s5p-tvout/s5p_tvout_cec.c |  362 +
 3 files changed, 602 insertions(+), 1 deletions(-)
 create mode 100644 drivers/media/video/s5p-tvout/hw_if/cec.c
 create mode 100644 drivers/media/video/s5p-tvout/s5p_tvout_cec.c

diff --git a/drivers/media/video/s5p-tvout/hw_if/cec.c 
b/drivers/media/video/s5p-tvout/hw_if/cec.c
new file mode 100644
index 000..dbff584
--- /dev/null
+++ b/drivers/media/video/s5p-tvout/hw_if/cec.c
@@ -0,0 +1,239 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd.
+ * http://www.samsung.com
+ *
+ * CEC for Samsung S5P TVOUT driver
+ *
+ * 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/io.h
+#include linux/slab.h
+
+#include mach/regs-clock.h
+#include mach/regs-clock.h
+#include mach/regs-cec.h
+
+#include ../s5p_tvout_common_lib.h
+#include hw_if.h
+
+#define S5P_HDMI_FIN   2400
+#define CEC_DIV_RATIO  32
+
+#define CEC_MESSAGE_BROADCAST_MASK 0x0F
+#define CEC_MESSAGE_BROADCAST  0x0F
+#define CEC_FILTER_THRESHOLD   0x15
+
+static struct resource *cec_mem;
+void __iomem   *cec_base;
+
+struct cec_rx_struct cec_rx_struct;
+struct cec_tx_struct cec_tx_struct;
+
+void s5p_cec_set_divider(void)
+{
+   u32 div_ratio, reg, div_val;
+
+   div_ratio  = (S5P_HDMI_FIN / CEC_DIV_RATIO) - 1;
+
+   reg = readl(S5P_HDMI_PHY_CONTROL);
+   reg = (reg  ~(0x3FF  16)) | (div_ratio  16);
+
+   writel(reg, S5P_HDMI_PHY_CONTROL);
+
+   div_val = (CEC_DIV_RATIO * 0.5) - 1;
+
+   writeb(0x0, cec_base + S5P_CEC_DIVISOR_3);
+   writeb(0x0, cec_base + S5P_CEC_DIVISOR_2);
+   writeb(0x0, cec_base + S5P_CEC_DIVISOR_1);
+   writeb(div_val, cec_base + S5P_CEC_DIVISOR_0);
+}
+
+void s5p_cec_enable_rx(void)
+{
+   u8 reg;
+
+   reg = readb(cec_base + S5P_CEC_RX_CTRL);
+   reg |= S5P_CEC_RX_CTRL_ENABLE;
+   writeb(reg, cec_base + S5P_CEC_RX_CTRL);
+}
+
+void s5p_cec_mask_rx_interrupts(void)
+{
+   u8 reg;
+
+   reg = readb(cec_base + S5P_CEC_IRQ_MASK);
+   reg |= S5P_CEC_IRQ_RX_DONE;
+   reg |= S5P_CEC_IRQ_RX_ERROR;
+   writeb(reg, cec_base + S5P_CEC_IRQ_MASK);
+}
+
+void s5p_cec_unmask_rx_interrupts(void)
+{
+   u8 reg;
+
+   reg = readb(cec_base + S5P_CEC_IRQ_MASK);
+   reg = ~S5P_CEC_IRQ_RX_DONE;
+   reg = ~S5P_CEC_IRQ_RX_ERROR;
+   writeb(reg, cec_base + S5P_CEC_IRQ_MASK);
+}
+
+void s5p_cec_mask_tx_interrupts(void)
+{
+   u8 reg;
+
+   reg = readb(cec_base + S5P_CEC_IRQ_MASK);
+   reg |= S5P_CEC_IRQ_TX_DONE;
+   reg |= S5P_CEC_IRQ_TX_ERROR;
+   writeb(reg, cec_base + S5P_CEC_IRQ_MASK);
+}
+
+void s5p_cec_unmask_tx_interrupts(void)
+{
+   u8 reg;
+
+   reg = readb(cec_base + S5P_CEC_IRQ_MASK);
+   reg = ~S5P_CEC_IRQ_TX_DONE;
+   reg = ~S5P_CEC_IRQ_TX_ERROR;
+   writeb(reg, cec_base + S5P_CEC_IRQ_MASK);
+}
+
+void s5p_cec_tx_reset(void)
+{
+   writeb(S5P_CEC_TX_CTRL_RESET, cec_base + S5P_CEC_TX_CTRL);
+}
+
+void s5p_cec_rx_reset(void)
+{
+   writeb(S5P_CEC_RX_CTRL_RESET, cec_base + S5P_CEC_RX_CTRL);
+}
+
+void s5p_cec_reset(void)
+{
+   s5p_cec_rx_reset();
+   s5p_cec_tx_reset();
+}
+
+void s5p_cec_threshold(void)
+{
+   writeb(CEC_FILTER_THRESHOLD, cec_base + S5P_CEC_RX_FILTER_TH);
+   writeb(0, cec_base + S5P_CEC_RX_FILTER_CTRL);
+}
+
+void s5p_cec_set_tx_state(enum cec_state state)
+{
+   atomic_set(cec_tx_struct.state, state);
+}
+
+void s5p_cec_set_rx_state(enum cec_state state)
+{
+   atomic_set(cec_rx_struct.state, state);
+}
+
+void s5p_cec_copy_packet(char *data, size_t count)
+{
+   int i = 0;
+   u8 reg;
+
+   while (i  count) {
+   writeb(data[i], cec_base + (S5P_CEC_TX_BUFF0 + (i * 4)));
+   i++;
+   }
+
+   writeb(count, cec_base + S5P_CEC_TX_BYTES);
+   s5p_cec_set_tx_state(STATE_TX);
+   reg = readb(cec_base + S5P_CEC_TX_CTRL);
+   reg |= S5P_CEC_TX_CTRL_START;
+
+   if ((data[0]  CEC_MESSAGE_BROADCAST_MASK) == CEC_MESSAGE_BROADCAST)
+   reg |= S5P_CEC_TX_CTRL_BCAST;
+   else
+

[PATCH] ARM: EXYNOS4: Adds Samsung NURI board support

2011-02-25 Thread Minkyu Kang
This patch adds Samsung NURI board support.

Signed-off-by: Minkyu Kang mk7.k...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
This patch is base on next-exynos4 branch at kgene tree.

 arch/arm/configs/exynos4_defconfig |1 +
 arch/arm/mach-exynos4/Kconfig  |   15 +++
 arch/arm/mach-exynos4/Makefile |1 +
 arch/arm/mach-exynos4/mach-nuri.c  |  233 
 4 files changed, 250 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/mach-exynos4/mach-nuri.c

diff --git a/arch/arm/configs/exynos4_defconfig 
b/arch/arm/configs/exynos4_defconfig
index 2ffba24..fd92324 100644
--- a/arch/arm/configs/exynos4_defconfig
+++ b/arch/arm/configs/exynos4_defconfig
@@ -9,6 +9,7 @@ CONFIG_S3C_LOWLEVEL_UART_PORT=1
 CONFIG_MACH_SMDKC210=y
 CONFIG_MACH_SMDKV310=y
 CONFIG_MACH_UNIVERSAL_C210=y
+CONFIG_MACH_NURI=y
 CONFIG_NO_HZ=y
 CONFIG_HIGH_RES_TIMERS=y
 CONFIG_SMP=y
diff --git a/arch/arm/mach-exynos4/Kconfig b/arch/arm/mach-exynos4/Kconfig
index ad03840..5bf00b9 100644
--- a/arch/arm/mach-exynos4/Kconfig
+++ b/arch/arm/mach-exynos4/Kconfig
@@ -123,6 +123,21 @@ config MACH_UNIVERSAL_C210
  Machine support for Samsung Mobile Universal S5PC210 Reference
  Board.
 
+config MACH_NURI
+   bool Mobile NURI Board
+   select CPU_EXYNOS4210
+   select S3C_DEV_WDT
+   select S3C_DEV_HSMMC
+   select S3C_DEV_HSMMC2
+   select S3C_DEV_HSMMC3
+   select S3C_DEV_I2C1
+   select S3C_DEV_I2C5
+   select EXYNOS4_SETUP_I2C1
+   select EXYNOS4_SETUP_I2C5
+   select EXYNOS4_SETUP_SDHCI
+   help
+ Machine support for Samsung Mobile NURI Board.
+
 endmenu
 
 comment Configuration for HSMMC bus width
diff --git a/arch/arm/mach-exynos4/Makefile b/arch/arm/mach-exynos4/Makefile
index 0558235..fa9e814 100644
--- a/arch/arm/mach-exynos4/Makefile
+++ b/arch/arm/mach-exynos4/Makefile
@@ -25,6 +25,7 @@ obj-$(CONFIG_HOTPLUG_CPU) += hotplug.o
 obj-$(CONFIG_MACH_SMDKC210)+= mach-smdkc210.o
 obj-$(CONFIG_MACH_SMDKV310)+= mach-smdkv310.o
 obj-$(CONFIG_MACH_UNIVERSAL_C210)  += mach-universal_c210.o
+obj-$(CONFIG_MACH_NURI)+= mach-nuri.o
 
 # device support
 
diff --git a/arch/arm/mach-exynos4/mach-nuri.c 
b/arch/arm/mach-exynos4/mach-nuri.c
new file mode 100644
index 000..28010bd
--- /dev/null
+++ b/arch/arm/mach-exynos4/mach-nuri.c
@@ -0,0 +1,233 @@
+/*
+ * linux/arch/arm/mach-exynos4/mach-nuri.c
+ *
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd.
+ *
+ * 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/platform_device.h
+#include linux/serial_core.h
+#include linux/input.h
+#include linux/i2c.h
+#include linux/gpio_keys.h
+#include linux/gpio.h
+#include linux/regulator/machine.h
+#include linux/regulator/fixed.h
+#include linux/mmc/host.h
+
+#include asm/mach/arch.h
+#include asm/mach-types.h
+
+#include plat/regs-serial.h
+#include plat/exynos4.h
+#include plat/cpu.h
+#include plat/devs.h
+#include plat/sdhci.h
+
+#include mach/map.h
+
+/* Following are default values for UCON, ULCON and UFCON UART registers */
+#define NURI_UCON_DEFAULT  (S3C2410_UCON_TXILEVEL |\
+S3C2410_UCON_RXILEVEL |\
+S3C2410_UCON_TXIRQMODE |   \
+S3C2410_UCON_RXIRQMODE |   \
+S3C2410_UCON_RXFIFO_TOI |  \
+S3C2443_UCON_RXERR_IRQEN)
+
+#define NURI_ULCON_DEFAULT S3C2410_LCON_CS8
+
+#define NURI_UFCON_DEFAULT (S3C2410_UFCON_FIFOMODE |   \
+S5PV210_UFCON_TXTRIG256 |  \
+S5PV210_UFCON_RXTRIG256)
+
+enum fixed_regulator_id {
+   FIXED_REG_ID_MMC = 0,
+};
+
+static struct s3c2410_uartcfg nuri_uartcfgs[] __initdata = {
+   {
+   .hwport = 0,
+   .ucon   = NURI_UCON_DEFAULT,
+   .ulcon  = NURI_ULCON_DEFAULT,
+   .ufcon  = NURI_UFCON_DEFAULT,
+   },
+   {
+   .hwport = 1,
+   .ucon   = NURI_UCON_DEFAULT,
+   .ulcon  = NURI_ULCON_DEFAULT,
+   .ufcon  = NURI_UFCON_DEFAULT,
+   },
+   {
+   .hwport = 2,
+   .ucon   = NURI_UCON_DEFAULT,
+   .ulcon  = NURI_ULCON_DEFAULT,
+   .ufcon  = NURI_UFCON_DEFAULT,
+   },
+   {
+   .hwport = 3,
+   .ucon   = NURI_UCON_DEFAULT,
+   .ulcon  = NURI_ULCON_DEFAULT,
+   .ufcon  = NURI_UFCON_DEFAULT,
+   },
+};
+
+/* eMMC */
+static struct s3c_sdhci_platdata nuri_hsmmc0_data __initdata 

RE: [PATCH 2/5] ARM: Samsung: cleanup S5P gpio interrupt code

2011-02-25 Thread Marek Szyprowski
Hello,

On Wednesday, February 23, 2011 11:15 AM Kukjin Kim wrote:

 Marek Szyprowski wrote:
 
  This patch performs a global cleanup in s5p gpio interrupt support code.
  The code is prepared for upcoming support for gpio interrupts on S5PC210
  platform, which has 2 gpio banks (regions) instead of one (like on
  S5PC110 and S5PC100).
 
  Signed-off-by: Marek Szyprowski m.szyprow...@samsung.com
  Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
  ---
   arch/arm/plat-s5p/irq-gpioint.c |  106
 +
  --
   1 files changed, 46 insertions(+), 60 deletions(-)
 
  diff --git a/arch/arm/plat-s5p/irq-gpioint.c b/arch/arm/plat-s5p/irq-
  gpioint.c
  index 3b6bf89..af10328 100644
  --- a/arch/arm/plat-s5p/irq-gpioint.c
  +++ b/arch/arm/plat-s5p/irq-gpioint.c
  @@ -22,77 +22,64 @@
   #include plat/gpio-core.h
   #include plat/gpio-cfg.h
 
  -#define S5P_GPIOREG(x) (S5P_VA_GPIO + (x))
  +#define GPIO_BASE(chip)(((unsigned long)(chip)-base) 
  ~(SZ_4K - 1))
 
 
 Need SZ_4K here instead of 0xF000?

No problem, I can change it to 0xF000

 
  -#define GPIOINT_CON_OFFSET 0x700
  -#define GPIOINT_MASK_OFFSET0x900
  -#define GPIOINT_PEND_OFFSET0xA00
  +#define CON_OFFSET 0x700
  +#define MASK_OFFSET0x900
  +#define PEND_OFFSET0xA00
 
 I don't know why need to change above definitions...

I've shortened them to make the code the uses them to fit 80 characters
per line... They are just a local defines that imho don't need to be
prefixed with GPIOINT_

  +#define REG_OFFSET(x)  ((x)  2)
 
 Actually, this is used instead of group  2 in this file.
 So how about GPIOINT_REG_OFFSET(x) like others?

Ok.

   static void s5p_gpioint_ack(struct irq_data *data)
   {
  +   struct s3c_gpio_chip *chip = irq_data_get_irq_data(data);
  int group, offset, pend_offset;
  unsigned int value;
 
  -   group = s5p_gpioint_get_group(data);
  +   group = chip-group;
  offset = s5p_gpioint_get_offset(data);
  -   pend_offset = group  2;
  +   pend_offset = REG_OFFSET(group);
 
  -   value = __raw_readl(S5P_GPIOREG(GPIOINT_PEND_OFFSET) + pend_offset);
  -   value |= 1  offset;
  -   __raw_writel(value, S5P_GPIOREG(GPIOINT_PEND_OFFSET) + pend_offset);
  +   value = __raw_readl(GPIO_BASE(chip) + PEND_OFFSET + pend_offset);
  +   value |= BIT(offset);
 
 No need inclusion linux/bitops.h?

It has been included indirectly, because the code compiled fine.

snip

   static void s5p_gpioint_handler(unsigned int irq, struct irq_desc *desc)
   {
  -   int group, offset, pend_offset, mask_offset;
  -   int real_irq;
  +   int group, pend_offset, mask_offset;
  unsigned int pend, mask;
 
  for (group = 0; group  S5P_GPIOINT_GROUP_MAXNR; group++) {
  -   pend_offset = group  2;
  -   pend = __raw_readl(S5P_GPIOREG(GPIOINT_PEND_OFFSET) +
  -   pend_offset);
  +   struct s3c_gpio_chip *chip = irq_chips[group];
  +   if (!chip)
  +   continue;
  +
  +   pend_offset = REG_OFFSET(group);
  +   pend = __raw_readl(GPIO_BASE(chip) + PEND_OFFSET +
  pend_offset);
  if (!pend)
  continue;
 
  -   mask_offset = group  2;
  -   mask = __raw_readl(S5P_GPIOREG(GPIOINT_MASK_OFFSET) +
  -   mask_offset);
  +   mask_offset = REG_OFFSET(group);
  +   mask = __raw_readl(GPIO_BASE(chip) + MASK_OFFSET +
  mask_offset);
  pend = ~mask;
 
  -   for (offset = 0; offset  8; offset++) {
  -   if (pend  (1  offset)) {
  -   struct s3c_gpio_chip *chip =
 irq_chips[group];
  -   if (chip) {
  -   real_irq = chip-irq_base + offset;
  -   generic_handle_irq(real_irq);
  -   }
  -   }
  +   while (pend) {
  +   int offset = fls(pend) - 1;
 
 __ffs?

I don't see much difference between ffs and fls here...

 And hmm...do we really need while loop here?

Yes, because more than one gpio pin in a group can issue an interrupt at the
same time. The previous version used for() loop here.

 
  +   int real_irq = chip-irq_base + offset;
  +   generic_handle_irq(real_irq);
  +   pend = ~BIT(offset);
  }
  }
   }
  @@ -202,7 +188,7 @@ static __init int s5p_gpioint_add(struct s3c_gpio_chip
  *chip)
  for (i = 0; i  chip-chip.ngpio; i++) {
  irq = chip-irq_base + i;
  set_irq_chip(irq, s5p_gpioint);
  -   set_irq_data(irq, chip-chip);
  +   set_irq_data(irq, chip);
 
 ?

This simplifies all the functions that use get_irq_data. Now they get 
s3c_gpio_chip
directly and don't need to extract it with contrainer_of().

Best regards
--

Re: [PATCH] ARM: S5P: Add platform helpers for camera GPIO configuration

2011-02-25 Thread Sylwester Nawrocki

On 02/11/2011 07:07 PM, Sylwester Nawrocki wrote:
 Add functions for the parallel camera GPIO interface
 configuration on S5PV210 and S5PV310 SoCs.
 

Kukjin, are you OK with general concept of those?
I would probably need to rework the patches after recent
S5PV310 - EXYNOS4 renaming. And move camera.h 
to arch/arm/plat-samsung/include/plat/?

What's your opinion?

Thanks,
-- 
Sylwester Nawrocki
Samsung Poland RD Center
--
To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/3] ARM: S5P: Update defconfig for HRT support

2011-02-25 Thread Sangbeom Kim
This patch modify s5pv210_defconfig and s5p64x0_defconfig
for HRT support

Signed-off-by: Sangbeom Kim sbki...@samsung.com
---
 arch/arm/Kconfig   |4 ++--
 arch/arm/configs/s5p64x0_defconfig |2 ++
 arch/arm/configs/s5pv210_defconfig |2 ++
 3 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 166efa2..8b959e1 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -715,7 +715,7 @@ config ARCH_S5P64X0
select GENERIC_GPIO
select HAVE_CLK
select HAVE_S3C2410_WATCHDOG if WATCHDOG
-   select ARCH_USES_GETTIMEOFFSET
+   select GENERIC_CLOCKEVENTS
select HAVE_S3C2410_I2C if I2C
select HAVE_S3C_RTC if RTC_CLASS
help
@@ -753,7 +753,7 @@ config ARCH_S5PV210
select HAVE_CLK
select ARM_L1_CACHE_SHIFT_6
select ARCH_HAS_CPUFREQ
-   select ARCH_USES_GETTIMEOFFSET
+   select GENERIC_CLOCKEVENTS
select HAVE_S3C2410_I2C if I2C
select HAVE_S3C_RTC if RTC_CLASS
select HAVE_S3C2410_WATCHDOG if WATCHDOG
diff --git a/arch/arm/configs/s5p64x0_defconfig 
b/arch/arm/configs/s5p64x0_defconfig
index 2993ecd..ad6b61b 100644
--- a/arch/arm/configs/s5p64x0_defconfig
+++ b/arch/arm/configs/s5p64x0_defconfig
@@ -10,6 +10,8 @@ CONFIG_S3C_BOOT_ERROR_RESET=y
 CONFIG_S3C_LOWLEVEL_UART_PORT=1
 CONFIG_MACH_SMDK6440=y
 CONFIG_MACH_SMDK6450=y
+CONFIG_NO_HZ=y
+CONFIG_HIGH_RES_TIMERS=y
 CONFIG_CPU_32v6K=y
 CONFIG_AEABI=y
 CONFIG_CMDLINE=root=/dev/ram0 rw ramdisk=8192 initrd=0x2080,8M 
console=ttySAC1,115200 init=/linuxrc
diff --git a/arch/arm/configs/s5pv210_defconfig 
b/arch/arm/configs/s5pv210_defconfig
index 0488a1e..fa98990 100644
--- a/arch/arm/configs/s5pv210_defconfig
+++ b/arch/arm/configs/s5pv210_defconfig
@@ -13,6 +13,8 @@ CONFIG_MACH_AQUILA=y
 CONFIG_MACH_GONI=y
 CONFIG_MACH_SMDKC110=y
 CONFIG_MACH_SMDKV210=y
+CONFIG_NO_HZ=y
+CONFIG_HIGH_RES_TIMERS=y
 CONFIG_VMSPLIT_2G=y
 CONFIG_PREEMPT=y
 CONFIG_AEABI=y
-- 
1.7.1

--
To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/3] ARM: S5P: Update machine initialization for HRT

2011-02-25 Thread Sangbeom Kim
This patch update mach-s5p64x0 and mach-s5pv210
machine  initialization for hrt support

Signed-off-by: Sangbeom Kim sbki...@samsung.com
---
 arch/arm/mach-s5p64x0/mach-smdk6440.c |4 +++-
 arch/arm/mach-s5p64x0/mach-smdk6450.c |4 +++-
 arch/arm/mach-s5pv210/mach-aquila.c   |4 +++-
 arch/arm/mach-s5pv210/mach-goni.c |4 +++-
 arch/arm/mach-s5pv210/mach-smdkc110.c |4 +++-
 arch/arm/mach-s5pv210/mach-smdkv210.c |4 +++-
 arch/arm/mach-s5pv210/mach-torbreck.c |4 +++-
 7 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/arch/arm/mach-s5p64x0/mach-smdk6440.c 
b/arch/arm/mach-s5p64x0/mach-smdk6440.c
index e5beb84..f967736 100644
--- a/arch/arm/mach-s5p64x0/mach-smdk6440.c
+++ b/arch/arm/mach-s5p64x0/mach-smdk6440.c
@@ -43,6 +43,7 @@
 #include plat/pll.h
 #include plat/adc.h
 #include plat/ts.h
+#include plat/s5p-time.h
 
 #define SMDK6440_UCON_DEFAULT  (S3C2410_UCON_TXILEVEL |\
S3C2410_UCON_RXILEVEL | \
@@ -136,6 +137,7 @@ static void __init smdk6440_map_io(void)
s5p_init_io(NULL, 0, S5P64X0_SYS_ID);
s3c24xx_init_clocks(1200);
s3c24xx_init_uarts(smdk6440_uartcfgs, ARRAY_SIZE(smdk6440_uartcfgs));
+   s5p_set_timer_source(S5P_PWM2, S5P_PWM4);
 }
 
 static void __init smdk6440_machine_init(void)
@@ -159,5 +161,5 @@ MACHINE_START(SMDK6440, SMDK6440)
.init_irq   = s5p6440_init_irq,
.map_io = smdk6440_map_io,
.init_machine   = smdk6440_machine_init,
-   .timer  = s3c24xx_timer,
+   .timer  = s5p_timer,
 MACHINE_END
diff --git a/arch/arm/mach-s5p64x0/mach-smdk6450.c 
b/arch/arm/mach-s5p64x0/mach-smdk6450.c
index 3a20de0..686ec56 100644
--- a/arch/arm/mach-s5p64x0/mach-smdk6450.c
+++ b/arch/arm/mach-s5p64x0/mach-smdk6450.c
@@ -43,6 +43,7 @@
 #include plat/pll.h
 #include plat/adc.h
 #include plat/ts.h
+#include plat/s5p-time.h
 
 #define SMDK6450_UCON_DEFAULT  (S3C2410_UCON_TXILEVEL |\
S3C2410_UCON_RXILEVEL | \
@@ -155,6 +156,7 @@ static void __init smdk6450_map_io(void)
s5p_init_io(NULL, 0, S5P64X0_SYS_ID);
s3c24xx_init_clocks(1920);
s3c24xx_init_uarts(smdk6450_uartcfgs, ARRAY_SIZE(smdk6450_uartcfgs));
+   s5p_set_timer_source(S5P_PWM2, S5P_PWM4);
 }
 
 static void __init smdk6450_machine_init(void)
@@ -178,5 +180,5 @@ MACHINE_START(SMDK6450, SMDK6450)
.init_irq   = s5p6450_init_irq,
.map_io = smdk6450_map_io,
.init_machine   = smdk6450_machine_init,
-   .timer  = s3c24xx_timer,
+   .timer  = s5p_timer,
 MACHINE_END
diff --git a/arch/arm/mach-s5pv210/mach-aquila.c 
b/arch/arm/mach-s5pv210/mach-aquila.c
index 557add4..fab84f3 100644
--- a/arch/arm/mach-s5pv210/mach-aquila.c
+++ b/arch/arm/mach-s5pv210/mach-aquila.c
@@ -39,6 +39,7 @@
 #include plat/fb.h
 #include plat/fimc-core.h
 #include plat/sdhci.h
+#include plat/s5p-time.h
 
 /* Following are default values for UCON, ULCON and UFCON UART registers */
 #define AQUILA_UCON_DEFAULT(S3C2410_UCON_TXILEVEL |\
@@ -664,6 +665,7 @@ static void __init aquila_map_io(void)
s5p_init_io(NULL, 0, S5P_VA_CHIPID);
s3c24xx_init_clocks(2400);
s3c24xx_init_uarts(aquila_uartcfgs, ARRAY_SIZE(aquila_uartcfgs));
+   s5p_set_timer_source(S5P_PWM2, S5P_PWM4);
 }
 
 static void __init aquila_machine_init(void)
@@ -698,5 +700,5 @@ MACHINE_START(AQUILA, Aquila)
.init_irq   = s5pv210_init_irq,
.map_io = aquila_map_io,
.init_machine   = aquila_machine_init,
-   .timer  = s3c24xx_timer,
+   .timer  = s5p_timer,
 MACHINE_END
diff --git a/arch/arm/mach-s5pv210/mach-goni.c 
b/arch/arm/mach-s5pv210/mach-goni.c
index 056f5c7..5eda4a1 100644
--- a/arch/arm/mach-s5pv210/mach-goni.c
+++ b/arch/arm/mach-s5pv210/mach-goni.c
@@ -45,6 +45,7 @@
 #include plat/keypad.h
 #include plat/sdhci.h
 #include plat/clock.h
+#include plat/s5p-time.h
 
 /* Following are default values for UCON, ULCON and UFCON UART registers */
 #define GONI_UCON_DEFAULT  (S3C2410_UCON_TXILEVEL |\
@@ -823,6 +824,7 @@ static void __init goni_map_io(void)
s5p_init_io(NULL, 0, S5P_VA_CHIPID);
s3c24xx_init_clocks(2400);
s3c24xx_init_uarts(goni_uartcfgs, ARRAY_SIZE(goni_uartcfgs));
+   s5p_set_timer_source(S5P_PWM2, S5P_PWM4);
 }
 
 static void __init goni_machine_init(void)
@@ -873,5 +875,5 @@ MACHINE_START(GONI, GONI)
.init_irq   = s5pv210_init_irq,
.map_io = goni_map_io,
.init_machine   = goni_machine_init,
-   .timer  = s3c24xx_timer,
+   .timer  = s5p_timer,
 MACHINE_END
diff --git a/arch/arm/mach-s5pv210/mach-smdkc110.c 
b/arch/arm/mach-s5pv210/mach-smdkc110.c
index ce11a02..f304383 100644
--- a/arch/arm/mach-s5pv210/mach-smdkc110.c
+++ b/arch/arm/mach-s5pv210/mach-smdkc110.c
@@ -30,6 +30,7 @@
 #include plat/ata.h
 

[PATCH 0/3] ARM: S5P: Add high resolution timer support

2011-02-25 Thread Sangbeom Kim
This patch-set adds support for HRT(High Resolution Timer).
In Samsung SoCs, there is many HRT timer sources.
PWM Timer, System Timer, MCT, RTC can be used for that.
In this patches, Only support PWM Timer.
But All kind of pwm timer can be used for clock source.
This patch is tested on SMDKC110, SMDK6450.
APM is only tested on SMDKC110.
Next version will support System Timer, RTC, MCT.

[PATCH 1/3] ARM: S5P: Add s5p_timer support for HRT
[PATCH 2/3] ARM: S5P: Update machine initialization for HRT
[PATCH 3/3] ARM: S5P: Update defconfig for HRT support
--
To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] ARM: S5P64X0: Modify number of GPIO lines in Bank F

2011-02-25 Thread Banajit Goswami
This patch modifies the number of total GPIO lines for Bank F
for Samsung S5P6440 and S5P6450 SoCs from 2 to 16.
This is necessary as the GPIO lines from 0 to 13 are reserved
and only lines 14 and 15 are used. As during initialization,
the line number starts at 0, putting 2 does not solve the
intended purpose.

Signed-off-by: Banajit Goswami banaji...@samsung.com
---
 arch/arm/mach-s5p64x0/include/mach/gpio.h |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-s5p64x0/include/mach/gpio.h 
b/arch/arm/mach-s5p64x0/include/mach/gpio.h
index 5486c8f..adb5f29 100644
--- a/arch/arm/mach-s5p64x0/include/mach/gpio.h
+++ b/arch/arm/mach-s5p64x0/include/mach/gpio.h
@@ -23,7 +23,7 @@
 #define S5P6440_GPIO_A_NR  (6)
 #define S5P6440_GPIO_B_NR  (7)
 #define S5P6440_GPIO_C_NR  (8)
-#define S5P6440_GPIO_F_NR  (2)
+#define S5P6440_GPIO_F_NR  (16)
 #define S5P6440_GPIO_G_NR  (7)
 #define S5P6440_GPIO_H_NR  (10)
 #define S5P6440_GPIO_I_NR  (16)
@@ -36,7 +36,7 @@
 #define S5P6450_GPIO_B_NR  (7)
 #define S5P6450_GPIO_C_NR  (8)
 #define S5P6450_GPIO_D_NR  (8)
-#define S5P6450_GPIO_F_NR  (2)
+#define S5P6450_GPIO_F_NR  (16)
 #define S5P6450_GPIO_G_NR  (14)
 #define S5P6450_GPIO_H_NR  (10)
 #define S5P6450_GPIO_I_NR  (16)
-- 
1.6.5.2

--
To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/6] ARM: SAMSUNG: Add support PWM backlight

2011-02-25 Thread Banajit Goswami
This patch adds support PWM backlight for S5P SoCs.

1. Move PWM timer code from plat-s3c24xx to plat-samsung for common useability
2. Add PWM backlight support for SMDK6410/6440/6450/C100 and SMDKV210

Note: The modification of GPIO F for S5P64X0 patch should be merged first as
there is a dependency for PWM on S5P64X0.

[PATCH 1/6] ARM: SAMSUNG: Move PWM device definition from plat-s3c24xx to 
plat-samsung
[PATCH 2/6] ARM: S3C64XX: Add PWM backlight support on SMDK6410
[PATCH 3/6] ARM: S5P64X0: Add PWM backlight support on SMDK6440
[PATCH 4/6] ARM: S5P64X0: Add PWM backlight support on SMDK6450
[PATCH 5/6] ARM: S5PC100: Add PWM backlight support on SMDKC100
[PATCH 6/6] ARM: S5PV210: Add PWM backlight support on SMDKV210
--
To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 5/6] ARM: S5PC100: Add PWM backlight support on SMDKC100

2011-02-25 Thread Banajit Goswami
This patch adds support for LCD backlight using PWM timer for
Samsung SMDKC100 board.

Signed-off-by: Banajit Goswami banaji...@samsung.com
---
 arch/arm/mach-s5pc100/Kconfig |1 +
 arch/arm/mach-s5pc100/mach-smdkc100.c |   48 ++---
 2 files changed, 45 insertions(+), 4 deletions(-)

diff --git a/arch/arm/mach-s5pc100/Kconfig b/arch/arm/mach-s5pc100/Kconfig
index b8fbf2f..608722f 100644
--- a/arch/arm/mach-s5pc100/Kconfig
+++ b/arch/arm/mach-s5pc100/Kconfig
@@ -58,6 +58,7 @@ config MACH_SMDKC100
select SAMSUNG_DEV_ADC
select SAMSUNG_DEV_IDE
select SAMSUNG_DEV_KEYPAD
+   select SAMSUNG_DEV_PWM
select SAMSUNG_DEV_TS
select S5PC100_SETUP_FB_24BPP
select S5PC100_SETUP_I2C1
diff --git a/arch/arm/mach-s5pc100/mach-smdkc100.c 
b/arch/arm/mach-s5pc100/mach-smdkc100.c
index dd192a2..22d5348 100644
--- a/arch/arm/mach-s5pc100/mach-smdkc100.c
+++ b/arch/arm/mach-s5pc100/mach-smdkc100.c
@@ -23,12 +23,15 @@
 #include linux/fb.h
 #include linux/delay.h
 #include linux/input.h
+#include linux/pwm_backlight.h
 
 #include asm/mach/arch.h
 #include asm/mach/map.h
 
 #include mach/map.h
 #include mach/regs-fb.h
+#include mach/regs-gpio.h
+
 #include video/platform_lcd.h
 
 #include asm/irq.h
@@ -107,9 +110,6 @@ static struct i2c_board_info i2c_devs1[] __initdata = {
 static void smdkc100_lcd_power_set(struct plat_lcd_data *pd,
   unsigned int power)
 {
-   /* backlight */
-   gpio_direction_output(S5PC100_GPD(0), power);
-
if (power) {
/* module reset */
gpio_direction_output(S5PC100_GPH0(6), 1);
@@ -178,6 +178,44 @@ static struct samsung_keypad_platdata smdkc100_keypad_data 
__initdata = {
.rows   = 2,
.cols   = 8,
 };
+
+static int smdkc100_backlight_init(struct device *dev)
+{
+   int ret;
+
+   ret = gpio_request(S5PC100_GPD(0), Backlight);
+   if (ret) {
+   printk(KERN_ERR failed to request GPF for PWM-OUT0\n);
+   return ret;
+   }
+
+   /* Configure GPIO pin with S5PC100_GPD_TOUT_0 */
+   s3c_gpio_cfgpin(S5PC100_GPD(0), (0x2  0));
+
+   return 0;
+}
+
+static void smdkc100_backlight_exit(struct device *dev)
+{
+   s3c_gpio_cfgpin(S5PC100_GPD(0), S3C_GPIO_OUTPUT);
+   gpio_free(S5PC100_GPD(0));
+}
+
+static struct platform_pwm_backlight_data smdkc100_backlight_data = {
+   .pwm_id = 0,
+   .max_brightness = 255,
+   .dft_brightness = 255,
+   .pwm_period_ns  = 78770,
+   .init   = smdkc100_backlight_init,
+   .exit   = smdkc100_backlight_exit,
+};
+
+static struct platform_device smdkc100_backlight_device = {
+   .name   = pwm-backlight,
+   .dev= {
+   .parent = s3c_device_timer[0].dev,
+   .platform_data  = smdkc100_backlight_data,
+   },
+};
 
 static struct platform_device *smdkc100_devices[] __initdata = {
s3c_device_adc,
@@ -200,6 +238,9 @@ static struct platform_device *smdkc100_devices[] 
__initdata = {
s5p_device_fimc1,
s5p_device_fimc2,
s5pc100_device_spdif,
+   s3c_device_timer[0],
+   s3c_device_timer[1],
+   smdkc100_backlight_device,
 };
 
 static struct s3c2410_ts_mach_info s3c_ts_platform __initdata = {
@@ -233,7 +274,6 @@ static void __init smdkc100_machine_init(void)
s5pc100_spdif_setup_gpio(S5PC100_SPDIF_GPD);
 
/* LCD init */
-   gpio_request(S5PC100_GPD(0), GPD);
gpio_request(S5PC100_GPH0(6), GPH0);
smdkc100_lcd_power_set(smdkc100_lcd_power_data, 0);
platform_add_devices(smdkc100_devices, ARRAY_SIZE(smdkc100_devices));
-- 
1.6.5.2

--
To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/6] ARM: S5P64X0: Add PWM backlight support on SMDK6440

2011-02-25 Thread Banajit Goswami
This patch adds support for LCD backlight control using PWM timer
for Samsung SMDK6440 board.

Signed-off-by: Banajit Goswami banaji...@samsung.com
---
 arch/arm/mach-s5p64x0/Kconfig |1 +
 arch/arm/mach-s5p64x0/mach-smdk6440.c |   44 +
 2 files changed, 45 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-s5p64x0/Kconfig b/arch/arm/mach-s5p64x0/Kconfig
index 164d278..be5888a 100644
--- a/arch/arm/mach-s5p64x0/Kconfig
+++ b/arch/arm/mach-s5p64x0/Kconfig
@@ -34,6 +34,7 @@ config MACH_SMDK6440
select S3C_DEV_WDT
select S3C64XX_DEV_SPI
select SAMSUNG_DEV_ADC
+   select SAMSUNG_DEV_PWM
select SAMSUNG_DEV_TS
select S5P64X0_SETUP_I2C1
help
diff --git a/arch/arm/mach-s5p64x0/mach-smdk6440.c 
b/arch/arm/mach-s5p64x0/mach-smdk6440.c
index e5beb84..58941d7 100644
--- a/arch/arm/mach-s5p64x0/mach-smdk6440.c
+++ b/arch/arm/mach-s5p64x0/mach-smdk6440.c
@@ -22,6 +22,7 @@
 #include linux/module.h
 #include linux/clk.h
 #include linux/gpio.h
+#include linux/pwm_backlight.h
 
 #include asm/mach/arch.h
 #include asm/mach/map.h
@@ -32,6 +33,7 @@
 #include mach/map.h
 #include mach/regs-clock.h
 #include mach/i2c.h
+#include mach/regs-gpio.h
 
 #include plat/regs-serial.h
 #include plat/gpio-cfg.h
@@ -88,6 +90,45 @@ static struct s3c2410_uartcfg smdk6440_uartcfgs[] __initdata 
= {
},
 };
 
+static int smdk6440_backlight_init(struct device *dev)
+{
+   int ret;
+
+   ret = gpio_request(S5P6440_GPF(15), Backlight);
+   if (ret) {
+   printk(KERN_ERR failed to request GPF for PWM-OUT1\n);
+   return ret;
+   }
+
+   /* Configure GPIO pin with S5P6440_GPF15_PWM_TOUT1 */
+   s3c_gpio_cfgpin(S5P6440_GPF(15), (0x02  30));
+
+   return 0;
+}
+
+static void smdk6440_backlight_exit(struct device *dev)
+{
+   s3c_gpio_cfgpin(S5P6440_GPF(15), S3C_GPIO_OUTPUT);
+   gpio_free(S5P6440_GPF(15));
+}
+
+static struct platform_pwm_backlight_data smdk6440_backlight_data = {
+   .pwm_id = 1,
+   .max_brightness = 255,
+   .dft_brightness = 255,
+   .pwm_period_ns  = 78770,
+   .init   = smdk6440_backlight_init,
+   .exit   = smdk6440_backlight_exit,
+};
+
+static struct platform_device smdk6440_backlight_device = {
+   .name   = pwm-backlight,
+   .dev= {
+   .parent = s3c_device_timer[1].dev,
+   .platform_data  = smdk6440_backlight_data,
+   },
+};
+
 static struct platform_device *smdk6440_devices[] __initdata = {
s3c_device_adc,
s3c_device_rtc,
@@ -97,6 +138,9 @@ static struct platform_device *smdk6440_devices[] __initdata 
= {
s3c_device_wdt,
samsung_asoc_dma,
s5p6440_device_iis,
+   s3c_device_timer[0],
+   s3c_device_timer[1],
+   smdk6440_backlight_device,
 };
 
 static struct s3c2410_platform_i2c s5p6440_i2c0_data __initdata = {
-- 
1.6.5.2

--
To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/6] ARM: S3C64XX: Add PWM backlight support on SMDK6410

2011-02-25 Thread Banajit Goswami
This patch adds support for LCD backlight using PWM timer for
Samsung SMDK6410 board.

Signed-off-by: Banajit Goswami banaji...@samsung.com
---
 arch/arm/mach-s3c64xx/Kconfig |1 +
 arch/arm/mach-s3c64xx/mach-smdk6410.c |   46 ++--
 2 files changed, 44 insertions(+), 3 deletions(-)

diff --git a/arch/arm/mach-s3c64xx/Kconfig b/arch/arm/mach-s3c64xx/Kconfig
index f3a953f..e4177e2 100644
--- a/arch/arm/mach-s3c64xx/Kconfig
+++ b/arch/arm/mach-s3c64xx/Kconfig
@@ -143,6 +143,7 @@ config MACH_SMDK6410
select S3C_DEV_USB_HSOTG
select S3C_DEV_WDT
select SAMSUNG_DEV_KEYPAD
+   select SAMSUNG_DEV_PWM
select HAVE_S3C2410_WATCHDOG if WATCHDOG
select S3C64XX_SETUP_SDHCI
select S3C64XX_SETUP_I2C1
diff --git a/arch/arm/mach-s3c64xx/mach-smdk6410.c 
b/arch/arm/mach-s3c64xx/mach-smdk6410.c
index e85192a..4a3fe0c 100644
--- a/arch/arm/mach-s3c64xx/mach-smdk6410.c
+++ b/arch/arm/mach-s3c64xx/mach-smdk6410.c
@@ -28,6 +28,7 @@
 #include linux/delay.h
 #include linux/smsc911x.h
 #include linux/regulator/fixed.h
+#include linux/pwm_backlight.h
 
 #ifdef CONFIG_SMDK6410_WM1190_EV1
 #include linux/mfd/wm8350/core.h
@@ -48,6 +49,7 @@
 #include mach/hardware.h
 #include mach/regs-fb.h
 #include mach/map.h
+#include mach/gpio-bank-f.h
 
 #include asm/irq.h
 #include asm/mach-types.h
@@ -118,7 +120,6 @@ static void smdk6410_lcd_power_set(struct plat_lcd_data *pd,
 {
if (power) {
gpio_direction_output(S3C64XX_GPF(13), 1);
-   gpio_direction_output(S3C64XX_GPF(15), 1);
 
/* fire nRESET on power up */
gpio_direction_output(S3C64XX_GPN(5), 0);
@@ -126,7 +127,6 @@ static void smdk6410_lcd_power_set(struct plat_lcd_data *pd,
gpio_direction_output(S3C64XX_GPN(5), 1);
msleep(1);
} else {
-   gpio_direction_output(S3C64XX_GPF(15), 0);
gpio_direction_output(S3C64XX_GPF(13), 0);
}
 }
@@ -269,6 +269,45 @@ static struct samsung_keypad_platdata smdk6410_keypad_data 
__initdata = {
.cols   = 8,
 };
 
+static int smdk6410_backlight_init(struct device *dev)
+{
+   int ret;
+
+   ret = gpio_request(S3C64XX_GPF(15), Backlight);
+   if (ret) {
+   printk(KERN_ERR failed to request GPF for PWM-OUT1\n);
+   return ret;
+   }
+
+   /* Configure GPIO pin with S3C64XX_GPF15_PWM_TOUT1 */
+   s3c_gpio_cfgpin(S3C64XX_GPF(15), S3C64XX_GPF15_PWM_TOUT1);
+
+   return 0;
+}
+
+static void smdk6410_backlight_exit(struct device *dev)
+{
+   s3c_gpio_cfgpin(S3C64XX_GPF(15), S3C_GPIO_OUTPUT);
+   gpio_free(S3C64XX_GPF(15));
+}
+
+static struct platform_pwm_backlight_data smdk6410_backlight_data = {
+   .pwm_id = 1,
+   .max_brightness = 255,
+   .dft_brightness = 255,
+   .pwm_period_ns  = 78770,
+   .init   = smdk6410_backlight_init,
+   .exit   = smdk6410_backlight_exit,
+};
+
+static struct platform_device smdk6410_backlight_device = {
+   .name   = pwm-backlight,
+   .dev= {
+   .parent = s3c_device_timer[1].dev,
+   .platform_data  = smdk6410_backlight_data,
+   },
+};
+
 static struct map_desc smdk6410_iodesc[] = {};
 
 static struct platform_device *smdk6410_devices[] __initdata = {
@@ -298,6 +337,9 @@ static struct platform_device *smdk6410_devices[] 
__initdata = {
s3c_device_rtc,
s3c_device_ts,
s3c_device_wdt,
+   s3c_device_timer[0],
+   s3c_device_timer[1],
+   smdk6410_backlight_device,
 };
 
 #ifdef CONFIG_REGULATOR
@@ -693,7 +735,6 @@ static void __init smdk6410_machine_init(void)
 
gpio_request(S3C64XX_GPN(5), LCD power);
gpio_request(S3C64XX_GPF(13), LCD power);
-   gpio_request(S3C64XX_GPF(15), LCD power);
 
i2c_register_board_info(0, i2c_devs0, ARRAY_SIZE(i2c_devs0));
i2c_register_board_info(1, i2c_devs1, ARRAY_SIZE(i2c_devs1));
-- 
1.6.5.2

--
To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/6] ARM: SAMSUNG: Move PWM device definition from plat-s3c24xx to plat-samsung

2011-02-25 Thread Banajit Goswami
This patch does the following:
1. It moves file pwm.c from plat-s3c24xx to plat-samsung. This will
   enable all machines with Samsung SoCs to make use of the same code.
2. The device definitions have been separated to a new file dev-pwm.c
   for better clarity and structure.
3. It will enable all Samsung S3C and S5P series SoC's to use common
   PWM Kconfig definition.

Signed-off-by: Banajit Goswami banaji...@samsung.com
---
 arch/arm/mach-s3c64xx/Kconfig   |4 +-
 arch/arm/plat-s3c24xx/Kconfig   |7 -
 arch/arm/plat-samsung/Kconfig   |   13 +
 arch/arm/plat-samsung/Makefile  |1 +
 arch/arm/plat-samsung/dev-pwm.c |   52 +++
 arch/arm/plat-samsung/pwm.c |   33 
 6 files changed, 68 insertions(+), 42 deletions(-)
 create mode 100644 arch/arm/plat-samsung/dev-pwm.c

diff --git a/arch/arm/mach-s3c64xx/Kconfig b/arch/arm/mach-s3c64xx/Kconfig
index 579d2f0..f3a953f 100644
--- a/arch/arm/mach-s3c64xx/Kconfig
+++ b/arch/arm/mach-s3c64xx/Kconfig
@@ -231,7 +231,7 @@ config MACH_HMT
select S3C_DEV_NAND
select S3C_DEV_USB_HOST
select S3C64XX_SETUP_FB_24BPP
-   select HAVE_PWM
+   select SAMSUNG_DEV_PWM
help
  Machine support for the Airgoo HMT
 
@@ -249,8 +249,8 @@ config MACH_SMARTQ
select S3C64XX_SETUP_SDHCI
select S3C64XX_SETUP_FB_24BPP
select SAMSUNG_DEV_ADC
+   select SAMSUNG_DEV_PWM
select SAMSUNG_DEV_TS
-   select HAVE_PWM
help
Shared machine support for SmartQ 5/7
 
diff --git a/arch/arm/plat-s3c24xx/Kconfig b/arch/arm/plat-s3c24xx/Kconfig
index eb105e6..d9c4096 100644
--- a/arch/arm/plat-s3c24xx/Kconfig
+++ b/arch/arm/plat-s3c24xx/Kconfig
@@ -56,13 +56,6 @@ config S3C24XX_DCLK
help
  Clock code for supporting DCLK/CLKOUT on S3C24XX architectures
 
-config S3C24XX_PWM
-   bool PWM device support
-   select HAVE_PWM
-   help
- Support for exporting the PWM timer blocks via the pwm device
- system.
-
 # gpio configurations
 
 config S3C24XX_GPIO_EXTRA
diff --git a/arch/arm/plat-samsung/Kconfig b/arch/arm/plat-samsung/Kconfig
index 32be05c..184a85a 100644
--- a/arch/arm/plat-samsung/Kconfig
+++ b/arch/arm/plat-samsung/Kconfig
@@ -273,6 +273,19 @@ config SAMSUNG_DEV_KEYPAD
help
  Compile in platform device definitions for keypad
 
+config SAMSUNG_DEV_PWM
+   bool
+   default y if ARCH_S3C2410
+   help
+ Compile in platform device definition for PWM Timer
+
+config S3C24XX_PWM
+   bool PWM device support
+   select HAVE_PWM
+   help
+ Support for exporting the PWM timer blocks via the pwm device
+ system.
+
 # DMA
 
 config S3C_DMA
diff --git a/arch/arm/plat-samsung/Makefile b/arch/arm/plat-samsung/Makefile
index 29932f8..e9de58a 100644
--- a/arch/arm/plat-samsung/Makefile
+++ b/arch/arm/plat-samsung/Makefile
@@ -59,6 +59,7 @@ obj-$(CONFIG_SAMSUNG_DEV_ADC) += dev-adc.o
 obj-$(CONFIG_SAMSUNG_DEV_IDE)  += dev-ide.o
 obj-$(CONFIG_SAMSUNG_DEV_TS)   += dev-ts.o
 obj-$(CONFIG_SAMSUNG_DEV_KEYPAD)   += dev-keypad.o
+obj-$(CONFIG_SAMSUNG_DEV_PWM)  += dev-pwm.o
 
 # DMA support
 
diff --git a/arch/arm/plat-samsung/dev-pwm.c b/arch/arm/plat-samsung/dev-pwm.c
new file mode 100644
index 000..68c5986
--- /dev/null
+++ b/arch/arm/plat-samsung/dev-pwm.c
@@ -0,0 +1,53 @@
+/* linux/arch/arm/plat-samsung/dev-pwm.c
+ *
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd.
+ * http://www.samsung.com
+ *
+ * Copyright (c) 2007 Ben Dooks
+ * Copyright (c) 2008 Simtec Electronics
+ * Ben Dooks b...@simtec.co.uk, ben-li...@fluff.org
+ *
+ * S3C series device definition for the PWM timer
+ *
+ * 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/kernel.h
+#include linux/platform_device.h
+
+#include mach/irqs.h
+
+#include plat/devs.h
+
+#define TIMER_RESOURCE_SIZE (1)
+
+#define TIMER_RESOURCE(_tmr, _irq) \
+   (struct resource [TIMER_RESOURCE_SIZE]) {   \
+   [0] = { \
+   .start  = _irq, \
+   .end= _irq, \
+   .flags  = IORESOURCE_IRQ\
+   }   \
+   }
+
+#define DEFINE_S3C_TIMER(_tmr_no, _irq)\
+   .name   = s3c24xx-pwm,\
+   .id = _tmr_no,  \
+   .num_resources  = TIMER_RESOURCE_SIZE,  \
+   .resource   = TIMER_RESOURCE(_tmr_no, _irq),\
+
+/*
+ * since we already have an static mapping for the timer,
+ * we do not bother setting any IO resource for the base.
+ */
+
+struct platform_device s3c_device_timer[] = {
+