Re: [Suggestion] kernel: 'now' may be used uninitialized in posix_cpu_timer_schedule function

2013-03-26 Thread Chen Gang

 oh, sorry, it seems better to let ARM folks know about it.

 ;-)


On 2013年03月26日 14:36, Chen Gang wrote:
 Hello Maintainers:
 
   compiling with EXTRA_CFLAGS=-W:
 make V=1 EXTRA_CFLAGS=-W ARCH=arm s3c2410_defconfig
 make V=1 EXTRA_CFLAGS=-W ARCH=arm menuconfig
   set 'arm-linux-gnu-' for cross chain prefix
 make V=1 EXTRA_CFLAGS=-W ARCH=arm
 
   it will report:
 kernel/posix-cpu-timers.c:1065:19: warning: ‘now’ may be used 
 uninitialized in this function [-Wuninitialized]
 
   it seems it is really a bug.
 can any member help to fix it ?
 or provide additional suggestion ?
   (it seems only unsigned long long now = 0 is not enough).
 
   :-)
 
 
 
 in kernel/posix-cpu-timers.c:
   for variable 'now' is defined without initialization (line 1029)
   it may be used without initialization (line 1066)
 
 
 1026 void posix_cpu_timer_schedule(struct k_itimer *timer)
 1027 {
 1028 struct task_struct *p = timer-it.cpu.task;
 1029 unsigned long long now;
 1030 
 1031 if (unlikely(p == NULL))
 1032 /*
 1033  * The task was cleaned up already, no future firings.
 1034  */
 1035 goto out;
 1036 
 1037 /*
 1038  * Fetch the current sample and update the timer's expiry time.
 1039  */
 1040 if (CPUCLOCK_PERTHREAD(timer-it_clock)) {
 1041 cpu_clock_sample(timer-it_clock, p, now);
 1042 bump_cpu_timer(timer, now);
 1043 if (unlikely(p-exit_state)) {
 1044 clear_dead_task(timer, now);
 1045 goto out;
 1046 }
 1047 read_lock(tasklist_lock); /* arm_timer needs it.  */
 1048 spin_lock(p-sighand-siglock);
 1049 } else {
 1050 read_lock(tasklist_lock);
 1051 if (unlikely(p-sighand == NULL)) {
 1052 /*
 1053  * The process has been reaped.
 1054  * We can't even collect a sample any more.
 1055  */
 1056 put_task_struct(p);
 1057 timer-it.cpu.task = p = NULL;
 1058 timer-it.cpu.expires = 0;
 1059 goto out_unlock;
 1060 } else if (unlikely(p-exit_state)  
 thread_group_empty(p)) {
 1061 /*
 1062  * We've noticed that the thread is dead, but
 1063  * not yet reaped.  Take this opportunity to
 1064  * drop our task ref.
 1065  */
 1066 clear_dead_task(timer, now);
 1067 goto out_unlock;
 1068 }
 1069 spin_lock(p-sighand-siglock);
 1070 cpu_timer_sample_group(timer-it_clock, p, now);
 1071 bump_cpu_timer(timer, now);
 1072 /* Leave the tasklist_lock locked for the call below.  */
 1073 }
 1074 
 1075 /*
 1076  * Now re-arm for the new expiry time.
 1077  */
 1078 BUG_ON(!irqs_disabled());
 1079 arm_timer(timer);
 1080 spin_unlock(p-sighand-siglock);
 1081 
 1082 out_unlock:
 1083 read_unlock(tasklist_lock);
 1084 
 1085 out:
 1086 timer-it_overrun_last = timer-it_overrun;
 1087 timer-it_overrun = -1;
 1088 ++timer-it_requeue_pending;
 1089 }
 


-- 
Chen Gang

Asianux Corporation
--
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:s3c24xx: beautify code, data-hwirq is unsigned long which is always = 0

2013-03-26 Thread Chen Gang

  data-hwirq is unsigned long which is always = 0

Signed-off-by: Chen Gang gang.c...@asianux.com
---
 arch/arm/mach-s3c24xx/irq.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-s3c24xx/irq.c b/arch/arm/mach-s3c24xx/irq.c
index 5c9f8b7..143f57b 100644
--- a/arch/arm/mach-s3c24xx/irq.c
+++ b/arch/arm/mach-s3c24xx/irq.c
@@ -210,7 +210,7 @@ static int s3c_irqext0_type(struct irq_data *data, unsigned 
int type)
void __iomem *gpcon_reg;
unsigned long gpcon_offset, extint_offset;
 
-   if ((data-hwirq = 0)  (data-hwirq = 3)) {
+   if (data-hwirq = 3) {
gpcon_reg = S3C2410_GPFCON;
extint_reg = S3C24XX_EXTINT0;
gpcon_offset = (data-hwirq) * 2;
-- 
1.7.7.6
--
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


Re: [PATCH V5 8/9] ARM: tegra: Provide regulator to pwm-backlight

2013-03-26 Thread Thierry Reding
On Mon, Mar 25, 2013 at 06:21:52PM -0700, Andrew Chew wrote:
 The pwm-backlight driver now takes a mandatory regulator that is gotten
 during driver probe.  Initialize a dummy regulator to satisfy this
 requirement.
 
 Signed-off-by: Andrew Chew ac...@nvidia.com
 Acked-by: Alexandre Courbot acour...@nvidia.com
 Acked-by: Stephen Warren swar...@nvidia.com
 ---
  arch/arm/boot/dts/tegra20-medcom-wide.dts | 1 +
  arch/arm/boot/dts/tegra20-tamonten.dtsi   | 5 +
  2 files changed, 6 insertions(+)
 
 diff --git a/arch/arm/boot/dts/tegra20-medcom-wide.dts 
 b/arch/arm/boot/dts/tegra20-medcom-wide.dts
 index a2d6d65..90d665e 100644
 --- a/arch/arm/boot/dts/tegra20-medcom-wide.dts
 +++ b/arch/arm/boot/dts/tegra20-medcom-wide.dts
 @@ -32,6 +32,7 @@
  
   brightness-levels = 0 4 8 16 32 64 128 255;
   default-brightness-level = 6;
 + power-supply = backlight_power_reg;
   };
  
   sound {
 diff --git a/arch/arm/boot/dts/tegra20-tamonten.dtsi 
 b/arch/arm/boot/dts/tegra20-tamonten.dtsi
 index 6e9d91f..2d8e7f2 100644
 --- a/arch/arm/boot/dts/tegra20-tamonten.dtsi
 +++ b/arch/arm/boot/dts/tegra20-tamonten.dtsi
 @@ -485,5 +485,10 @@
   regulator-max-microvolt = 500;
   regulator-always-on;
   };
 +
 + backlight_power_reg: regulator@1 {
 + compatible = regulator-fixed;
 + regulator-name = backlight-power;
 + };

This is missing a reg property to mirror the unit address @1. I've
just checked the schematics and there is indeed a physical pin that
can be used to enable backlight power on Tamonten. It just happens to
not be connected on Medcom-Wide for some reason.

The physical pin is Tegra's GPIO PB5 and the schematic calls the supply
lcd_bl_en, so I think a more accurate description of this would be:

backlight_power_reg: regulator@1 {
compatible = regulator-fixed;
reg = 1;
regulator-name = lcd_bl_en;
regulator-min-microvolt = 330;
regulator-max-microvolt = 330;
gpio = gpio 13 0; /* gpio PB5 */
enable-active-high;
};

Thierry


pgpr9ek_gNts9.pgp
Description: PGP signature


Re: [PATCH v5 7/7] irqchip: s3c24xx: add devicetree support

2013-03-26 Thread Heiko Stübner
Hi Arnd,

thanks again for taking the time to look at the changes.


Am Montag, 25. März 2013, 23:00:46 schrieb Arnd Bergmann:
 On Monday 25 March 2013, Heiko Stübner wrote:
  Add the necessary code to initialize the interrupt controller
  thru devicetree data using the irqchip infrastructure.
  
  Signed-off-by: Heiko Stuebner he...@sntech.de
 
 The binding looks fine now. I have a few detail comments but am happy
 with the series otherwise.
 
  +Required properties:
  +- compatible: Compatible property value should be samsung,s3c24xx-irq
  +  for non s3c2416 machines and samsung,s3c2416-irq for s3c2416
  machines
 
 We try to avoid wildcards in the compatible properties. Better use
 the name of the first SoC that had this controller, and let the other
 ones mark themselves as compatible with that one.
 
 I guess samsung,s3c2410-irq would be the right identifier here.

ok, sounds sensible


  +- #interrupt-cells : Specifies the number of cells needed to encode an
  +  interrupt source. The value shall be 4 and interrupt descriptor shall
  +  have the following format:
  +  ctrl_num ctrl_irq parent_irq type
  +
  +  ctrl_num contains the controller to use:
  +  - 0 ... main controller
  +  - 1 ... sub controller
  +  - 2 ... second main controller on s3c2416 and s3c2450
  +  ctrl_irq contains the interrupt bit of the controller
  +  parent_irq contains the parent bit in the main controller and will be
  + ignored in main controllers
 
 I expected the second and third cell to be in the opposite order, so
 the meaning of the second cell is always the same.

ok, so we do ctrl_num parent_irq ctrl_irq type, right? ... As it only 
involves exchanging the intspec values, that's easy :-)


  +   /* we're using individual domains for the non-dt case
  +* and one big domain for the dt case where the subintc
  +* starts at hwirq number 32.
  +*/
  +   offset = (intc-domain-of_node) ? 32 : 0;
 
 Wouldn't it be easier to always use the same setup for the domains here?

nope ... the non-dt domains are not uniform (different lengths and start-irqs) 
to recreate the static irq mappings that are still needed. For the non-dt case 
it also implement the handling of the external interrupts that is not part of 
the interrupt-controller itself but comes from the gpio-registers and will 
move to pinctrl for dt machines.

My hope is still to move to dt in a reasonable time, so this stuff can go 
away then altogether.


Heiko
--
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


Re: [PATCH V5 9/9] pwm_bl: Add mandatory backlight power regulator

2013-03-26 Thread Thierry Reding
On Mon, Mar 25, 2013 at 06:21:53PM -0700, Andrew Chew wrote:
[...]
 diff --git 
 a/Documentation/devicetree/bindings/video/backlight/pwm-backlight.txt 
 b/Documentation/devicetree/bindings/video/backlight/pwm-backlight.txt
 index 1e4fc72..cb2d46a 100644
 --- a/Documentation/devicetree/bindings/video/backlight/pwm-backlight.txt
 +++ b/Documentation/devicetree/bindings/video/backlight/pwm-backlight.txt
 @@ -10,6 +10,11 @@ Required properties:
last value in the array represents a 100% duty cycle (brightest).
- default-brightness-level: the default brightness level (index into the
array defined by the brightness-levels property)
 +  - power-supply: A phandle to the regulator device tree node. This
 +  regulator will be turned on and off as the pwm is enabled and disabled.

Please use PWM instead of pwm in prose.

  Optional properties:
- pwm-names: a list of names for the PWM devices specified in the
 @@ -19,10 +24,19 @@ Optional properties:
  
  Example:
  
 + bl_en: fixed-regulator {
 +compatible = regulator-fixed;
 +regulator-name = bl-en-supply;
 +regulator-boot-on;
 +gpio = some_gpio;
 +enable-active-high;
 + };

This uses a mix of tabs and spaces for indentation. Please stick to
tabs.

Thierry


pgpN6G5GyVy51.pgp
Description: PGP signature


Re: [RFC: PATCH v5] i2c: exynos5: add High Speed I2C controller driver

2013-03-26 Thread Wolfram Sang

  +   /* CLK_DIV max is 256 */
  +   for (i = 0; i  256; i++) {
  +   utemp1 = utemp0 / (i + 1);
  +   /* SCLK_L/H max is 256 / 2 */
  +   if (utemp1  128) {
 I think TSCLK_L and TSCLK_H both can be configured upto 255.Why
 limiting it to  128 ?
 By limiting it to  128 dont we achieve lesser SCL clock?

Thanks for reviewing but please quote only the relevant part of the
message (like I did). This improves readability a lot.
--
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] spi: spi-s3c64xx.c Remove unused argument.

2013-03-26 Thread Matthias Brugger
The pointer to the driver data is never used to get the slave
controller data. We can delete the unused argument from the function.

Signed-off-by: Matthias Brugger matthias@gmail.com
---
 drivers/spi/spi-s3c64xx.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c
index e862ab8..7f5f8ee 100644
--- a/drivers/spi/spi-s3c64xx.c
+++ b/drivers/spi/spi-s3c64xx.c
@@ -817,7 +817,6 @@ static int s3c64xx_spi_unprepare_transfer(struct spi_master 
*spi)
 }
 
 static struct s3c64xx_spi_csinfo *s3c64xx_get_slave_ctrldata(
-   struct s3c64xx_spi_driver_data *sdd,
struct spi_device *spi)
 {
struct s3c64xx_spi_csinfo *cs;
@@ -874,7 +873,7 @@ static int s3c64xx_spi_setup(struct spi_device *spi)
 
sdd = spi_master_get_devdata(spi-master);
if (!cs  spi-dev.of_node) {
-   cs = s3c64xx_get_slave_ctrldata(sdd, spi);
+   cs = s3c64xx_get_slave_ctrldata(spi);
spi-controller_data = cs;
}
 
-- 
1.7.11.7

--
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/1] clk: samsung: Fix compilation error

2013-03-26 Thread Sachin Kamat
Fixes the below compilation error during non-dt build.
drivers/clk/samsung/clk.c: In function ‘samsung_clk_of_register_fixed_ext’:
drivers/clk/samsung/clk.c:252:2: error:
implicit declaration of function ‘for_each_matching_node_and_match’
[-Werror=implicit-function-declaration]
drivers/clk/samsung/clk.c:252:60: error: expected ‘;’ before ‘{’ token

Signed-off-by: Sachin Kamat sachin.ka...@linaro.org
---
 drivers/clk/samsung/clk.c |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/drivers/clk/samsung/clk.c b/drivers/clk/samsung/clk.c
index 91d12f3..78615dd 100644
--- a/drivers/clk/samsung/clk.c
+++ b/drivers/clk/samsung/clk.c
@@ -239,6 +239,7 @@ void __init samsung_clk_register_gate(struct 
samsung_gate_clock *list,
  * obtain the clock speed of all external fixed clock sources from device
  * tree and register it
  */
+#ifdef CONFIG_OF
 void __init samsung_clk_of_register_fixed_ext(
struct samsung_fixed_rate_clock *fixed_rate_clk,
unsigned int nr_fixed_rate_clk,
@@ -255,6 +256,7 @@ void __init samsung_clk_of_register_fixed_ext(
}
samsung_clk_register_fixed_rate(fixed_rate_clk, nr_fixed_rate_clk);
 }
+#endif
 
 /* utility function to get the rate of a specified clock */
 unsigned long _get_rate(const char *clk_name)
-- 
1.7.4.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


Re: [PATCH] arm:exynos5250: Restore CLK_SRC_TOP3 register via CCF

2013-03-26 Thread Tomasz Figa
Hi Prasanna,

On Tuesday 26 of March 2013 10:12:15 Prasanna Kumar wrote:
 From: Prasanna Kumar prasanna...@samsung.com
 
 This patch adds support for restoring CLK_SRC_TOP3 register
 which gets modified while powergating corresponding power domains
 after a cycle of Suspend-to-Resume.
 
 Please refer below URL to know the background of this issue.
 http://www.mail-archive.com/linux-samsung-soc@vger.kernel.org/msg14347.html.
 
 This is based on Common Clock Framework defined for exynos5250 and
 patch mentioned here
 http://www.mail-archive.com/linux-samsung-soc@vger.kernel.org/msg16739.html
 
 Signed-off-by: Prasanna Kumar prasanna...@samsung.com
 ---
  arch/arm/mach-exynos/pm_domains.c |   43
 + 1 files changed, 43 insertions(+), 0
 deletions(-)
 
 diff --git a/arch/arm/mach-exynos/pm_domains.c
 b/arch/arm/mach-exynos/pm_domains.c index 9f1351d..b5ed384 100644
 --- a/arch/arm/mach-exynos/pm_domains.c
 +++ b/arch/arm/mach-exynos/pm_domains.c

First of all, why this is happening in power domain driver? It does not (and 
should not) know anything about clocks. I'm sure you can find a better place 
for this.

 @@ -21,8 +21,11 @@
  #include linux/of_address.h
  #include linux/of_platform.h
  #include linux/sched.h
 +#include linux/clk.h
 +#include linux/clk-private.h

This header is _not_ supposed included outside clock core and clock drivers.

 
  #include mach/regs-pmu.h
 +#include plat/cpu.h
  #include plat/devs.h
 
  /*
 @@ -35,6 +38,43 @@ struct exynos_pm_domain {
   struct generic_pm_domain pd;
  };
 +static int exynos_pdclk_restore(struct exynos_pm_domain *domain)
 +{
 + int i = 0;
 + struct clk *p_clk;
 + struct clk_hw *hw_clk;
 + const struct clk_ops *p_ops;
 +
 + const char *pdclks[][2] = {
 + { gsc-power-domain,
 + m_sub_aclk266 },
 + { gsc-power-domain,
 + m_sub_aclk300 },
 + { mfc-power-domain,
 + m_sub_aclk333 },
 + };
 +
 + for (i = 0; i  ARRAY_SIZE(pdclks); i++) {
 + if (!strcmp(domain-name, pdclks[i][0])) {
 + p_clk = clk_get(NULL, pdclks[i][1]);
 + if (IS_ERR(p_clk)) {
 + pr_err(failed to get base clk\n);
 + return PTR_ERR(p_clk);
 + }
 +
 + hw_clk = __clk_get_hw(p_clk);
 + if (IS_ERR(hw_clk)) {
 + pr_err(failed to get hw_clk\n);
 + return PTR_ERR(hw_clk);
 + }

This is completely wrong: hw_clk is an internal structure that should be used 
only inside the driver of this particular clock and clock core, nowhere else.

 + p_ops = p_clk-ops;
 + if (p_ops != NULL  p_ops-set_parent != NULL)
 + p_clk-ops-set_parent(hw_clk, 1);

Same goes here: p_clk is an opaque pointer to something that can _not_ be 
dereferenced outside clock core.

 + }
 + }
 + return 0;
 +}
 +

NAK.

This code contains so many Linux kernel development antipatterns, that it's 
missing only IS_ERR_OR_NULL to be placed on top of hall of fame of such, if 
one exists.

  static int exynos_pd_power(struct generic_pm_domain *domain, bool power_on)
 {
   struct exynos_pm_domain *pd;
 @@ -61,6 +101,9 @@ static int exynos_pd_power(struct generic_pm_domain
 *domain, bool power_on) cpu_relax();
   usleep_range(80, 100);
   }
 +
 + if (!power_on  soc_is_exynos5250())
 + exynos_pdclk_restore(pd);
   return 0;
  }

Best regards,
-- 
Tomasz Figa
Samsung Poland RD Center
SW Solution Development, Kernel and System Framework

--
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 8/9] thermal: exynos: Parse the platform data from the device tree.

2013-03-26 Thread Amit Daniel Kachhap
This patch adds code to parse the DT based platform data like threshold temp,
sensor configuration parameters like gain, reference voltages, calibration
modes etc.

Signed-off-by: Amit Daniel Kachhap amit.dan...@samsung.com
---
 .../bindings/thermal/exynos5440-thermal.txt|   93 
 drivers/thermal/samsung/exynos5440_thermal.c   |5 +-
 drivers/thermal/samsung/exynos_common.c|   92 +++
 drivers/thermal/samsung/exynos_common.h|2 +
 4 files changed, 189 insertions(+), 3 deletions(-)
 create mode 100644 
Documentation/devicetree/bindings/thermal/exynos5440-thermal.txt

diff --git a/Documentation/devicetree/bindings/thermal/exynos5440-thermal.txt 
b/Documentation/devicetree/bindings/thermal/exynos5440-thermal.txt
new file mode 100644
index 000..1ad2dee
--- /dev/null
+++ b/Documentation/devicetree/bindings/thermal/exynos5440-thermal.txt
@@ -0,0 +1,93 @@
+
+Exynos5440 TMU driver
+---
+
+Exynos5440 SoC Thermal Sensor driver for CPU temperature measurement and
+performing cooling actions.
+
+Required properties:
+- interrupts: Interrupt to know the threshold change interrupts.
+- clocks: phandle of the clock from common clock binding. More description can
+   be found in Documentation/devicetree/bindings/clock/clock-bindings.txt.
+- clock-name: clock name as used in the clock fetch.
+- tmu-ctrl-data: phandle of the TMU controller configuration data. Its member
+   description is shown below,
+- gain: A factor describing the gain of amplifier. The value varies between
+   0-15.
+- reference-voltage: A factor describing the reference volt to amplifier. The
+   value varies between 0-31.
+- noise-cancel-mode: This value selects thermal tripping mode. The possible
+   values can be,
+   0: Use current temp.
+   4: Use current temp and past 4 temp values.
+   5: Use current temp and past 8 temp values.
+   6: Use current temp and past 12 temp values.
+   7: Use current temp and past 16 temp values.
+-cal-type: This value selects temperature calibration mode. The possible values
+   can be,
+   0: No calibration.
+   1: 1 point trimming method at 25 C.
+   2: 1 point trimming method at 85 C.
+   3: 2 point trimming method.
+-cal-mode: This value selects hw/sw mode calibration. The possible values can 
be,
+   0: Software calibration.
+   1: Hardware calibration.
+
+Optional properties:
+-efuse-value: This value should be used when the controller does not contain
+   valid fused temperature data needed for calibration. This is a 16 bit
+   value.
+-threshold-falling: This value defines the falling threshold when it is added 
to
+   trip threshold. If this value is not supplied then rising and falling
+   threshold are same.
+
+-trip@: This node is added to define the trip properties. The trip members are
+   shown below,
+-trip: This field defines the trip ID. Exynos5440 has 5 trip ID.
+-trigger-temp: Temperature at which threshold trigger is fired. Its unit is
+   celsius.
+-type: This denotes the type of trigger. The possible values are,
+   0: active trip type
+   1: critical
+   2: hw system trip
+-frequency-max: cpu frequency when this trip is reached.
+
+Example:
+
+   tmu_ctrl_info: tmu-ctrl-info {
+   gain = 8;
+   reference-voltage = 16;
+   noise-cancel-mode = 4;
+   cal-type = 0;
+   cal-mode = 0;
+   efuse-value = 0xabcd;
+   threshold-falling = 5;
+
+   trip@0{
+   trip = 0;
+   trigger-temp = 80;
+   type = 0;
+   frequency-max = 120;
+   };
+
+   trip@3{
+   trip = 3;
+   trigger-temp = 110;
+   type = 1;
+   };
+
+   trip@4{
+   trip = 4;
+   trigger-temp = 120;
+   type = 2;
+   };
+   };
+
+   tmuctrl_0: tmuctrl@160118 {
+   compatible = samsung,exynos5440-tmu;
+   reg = 0x160118 0x300;
+   interrupts = 0 58 0;
+   clocks = clock 8;
+   clock-names = tmu_apbif;
+   tmu-ctrl-data = tmu_ctrl_info;
+   };
diff --git a/drivers/thermal/samsung/exynos5440_thermal.c 
b/drivers/thermal/samsung/exynos5440_thermal.c
index a3c75d3..c140e8c 100644
--- a/drivers/thermal/samsung/exynos5440_thermal.c
+++ b/drivers/thermal/samsung/exynos5440_thermal.c
@@ -564,9 +564,8 @@ static int exynos_tmu_probe(struct platform_device *pdev)
return -ENOMEM;
}
 
-   pdata = (struct exynos_tmu_platform_data *)
-   

[PATCH 9/9] ARM: dts: Add device tree node for exynos5440 TMU controller

2013-03-26 Thread Amit Daniel Kachhap
This patch adds device node for TMU controller. There are 3
instances of the controllers so 3 nodes are created.

Signed-off-by: Amit Daniel Kachhap amit.dan...@samsung.com
---
 arch/arm/boot/dts/exynos5440.dtsi |   43 +
 1 files changed, 43 insertions(+), 0 deletions(-)

diff --git a/arch/arm/boot/dts/exynos5440.dtsi 
b/arch/arm/boot/dts/exynos5440.dtsi
index 5f3562a..b74ce9f 100644
--- a/arch/arm/boot/dts/exynos5440.dtsi
+++ b/arch/arm/boot/dts/exynos5440.dtsi
@@ -16,6 +16,12 @@
 
interrupt-parent = gic;
 
+   aliases {
+   tmuctrl0 = tmuctrl_0;
+   tmuctrl1 = tmuctrl_1;
+   tmuctrl2 = tmuctrl_2;
+   };
+
gic:interrupt-controller@2E {
compatible = arm,cortex-a15-gic;
#interrupt-cells = 3;
@@ -156,4 +162,41 @@
reg = 0x13 0x1000;
interrupts = 0 17 0, 0 16 0;
};
+
+   tmu_ctrl_info: tmu-ctrl-info {
+   gain = 5;
+   reference-voltage = 16;
+   noise-cancel-mode = 4;
+   cal-type = 2;
+   cal-mode = 0;
+   efuse-value = 0x5b2c;
+   threshold-falling = 5;
+   };
+
+   tmuctrl_0: tmuctrl@160118 {
+   compatible = samsung,exynos5440-tmu;
+   reg = 0x160118 0x300;
+   interrupts = 0 58 0;
+   clocks = clock 8;
+   clock-names = tmu_apbif;
+   tmu-ctrl-data = tmu_ctrl_info;
+   };
+
+   tmuctrl_1: tmuctrl@16011C {
+   compatible = samsung,exynos5440-tmu;
+   reg = 0x16011C 0x300;
+   interrupts = 0 58 0;
+   clocks = clock 8;
+   clock-names = tmu_apbif;
+   tmu-ctrl-data = tmu_ctrl_info;
+   };
+
+   tmuctrl_2: tmuctrl@160120 {
+   compatible = samsung,exynos5440-tmu;
+   reg = 0x160120 0x300;
+   interrupts = 0 58 0;
+   clocks = clock 8;
+   clock-names = tmu_apbif;
+   tmu-ctrl-data = tmu_ctrl_info;
+   };
 };
-- 
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 7/9] thermal: exynos: Add support for exynos5440 TMU sensor.

2013-03-26 Thread Amit Daniel Kachhap
This sensor registers 3 instance of the tmu controller with the thermal zone
and hence reports 3 temperature output. This driver supports upto five trip
points. For critical threshold the driver uses the core driver thermal
framework for shutdown and for non-critical threshold it invokes the hw based
frequency clipping limits. Because of such differences with the existing 4210
tmu controller, exynos5440 tmu driver is added in a new file.

Signed-off-by: Amit Daniel Kachhap amit.dan...@samsung.com
---
 drivers/thermal/samsung/Kconfig  |9 +
 drivers/thermal/samsung/Makefile |1 +
 drivers/thermal/samsung/exynos5440_thermal.c |  713 ++
 3 files changed, 723 insertions(+), 0 deletions(-)
 create mode 100644 drivers/thermal/samsung/exynos5440_thermal.c

diff --git a/drivers/thermal/samsung/Kconfig b/drivers/thermal/samsung/Kconfig
index cefe693..0c7b4eb 100644
--- a/drivers/thermal/samsung/Kconfig
+++ b/drivers/thermal/samsung/Kconfig
@@ -20,4 +20,13 @@ config EXYNOS4210_THERMAL
  initialises the TMU controller and registers/unregisters with exynos
  common thermal layer.
 
+config EXYNOS5440_THERMAL
+   tristate Temperature sensor on Samsung EXYNOS 5440 SOC
+   depends on SOC_EXYNOS5440
+   help
+ If you say yes here you can enable TMU (Thermal Management Unit)
+ support on SAMSUNG EXYNOS 5440 series of SoC. This option initialises
+ the TMU controller and registers/unregisters with exynos common
+ thermal layer.
+
 endif
diff --git a/drivers/thermal/samsung/Makefile b/drivers/thermal/samsung/Makefile
index d51d0c2..53230cf 100644
--- a/drivers/thermal/samsung/Makefile
+++ b/drivers/thermal/samsung/Makefile
@@ -3,3 +3,4 @@
 #
 obj-$(CONFIG_EXYNOS_COMMON)+= exynos_common.o
 obj-$(CONFIG_EXYNOS4210_THERMAL)   += exynos4210_thermal.o
+obj-$(CONFIG_EXYNOS5440_THERMAL)   += exynos5440_thermal.o
diff --git a/drivers/thermal/samsung/exynos5440_thermal.c 
b/drivers/thermal/samsung/exynos5440_thermal.c
new file mode 100644
index 000..a3c75d3
--- /dev/null
+++ b/drivers/thermal/samsung/exynos5440_thermal.c
@@ -0,0 +1,713 @@
+/*
+ * exynos5440_thermal.c - Samsung EXYNOS 5440 TMU
+ * (Thermal Management Unit)
+ *
+ *  Copyright (C) 2013 Samsung Electronics
+ *  Amit Daniel Kachhap amit.dan...@samsung.com
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ */
+
+#include linux/clk.h
+#include linux/cpufreq.h
+#include linux/cpu_cooling.h
+#include linux/err.h
+#include linux/interrupt.h
+#include linux/io.h
+#include linux/kernel.h
+#include linux/kobject.h
+#include linux/module.h
+#include linux/mutex.h
+#include linux/of.h
+#include linux/of_address.h
+#include linux/of_irq.h
+#include linux/platform_device.h
+#include linux/slab.h
+#include linux/thermal.h
+#include linux/workqueue.h
+#include linux/platform_data/exynos_thermal.h
+
+#include exynos_common.h
+
+
+/* Exynos5440 specific registers */
+#define TMU_S0_7_TRIM  0x0118
+#define TMU_S0_7_CTRL  0x0138
+#define TMU_S0_7_DEBUG 0x0158
+#define TMU_S0_7_STATUS0x0178
+#define TMU_S0_7_COUNTER0  0x0198
+#define TMU_S0_7_COUNTER1  0x01b8
+#define TMU_S0_7_COUNTER2  0x01d8
+#define TMU_S0_7_COUNTER3  0x01f8
+#define TMU_S0_7_TEMP  0x0208
+#define TMU_S0_7_TH0   0x0228
+#define TMU_S0_7_TH1   0x0248
+#define TMU_S0_7_TH2   0x0268
+#define TMU_S0_7_PTEMP00x0288
+#define TMU_S0_7_PTEMP10x02a8
+#define TMU_S0_7_PTEMP20x02c8
+#define TMU_S0_7_PTEMP30x02e8
+#define TMU_S0_7_EVTEN 0x0308
+#define TMU_S0_7_IRQEN 0x0328
+#define TMU_S0_7_IRQ   0x0348
+#define TMU_IRQ_STATUS 0x0368
+#define TMU_PMIN   0x036c
+#define TMU_TEMP   0x0370
+#define TMU_MISC   0x0374
+
+/* Exynos5440 specific mask and shifts */
+#define TMU_TEMP_MASK  0xff
+
+#define TMU_TRIM_DATA_25C_SHIFT0x0
+#define TMU_TRIM_DATA_85C_SHIFT0x8
+
+#define 

[PATCH 5/9] thermal: exynos: Make the zone handling dependent on trip count

2013-03-26 Thread Amit Daniel Kachhap
This code changes the zone handling to use the trip count passed
by the TMU driver. This also helps in adding more zone support.

Signed-off-by: Amit Daniel Kachhap amit.dan...@samsung.com
---
 drivers/thermal/samsung/exynos_common.c  |   56 +
 drivers/thermal/samsung/exynos_common.h  |   13 +++---
 include/linux/platform_data/exynos_thermal.h |7 ++-
 3 files changed, 40 insertions(+), 36 deletions(-)

diff --git a/drivers/thermal/samsung/exynos_common.c 
b/drivers/thermal/samsung/exynos_common.c
index 649d67c..0c0098d 100644
--- a/drivers/thermal/samsung/exynos_common.c
+++ b/drivers/thermal/samsung/exynos_common.c
@@ -84,17 +84,16 @@ static int exynos_set_mode(struct thermal_zone_device 
*thermal,
 static int exynos_get_trip_type(struct thermal_zone_device *thermal, int trip,
 enum thermal_trip_type *type)
 {
-   switch (GET_ZONE(trip)) {
-   case MONITOR_ZONE:
-   case WARN_ZONE:
-   *type = THERMAL_TRIP_ACTIVE;
-   break;
-   case PANIC_ZONE:
-   *type = THERMAL_TRIP_CRITICAL;
-   break;
-   default:
+   struct exynos_thermal_zone *th_zone = thermal-devdata;
+   int max_trip = th_zone-sensor_conf-trip_data.trip_count;
+
+   if (trip  0 || trip = max_trip)
return -EINVAL;
-   }
+   else if (trip == (max_trip - 1))
+   *type = THERMAL_TRIP_CRITICAL;
+   else
+   *type = THERMAL_TRIP_ACTIVE;
+
return 0;
 }
 
@@ -103,8 +102,9 @@ static int exynos_get_trip_temp(struct thermal_zone_device 
*thermal, int trip,
unsigned long *temp)
 {
struct exynos_thermal_zone *th_zone = thermal-devdata;
+   int max_trip = th_zone-sensor_conf-trip_data.trip_count;
 
-   if (trip  GET_TRIP(MONITOR_ZONE) || trip  GET_TRIP(PANIC_ZONE))
+   if (trip  0 || trip = max_trip)
return -EINVAL;
 
*temp = th_zone-sensor_conf-trip_data.trip_val[trip];
@@ -118,10 +118,10 @@ static int exynos_get_trip_temp(struct 
thermal_zone_device *thermal, int trip,
 static int exynos_get_crit_temp(struct thermal_zone_device *thermal,
unsigned long *temp)
 {
-   int ret;
-   /* Panic zone */
-   ret = exynos_get_trip_temp(thermal, GET_TRIP(PANIC_ZONE), temp);
-   return ret;
+   struct exynos_thermal_zone *th_zone = thermal-devdata;
+   int max_trip = th_zone-sensor_conf-trip_data.trip_count;
+   /* Get the temp of highest trip*/
+   return exynos_get_trip_temp(thermal, max_trip - 1, temp);
 }
 
 int exynos_get_frequency_level(unsigned int cpu, unsigned int freq)
@@ -157,7 +157,7 @@ static int exynos_bind(struct thermal_zone_device *thermal,
tab_size = data-cooling_data.freq_clip_count;
 
if (tab_ptr == NULL || tab_size == 0)
-   return -EINVAL;
+   return 0;
 
/* find the cooling device registered*/
for (i = 0; i  th_zone-cool_dev_size; i++)
@@ -206,7 +206,7 @@ static int exynos_unbind(struct thermal_zone_device 
*thermal,
tab_size = data-cooling_data.freq_clip_count;
 
if (tab_size == 0)
-   return -EINVAL;
+   return 0;
 
/* find the cooling device registered*/
for (i = 0; i  th_zone-cool_dev_size; i++)
@@ -366,19 +366,21 @@ int exynos_register_thermal(struct thermal_sensor_conf 
*sensor_conf)
return -ENOMEM;
 
th_zone-sensor_conf = sensor_conf;
-   cpumask_set_cpu(0, mask_val);
-   th_zone-cool_dev[0] = cpufreq_cooling_register(mask_val);
-   if (IS_ERR(th_zone-cool_dev[0])) {
-   pr_err(Failed to register cpufreq cooling device\n);
-   ret = -EINVAL;
-   goto err_unregister;
+   if (sensor_conf-cooling_data.freq_clip_count  0) {
+   cpumask_set_cpu(0, mask_val);
+   th_zone-cool_dev[0] = cpufreq_cooling_register(mask_val);
+   if (IS_ERR(th_zone-cool_dev[0])) {
+   pr_err(Failed to register cpufreq cooling device\n);
+   ret = -EINVAL;
+   goto err_unregister;
+   }
+   th_zone-cool_dev_size++;
}
-   th_zone-cool_dev_size++;
 
th_zone-therm_dev = thermal_zone_device_register(sensor_conf-name,
-   EXYNOS_ZONE_COUNT, 0, th_zone, exynos_dev_ops, NULL, 0,
-   sensor_conf-trip_data.trigger_falling ?
-   0 : IDLE_INTERVAL);
+   sensor_conf-trip_data.trip_count, 0, th_zone, exynos_dev_ops,
+   NULL, 0, sensor_conf-trip_data.trigger_falling ?
+   0 : IDLE_INTERVAL);
 
if (IS_ERR(th_zone-therm_dev)) {
pr_err(Failed to register thermal zone device\n);
diff --git a/drivers/thermal/samsung/exynos_common.h 
b/drivers/thermal/samsung/exynos_common.h
index b8d289e..453e09a 100644

[PATCH 1/9] thermal: exynos: Adapt to temperature emulation core thermal framework

2013-03-26 Thread Amit Daniel Kachhap
This removes the driver specific sysfs support of the temperature
emulation and uses the newly added core thermal framework for thermal
emulation. An exynos platform specific handler is added to support this.

In this patch, the exynos senor(tmu) related code and exynos framework
related (thermal zone, cooling devices) code are intentionally kept separate.
So an emulated function pointer is passed from sensor to framework. This is
beneficial in adding more sensor support using the same framework code
which is an ongoing work. The goal is to finally split them totally. Even
the existing read_temperature also follows the same execution method.

Acked-by: Kukjin Kim kgene@samsung.com
Signed-off-by: Amit Daniel Kachhap amit.dan...@samsung.com
---
 Documentation/thermal/exynos_thermal_emulation |8 +-
 drivers/thermal/Kconfig|9 --
 drivers/thermal/exynos_thermal.c   |  158 ++--
 3 files changed, 67 insertions(+), 108 deletions(-)

diff --git a/Documentation/thermal/exynos_thermal_emulation 
b/Documentation/thermal/exynos_thermal_emulation
index b73bbfb..36a3e79 100644
--- a/Documentation/thermal/exynos_thermal_emulation
+++ b/Documentation/thermal/exynos_thermal_emulation
@@ -13,11 +13,11 @@ Thermal emulation mode supports software debug for TMU's 
operation. User can set
 manually with software code and TMU will read current temperature from user 
value not from
 sensor's value.
 
-Enabling CONFIG_EXYNOS_THERMAL_EMUL option will make this support in available.
-When it's enabled, sysfs node will be created under
-/sys/bus/platform/devices/'exynos device name'/ with name of 'emulation'.
+Enabling CONFIG_THERMAL_EMULATION option will make this support available.
+When it's enabled, sysfs node will be created as
+/sys/devices/virtual/thermal/thermal_zone'zone id'/emul_temp.
 
-The sysfs node, 'emulation', will contain value 0 for the initial state. When 
you input any
+The sysfs node, 'emul_node', will contain value 0 for the initial state. When 
you input any
 temperature you want to update to sysfs node, it automatically enable 
emulation mode and
 current temperature will be changed into it.
 (Exynos also supports user changable delay time which would be used to delay of
diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig
index a764f16..da4c19e 100644
--- a/drivers/thermal/Kconfig
+++ b/drivers/thermal/Kconfig
@@ -117,15 +117,6 @@ config EXYNOS_THERMAL
  If you say yes here you get support for TMU (Thermal Management
  Unit) on SAMSUNG EXYNOS series of SoC.
 
-config EXYNOS_THERMAL_EMUL
-   bool EXYNOS TMU emulation mode support
-   depends on EXYNOS_THERMAL
-   help
- Exynos 4412 and 4414 and 5 series has emulation mode on TMU.
- Enable this option will be make sysfs node in exynos thermal platform
- device directory to support emulation mode. With emulation mode sysfs
- node, you can manually input temperature to TMU for simulation 
purpose.
-
 config DOVE_THERMAL
tristate Temperature sensor on Marvell Dove SoCs
depends on ARCH_DOVE
diff --git a/drivers/thermal/exynos_thermal.c b/drivers/thermal/exynos_thermal.c
index 46568c0..1cd7837 100644
--- a/drivers/thermal/exynos_thermal.c
+++ b/drivers/thermal/exynos_thermal.c
@@ -100,13 +100,13 @@
 #define IDLE_INTERVAL 1
 #define MCELSIUS   1000
 
-#ifdef CONFIG_EXYNOS_THERMAL_EMUL
+#ifdef CONFIG_THERMAL_EMULATION
 #define EXYNOS_EMUL_TIME   0x57F0
 #define EXYNOS_EMUL_TIME_SHIFT 16
 #define EXYNOS_EMUL_DATA_SHIFT 8
 #define EXYNOS_EMUL_DATA_MASK  0xFF
 #define EXYNOS_EMUL_ENABLE 0x1
-#endif /* CONFIG_EXYNOS_THERMAL_EMUL */
+#endif /* CONFIG_THERMAL_EMULATION */
 
 /* CPU Zone information */
 #define PANIC_ZONE  4
@@ -145,6 +145,7 @@ struct  thermal_cooling_conf {
 struct thermal_sensor_conf {
char name[SENSOR_NAME_LEN];
int (*read_temperature)(void *data);
+   int (*write_emul_temp)(void *drv_data, unsigned long temp);
struct thermal_trip_point_conf trip_data;
struct thermal_cooling_conf cooling_data;
void *private_data;
@@ -369,6 +370,23 @@ static int exynos_get_temp(struct thermal_zone_device 
*thermal,
return 0;
 }
 
+/* Get temperature callback functions for thermal zone */
+static int exynos_set_emul_temp(struct thermal_zone_device *thermal,
+   unsigned long temp)
+{
+   void *data;
+   int ret = -EINVAL;
+
+   if (!th_zone-sensor_conf) {
+   pr_info(Temperature sensor not initialised\n);
+   return -EINVAL;
+   }
+   data = th_zone-sensor_conf-private_data;
+   if (th_zone-sensor_conf-write_emul_temp)
+   ret = th_zone-sensor_conf-write_emul_temp(data, temp);
+   return ret;
+}
+
 /* Get the temperature trend */
 static int exynos_get_trend(struct thermal_zone_device *thermal,
int trip, enum 

[PATCH 2/9] thermal: exynos: Add support for instance based register/unregister

2013-03-26 Thread Amit Daniel Kachhap
This code modifies the thermal driver to have multiple thermal zone
support by replacing the global thermal zone varibale with device data
member of thermal_zone_device.

Signed-off-by: Amit Daniel Kachhap amit.dan...@samsung.com
---
 drivers/thermal/exynos_thermal.c |   65 ++---
 1 files changed, 39 insertions(+), 26 deletions(-)

diff --git a/drivers/thermal/exynos_thermal.c b/drivers/thermal/exynos_thermal.c
index 1cd7837..dc9b91b 100644
--- a/drivers/thermal/exynos_thermal.c
+++ b/drivers/thermal/exynos_thermal.c
@@ -148,7 +148,8 @@ struct thermal_sensor_conf {
int (*write_emul_temp)(void *drv_data, unsigned long temp);
struct thermal_trip_point_conf trip_data;
struct thermal_cooling_conf cooling_data;
-   void *private_data;
+   void *driver_data;
+   void *pzone_data;
 };
 
 struct exynos_thermal_zone {
@@ -161,14 +162,14 @@ struct exynos_thermal_zone {
bool bind;
 };
 
-static struct exynos_thermal_zone *th_zone;
-static void exynos_unregister_thermal(void);
+static void exynos_unregister_thermal(struct thermal_sensor_conf *sensor_conf);
 static int exynos_register_thermal(struct thermal_sensor_conf *sensor_conf);
 
 /* Get mode callback functions for thermal zone */
 static int exynos_get_mode(struct thermal_zone_device *thermal,
enum thermal_device_mode *mode)
 {
+   struct exynos_thermal_zone *th_zone = thermal-devdata;
if (th_zone)
*mode = th_zone-mode;
return 0;
@@ -178,25 +179,26 @@ static int exynos_get_mode(struct thermal_zone_device 
*thermal,
 static int exynos_set_mode(struct thermal_zone_device *thermal,
enum thermal_device_mode mode)
 {
-   if (!th_zone-therm_dev) {
+   struct exynos_thermal_zone *th_zone = thermal-devdata;
+   if (!th_zone) {
pr_notice(thermal zone not registered\n);
return 0;
}
 
-   mutex_lock(th_zone-therm_dev-lock);
+   mutex_lock(thermal-lock);
 
if (mode == THERMAL_DEVICE_ENABLED 
!th_zone-sensor_conf-trip_data.trigger_falling)
-   th_zone-therm_dev-polling_delay = IDLE_INTERVAL;
+   thermal-polling_delay = IDLE_INTERVAL;
else
-   th_zone-therm_dev-polling_delay = 0;
+   thermal-polling_delay = 0;
 
-   mutex_unlock(th_zone-therm_dev-lock);
+   mutex_unlock(thermal-lock);
 
th_zone-mode = mode;
-   thermal_zone_device_update(th_zone-therm_dev);
+   thermal_zone_device_update(thermal);
pr_info(thermal polling set for duration=%d msec\n,
-   th_zone-therm_dev-polling_delay);
+   thermal-polling_delay);
return 0;
 }
 
@@ -223,6 +225,8 @@ static int exynos_get_trip_type(struct thermal_zone_device 
*thermal, int trip,
 static int exynos_get_trip_temp(struct thermal_zone_device *thermal, int trip,
unsigned long *temp)
 {
+   struct exynos_thermal_zone *th_zone = thermal-devdata;
+
if (trip  GET_TRIP(MONITOR_ZONE) || trip  GET_TRIP(PANIC_ZONE))
return -EINVAL;
 
@@ -269,6 +273,7 @@ static int exynos_bind(struct thermal_zone_device *thermal,
 {
int ret = 0, i, tab_size, level;
struct freq_clip_table *tab_ptr, *clip_data;
+   struct exynos_thermal_zone *th_zone = thermal-devdata;
struct thermal_sensor_conf *data = th_zone-sensor_conf;
 
tab_ptr = (struct freq_clip_table *)data-cooling_data.freq_data;
@@ -315,6 +320,7 @@ static int exynos_unbind(struct thermal_zone_device 
*thermal,
struct thermal_cooling_device *cdev)
 {
int ret = 0, i, tab_size;
+   struct exynos_thermal_zone *th_zone = thermal-devdata;
struct thermal_sensor_conf *data = th_zone-sensor_conf;
 
if (th_zone-bind == false)
@@ -357,13 +363,14 @@ static int exynos_unbind(struct thermal_zone_device 
*thermal,
 static int exynos_get_temp(struct thermal_zone_device *thermal,
unsigned long *temp)
 {
+   struct exynos_thermal_zone *th_zone = thermal-devdata;
void *data;
 
if (!th_zone-sensor_conf) {
pr_info(Temperature sensor not initialised\n);
return -EINVAL;
}
-   data = th_zone-sensor_conf-private_data;
+   data = th_zone-sensor_conf-driver_data;
*temp = th_zone-sensor_conf-read_temperature(data);
/* convert the temperature into millicelsius */
*temp = *temp * MCELSIUS;
@@ -376,12 +383,13 @@ static int exynos_set_emul_temp(struct 
thermal_zone_device *thermal,
 {
void *data;
int ret = -EINVAL;
+   struct exynos_thermal_zone *th_zone = thermal-devdata;
 
if (!th_zone-sensor_conf) {
pr_info(Temperature sensor not initialised\n);
return -EINVAL;
}
-   data = th_zone-sensor_conf-private_data;
+  

[PATCH 6/9] thermal: exynos: small cleanups to prepare for adding exynos5440 driver

2013-03-26 Thread Amit Daniel Kachhap
Add calib mode, trigger types and trigger_enable array. This is needed
for adding exynos5440 TMU driver.

Signed-off-by: Amit Daniel Kachhap amit.dan...@samsung.com
---
 drivers/thermal/samsung/exynos4210_thermal.c |   30 
 include/linux/platform_data/exynos_thermal.h |   32 +-
 2 files changed, 31 insertions(+), 31 deletions(-)

diff --git a/drivers/thermal/samsung/exynos4210_thermal.c 
b/drivers/thermal/samsung/exynos4210_thermal.c
index 09ea8c8..58d16ac 100644
--- a/drivers/thermal/samsung/exynos4210_thermal.c
+++ b/drivers/thermal/samsung/exynos4210_thermal.c
@@ -276,10 +276,10 @@ static void exynos_tmu_control(struct platform_device 
*pdev, bool on)
 
if (on) {
con |= EXYNOS_TMU_CORE_ON;
-   interrupt_en = pdata-trigger_level3_en  12 |
-   pdata-trigger_level2_en  8 |
-   pdata-trigger_level1_en  4 |
-   pdata-trigger_level0_en;
+   interrupt_en = pdata-trigger_enable[3]  12 |
+   pdata-trigger_enable[2]  8 |
+   pdata-trigger_enable[1]  4 |
+   pdata-trigger_enable[0];
if (pdata-threshold_falling)
interrupt_en |= interrupt_en  16;
} else {
@@ -394,10 +394,10 @@ static struct exynos_tmu_platform_data const 
exynos4210_default_tmu_data = {
.trigger_levels[0] = 5,
.trigger_levels[1] = 20,
.trigger_levels[2] = 30,
-   .trigger_level0_en = 1,
-   .trigger_level1_en = 1,
-   .trigger_level2_en = 1,
-   .trigger_level3_en = 0,
+   .trigger_enable[0] = 1,
+   .trigger_enable[1] = 1,
+   .trigger_enable[2] = 1,
+   .trigger_enable[3] = 0,
.gain = 15,
.reference_voltage = 7,
.cal_type = TYPE_ONE_POINT_TRIMMING,
@@ -423,10 +423,10 @@ static struct exynos_tmu_platform_data const 
exynos_default_tmu_data = {
.trigger_levels[0] = 85,
.trigger_levels[1] = 103,
.trigger_levels[2] = 110,
-   .trigger_level0_en = 1,
-   .trigger_level1_en = 1,
-   .trigger_level2_en = 1,
-   .trigger_level3_en = 0,
+   .trigger_enable[0] = 1,
+   .trigger_enable[1] = 1,
+   .trigger_enable[2] = 1,
+   .trigger_enable[3] = 0,
.gain = 8,
.reference_voltage = 16,
.noise_cancel_mode = 4,
@@ -566,9 +566,9 @@ static int exynos_tmu_probe(struct platform_device *pdev)
 
/* Register the sensor with thermal management interface */
(exynos_sensor_conf)-driver_data = data;
-   exynos_sensor_conf.trip_data.trip_count = pdata-trigger_level0_en +
-   pdata-trigger_level1_en + pdata-trigger_level2_en +
-   pdata-trigger_level3_en;
+   exynos_sensor_conf.trip_data.trip_count = pdata-trigger_enable[0] +
+   pdata-trigger_enable[1] + pdata-trigger_enable[2] +
+   pdata-trigger_enable[3];
 
for (i = 0; i  exynos_sensor_conf.trip_data.trip_count; i++)
exynos_sensor_conf.trip_data.trip_val[i] =
diff --git a/include/linux/platform_data/exynos_thermal.h 
b/include/linux/platform_data/exynos_thermal.h
index 893b758..1090f48 100644
--- a/include/linux/platform_data/exynos_thermal.h
+++ b/include/linux/platform_data/exynos_thermal.h
@@ -31,6 +31,17 @@ enum calibration_type {
TYPE_NONE,
 };
 
+enum calibration_mode {
+   SW_MODE,
+   HW_MODE,
+};
+
+enum trigger_type {
+   ACTIVE,
+   CRITICAL,
+   HW_TRIP,
+};
+
 enum soc_type {
SOC_ARCH_EXYNOS4210 = 1,
SOC_ARCH_EXYNOS,
@@ -71,18 +82,9 @@ struct freq_clip_table {
  * 3: temperature for trigger_level3 interrupt
  *condition for trigger_level3 interrupt:
  * current temperature  threshold + trigger_levels[3]
- * @trigger_level0_en:
+ * @trigger_enable[]: array to denote which trigger levels are enabled.
  * 1 = enable trigger_level0 interrupt,
  * 0 = disable trigger_level0 interrupt
- * @trigger_level1_en:
- * 1 = enable trigger_level1 interrupt,
- * 0 = disable trigger_level1 interrupt
- * @trigger_level2_en:
- * 1 = enable trigger_level2 interrupt,
- * 0 = disable trigger_level2 interrupt
- * @trigger_level3_en:
- * 1 = enable trigger_level3 interrupt,
- * 0 = disable trigger_level3 interrupt
  * @gain: gain of amplifier in the positive-TC generator block
  * 0 = gain = 15
  * @reference_voltage: reference voltage of amplifier
@@ -93,6 +95,7 @@ struct freq_clip_table {
  * @type: determines the type of SOC
  * @efuse_value: platform defined fuse value
  * @cal_type: calibration type for temperature
+ * @cal_mode: calibration mode for temperature
  * @freq_clip_table: Table representing frequency reduction percentage.
  * @freq_tab_count: Count of the above table as frequency reduction may
  * applicable to only some of the trigger levels.
@@ -103,18 +106,15 @@ 

Re: [RFC 01/12] exynos-fimc-is: Adding device tree nodes

2013-03-26 Thread Arun Kumar K
Hi Sylwester,

Thank you for the review.


 +Sensor sub-nodes:
 +
 +FIMC-IS IP supports custom built sensors to be controlled exclusively by
 +the FIMC-IS firmware. These sensor properties are to be defined here.


[snip]


 Defining image sensor nodes in a standard way as ISP I2C bus controller
 nodes has an disadvantage that we need dummy I2C bus controller driver,
 at least this is how I have written the driver for Exynos4x12. In some
 version of it I had sensor nodes put in a isp-i2c fimc-is sub-node, but
 then there was an issue that this was not a fully specified I2C bus
 controller node.

 You can refer to my exynos4 fimc-is patch series for details on how this
 is now implemented.

 Handling the image sensor in a standard way, as regular I2C client devices
 has an advantage that we can put pinctrl properties in relevant device
 nodes,
 where available, which more closely describes the hardware structure.

 I'm not really sure in 100% if all this complication is required. It would
 allow to use same DT blob for different Imaging Subsystem SW architecture.
 For example some parts of functionality handled currently by FIMC-IS (ARM
 Cortex-A5) could be moved to host CPU, without any change in the device
 tree structure. The kernel could decide e.g. if it uses image sensor driver
 implemented in the ISP firmware, or a driver run on the host CPU.

 What do you think ?


I have seen your Exynos4 FIMC-IS patchset and you have made a dummy
I2C sensor driver there.
That mode would work fine in Exynos4 since the sensor and ISP will be used
by the same media controller pipeline. So the ISP component in the pipeline
will ensure that the HW is initialized and sensor is working.

But in Exynos5, we are using sensor in pipeline0 and ISP in pipeline1.
So there is a possibility of using sensor subdev independently
without using pipeline1 ISP components.

So with the driver I sent, the pipeline0 can still work like this --

ISP sensor --- MIPI-CSIS --- FIMC-LITE --- Memory

This cannot be done if a dummy I2C driver is made for ISP sensor.
What is your suggestion on this?

Regards
Arun
--
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 v2] ARM: dts: Add SYSREG block node for S5P/Exynos4 SoC series

2013-03-26 Thread Sylwester Nawrocki
This patch adds device tree node for the SYSREG registers block
found in Samsung S5P/Exynos SoC series. The SYSREG module
generates control signals for the ARM CPU and various IP blocks
and buses. SYSREG block registers are exposed through APB bus
interface. A sysreg device tree node is to be associated with
mfd syscon driver and all SYSREG clients should use regmap
interface it provides. It allows to eliminate any possible races
and conflicts should different drivers attempt to concurrently
access same register.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---

Changes since v1:
 - Added missing samsung, prefix to the compatible property,
 - the binding documentation moved to ...bindings/arm/samsung
   as SYSREG block can be also found on other SoCs than Exynos.
---
 .../devicetree/bindings/arm/samsung/sysreg.txt |7 +++
 arch/arm/boot/dts/exynos4.dtsi |5 +
 2 files changed, 12 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/arm/samsung/sysreg.txt

diff --git a/Documentation/devicetree/bindings/arm/samsung/sysreg.txt 
b/Documentation/devicetree/bindings/arm/samsung/sysreg.txt
new file mode 100644
index 000..5039c0a
--- /dev/null
+++ b/Documentation/devicetree/bindings/arm/samsung/sysreg.txt
@@ -0,0 +1,7 @@
+SAMSUNG S5P/Exynos SoC series System Registers (SYSREG)
+
+Properties:
+ - name : should be 'sysreg';
+ - compatible : should contain samsung,chip name-sysreg, syscon;
+   For Exynos4 SoC series it should be samsung,exynos4-sysreg, syscon;
+ - reg : offset and length of the register set.
diff --git a/arch/arm/boot/dts/exynos4.dtsi b/arch/arm/boot/dts/exynos4.dtsi
index 9ac47d5..462f055 100644
--- a/arch/arm/boot/dts/exynos4.dtsi
+++ b/arch/arm/boot/dts/exynos4.dtsi
@@ -82,6 +82,11 @@
reg = 0x1044 0x1000;
};
 
+   sys_reg: sysreg {
+   compatible = samsung,exynos4-sysreg, syscon;
+   reg = 0x1001 0x400;
+   };
+
watchdog@1006 {
compatible = samsung,s3c2410-wdt;
reg = 0x1006 0x100;
-- 
1.7.9.5

--
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


Re: [PATCH] spi: spi-s3c64xx.c Remove unused argument.

2013-03-26 Thread Mark Brown
On Tue, Mar 26, 2013 at 10:27:35AM +0100, Matthias Brugger wrote:
 The pointer to the driver data is never used to get the slave
 controller data. We can delete the unused argument from the function.

Applied, thanks.


signature.asc
Description: Digital signature


[PATCH] i2c: s3c2410: Add SMBus emulation for block read

2013-03-26 Thread Prasanna Kumar
From: Jaemin Yoo jmin@samsung.com

SMBus read and write are supported by the emulation layer of i2c
framework if the controller doesn't have SMBus features.

I2C_M_RECV_LEN flag is used to let i2c drivers know rx length is not
yet determined but will be read to the first byte in rx buffer.

s3c2410 doesn't handle this flag. So only one byte is read from slave.
There fore following two features are added to the driver code.

1. skip rx length check if I2C_M_RECV_LEN is set and the length is 1.
2. add actual bytes to the rx length after reading first bytes if
   I2C_M_RECV_LEN.

I2C_M_RECV_LEN is only set for SMBus command. So this code does not
affect legacy codes which only use i2c command for s3c2410.

Signed-off-by: Jaemin Yoo jmin@samsung.com
Tested-by: Prasanna Kumar prasanna...@samsung.com
---
 drivers/i2c/busses/i2c-s3c2410.c |9 +
 1 file changed, 9 insertions(+)

diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
index 17c5c37..e4ab9ea 100644
--- a/drivers/i2c/busses/i2c-s3c2410.c
+++ b/drivers/i2c/busses/i2c-s3c2410.c
@@ -309,6 +309,12 @@ static inline int is_lastmsg(struct s3c24xx_i2c *i2c)
 
 static inline int is_msglast(struct s3c24xx_i2c *i2c)
 {
+   /* msg-len is always 1 for the first byte of smbus block read.
+* Actual length will be read from slave. More bytes will be
+* read according to the length then. */
+   if (i2c-msg-flags  I2C_M_RECV_LEN  i2c-msg-len == 1)
+   return 0;
+
return i2c-msg_ptr == i2c-msg-len-1;
 }
 
@@ -448,6 +454,9 @@ static int i2c_s3c_irq_nextbyte(struct s3c24xx_i2c *i2c, 
unsigned long iicstat)
byte = readb(i2c-regs + S3C2410_IICDS);
i2c-msg-buf[i2c-msg_ptr++] = byte;
 
+   /* Add actual length to read for smbus block read */
+   if (i2c-msg-flags  I2C_M_RECV_LEN  i2c-msg-len == 1)
+   i2c-msg-len += byte;
  prepare_read:
if (is_msglast(i2c)) {
/* last byte of buffer */
-- 
1.7.10.4

--
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] Samsung USB PHY SoC support cleanup

2013-03-26 Thread Tomasz Figa
This patch series intends to improve handling of SoC-specific differences
in Samsung USB PHY drivers, by reducing the need to explicitly check
SoC type using if and switch statements.

In addition, last patch adds support for Exynos 4x12, as this is simply
a matter of adding appropriate driver data and additional case in two switches.

Tested on Exynos4210-based Trats board and Exynos4412-based internal
Samsung board.

Tomasz Figa (6):
  usb: phy: samsung: Select common driver part implicitly
  usb: phy: samsung: Use clk_get to get reference clock
  usb: phy: samsung: Consolidate reference clock rate handling
  usb: phy: samsung: Pass set_isolation callback through driver data
  usb: phy: samsung: Pass enable/disable callbacks through driver data
  usb: phy: samsung: Add support for USB 2.0 PHY on Exynos 4x12

 drivers/usb/phy/Kconfig|   2 +-
 drivers/usb/phy/phy-samsung-usb.c  | 154 ++---
 drivers/usb/phy/phy-samsung-usb.h  |  14 +++-
 drivers/usb/phy/phy-samsung-usb2.c |  53 +
 drivers/usb/phy/phy-samsung-usb3.c |  23 --
 5 files changed, 146 insertions(+), 100 deletions(-)

-- 
1.8.1.5

--
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] usb: phy: samsung: Select common driver part implicitly

2013-03-26 Thread Tomasz Figa
Since phy-samsung-usb library can be used only by phy-samsung-usb2 and
phy-samsung-usb3 drivers, there is no need to give explicit control over
its Kconfig symbol.

This patch makes CONFIG_SAMSUNG_USBPHY symbol hidden and selected
implicitly by CONFIG_SAMSUNG_USB2PHY and CONFIG_SAMSUNG_USB3PHY.

Signed-off-by: Tomasz Figa t.f...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/usb/phy/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/phy/Kconfig b/drivers/usb/phy/Kconfig
index 7e8fe0f..5fb0939 100644
--- a/drivers/usb/phy/Kconfig
+++ b/drivers/usb/phy/Kconfig
@@ -86,7 +86,7 @@ config OMAP_USB3
  on/off the PHY.
 
 config SAMSUNG_USBPHY
-   tristate Samsung USB PHY Driver
+   tristate
help
  Enable this to support Samsung USB phy helper driver for Samsung SoCs.
  This driver provides common interface to interact, for Samsung USB 
2.0 PHY
-- 
1.8.1.5

--
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] usb: phy: samsung: Use clk_get to get reference clock

2013-03-26 Thread Tomasz Figa
There is no need to use devm_clk_get to get a clock that is being put
at the end of the function.

This patch changes the code getting reference clock to use clk_get
instead of useless in this case devm_clk_get.

Signed-off-by: Tomasz Figa t.f...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/usb/phy/phy-samsung-usb.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/phy/phy-samsung-usb.c 
b/drivers/usb/phy/phy-samsung-usb.c
index 7b118ee5..62cdb7e 100644
--- a/drivers/usb/phy/phy-samsung-usb.c
+++ b/drivers/usb/phy/phy-samsung-usb.c
@@ -175,9 +175,9 @@ int samsung_usbphy_get_refclk_freq(struct samsung_usbphy 
*sphy)
 * external crystal clock XXTI
 */
if (sphy-drv_data-cpu_type == TYPE_EXYNOS5250)
-   ref_clk = devm_clk_get(sphy-dev, ext_xtal);
+   ref_clk = clk_get(sphy-dev, ext_xtal);
else
-   ref_clk = devm_clk_get(sphy-dev, xusbxti);
+   ref_clk = clk_get(sphy-dev, xusbxti);
if (IS_ERR(ref_clk)) {
dev_err(sphy-dev, Failed to get reference clock\n);
return PTR_ERR(ref_clk);
-- 
1.8.1.5

--
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] usb: phy: samsung: Consolidate reference clock rate handling

2013-03-26 Thread Tomasz Figa
This patch cleans up handling of reference clock rate in Samsung USB PHY
drivers. It is mostly a cosmetic change but improves error handling in
case of failing to get reference clock or invalid clock rate.

Signed-off-by: Tomasz Figa t.f...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/usb/phy/phy-samsung-usb.c  | 114 ++---
 drivers/usb/phy/phy-samsung-usb.h  |   7 +++
 drivers/usb/phy/phy-samsung-usb2.c |   8 ++-
 drivers/usb/phy/phy-samsung-usb3.c |   6 +-
 4 files changed, 86 insertions(+), 49 deletions(-)

diff --git a/drivers/usb/phy/phy-samsung-usb.c 
b/drivers/usb/phy/phy-samsung-usb.c
index 62cdb7e..c40ea32 100644
--- a/drivers/usb/phy/phy-samsung-usb.c
+++ b/drivers/usb/phy/phy-samsung-usb.c
@@ -162,13 +162,76 @@ int samsung_usbphy_set_type(struct usb_phy *phy,
 }
 EXPORT_SYMBOL_GPL(samsung_usbphy_set_type);
 
+int samsung_usbphy_rate_to_clksel_64xx(struct samsung_usbphy *sphy,
+   unsigned long rate)
+{
+   unsigned int clksel;
+
+   switch (rate) {
+   case 12 * MHZ:
+   clksel = PHYCLK_CLKSEL_12M;
+   break;
+   case 24 * MHZ:
+   clksel = PHYCLK_CLKSEL_24M;
+   break;
+   case 48 * MHZ:
+   clksel = PHYCLK_CLKSEL_48M;
+   break;
+   default:
+   dev_err(sphy-dev,
+   Invalid reference clock frequency: %lu\n, rate);
+   return -EINVAL;
+   }
+
+   return clksel;
+}
+EXPORT_SYMBOL_GPL(samsung_usbphy_rate_to_clksel_64xx);
+
+int samsung_usbphy_rate_to_clksel_4x12(struct samsung_usbphy *sphy,
+   unsigned long rate)
+{
+   unsigned int clksel;
+
+   switch (rate) {
+   case 9600 * KHZ:
+   clksel = FSEL_CLKSEL_9600K;
+   break;
+   case 10 * MHZ:
+   clksel = FSEL_CLKSEL_10M;
+   break;
+   case 12 * MHZ:
+   clksel = FSEL_CLKSEL_12M;
+   break;
+   case 19200 * KHZ:
+   clksel = FSEL_CLKSEL_19200K;
+   break;
+   case 20 * MHZ:
+   clksel = FSEL_CLKSEL_20M;
+   break;
+   case 24 * MHZ:
+   clksel = FSEL_CLKSEL_24M;
+   break;
+   case 50 * MHZ:
+   clksel = FSEL_CLKSEL_50M;
+   break;
+   default:
+   dev_err(sphy-dev,
+   Invalid reference clock frequency: %lu\n, rate);
+   return -EINVAL;
+   }
+
+   return clksel;
+}
+EXPORT_SYMBOL_GPL(samsung_usbphy_rate_to_clksel_4x12);
+
 /*
  * Returns reference clock frequency selection value
  */
 int samsung_usbphy_get_refclk_freq(struct samsung_usbphy *sphy)
 {
struct clk *ref_clk;
-   int refclk_freq = 0;
+   unsigned long rate;
+   int refclk_freq;
 
/*
 * In exynos5250 USB host and device PHY use
@@ -183,52 +246,9 @@ int samsung_usbphy_get_refclk_freq(struct samsung_usbphy 
*sphy)
return PTR_ERR(ref_clk);
}
 
-   if (sphy-drv_data-cpu_type == TYPE_EXYNOS5250) {
-   /* set clock frequency for PLL */
-   switch (clk_get_rate(ref_clk)) {
-   case 9600 * KHZ:
-   refclk_freq = FSEL_CLKSEL_9600K;
-   break;
-   case 10 * MHZ:
-   refclk_freq = FSEL_CLKSEL_10M;
-   break;
-   case 12 * MHZ:
-   refclk_freq = FSEL_CLKSEL_12M;
-   break;
-   case 19200 * KHZ:
-   refclk_freq = FSEL_CLKSEL_19200K;
-   break;
-   case 20 * MHZ:
-   refclk_freq = FSEL_CLKSEL_20M;
-   break;
-   case 50 * MHZ:
-   refclk_freq = FSEL_CLKSEL_50M;
-   break;
-   case 24 * MHZ:
-   default:
-   /* default reference clock */
-   refclk_freq = FSEL_CLKSEL_24M;
-   break;
-   }
-   } else {
-   switch (clk_get_rate(ref_clk)) {
-   case 12 * MHZ:
-   refclk_freq = PHYCLK_CLKSEL_12M;
-   break;
-   case 24 * MHZ:
-   refclk_freq = PHYCLK_CLKSEL_24M;
-   break;
-   case 48 * MHZ:
-   refclk_freq = PHYCLK_CLKSEL_48M;
-   break;
-   default:
-   if (sphy-drv_data-cpu_type == TYPE_S3C64XX)
-   refclk_freq = PHYCLK_CLKSEL_48M;
-   else
-   refclk_freq = PHYCLK_CLKSEL_24M;
-   break;
-   }
-   }
+   rate = 

[PATCH 4/6] usb: phy: samsung: Pass set_isolation callback through driver data

2013-03-26 Thread Tomasz Figa
This patch extends driver data structure with set_isolation callback,
which allows to remove the need for checking for SoC type in a switch
statement.

Signed-off-by: Tomasz Figa t.f...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/usb/phy/phy-samsung-usb.c  | 36 
 drivers/usb/phy/phy-samsung-usb.h  |  4 +++-
 drivers/usb/phy/phy-samsung-usb2.c | 11 +++
 drivers/usb/phy/phy-samsung-usb3.c |  7 +--
 4 files changed, 23 insertions(+), 35 deletions(-)

diff --git a/drivers/usb/phy/phy-samsung-usb.c 
b/drivers/usb/phy/phy-samsung-usb.c
index c40ea32..7a1ed90 100644
--- a/drivers/usb/phy/phy-samsung-usb.c
+++ b/drivers/usb/phy/phy-samsung-usb.c
@@ -73,7 +73,7 @@ EXPORT_SYMBOL_GPL(samsung_usbphy_parse_dt);
  * Here 'on = true' would mean USB PHY block is isolated, hence
  * de-activated and vice-versa.
  */
-void samsung_usbphy_set_isolation(struct samsung_usbphy *sphy, bool on)
+void samsung_usbphy_set_isolation_4210(struct samsung_usbphy *sphy, bool on)
 {
void __iomem *reg = NULL;
u32 reg_val;
@@ -84,32 +84,12 @@ void samsung_usbphy_set_isolation(struct samsung_usbphy 
*sphy, bool on)
return;
}
 
-   switch (sphy-drv_data-cpu_type) {
-   case TYPE_S3C64XX:
-   /*
-* Do nothing: We will add here once S3C64xx goes for DT support
-*/
-   break;
-   case TYPE_EXYNOS4210:
-   /*
-* Fall through since exynos4210 and exynos5250 have similar
-* register architecture: two separate registers for host and
-* device phy control with enable bit at position 0.
-*/
-   case TYPE_EXYNOS5250:
-   if (sphy-phy_type == USB_PHY_TYPE_DEVICE) {
-   reg = sphy-pmuregs +
-   sphy-drv_data-devphy_reg_offset;
-   en_mask = sphy-drv_data-devphy_en_mask;
-   } else if (sphy-phy_type == USB_PHY_TYPE_HOST) {
-   reg = sphy-pmuregs +
-   sphy-drv_data-hostphy_reg_offset;
-   en_mask = sphy-drv_data-hostphy_en_mask;
-   }
-   break;
-   default:
-   dev_err(sphy-dev, Invalid SoC type\n);
-   return;
+   if (sphy-phy_type == USB_PHY_TYPE_DEVICE) {
+   reg = sphy-pmuregs + sphy-drv_data-devphy_reg_offset;
+   en_mask = sphy-drv_data-devphy_en_mask;
+   } else if (sphy-phy_type == USB_PHY_TYPE_HOST) {
+   reg = sphy-pmuregs + sphy-drv_data-hostphy_reg_offset;
+   en_mask = sphy-drv_data-hostphy_en_mask;
}
 
reg_val = readl(reg);
@@ -121,7 +101,7 @@ void samsung_usbphy_set_isolation(struct samsung_usbphy 
*sphy, bool on)
 
writel(reg_val, reg);
 }
-EXPORT_SYMBOL_GPL(samsung_usbphy_set_isolation);
+EXPORT_SYMBOL_GPL(samsung_usbphy_set_isolation_4210);
 
 /*
  * Configure the mode of working of usb-phy here: HOST/DEVICE.
diff --git a/drivers/usb/phy/phy-samsung-usb.h 
b/drivers/usb/phy/phy-samsung-usb.h
index 0336f6b..5203784 100644
--- a/drivers/usb/phy/phy-samsung-usb.h
+++ b/drivers/usb/phy/phy-samsung-usb.h
@@ -271,6 +271,7 @@ struct samsung_usbphy_drvdata {
u32 devphy_reg_offset;
u32 hostphy_reg_offset;
int (*rate_to_clksel)(struct samsung_usbphy *, unsigned long);
+   void (*set_isolation)(struct samsung_usbphy *, bool);
 };
 
 /*
@@ -323,7 +324,8 @@ static inline const struct samsung_usbphy_drvdata
 }
 
 extern int samsung_usbphy_parse_dt(struct samsung_usbphy *sphy);
-extern void samsung_usbphy_set_isolation(struct samsung_usbphy *sphy, bool on);
+extern void samsung_usbphy_set_isolation_4210(struct samsung_usbphy *sphy,
+   bool on);
 extern void samsung_usbphy_cfg_sel(struct samsung_usbphy *sphy);
 extern int samsung_usbphy_set_type(struct usb_phy *phy,
enum samsung_usb_phy_type phy_type);
diff --git a/drivers/usb/phy/phy-samsung-usb2.c 
b/drivers/usb/phy/phy-samsung-usb2.c
index 802e738..ae6da68 100644
--- a/drivers/usb/phy/phy-samsung-usb2.c
+++ b/drivers/usb/phy/phy-samsung-usb2.c
@@ -284,8 +284,8 @@ static int samsung_usb2phy_init(struct usb_phy *phy)
/* Disable phy isolation */
if (sphy-plat  sphy-plat-pmu_isolation)
sphy-plat-pmu_isolation(false);
-   else
-   samsung_usbphy_set_isolation(sphy, false);
+   else if (sphy-drv_data-set_isolation)
+   sphy-drv_data-set_isolation(sphy, false);
 
/* Selecting Host/OTG mode; After reset USB2.0PHY_CFG: HOST */
samsung_usbphy_cfg_sel(sphy);
@@ -342,8 +342,8 @@ static void samsung_usb2phy_shutdown(struct usb_phy *phy)
/* Enable phy isolation */
if (sphy-plat  sphy-plat-pmu_isolation)

[PATCH 5/6] usb: phy: samsung: Pass enable/disable callbacks through driver data

2013-03-26 Thread Tomasz Figa
To remove unnecessary if statements, this patch introduces phy_enable
and phy_disable callbacks in driver data structure that implement
SoC-specific PHY initialization and deinitialization.

Signed-off-by: Tomasz Figa t.f...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/usb/phy/phy-samsung-usb.h  |  2 ++
 drivers/usb/phy/phy-samsung-usb2.c | 16 
 drivers/usb/phy/phy-samsung-usb3.c | 10 +-
 3 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/drivers/usb/phy/phy-samsung-usb.h 
b/drivers/usb/phy/phy-samsung-usb.h
index 5203784..31e2ec3 100644
--- a/drivers/usb/phy/phy-samsung-usb.h
+++ b/drivers/usb/phy/phy-samsung-usb.h
@@ -272,6 +272,8 @@ struct samsung_usbphy_drvdata {
u32 hostphy_reg_offset;
int (*rate_to_clksel)(struct samsung_usbphy *, unsigned long);
void (*set_isolation)(struct samsung_usbphy *, bool);
+   void (*phy_enable)(struct samsung_usbphy *);
+   void (*phy_disable)(struct samsung_usbphy *);
 };
 
 /*
diff --git a/drivers/usb/phy/phy-samsung-usb2.c 
b/drivers/usb/phy/phy-samsung-usb2.c
index ae6da68..b81347b 100644
--- a/drivers/usb/phy/phy-samsung-usb2.c
+++ b/drivers/usb/phy/phy-samsung-usb2.c
@@ -291,10 +291,7 @@ static int samsung_usb2phy_init(struct usb_phy *phy)
samsung_usbphy_cfg_sel(sphy);
 
/* Initialize usb phy registers */
-   if (sphy-drv_data-cpu_type == TYPE_EXYNOS5250)
-   samsung_exynos5_usb2phy_enable(sphy);
-   else
-   samsung_usb2phy_enable(sphy);
+   sphy-drv_data-phy_enable(sphy);
 
spin_unlock_irqrestore(sphy-lock, flags);
 
@@ -334,10 +331,7 @@ static void samsung_usb2phy_shutdown(struct usb_phy *phy)
}
 
/* De-initialize usb phy registers */
-   if (sphy-drv_data-cpu_type == TYPE_EXYNOS5250)
-   samsung_exynos5_usb2phy_disable(sphy);
-   else
-   samsung_usb2phy_disable(sphy);
+   sphy-drv_data-phy_disable(sphy);
 
/* Enable phy isolation */
if (sphy-plat  sphy-plat-pmu_isolation)
@@ -448,6 +442,8 @@ static const struct samsung_usbphy_drvdata usb2phy_s3c64xx 
= {
.devphy_en_mask = S3C64XX_USBPHY_ENABLE,
.rate_to_clksel = samsung_usbphy_rate_to_clksel_64xx,
.set_isolation  = NULL, /* TODO */
+   .phy_enable = samsung_usb2phy_enable,
+   .phy_disable= samsung_usb2phy_disable,
 };
 
 static const struct samsung_usbphy_drvdata usb2phy_exynos4 = {
@@ -456,6 +452,8 @@ static const struct samsung_usbphy_drvdata usb2phy_exynos4 
= {
.hostphy_en_mask= EXYNOS_USBPHY_ENABLE,
.rate_to_clksel = samsung_usbphy_rate_to_clksel_64xx,
.set_isolation  = samsung_usbphy_set_isolation_4210,
+   .phy_enable = samsung_usb2phy_enable,
+   .phy_disable= samsung_usb2phy_disable,
 };
 
 static struct samsung_usbphy_drvdata usb2phy_exynos5 = {
@@ -464,6 +462,8 @@ static struct samsung_usbphy_drvdata usb2phy_exynos5 = {
.hostphy_reg_offset = EXYNOS_USBHOST_PHY_CTRL_OFFSET,
.rate_to_clksel = samsung_usbphy_rate_to_clksel_4x12,
.set_isolation  = samsung_usbphy_set_isolation_4210,
+   .phy_enable = samsung_exynos5_usb2phy_enable,
+   .phy_disable= samsung_exynos5_usb2phy_disable,
 };
 
 #ifdef CONFIG_OF
diff --git a/drivers/usb/phy/phy-samsung-usb3.c 
b/drivers/usb/phy/phy-samsung-usb3.c
index a4f4fa6..a7242e6 100644
--- a/drivers/usb/phy/phy-samsung-usb3.c
+++ b/drivers/usb/phy/phy-samsung-usb3.c
@@ -65,7 +65,7 @@ static u32 samsung_usb3phy_set_refclk(struct samsung_usbphy 
*sphy)
return reg;
 }
 
-static int samsung_exynos5_usb3phy_enable(struct samsung_usbphy *sphy)
+static void samsung_exynos5_usb3phy_enable(struct samsung_usbphy *sphy)
 {
void __iomem *regs = sphy-regs;
u32 phyparam0;
@@ -133,8 +133,6 @@ static int samsung_exynos5_usb3phy_enable(struct 
samsung_usbphy *sphy)
 
phyclkrst = ~(PHYCLKRST_PORTRESET);
writel(phyclkrst, regs + EXYNOS5_DRD_PHYCLKRST);
-
-   return 0;
 }
 
 static void samsung_exynos5_usb3phy_disable(struct samsung_usbphy *sphy)
@@ -188,7 +186,7 @@ static int samsung_usb3phy_init(struct usb_phy *phy)
sphy-drv_data-set_isolation(sphy, false);
 
/* Initialize usb phy registers */
-   samsung_exynos5_usb3phy_enable(sphy);
+   sphy-drv_data-phy_enable(sphy);
 
spin_unlock_irqrestore(sphy-lock, flags);
 
@@ -219,7 +217,7 @@ static void samsung_usb3phy_shutdown(struct usb_phy *phy)
samsung_usbphy_set_type(sphy-phy, USB_PHY_TYPE_DEVICE);
 
/* De-initialize usb phy registers */
-   samsung_exynos5_usb3phy_disable(sphy);
+   sphy-drv_data-phy_disable(sphy);
 
/* Enable phy isolation */
if (sphy-drv_data-set_isolation)
@@ -314,6 +312,8 @@ static struct samsung_usbphy_drvdata usb3phy_exynos5 = {
   

[PATCH] tty: serial: samsung: Disable interrupts in a suspend-friendly way

2013-03-26 Thread Tomasz Figa
Since the interrupt mask register is not preserved across system suspend
and it defaults to all interrupts enabled, it is not enough to disable
UART interrupt.

This patch adds free_irq to port shutdown and mask setting to port
startup to handle IRQ disabling in a suspend-friendly way. In addition,
a bug caused by multiple request_irq calls in port startup callback is
fixed.

Signed-off-by: Tomasz Figa t.f...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/tty/serial/samsung.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c
index 2769a38..b386fc8 100644
--- a/drivers/tty/serial/samsung.c
+++ b/drivers/tty/serial/samsung.c
@@ -446,6 +446,8 @@ static void s3c24xx_serial_shutdown(struct uart_port *port)
 
/* Clear pending interrupts and mask all interrupts */
if (s3c24xx_serial_has_interrupt_mask(port)) {
+   free_irq(port-irq, ourport);
+
wr_regl(port, S3C64XX_UINTP, 0xf);
wr_regl(port, S3C64XX_UINTM, 0xf);
}
@@ -505,6 +507,8 @@ static int s3c64xx_serial_startup(struct uart_port *port)
dbg(s3c64xx_serial_startup: port=%p (%08lx,%p)\n,
port-mapbase, port-membase);
 
+   wr_regl(port, S3C64XX_UINTM, 0xf);
+
ret = request_irq(port-irq, s3c64xx_serial_handle_irq, IRQF_SHARED,
  s3c24xx_serial_portname(port), ourport);
if (ret) {
-- 
1.8.1.5

--
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


[REVIEW PATCH 0/3] s5p-fimc driver updates

2013-03-26 Thread Sylwester Nawrocki
This patch series contains mostly conversion of the video capture node
drivers to videobuf2 ioctl/fop helpers.

Sylwester Nawrocki (3):
  s5p-fimc: Use video entity for marking media pipeline as streaming
  s5p-fimc: Use vb2 ioctl/fop helpers in FIMC capture driver
  s5p-fimc: Use vb2 ioctl helpers in fimc-lite

 drivers/media/platform/s5p-fimc/fimc-capture.c |  178 +++-
 drivers/media/platform/s5p-fimc/fimc-lite.c|  177 +++
 drivers/media/platform/s5p-fimc/fimc-m2m.c |9 +-
 3 files changed, 100 insertions(+), 264 deletions(-)

--
1.7.9.5

--
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


[REVIEW PATCH 1/3] s5p-fimc: Use video entity for marking media pipeline as streaming

2013-03-26 Thread Sylwester Nawrocki
It doesn't matter whether we start from the sensor of from
the video node entity. Remove use of pipeline-subdevs array
where possible, so we can partly drop dependency on struct
fimc_pipeline in the fimc-lite module, which is also used
by the exynos5-is driver.
Also make sure we revert any media entity pipeline operations
when vb2_streamon() function fails.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/platform/s5p-fimc/fimc-capture.c |   27 +++-
 drivers/media/platform/s5p-fimc/fimc-lite.c|9 
 2 files changed, 21 insertions(+), 15 deletions(-)

diff --git a/drivers/media/platform/s5p-fimc/fimc-capture.c 
b/drivers/media/platform/s5p-fimc/fimc-capture.c
index 87b6842..257afc1 100644
--- a/drivers/media/platform/s5p-fimc/fimc-capture.c
+++ b/drivers/media/platform/s5p-fimc/fimc-capture.c
@@ -1230,36 +1230,43 @@ static int fimc_cap_streamon(struct file *file, void 
*priv,
 {
struct fimc_dev *fimc = video_drvdata(file);
struct fimc_pipeline *p = fimc-pipeline;
-   struct v4l2_subdev *sd = p-subdevs[IDX_SENSOR];
+   struct fimc_vid_cap *vc = fimc-vid_cap;
+   struct media_entity *entity = vc-vfd.entity;
int ret;
 
if (fimc_capture_active(fimc))
return -EBUSY;
 
-   ret = media_entity_pipeline_start(sd-entity, p-m_pipeline);
+   ret = media_entity_pipeline_start(entity, p-m_pipeline);
if (ret  0)
return ret;
 
-   if (fimc-vid_cap.user_subdev_api) {
+   if (vc-user_subdev_api) {
ret = fimc_pipeline_validate(fimc);
-   if (ret  0) {
-   media_entity_pipeline_stop(sd-entity);
-   return ret;
-   }
+   if (ret  0)
+   goto err_p_stop;
}
-   return vb2_streamon(fimc-vid_cap.vbq, type);
+
+   ret = vb2_streamon(vc-vbq, type);
+   if (!ret)
+   return ret;
+
+err_p_stop:
+   media_entity_pipeline_stop(entity);
+   return ret;
 }
 
 static int fimc_cap_streamoff(struct file *file, void *priv,
enum v4l2_buf_type type)
 {
struct fimc_dev *fimc = video_drvdata(file);
-   struct v4l2_subdev *sd = fimc-pipeline.subdevs[IDX_SENSOR];
int ret;
 
ret = vb2_streamoff(fimc-vid_cap.vbq, type);
+
if (ret == 0)
-   media_entity_pipeline_stop(sd-entity);
+   media_entity_pipeline_stop(fimc-vid_cap.vfd.entity);
+
return ret;
 }
 
diff --git a/drivers/media/platform/s5p-fimc/fimc-lite.c 
b/drivers/media/platform/s5p-fimc/fimc-lite.c
index 8ebefdb..40733e0 100644
--- a/drivers/media/platform/s5p-fimc/fimc-lite.c
+++ b/drivers/media/platform/s5p-fimc/fimc-lite.c
@@ -800,20 +800,20 @@ static int fimc_lite_streamon(struct file *file, void 
*priv,
  enum v4l2_buf_type type)
 {
struct fimc_lite *fimc = video_drvdata(file);
-   struct v4l2_subdev *sensor = fimc-pipeline.subdevs[IDX_SENSOR];
+   struct media_entity *entity = fimc-vfd.entity;
struct fimc_pipeline *p = fimc-pipeline;
int ret;
 
if (fimc_lite_active(fimc))
return -EBUSY;
 
-   ret = media_entity_pipeline_start(sensor-entity, p-m_pipeline);
+   ret = media_entity_pipeline_start(entity, p-m_pipeline);
if (ret  0)
return ret;
 
ret = fimc_pipeline_validate(fimc);
if (ret) {
-   media_entity_pipeline_stop(sensor-entity);
+   media_entity_pipeline_stop(entity);
return ret;
}
 
@@ -824,12 +824,11 @@ static int fimc_lite_streamoff(struct file *file, void 
*priv,
   enum v4l2_buf_type type)
 {
struct fimc_lite *fimc = video_drvdata(file);
-   struct v4l2_subdev *sd = fimc-pipeline.subdevs[IDX_SENSOR];
int ret;
 
ret = vb2_streamoff(fimc-vb_queue, type);
if (ret == 0)
-   media_entity_pipeline_stop(sd-entity);
+   media_entity_pipeline_stop(fimc-vfd.entity);
return ret;
 }
 
-- 
1.7.9.5

--
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


[REVIEW PATCH 2/3] s5p-fimc: Use vb2 ioctl/fop helpers in FIMC capture driver

2013-03-26 Thread Sylwester Nawrocki
mmap/poll file operation and several ioctl handlers are replaced
with the vb2 helper functions. Some helpers are used indirectly
to maintain the buffer queue ownership.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/platform/s5p-fimc/fimc-capture.c |  153 +---
 drivers/media/platform/s5p-fimc/fimc-m2m.c |9 +-
 2 files changed, 36 insertions(+), 126 deletions(-)

diff --git a/drivers/media/platform/s5p-fimc/fimc-capture.c 
b/drivers/media/platform/s5p-fimc/fimc-capture.c
index 257afc1..b05d97b 100644
--- a/drivers/media/platform/s5p-fimc/fimc-capture.c
+++ b/drivers/media/platform/s5p-fimc/fimc-capture.c
@@ -454,24 +454,12 @@ static void buffer_queue(struct vb2_buffer *vb)
spin_unlock_irqrestore(fimc-slock, flags);
 }
 
-static void fimc_lock(struct vb2_queue *vq)
-{
-   struct fimc_ctx *ctx = vb2_get_drv_priv(vq);
-   mutex_lock(ctx-fimc_dev-lock);
-}
-
-static void fimc_unlock(struct vb2_queue *vq)
-{
-   struct fimc_ctx *ctx = vb2_get_drv_priv(vq);
-   mutex_unlock(ctx-fimc_dev-lock);
-}
-
 static struct vb2_ops fimc_capture_qops = {
.queue_setup= queue_setup,
.buf_prepare= buffer_prepare,
.buf_queue  = buffer_queue,
-   .wait_prepare   = fimc_unlock,
-   .wait_finish= fimc_lock,
+   .wait_prepare   = vb2_ops_wait_prepare,
+   .wait_finish= vb2_ops_wait_finish,
.start_streaming= start_streaming,
.stop_streaming = stop_streaming,
 };
@@ -530,7 +518,7 @@ static int fimc_capture_open(struct file *file)
goto unlock;
}
 
-   if (++fimc-vid_cap.refcnt == 1) {
+   if (v4l2_fh_is_singular_file(file)) {
ret = fimc_pipeline_call(fimc, open, fimc-pipeline,
 fimc-vid_cap.vfd.entity, true);
 
@@ -543,8 +531,9 @@ static int fimc_capture_open(struct file *file)
if (ret  0) {
clear_bit(ST_CAPT_BUSY, fimc-state);
pm_runtime_put_sync(fimc-pdev-dev);
-   fimc-vid_cap.refcnt--;
v4l2_fh_release(file);
+   } else {
+   fimc-vid_cap.refcnt++;
}
}
 unlock:
@@ -553,7 +542,7 @@ unlock:
return ret;
 }
 
-static int fimc_capture_close(struct file *file)
+static int fimc_capture_release(struct file *file)
 {
struct fimc_dev *fimc = video_drvdata(file);
int ret;
@@ -562,50 +551,20 @@ static int fimc_capture_close(struct file *file)
 
mutex_lock(fimc-lock);
 
-   if (--fimc-vid_cap.refcnt == 0) {
+   if (v4l2_fh_is_singular_file(file)) {
clear_bit(ST_CAPT_BUSY, fimc-state);
fimc_stop_capture(fimc, false);
fimc_pipeline_call(fimc, close, fimc-pipeline);
clear_bit(ST_CAPT_SUSPENDED, fimc-state);
+   fimc-vid_cap.refcnt--;
}
 
pm_runtime_put(fimc-pdev-dev);
 
-   if (fimc-vid_cap.refcnt == 0) {
-   vb2_queue_release(fimc-vid_cap.vbq);
+   if (v4l2_fh_is_singular_file(file))
fimc_ctrls_delete(fimc-vid_cap.ctx);
-   }
-
-   ret = v4l2_fh_release(file);
-
-   mutex_unlock(fimc-lock);
-   return ret;
-}
-
-static unsigned int fimc_capture_poll(struct file *file,
- struct poll_table_struct *wait)
-{
-   struct fimc_dev *fimc = video_drvdata(file);
-   int ret;
 
-   if (mutex_lock_interruptible(fimc-lock))
-   return POLL_ERR;
-
-   ret = vb2_poll(fimc-vid_cap.vbq, file, wait);
-   mutex_unlock(fimc-lock);
-
-   return ret;
-}
-
-static int fimc_capture_mmap(struct file *file, struct vm_area_struct *vma)
-{
-   struct fimc_dev *fimc = video_drvdata(file);
-   int ret;
-
-   if (mutex_lock_interruptible(fimc-lock))
-   return -ERESTARTSYS;
-
-   ret = vb2_mmap(fimc-vid_cap.vbq, vma);
+   ret = vb2_fop_release(file);
mutex_unlock(fimc-lock);
 
return ret;
@@ -614,10 +573,10 @@ static int fimc_capture_mmap(struct file *file, struct 
vm_area_struct *vma)
 static const struct v4l2_file_operations fimc_capture_fops = {
.owner  = THIS_MODULE,
.open   = fimc_capture_open,
-   .release= fimc_capture_close,
-   .poll   = fimc_capture_poll,
+   .release= fimc_capture_release,
+   .poll   = vb2_fop_poll,
.unlocked_ioctl = video_ioctl2,
-   .mmap   = fimc_capture_mmap,
+   .mmap   = vb2_fop_mmap,
 };
 
 /*
@@ -1247,7 +1206,7 @@ static int fimc_cap_streamon(struct file *file, void 
*priv,
goto err_p_stop;
}
 
-   ret = vb2_streamon(vc-vbq, type);
+   ret = vb2_ioctl_streamon(file, 

[REVIEW PATCH 3/3] s5p-fimc: Use vb2 ioctl helpers in fimc-lite

2013-03-26 Thread Sylwester Nawrocki
Replace some ioctl, file and video buffer queue operation handlers
with the videobuf2 helpers. This allows to get rid of significant
amount of boilerplate.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/platform/s5p-fimc/fimc-lite.c |  170 +++
 1 file changed, 45 insertions(+), 125 deletions(-)

diff --git a/drivers/media/platform/s5p-fimc/fimc-lite.c 
b/drivers/media/platform/s5p-fimc/fimc-lite.c
index 40733e0..187d9f6 100644
--- a/drivers/media/platform/s5p-fimc/fimc-lite.c
+++ b/drivers/media/platform/s5p-fimc/fimc-lite.c
@@ -425,24 +425,12 @@ static void buffer_queue(struct vb2_buffer *vb)
spin_unlock_irqrestore(fimc-slock, flags);
 }
 
-static void fimc_lock(struct vb2_queue *vq)
-{
-   struct fimc_lite *fimc = vb2_get_drv_priv(vq);
-   mutex_lock(fimc-lock);
-}
-
-static void fimc_unlock(struct vb2_queue *vq)
-{
-   struct fimc_lite *fimc = vb2_get_drv_priv(vq);
-   mutex_unlock(fimc-lock);
-}
-
 static const struct vb2_ops fimc_lite_qops = {
.queue_setup = queue_setup,
.buf_prepare = buffer_prepare,
.buf_queue   = buffer_queue,
-   .wait_prepare= fimc_unlock,
-   .wait_finish = fimc_lock,
+   .wait_prepare= vb2_ops_wait_prepare,
+   .wait_finish = vb2_ops_wait_finish,
.start_streaming = start_streaming,
.stop_streaming  = stop_streaming,
 };
@@ -467,99 +455,69 @@ static int fimc_lite_open(struct file *file)
mutex_lock(fimc-lock);
if (atomic_read(fimc-out_path) != FIMC_IO_DMA) {
ret = -EBUSY;
-   goto done;
+   goto unlock;
}
 
set_bit(ST_FLITE_IN_USE, fimc-state);
ret = pm_runtime_get_sync(fimc-pdev-dev);
if (ret  0)
-   goto done;
+   goto unlock;
 
ret = v4l2_fh_open(file);
if (ret  0)
-   goto done;
+   goto err_pm;
 
-   if (++fimc-ref_count == 1 
-   atomic_read(fimc-out_path) == FIMC_IO_DMA) {
-   ret = fimc_pipeline_call(fimc, open, fimc-pipeline,
-fimc-vfd.entity, true);
-   if (ret  0) {
-   pm_runtime_put_sync(fimc-pdev-dev);
-   fimc-ref_count--;
-   v4l2_fh_release(file);
-   clear_bit(ST_FLITE_IN_USE, fimc-state);
-   }
+   if (!v4l2_fh_is_singular_file(file) ||
+   atomic_read(fimc-out_path) != FIMC_IO_DMA)
+   goto unlock;
 
+   ret = fimc_pipeline_call(fimc, open, fimc-pipeline,
+   me, true);
+   if (!ret) {
fimc_lite_clear_event_counters(fimc);
+   fimc-ref_count++;
+   goto unlock;
}
-done:
+
+   v4l2_fh_release(file);
+err_pm:
+   pm_runtime_put_sync(fimc-pdev-dev);
+   clear_bit(ST_FLITE_IN_USE, fimc-state);
+unlock:
mutex_unlock(fimc-lock);
mutex_unlock(me-parent-graph_mutex);
return ret;
 }
 
-static int fimc_lite_close(struct file *file)
+static int fimc_lite_release(struct file *file)
 {
struct fimc_lite *fimc = video_drvdata(file);
-   int ret;
 
mutex_lock(fimc-lock);
 
-   if (--fimc-ref_count == 0 
+   if (v4l2_fh_is_singular_file(file) 
atomic_read(fimc-out_path) == FIMC_IO_DMA) {
clear_bit(ST_FLITE_IN_USE, fimc-state);
fimc_lite_stop_capture(fimc, false);
fimc_pipeline_call(fimc, close, fimc-pipeline);
-   clear_bit(ST_FLITE_SUSPENDED, fimc-state);
+   fimc-ref_count--;
}
 
+   vb2_fop_release(file);
pm_runtime_put(fimc-pdev-dev);
+   clear_bit(ST_FLITE_SUSPENDED, fimc-state);
 
-   if (fimc-ref_count == 0)
-   vb2_queue_release(fimc-vb_queue);
-
-   ret = v4l2_fh_release(file);
-
-   mutex_unlock(fimc-lock);
-   return ret;
-}
-
-static unsigned int fimc_lite_poll(struct file *file,
-  struct poll_table_struct *wait)
-{
-   struct fimc_lite *fimc = video_drvdata(file);
-   int ret;
-
-   if (mutex_lock_interruptible(fimc-lock))
-   return POLL_ERR;
-
-   ret = vb2_poll(fimc-vb_queue, file, wait);
-   mutex_unlock(fimc-lock);
-
-   return ret;
-}
-
-static int fimc_lite_mmap(struct file *file, struct vm_area_struct *vma)
-{
-   struct fimc_lite *fimc = video_drvdata(file);
-   int ret;
-
-   if (mutex_lock_interruptible(fimc-lock))
-   return -ERESTARTSYS;
-
-   ret = vb2_mmap(fimc-vb_queue, vma);
mutex_unlock(fimc-lock);
-
-   return ret;
+   return 0;
 }
 
 static const struct v4l2_file_operations fimc_lite_fops = {
.owner  = THIS_MODULE,
.open   = fimc_lite_open,
-   .release 

[PATCH v3] of/pci: Provide support for parsing PCI DT ranges property

2013-03-26 Thread Andrew Murray
This patch factors out common implementation patterns to reduce overall kernel
code and provide a means for host bridge drivers to directly obtain struct
resources from the DT's ranges property without relying on architecture specific
DT handling. This will make it easier to write archiecture independent host 
bridge
drivers and mitigate against further duplication of DT parsing code.

This patch can be used in the following way:

struct of_pci_range_parser parser;
struct of_pci_range range;

if (of_pci_range_parser(parser, np))
; //no ranges property

for_each_of_pci_range(parser, range) {

/*
directly access properties of the address range, e.g.:
range.pci_space, range.pci_addr, range.cpu_addr,
range.size, range.flags

alternatively obtain a struct resource, e.g.:
struct resource res;
of_pci_range_to_resource(range, np, res);
*/
}

Additionally the implementation takes care of adjacent ranges and merges them
into a single range (as was the case with powerpc and microblaze).

The modifications to microblaze, mips and powerpc have not been tested.

Signed-off-by: Andrew Murray andrew.mur...@arm.com
Signed-off-by: Liviu Dudau liviu.du...@arm.com
Signed-off-by: Thomas Petazzoni thomas.petazz...@free-electrons.com
---
Compared to [PATCH v5 01/17] of/pci: Provide support for parsing PCI DT
ranges property, the following changes have been made:

 * Correct use of IORESOURCE_* as suggested by Russell King

 * Improved interface and naming as suggested by Thierry Reding

Compared to the v2 sent by Andrew Murray, Thomas Petazzoni did:

 * Add a memset() on the struct of_pci_range_iter when starting the
   for loop in for_each_pci_range(). Otherwise, with an uninitialized
   of_pci_range_iter, of_pci_process_ranges() may crash.

 * Add parenthesis around 'res', 'np' and 'iter' in the
   for_each_of_pci_range macro definitions. Otherwise, passing
   something like foobar as 'res' didn't work.

 * Rebased on top of 3.9-rc2, which required fixing a few conflicts in
   the Microblaze code.

v2:
  This follows on from suggestions made by Grant Likely
  (marc.info/?l=linux-kernelm=136079602806328)
---
 arch/microblaze/pci/pci-common.c |  110 +
 arch/mips/pci/pci.c  |   50 ++
 arch/powerpc/kernel/pci-common.c |   99 --
 drivers/of/address.c |   63 ++
 include/linux/of_address.h   |   42 ++
 5 files changed, 194 insertions(+), 170 deletions(-)

diff --git a/arch/microblaze/pci/pci-common.c b/arch/microblaze/pci/pci-common.c
index 9ea521e..17a7ad1 100644
--- a/arch/microblaze/pci/pci-common.c
+++ b/arch/microblaze/pci/pci-common.c
@@ -658,67 +658,43 @@ void pci_resource_to_user(const struct pci_dev *dev, int 
bar,
 void pci_process_bridge_OF_ranges(struct pci_controller *hose,
  struct device_node *dev, int primary)
 {
-   const u32 *ranges;
-   int rlen;
-   int pna = of_n_addr_cells(dev);
-   int np = pna + 5;
int memno = 0, isa_hole = -1;
-   u32 pci_space;
-   unsigned long long pci_addr, cpu_addr, pci_next, cpu_next, size;
unsigned long long isa_mb = 0;
struct resource *res;
+   struct of_pci_range range;
+   struct of_pci_range_parser parser;
+   u32 res_type;
 
pr_info(PCI host bridge %s %s ranges:\n,
   dev-full_name, primary ? (primary) : );
 
-   /* Get ranges property */
-   ranges = of_get_property(dev, ranges, rlen);
-   if (ranges == NULL)
+   /* Check for ranges property */
+   if (of_pci_range_parser(parser, dev))
return;
 
-   /* Parse it */
pr_debug(Parsing ranges property...\n);
-   while ((rlen -= np * 4) = 0) {
+   for_each_of_pci_range(parser, range) {
/* Read next ranges element */
-   pci_space = ranges[0];
-   pci_addr = of_read_number(ranges + 1, 2);
-   cpu_addr = of_translate_address(dev, ranges + 3);
-   size = of_read_number(ranges + pna + 3, 2);
-
-   pr_debug(pci_space: 0x%08x pci_addr:0x%016llx ,
-   pci_space, pci_addr);
-   pr_debug(cpu_addr:0x%016llx size:0x%016llx\n,
-   cpu_addr, size);
-
-   ranges += np;
+   pr_debug(pci_space: 0x%08x pci_addr: 0x%016llx ,
+   range.pci_space, range.pci_addr);
+   pr_debug(cpu_addr: 0x%016llx size: 0x%016llx\n,
+   range.cpu_addr, range.size);
 
/* If we failed translation or got a zero-sized region
 * (some FW try to feed us with non sensical 

Re: [PATCH v2 0/7] Add G2D nodes to Exynos4 machines

2013-03-26 Thread Sachin Kamat
On 11 March 2013 12:24, Kukjin Kim kgene@samsung.com wrote:
 Sachin Kamat wrote:

 Hi Kukjin,

 Can you please look into this series as it is pending since quite some time.

 Applied, I have another opinion about the compatible string though...

Couldn't find this series in your latest for-next. Please let me know
which branch this is applied to.



 On 18 February 2013 10:32, Sachin Kamat sachin.ka...@linaro.org wrote:
  This patch series is based on Kukjin Kim's next/dt-exynos branch of
  git://git.kernel.org/pub/scm/linux/kernel/git/kgene/linux-samsung.git
  tree.
 
  Changes since v1:
  * Removed power-domain entry in patch 1/7 as the driver currently
does not use it.
  * Addressed review comments from Sylwester Nawrocki and Tomasz Figa
in patch 7/7.
 
  Sachin Kamat (7):
ARM: dts: Add G2D node to exynos4210.dtsi
ARM: dts: Add G2D node to SMDKV310
ARM: dts: Add G2D node to exynos4210-origen
ARM: dts: Add G2D node to exynos4x12.dtsi
ARM: dts: Add G2D node to SMDK4412
ARM: dts: Add G2D node to exynos4412-origen
ARM: dts: Add Samsung G2D DT bindings documentation




-- 
With warm regards,
Sachin
--
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 v5 0/6] Device tree support for Exynos SoC camera subsystem

2013-03-26 Thread Sylwester Nawrocki
Changes in this iteration include mostly adaptation to changes at the
V4L2 OF parser lib and an addition of clocks/clock-names properties
in the bindings of the IP blocks.

If there is no more comments I intend to send a pull request including
the DT bindings documentation, the V4L2 OF parser and these patches at
end of this week.

This patch series with all dependencies can be found at:
http://git.linuxtv.org/snawrocki/samsung.git/devicetree-fimc-v5

Sylwester Nawrocki (6):
  s5p-csis: Add device tree support
  s5p-fimc: Add device tree support for FIMC device driver
  s5p-fimc: Add device tree support for FIMC-LITE device driver
  s5p-fimc: Add device tree support for the media device driver
  s5p-fimc: Add device tree based sensors registration
  s5p-fimc: Use pinctrl API for camera ports configuration

 .../devicetree/bindings/media/exynos-fimc-lite.txt |   14 +
 .../devicetree/bindings/media/samsung-fimc.txt |  200 +++
 .../bindings/media/samsung-mipi-csis.txt   |   81 +
 drivers/media/platform/s5p-fimc/fimc-capture.c |6 +-
 drivers/media/platform/s5p-fimc/fimc-core.c|  239 +++--
 drivers/media/platform/s5p-fimc/fimc-core.h|   21 +-
 drivers/media/platform/s5p-fimc/fimc-lite.c|   63 +++-
 drivers/media/platform/s5p-fimc/fimc-m2m.c |2 +-
 drivers/media/platform/s5p-fimc/fimc-mdevice.c |  370 +---
 drivers/media/platform/s5p-fimc/fimc-mdevice.h |   16 +
 drivers/media/platform/s5p-fimc/fimc-reg.c |6 +-
 drivers/media/platform/s5p-fimc/mipi-csis.c|  155 ++--
 drivers/media/platform/s5p-fimc/mipi-csis.h|1 +
 include/media/s5p_fimc.h   |   17 +
 14 files changed, 982 insertions(+), 209 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/media/exynos-fimc-lite.txt
 create mode 100644 Documentation/devicetree/bindings/media/samsung-fimc.txt
 create mode 100644 
Documentation/devicetree/bindings/media/samsung-mipi-csis.txt

--
1.7.9.5

--
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 v5 1/6] s5p-csis: Add device tree support

2013-03-26 Thread Sylwester Nawrocki
This patch support for binding the driver to the MIPI-CSIS
devices instantiated from device tree and parsing the SoC
and board specific properties. The MIPI CSI-2 channel is
determined by the value of reg property placed in csis'
port subnode.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---

Changes since v5:
 - added clocks/clock-names properties to the binding documentation.

Changes since v4:
 - dropped node aliases, the IP instances are now identified
   by the port's node reg property value; as a side effect this
   introduces dependency on the s5p_fimc.h header,
 - re-added bus-width property, so the number of data lanes
   supported per each IP instance can be specified in the
   device tree,
 - the bindings documentation moved to Documentation/
   devicetree/bindings/media/samsung-mipi-csis.txt.
 - samsung,exynos3110-csis renamed to samsung,s5pv210-csis,
   updated the bindings documentation.

Changes since v3:
 - dropped 'bus-width' property, hard coded the number of supported
   data lanes per device also in dt case, it can be derived from the
   compatible property if required;
 - samsung,s5pv210-csis renamed to samsung,exynos3110-csis,
   updated the bindings description.
---
 .../bindings/media/samsung-mipi-csis.txt   |   81 ++
 drivers/media/platform/s5p-fimc/mipi-csis.c|  155 +++-
 drivers/media/platform/s5p-fimc/mipi-csis.h|1 +
 include/media/s5p_fimc.h   |   13 ++
 4 files changed, 215 insertions(+), 35 deletions(-)
 create mode 100644 
Documentation/devicetree/bindings/media/samsung-mipi-csis.txt

diff --git a/Documentation/devicetree/bindings/media/samsung-mipi-csis.txt 
b/Documentation/devicetree/bindings/media/samsung-mipi-csis.txt
new file mode 100644
index 000..5f8e28e
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/samsung-mipi-csis.txt
@@ -0,0 +1,81 @@
+Samsung S5P/EXYNOS SoC series MIPI CSI-2 receiver (MIPI CSIS)
+-
+
+Required properties:
+
+- compatible : samsung,s5pv210-csis for S5PV210 (S5PC110),
+   samsung,exynos4210-csis for Exynos4210 (S5PC210),
+   samsung,exynos4212-csis for Exynos4212/Exynos4412
+   SoC series;
+- reg: offset and length of the register set for the device;
+- interrupts  : should contain MIPI CSIS interrupt; the format of the
+   interrupt specifier depends on the interrupt controller;
+- bus-width  : maximum number of data lanes supported (SoC specific);
+- vddio-supply: MIPI CSIS I/O and PLL voltage supply (e.g. 1.8V);
+- vddcore-supply  : MIPI CSIS Core voltage supply (e.g. 1.1V);
+- clocks : list of clock specifiers, corresponding to entries in
+   clock-names property;
+- clock-names: must contain csis, sclk_csis entries, matching entries
+   in the clocks property.
+
+Optional properties:
+
+- clock-frequency : The IP's main (system bus) clock frequency in Hz, default
+   value when this property is not specified is 166 MHz;
+- samsung,csis-wclk : CSI-2 wrapper clock selection. If this property is 
present
+   external clock from CMU will be used, or the bus clock if
+   if it's not specified.
+
+The device node should contain one 'port' child node with one child 'endpoint'
+node, according to the bindings defined in Documentation/devicetree/bindings/
+media/video-interfaces.txt. The following are properties specific to those 
nodes.
+
+port node
+-
+
+- reg: (required) must be 3 for camera C input (CSIS0) or 4 for
+   camera D input (CSIS1);
+
+endpoint node
+-
+
+- data-lanes : (required) an array specifying active physical MIPI-CSI2
+   data input lanes and their mapping to logical lanes; the
+   array's content is unused, only its length is meaningful;
+
+- samsung,csis-hs-settle : (optional) differential receiver (HS-RX) settle 
time;
+
+
+Example:
+
+   reg0: regulator@0 {
+   };
+
+   reg1: regulator@1 {
+   };
+
+/* SoC properties */
+
+   csis_0: csis@1188 {
+   compatible = samsung,exynos4210-csis;
+   reg = 0x1188 0x1000;
+   interrupts = 0 78 0;
+   #address-cells = 1;
+   #size-cells = 0;
+   };
+
+/* Board properties */
+
+   csis_0: csis@1188 {
+   clock-frequency = 16600;
+   vddio-supply = reg0;
+   vddcore-supply = reg1;
+   port {
+   reg = 3; /* 3 - CSIS0, 4 - CSIS1 */
+   csis0_ep: endpoint {
+   remote-endpoint = ...;
+   data-lanes = 1, 2;
+   samsung,csis-hs-settle = 12;
+  

[PATCH v5 2/6] s5p-fimc: Add device tree support for FIMC device driver

2013-03-26 Thread Sylwester Nawrocki
This patch adds device tree support for FIMC driver on S5PV210
and Exynos4 SoCs.

The FIMC IP block's features and quirks encoded statically in
the driver are now parsed from the device tree. Once all relevant
platforms are converted to device tree based booting the FIMC
variant data structures will all be removed from the driver.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---

Changes since v5:
 - Added clocks/clock-names properties to the binding documentation.

Changes since v4:
 - Added parsing of FIMC features and quirks for DT, the static
   variant data removed for Exynos4x12 SoC which is a dt-only
   platform upstream;
 - the bindings documentation moved to Documentation/
   devicetree/bindings/media/samsung-fimc.txt

Changes since v3:
 - added optional clock-frequency property to specify local bus
   (FIMCn_LCLK) clock frequency

fimc dt doc
---
 .../devicetree/bindings/media/samsung-fimc.txt |  101 +
 drivers/media/platform/s5p-fimc/fimc-capture.c |6 +-
 drivers/media/platform/s5p-fimc/fimc-core.c|  238 
 drivers/media/platform/s5p-fimc/fimc-core.h|   21 +-
 drivers/media/platform/s5p-fimc/fimc-m2m.c |2 +-
 drivers/media/platform/s5p-fimc/fimc-reg.c |6 +-
 6 files changed, 260 insertions(+), 114 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/media/samsung-fimc.txt

diff --git a/Documentation/devicetree/bindings/media/samsung-fimc.txt 
b/Documentation/devicetree/bindings/media/samsung-fimc.txt
new file mode 100644
index 000..22e2889
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/samsung-fimc.txt
@@ -0,0 +1,101 @@
+Samsung S5P/EXYNOS SoC Camera Subsystem (FIMC)
+--
+
+The S5P/Exynos SoC Camera subsystem comprises of multiple sub-devices
+represented by separate device tree nodes. Currently this includes: FIMC (in
+the S5P SoCs series known as CAMIF), MIPI CSIS, FIMC-LITE and FIMC-IS (ISP).
+
+The sub-subdevices are defined as child nodes of the common 'camera' node which
+also includes common properties of the whole subsystem not really specific to
+any single sub-device, like common camera port pins or the CAMCLK clock outputs
+for external image sensors attached to an SoC.
+
+Common 'camera' node
+
+
+Required properties:
+
+- compatible   : must be samsung,fimc, simple-bus
+- clocks   : list of clock specifiers, corresponding to entries in
+ clock-names property;
+- clock-names  : must contain fimc, sclk_fimc entries, matching entries
+ in the clocks property.
+
+The 'camera' node must include at least one 'fimc' child node.
+
+
+'fimc' device nodes
+---
+
+Required properties:
+
+- compatible: samsung,s5pv210-fimc for S5PV210, samsung,exynos4210-fimc
+  for Exynos4210 and samsung,exynos4212-fimc for Exynos4x12 SoCs;
+- reg: physical base address and length of the registers set for the device;
+- interrupts: should contain FIMC interrupt;
+- clocks: list of clock specifiers, must contain an entry for each required
+  entry in clock-names;
+- clock-names: must include fimc, sclk_fimc, mux entries and optionally
+  parent entry.
+- samsung,pix-limits: an array of maximum supported image sizes in pixels, for
+  details refer to Table 2-1 in the S5PV210 SoC User Manual; The meaning of
+  each cell is as follows:
+  0 - scaler input horizontal size,
+  1 - input horizontal size for the scaler bypassed,
+  2 - REAL_WIDTH without input rotation,
+  3 - REAL_HEIGHT with input rotation,
+- samsung,sysreg: a phandle to the SYSREG node.
+
+Each FIMC device should have an alias in the aliases node, in the form of
+fimcn, where n is an integer specifying the IP block instance.
+
+Optional properties:
+
+- clock-frequency: maximum FIMC local clock (LCLK) frequency;
+- samsung,min-pix-sizes: an array specyfing minimum image size in pixels at
+  the FIMC input and output DMA, in the first and second cell respectively.
+  Default value when this property is not present is 16 16;
+- samsung,min-pix-alignment: minimum supported image height alignment (first
+  cell) and the horizontal image offset (second cell). The values are in pixels
+  and default to 2 1 when this property is not present;
+- samsung,mainscaler-ext: a boolean property indicating whether the FIMC IP
+  supports extended image size and has CIEXTEN register;
+- samsung,rotators: a bitmask specifying whether this IP has the input and
+  the output rotator. Bits 4 and 0 correspond to input and output rotator
+  respectively. If a rotator is present its corresponding bit should be set.
+  Default value when this property is not specified is 0x11.
+- samsung,cam-if: a bolean property indicating whether the IP block includes
+  the camera input interface.
+- samsung,isp-wb: this property must be present if the IP block has the ISP
+  writeback input.
+- 

[PATCH v5 3/6] s5p-fimc: Add device tree support for FIMC-LITE device driver

2013-03-26 Thread Sylwester Nawrocki
This patch adds the device tree support for FIMC-LITE device
driver. The bindings include compatible property for the Exynos5
SoC series, however the actual implementation for these SoCs will
be added in a separate patch.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---

Changes since v5:
 - Added clocks/clock-names properties to the binding documentation.
---
 .../devicetree/bindings/media/exynos-fimc-lite.txt |   14 +
 drivers/media/platform/s5p-fimc/fimc-lite.c|   63 ++--
 2 files changed, 59 insertions(+), 18 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/media/exynos-fimc-lite.txt

diff --git a/Documentation/devicetree/bindings/media/exynos-fimc-lite.txt 
b/Documentation/devicetree/bindings/media/exynos-fimc-lite.txt
new file mode 100644
index 000..3f62adf
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/exynos-fimc-lite.txt
@@ -0,0 +1,14 @@
+Exynos4x12/Exynos5 SoC series camera host interface (FIMC-LITE)
+
+Required properties:
+
+- compatible   : should be samsung,exynos4212-fimc for Exynos4212 and
+ Exynos4412 SoCs;
+- reg  : physical base address and size of the device memory mapped
+ registers;
+- interrupts   : should contain FIMC-LITE interrupt;
+- clocks   : FIMC LITE gate clock should be specified in this property.
+- clock-names  : should contain flite entry.
+
+Each FIMC device should have an alias in the aliases node, in the form of
+fimc-liten, where n is an integer specifying the IP block instance.
diff --git a/drivers/media/platform/s5p-fimc/fimc-lite.c 
b/drivers/media/platform/s5p-fimc/fimc-lite.c
index 187d9f6..c76a9d6 100644
--- a/drivers/media/platform/s5p-fimc/fimc-lite.c
+++ b/drivers/media/platform/s5p-fimc/fimc-lite.c
@@ -17,6 +17,7 @@
 #include linux/kernel.h
 #include linux/list.h
 #include linux/module.h
+#include linux/of.h
 #include linux/types.h
 #include linux/platform_device.h
 #include linux/pm_runtime.h
@@ -1401,18 +1402,34 @@ static int fimc_lite_clk_get(struct fimc_lite *fimc)
return ret;
 }
 
+static const struct of_device_id flite_of_match[];
+
 static int fimc_lite_probe(struct platform_device *pdev)
 {
-   struct flite_drvdata *drv_data = fimc_lite_get_drvdata(pdev);
+   struct flite_drvdata *drv_data = NULL;
+   struct device *dev = pdev-dev;
+   const struct of_device_id *of_id;
struct fimc_lite *fimc;
struct resource *res;
int ret;
 
-   fimc = devm_kzalloc(pdev-dev, sizeof(*fimc), GFP_KERNEL);
+   fimc = devm_kzalloc(dev, sizeof(*fimc), GFP_KERNEL);
if (!fimc)
return -ENOMEM;
 
-   fimc-index = pdev-id;
+   if (dev-of_node) {
+   of_id = of_match_node(flite_of_match, dev-of_node);
+   if (of_id)
+   drv_data = (struct flite_drvdata *)of_id-data;
+   fimc-index = of_alias_get_id(dev-of_node, fimc-lite);
+   } else {
+   drv_data = fimc_lite_get_drvdata(pdev);
+   fimc-index = pdev-id;
+   }
+
+   if (!drv_data || fimc-index  0 || fimc-index = FIMC_LITE_MAX_DEVS)
+   return -EINVAL;
+
fimc-variant = drv_data-variant[fimc-index];
fimc-pdev = pdev;
 
@@ -1421,13 +1438,13 @@ static int fimc_lite_probe(struct platform_device *pdev)
mutex_init(fimc-lock);
 
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-   fimc-regs = devm_ioremap_resource(pdev-dev, res);
+   fimc-regs = devm_ioremap_resource(dev, res);
if (IS_ERR(fimc-regs))
return PTR_ERR(fimc-regs);
 
res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
if (res == NULL) {
-   dev_err(pdev-dev, Failed to get IRQ resource\n);
+   dev_err(dev, Failed to get IRQ resource\n);
return -ENXIO;
}
 
@@ -1435,10 +1452,10 @@ static int fimc_lite_probe(struct platform_device *pdev)
if (ret)
return ret;
 
-   ret = devm_request_irq(pdev-dev, res-start, flite_irq_handler,
-  0, dev_name(pdev-dev), fimc);
+   ret = devm_request_irq(dev, res-start, flite_irq_handler,
+  0, dev_name(dev), fimc);
if (ret) {
-   dev_err(pdev-dev, Failed to install irq (%d)\n, ret);
+   dev_err(dev, Failed to install irq (%d)\n, ret);
goto err_clk;
}
 
@@ -1448,23 +1465,23 @@ static int fimc_lite_probe(struct platform_device *pdev)
goto err_clk;
 
platform_set_drvdata(pdev, fimc);
-   pm_runtime_enable(pdev-dev);
-   ret = pm_runtime_get_sync(pdev-dev);
+   pm_runtime_enable(dev);
+   ret = pm_runtime_get_sync(dev);
if (ret  0)
goto err_sd;
 
-   fimc-alloc_ctx = vb2_dma_contig_init_ctx(pdev-dev);
+   fimc-alloc_ctx = 

[PATCH v5 6/6] s5p-fimc: Use pinctrl API for camera ports configuration

2013-03-26 Thread Sylwester Nawrocki
Before the camera ports can be used the pinmux needs to be configured
properly. This patch adds a function to set the camera ports pinctrl
to a default state within the media driver's probe().
The camera port(s) are then configured for the video bus operation.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---

Changes since v5:
 - None.

Changes since v4:
 - Added more pinctrl states for camera port A and B normal operation
   and idle state (with CAMCLK output pin switched to high impedance
   state).

Changes since v3:
 - Removed the inactive pinctrl state, it will be added later if
   required.
---
 .../devicetree/bindings/media/samsung-fimc.txt |   12 +
 drivers/media/platform/s5p-fimc/fimc-mdevice.c |   26 
 drivers/media/platform/s5p-fimc/fimc-mdevice.h |   11 +
 3 files changed, 49 insertions(+)

diff --git a/Documentation/devicetree/bindings/media/samsung-fimc.txt 
b/Documentation/devicetree/bindings/media/samsung-fimc.txt
index 7617b93..b379822 100644
--- a/Documentation/devicetree/bindings/media/samsung-fimc.txt
+++ b/Documentation/devicetree/bindings/media/samsung-fimc.txt
@@ -21,6 +21,15 @@ Required properties:
 - clock-names  : must contain fimc, sclk_fimc entries, matching entries
  in the clocks property.
 
+The pinctrl bindings defined in ../pinctrl/pinctrl-bindings.txt must be used
+to define a required pinctrl state named default and optional pinctrl states:
+idle, active-a, active-b. These optional states can be used to switch the
+camera port pinmux at runtime. The idle state should configure both the 
camera
+ports A and B into high impedance state, especially the CAMCLK clock output
+should be inactive. For the active-a state the camera port A must be 
activated
+and the port B deactivated and for the state active-b it should be the other
+way around.
+
 The 'camera' node must include at least one 'fimc' child node.
 
 
@@ -147,6 +156,9 @@ Example:
#size-cells = 1;
status = okay;
 
+   pinctrl-names = default;
+   pinctrl-0 = cam_port_a_clk_active;
+
/* parallel camera ports */
parallel-ports {
/* camera A input */
diff --git a/drivers/media/platform/s5p-fimc/fimc-mdevice.c 
b/drivers/media/platform/s5p-fimc/fimc-mdevice.c
index d6d38b9..b689166 100644
--- a/drivers/media/platform/s5p-fimc/fimc-mdevice.c
+++ b/drivers/media/platform/s5p-fimc/fimc-mdevice.c
@@ -1171,6 +1171,25 @@ static ssize_t fimc_md_sysfs_store(struct device *dev,
 static DEVICE_ATTR(subdev_conf_mode, S_IWUSR | S_IRUGO,
   fimc_md_sysfs_show, fimc_md_sysfs_store);
 
+static int fimc_md_get_pinctrl(struct fimc_md *fmd)
+{
+   struct device *dev = fmd-pdev-dev;
+   struct fimc_pinctrl *pctl = fmd-pinctl;
+
+   pctl-pinctrl = devm_pinctrl_get(dev);
+   if (IS_ERR(pctl-pinctrl))
+   return PTR_ERR(pctl-pinctrl);
+
+   pctl-state_default = pinctrl_lookup_state(pctl-pinctrl,
+   PINCTRL_STATE_DEFAULT);
+   if (IS_ERR(pctl-state_default))
+   return PTR_ERR(pctl-state_default);
+
+   pctl-state_idle = pinctrl_lookup_state(pctl-pinctrl,
+   PINCTRL_STATE_IDLE);
+   return 0;
+}
+
 static int fimc_md_probe(struct platform_device *pdev)
 {
struct device *dev = pdev-dev;
@@ -1214,6 +1233,13 @@ static int fimc_md_probe(struct platform_device *pdev)
/* Protect the media graph while we're registering entities */
mutex_lock(fmd-media_dev.graph_mutex);
 
+   ret = fimc_md_get_pinctrl(fmd);
+   if (ret  0) {
+   if (ret != EPROBE_DEFER)
+   dev_err(dev, Failed to get pinctrl: %d\n, ret);
+   goto err_unlock;
+   }
+
if (dev-of_node)
ret = fimc_md_register_of_platform_entities(fmd, dev-of_node);
else
diff --git a/drivers/media/platform/s5p-fimc/fimc-mdevice.h 
b/drivers/media/platform/s5p-fimc/fimc-mdevice.h
index b6ceb59..5d6146e 100644
--- a/drivers/media/platform/s5p-fimc/fimc-mdevice.h
+++ b/drivers/media/platform/s5p-fimc/fimc-mdevice.h
@@ -12,6 +12,7 @@
 #include linux/clk.h
 #include linux/platform_device.h
 #include linux/mutex.h
+#include linux/pinctrl/consumer.h
 #include media/media-device.h
 #include media/media-entity.h
 #include media/v4l2-device.h
@@ -26,6 +27,8 @@
 #define FIMC_IS_OF_NODE_NAME   fimc-is
 #define CSIS_OF_NODE_NAME  csis
 
+#define PINCTRL_STATE_IDLE idle
+
 /* Group IDs of sensor, MIPI-CSIS, FIMC-LITE and the writeback subdevs. */
 #define GRP_ID_SENSOR  (1  8)
 #define GRP_ID_FIMC_IS_SENSOR  (1  9)
@@ -73,6 +76,9 @@ struct fimc_sensor_info {
  * @media_dev: top level media device
  * @v4l2_dev: top level v4l2_device holding up the subdevs
  * @pdev: platform device this media device is hooked up 

Re: [PATCH v5 0/6] Device tree support for Exynos SoC camera subsystem

2013-03-26 Thread Sylwester Nawrocki
On 03/26/2013 05:39 PM, Sylwester Nawrocki wrote:
 Changes in this iteration include mostly adaptation to changes at the
 V4L2 OF parser lib and an addition of clocks/clock-names properties
 in the bindings of the IP blocks.
 
 If there is no more comments I intend to send a pull request including
 the DT bindings documentation, the V4L2 OF parser and these patches at
 end of this week.
 
 This patch series with all dependencies can be found at:
 http://git.linuxtv.org/snawrocki/samsung.git/devicetree-fimc-v5

Ugh, this should have been v6 and the correct url is
http://git.linuxtv.org/snawrocki/samsung.git/devicetree-fimc-v6

My apologies for this confusion.

Thanks,

Sylwester
--
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 v2 00/10] s5p-fimc: Exynos4x12 FIMC-IS support prerequisite

2013-03-26 Thread Sylwester Nawrocki
This patch series contains a few fixes to the s5p-fimc driver and changes
necessary for the Exynos4x12 FIMC-IS support.

The changes are listed at each patch, if there were any. I have removed
two patches, adding support for setting parent clocks and added a patch
changing the driver directory to drivers/media/platform/exynos4-is.

This series, including dependencies, can be browsed at:
http://git.linuxtv.org/snawrocki/samsung.git/exynos4-fimc-is-v2

Andrzej Hajda (1):
  s5p-fimc: Add error checks for pipeline stream on callbacks

Sylwester Nawrocki (9):
  V4L: Add MATRIX option to V4L2_CID_EXPOSURE_METERING control
  s5p-fimc: Update graph traversal for entities with multiple source
pads
  s5p-fimc: Add support for PIXELASYNCMx clocks
  s5p-fimc: Add support for ISP Writeback data input bus type
  s5p-fimc: Ensure CAMCLK clock can be enabled by FIMC-LITE devices
  s5p-fimc: Ensure proper s_stream() call order in the ISP datapaths
  s5p-fimc: Ensure proper s_power() call order in the ISP datapaths
  s5p-fimc: Remove dependency on fimc-core.h in fimc-lite driver
  s5p-fimc: Change the driver directory name to exynos4-is

 Documentation/DocBook/media/v4l/controls.xml   |7 +
 drivers/media/platform/Kconfig |2 +-
 drivers/media/platform/Makefile|2 +-
 .../platform/{s5p-fimc = exynos4-is}/Kconfig  |9 +-
 .../platform/{s5p-fimc = exynos4-is}/Makefile |2 +-
 .../{s5p-fimc = exynos4-is}/fimc-capture.c|  194 +---
 .../platform/{s5p-fimc = exynos4-is}/fimc-core.c  |   12 +-
 .../platform/{s5p-fimc = exynos4-is}/fimc-core.h  |   48 ++---
 .../{s5p-fimc = exynos4-is}/fimc-lite-reg.c   |0
 .../{s5p-fimc = exynos4-is}/fimc-lite-reg.h   |0
 .../platform/{s5p-fimc = exynos4-is}/fimc-lite.c  |3 +-
 .../platform/{s5p-fimc = exynos4-is}/fimc-lite.h  |3 +-
 .../platform/{s5p-fimc = exynos4-is}/fimc-m2m.c   |3 +-
 .../platform/{s5p-fimc = exynos4-is}/fimc-reg.c   |   75 ++--
 .../platform/{s5p-fimc = exynos4-is}/fimc-reg.h   |   11 ++
 .../fimc-mdevice.c = exynos4-is/media-dev.c}  |  182 +-
 .../fimc-mdevice.h = exynos4-is/media-dev.h}  |   12 ++
 .../platform/{s5p-fimc = exynos4-is}/mipi-csis.c  |0
 .../platform/{s5p-fimc = exynos4-is}/mipi-csis.h  |0
 drivers/media/v4l2-core/v4l2-ctrls.c   |1 +
 include/media/s5p_fimc.h   |   34 
 include/uapi/linux/v4l2-controls.h |1 +
 22 files changed, 428 insertions(+), 173 deletions(-)
 rename drivers/media/platform/{s5p-fimc = exynos4-is}/Kconfig (86%)
 rename drivers/media/platform/{s5p-fimc = exynos4-is}/Makefile (94%)
 rename drivers/media/platform/{s5p-fimc = exynos4-is}/fimc-capture.c (93%)
 rename drivers/media/platform/{s5p-fimc = exynos4-is}/fimc-core.c (99%)
 rename drivers/media/platform/{s5p-fimc = exynos4-is}/fimc-core.h (94%)
 rename drivers/media/platform/{s5p-fimc = exynos4-is}/fimc-lite-reg.c (100%)
 rename drivers/media/platform/{s5p-fimc = exynos4-is}/fimc-lite-reg.h (100%)
 rename drivers/media/platform/{s5p-fimc = exynos4-is}/fimc-lite.c (99%)
 rename drivers/media/platform/{s5p-fimc = exynos4-is}/fimc-lite.h (99%)
 rename drivers/media/platform/{s5p-fimc = exynos4-is}/fimc-m2m.c (99%)
 rename drivers/media/platform/{s5p-fimc = exynos4-is}/fimc-reg.c (92%)
 rename drivers/media/platform/{s5p-fimc = exynos4-is}/fimc-reg.h (96%)
 rename drivers/media/platform/{s5p-fimc/fimc-mdevice.c = 
exynos4-is/media-dev.c} (89%)
 rename drivers/media/platform/{s5p-fimc/fimc-mdevice.h = 
exynos4-is/media-dev.h} (92%)
 rename drivers/media/platform/{s5p-fimc = exynos4-is}/mipi-csis.c (100%)
 rename drivers/media/platform/{s5p-fimc = exynos4-is}/mipi-csis.h (100%)

--
1.7.9.5

--
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 v2 01/10] V4L: Add MATRIX option to V4L2_CID_EXPOSURE_METERING control

2013-03-26 Thread Sylwester Nawrocki
This patch adds a menu option to the V4L2_CID_EXPOSURE_METERING
control for multi-zone metering.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 Documentation/DocBook/media/v4l/controls.xml |7 +++
 drivers/media/v4l2-core/v4l2-ctrls.c |1 +
 include/uapi/linux/v4l2-controls.h   |1 +
 3 files changed, 9 insertions(+)

diff --git a/Documentation/DocBook/media/v4l/controls.xml 
b/Documentation/DocBook/media/v4l/controls.xml
index 7fe5be1..c5398ed 100644
--- a/Documentation/DocBook/media/v4l/controls.xml
+++ b/Documentation/DocBook/media/v4l/controls.xml
@@ -3159,6 +3159,13 @@ giving priority to the center of the metered 
area./entry
  
entryconstantV4L2_EXPOSURE_METERING_SPOT/constantnbsp;/entry
  entryMeasure only very small area at the center of the 
frame./entry
/row
+   row
+ 
entryconstantV4L2_EXPOSURE_METERING_MATRIX/constantnbsp;/entry
+ entryA multi-zone metering. The light intensity is measured
+in several points of the frame and the the results are combined. The
+algorithm of the zones selection and their significance in calculating the
+final value is device dependant./entry
+   /row
  /tbody
/entrytbl
  /row
diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c 
b/drivers/media/v4l2-core/v4l2-ctrls.c
index 4b45d49..6b56d7b 100644
--- a/drivers/media/v4l2-core/v4l2-ctrls.c
+++ b/drivers/media/v4l2-core/v4l2-ctrls.c
@@ -234,6 +234,7 @@ const char * const *v4l2_ctrl_get_menu(u32 id)
Average,
Center Weighted,
Spot,
+   Matrix,
NULL
};
static const char * const camera_auto_focus_range[] = {
diff --git a/include/uapi/linux/v4l2-controls.h 
b/include/uapi/linux/v4l2-controls.h
index f56c945..22556a2 100644
--- a/include/uapi/linux/v4l2-controls.h
+++ b/include/uapi/linux/v4l2-controls.h
@@ -642,6 +642,7 @@ enum v4l2_exposure_metering {
V4L2_EXPOSURE_METERING_AVERAGE  = 0,
V4L2_EXPOSURE_METERING_CENTER_WEIGHTED  = 1,
V4L2_EXPOSURE_METERING_SPOT = 2,
+   V4L2_EXPOSURE_METERING_MATRIX   = 3,
 };
 
 #define V4L2_CID_SCENE_MODE(V4L2_CID_CAMERA_CLASS_BASE+26)
-- 
1.7.9.5

--
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 v2 02/10] s5p-fimc: Add error checks for pipeline stream on callbacks

2013-03-26 Thread Sylwester Nawrocki
From: Andrzej Hajda a.ha...@samsung.com

set_stream error for pipelines is logged or reported to user
space if possible.

Signed-off-by: Andrzej Hajda a.ha...@samsung.com
Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/platform/s5p-fimc/fimc-capture.c |   15 ++-
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/media/platform/s5p-fimc/fimc-capture.c 
b/drivers/media/platform/s5p-fimc/fimc-capture.c
index 344e85e..3f3ceb2 100644
--- a/drivers/media/platform/s5p-fimc/fimc-capture.c
+++ b/drivers/media/platform/s5p-fimc/fimc-capture.c
@@ -286,8 +286,8 @@ static int start_streaming(struct vb2_queue *q, unsigned 
int count)
fimc_activate_capture(ctx);
 
if (!test_and_set_bit(ST_CAPT_ISP_STREAM, fimc-state))
-   fimc_pipeline_call(fimc, set_stream,
-  fimc-pipeline, 1);
+   return fimc_pipeline_call(fimc, set_stream,
+ fimc-pipeline, 1);
}
 
return 0;
@@ -443,12 +443,17 @@ static void buffer_queue(struct vb2_buffer *vb)
if (vb2_is_streaming(vid_cap-vbq) 
vid_cap-active_buf_cnt = min_bufs 
!test_and_set_bit(ST_CAPT_STREAM, fimc-state)) {
+   int ret;
+
fimc_activate_capture(ctx);
spin_unlock_irqrestore(fimc-slock, flags);
 
-   if (!test_and_set_bit(ST_CAPT_ISP_STREAM, fimc-state))
-   fimc_pipeline_call(fimc, set_stream,
-  fimc-pipeline, 1);
+   if (test_and_set_bit(ST_CAPT_ISP_STREAM, fimc-state))
+   return;
+
+   ret = fimc_pipeline_call(fimc, set_stream, fimc-pipeline, 1);
+   if (ret  0)
+   v4l2_err(vid_cap-vfd, stream on failed: %d\n, ret);
return;
}
spin_unlock_irqrestore(fimc-slock, flags);
-- 
1.7.9.5

--
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 v2 04/10] s5p-fimc: Add support for PIXELASYNCMx clocks

2013-03-26 Thread Sylwester Nawrocki
This patch ads handling of clocks for the CAMBLK subsystem which
is a glue logic for FIMC-IS or LCD controller and FIMC IP.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---

Changes since v1:

 - Do not keep PXLASYNC clocks always enabled. Enable PXLASYNC0
   clock only if video pipeline including FIMC-IS was opened.
   Enabling this clock only when it is actually used decreases
   power consumption a bit.
---
 drivers/media/platform/s5p-fimc/fimc-mdevice.c |   83 
 drivers/media/platform/s5p-fimc/fimc-mdevice.h |   10 +++
 2 files changed, 82 insertions(+), 11 deletions(-)

diff --git a/drivers/media/platform/s5p-fimc/fimc-mdevice.c 
b/drivers/media/platform/s5p-fimc/fimc-mdevice.c
index abd3ad3..c5bc0d1 100644
--- a/drivers/media/platform/s5p-fimc/fimc-mdevice.c
+++ b/drivers/media/platform/s5p-fimc/fimc-mdevice.c
@@ -151,26 +151,48 @@ static int fimc_pipeline_s_power(struct fimc_pipeline *p, 
bool state)
  * __fimc_pipeline_open - update the pipeline information, enable power
  *of all pipeline subdevs and the sensor clock
  * @me: media entity to start graph walk with
- * @prep: true to acquire sensor (and csis) subdevs
+ * @prepare: true to walk the current pipeline and acquire all subdevs
  *
  * Called with the graph mutex held.
  */
 static int __fimc_pipeline_open(struct fimc_pipeline *p,
-   struct media_entity *me, bool prep)
+   struct media_entity *me, bool prepare)
 {
+   struct fimc_md *fmd = entity_to_fimc_mdev(me);
+   struct v4l2_subdev *sd;
int ret;
 
-   if (prep)
+   if (WARN_ON(p == NULL || me == NULL))
+   return -EINVAL;
+
+   if (prepare)
fimc_pipeline_prepare(p, me);
 
-   if (p-subdevs[IDX_SENSOR] == NULL)
+   sd = p-subdevs[IDX_SENSOR];
+   if (sd == NULL)
return -EINVAL;
 
-   ret = fimc_md_set_camclk(p-subdevs[IDX_SENSOR], true);
-   if (ret)
-   return ret;
+   /* Disable PXLASYNC clock if this pipeline includes FIMC-IS */
+   if (!IS_ERR(fmd-wbclk[CLK_IDX_WB_B])  p-subdevs[IDX_IS_ISP]) {
+   ret = clk_prepare_enable(fmd-wbclk[CLK_IDX_WB_B]);
+   if (ret  0)
+   return ret;
+   }
+   ret = fimc_md_set_camclk(sd, true);
+   if (ret  0)
+   goto err_wbclk;
+
+   ret = fimc_pipeline_s_power(p, 1);
+   if (!ret)
+   return 0;
+
+   fimc_md_set_camclk(sd, false);
 
-   return fimc_pipeline_s_power(p, 1);
+err_wbclk:
+   if (!IS_ERR(fmd-wbclk[CLK_IDX_WB_B])  p-subdevs[IDX_IS_ISP])
+   clk_disable_unprepare(fmd-wbclk[CLK_IDX_WB_B]);
+
+   return ret;
 }
 
 /**
@@ -181,15 +203,24 @@ static int __fimc_pipeline_open(struct fimc_pipeline *p,
  */
 static int __fimc_pipeline_close(struct fimc_pipeline *p)
 {
+   struct v4l2_subdev *sd = p ? p-subdevs[IDX_SENSOR] : NULL;
+   struct fimc_md *fmd;
int ret = 0;
 
-   if (!p || !p-subdevs[IDX_SENSOR])
+   if (WARN_ON(sd == NULL))
return -EINVAL;
 
if (p-subdevs[IDX_SENSOR]) {
ret = fimc_pipeline_s_power(p, 0);
-   fimc_md_set_camclk(p-subdevs[IDX_SENSOR], false);
+   fimc_md_set_camclk(sd, false);
}
+
+   fmd = entity_to_fimc_mdev(sd-entity);
+
+   /* Disable PXLASYNC clock if this pipeline includes FIMC-IS */
+   if (!IS_ERR(fmd-wbclk[CLK_IDX_WB_B])  p-subdevs[IDX_IS_ISP])
+   clk_disable_unprepare(fmd-wbclk[CLK_IDX_WB_B]);
+
return ret == -ENXIO ? 0 : ret;
 }
 
@@ -957,7 +988,7 @@ static int fimc_md_create_links(struct fimc_md *fmd)
 }
 
 /*
- * The peripheral sensor clock management.
+ * The peripheral sensor and CAM_BLK (PIXELASYNCMx) clocks management.
  */
 static void fimc_md_put_clocks(struct fimc_md *fmd)
 {
@@ -970,6 +1001,14 @@ static void fimc_md_put_clocks(struct fimc_md *fmd)
clk_put(fmd-camclk[i].clock);
fmd-camclk[i].clock = ERR_PTR(-EINVAL);
}
+
+   /* Writeback (PIXELASYNCMx) clocks */
+   for (i = 0; i  FIMC_MAX_WBCLKS; i++) {
+   if (IS_ERR(fmd-wbclk[i]))
+   continue;
+   clk_put(fmd-wbclk[i]);
+   fmd-wbclk[i] = ERR_PTR(-EINVAL);
+   }
 }
 
 static int fimc_md_get_clocks(struct fimc_md *fmd)
@@ -1006,6 +1045,28 @@ static int fimc_md_get_clocks(struct fimc_md *fmd)
if (ret)
fimc_md_put_clocks(fmd);
 
+   if (!fmd-use_isp)
+   return 0;
+   /*
+* For now get only PIXELASYNCM1 clock (Writeback B/ISP),
+* leave PIXELASYNCM0 out for the LCD Writeback driver.
+*/
+   fmd-wbclk[CLK_IDX_WB_A] = ERR_PTR(-EINVAL);
+
+   for (i = CLK_IDX_WB_B; i  FIMC_MAX_WBCLKS; i++) {
+   snprintf(clk_name, sizeof(clk_name), 

[PATCH v2 06/10] s5p-fimc: Ensure CAMCLK clock can be enabled by FIMC-LITE devices

2013-03-26 Thread Sylwester Nawrocki
In configurations where FIMC-LITE is used to capture image signal
from an external sensor only we need to ensure one of FIMC devices
is in active power state and the fimc gate clock is enabled.
Otherwise the CAMCLK clock output signal will be masked off
preventing an external sensor's operation.
This affect processing pipelines like:

 - sensor - FIMC-LITE - memory
 - sensor - MIPI-CSIS - FIMC-LITE - memory

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/platform/s5p-fimc/fimc-mdevice.c |   18 ++
 drivers/media/platform/s5p-fimc/fimc-mdevice.h |2 ++
 2 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/drivers/media/platform/s5p-fimc/fimc-mdevice.c 
b/drivers/media/platform/s5p-fimc/fimc-mdevice.c
index 5b11e39..d519ee7 100644
--- a/drivers/media/platform/s5p-fimc/fimc-mdevice.c
+++ b/drivers/media/platform/s5p-fimc/fimc-mdevice.c
@@ -507,7 +507,6 @@ static int fimc_md_register_sensor_entities(struct fimc_md 
*fmd)
 {
struct s5p_platform_fimc *pdata = fmd-pdev-dev.platform_data;
struct device_node *of_node = fmd-pdev-dev.of_node;
-   struct fimc_dev *fd = NULL;
int num_clients = 0;
int ret, i;
 
@@ -515,13 +514,10 @@ static int fimc_md_register_sensor_entities(struct 
fimc_md *fmd)
 * Runtime resume one of the FIMC entities to make sure
 * the sclk_cam clocks are not globally disabled.
 */
-   for (i = 0; !fd  i  ARRAY_SIZE(fmd-fimc); i++)
-   if (fmd-fimc[i])
-   fd = fmd-fimc[i];
-   if (!fd)
+   if (!fmd-pmf)
return -ENXIO;
 
-   ret = pm_runtime_get_sync(fd-pdev-dev);
+   ret = pm_runtime_get_sync(fmd-pmf);
if (ret  0)
return ret;
 
@@ -555,7 +551,7 @@ static int fimc_md_register_sensor_entities(struct fimc_md 
*fmd)
}
}
 
-   pm_runtime_put(fd-pdev-dev);
+   pm_runtime_put(fmd-pmf);
return ret;
 }
 
@@ -600,6 +596,8 @@ static int register_fimc_entity(struct fimc_md *fmd, struct 
fimc_dev *fimc)
 
ret = v4l2_device_register_subdev(fmd-v4l2_dev, sd);
if (!ret) {
+   if (!fmd-pmf  fimc-pdev)
+   fmd-pmf = fimc-pdev-dev;
fmd-fimc[fimc-id] = fimc;
fimc-vid_cap.user_subdev_api = fmd-user_subdev_api;
} else {
@@ -1083,7 +1081,7 @@ static int __fimc_md_set_camclk(struct fimc_md *fmd,
struct fimc_camclk_info *camclk;
int ret = 0;
 
-   if (WARN_ON(pdata-clk_id = FIMC_MAX_CAMCLKS) || fmd == NULL)
+   if (WARN_ON(pdata-clk_id = FIMC_MAX_CAMCLKS) || !fmd || !fmd-pmf)
return -EINVAL;
 
camclk = fmd-camclk[pdata-clk_id];
@@ -1099,6 +1097,9 @@ static int __fimc_md_set_camclk(struct fimc_md *fmd,
if (camclk-use_count++ == 0) {
clk_set_rate(camclk-clock, pdata-clk_frequency);
camclk-frequency = pdata-clk_frequency;
+   ret = pm_runtime_get_sync(fmd-pmf);
+   if (ret  0)
+   return ret;
ret = clk_enable(camclk-clock);
dbg(Enabled camclk %d: f: %lu, pdata-clk_id,
clk_get_rate(camclk-clock));
@@ -,6 +1112,7 @@ static int __fimc_md_set_camclk(struct fimc_md *fmd,
 
if (--camclk-use_count == 0) {
clk_disable(camclk-clock);
+   pm_runtime_put(fmd-pmf);
dbg(Disabled camclk %d, pdata-clk_id);
}
return ret;
diff --git a/drivers/media/platform/s5p-fimc/fimc-mdevice.h 
b/drivers/media/platform/s5p-fimc/fimc-mdevice.h
index 46f3b82..1d5cea5 100644
--- a/drivers/media/platform/s5p-fimc/fimc-mdevice.h
+++ b/drivers/media/platform/s5p-fimc/fimc-mdevice.h
@@ -81,6 +81,7 @@ struct fimc_sensor_info {
  * @camclk: external sensor clock information
  * @fimc: array of registered fimc devices
  * @use_isp: set to true when FIMC-IS subsystem is used
+ * @pmf: handle to the CAMCLK clock control FIMC helper device
  * @media_dev: top level media device
  * @v4l2_dev: top level v4l2_device holding up the subdevs
  * @pdev: platform device this media device is hooked up into
@@ -99,6 +100,7 @@ struct fimc_md {
struct fimc_lite *fimc_lite[FIMC_LITE_MAX_DEVS];
struct fimc_dev *fimc[FIMC_MAX_DEVS];
bool use_isp;
+   struct device *pmf;
struct media_device media_dev;
struct v4l2_device v4l2_dev;
struct platform_device *pdev;
-- 
1.7.9.5

--
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 v2 07/10] s5p-fimc: Ensure proper s_stream() call order in the ISP datapaths

2013-03-26 Thread Sylwester Nawrocki
Since the FIMC-IS firmware communicates with an image sensor directly
through the ISP I2C bus controllers data streaming cannot be simply
enabled from left to right or disabled from right to left along the
processing pipeline. Thus a subdev index to call s_stream() on is
looked up from a table, rather than doing the op call based on
increasing/decreasing indexes.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/platform/s5p-fimc/fimc-mdevice.c |   22 +++---
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/drivers/media/platform/s5p-fimc/fimc-mdevice.c 
b/drivers/media/platform/s5p-fimc/fimc-mdevice.c
index d519ee7..53bfd20 100644
--- a/drivers/media/platform/s5p-fimc/fimc-mdevice.c
+++ b/drivers/media/platform/s5p-fimc/fimc-mdevice.c
@@ -225,28 +225,36 @@ static int __fimc_pipeline_close(struct fimc_pipeline *p)
 }
 
 /**
- * __fimc_pipeline_s_stream - invoke s_stream on pipeline subdevs
+ * __fimc_pipeline_s_stream - call s_stream() on pipeline subdevs
  * @pipeline: video pipeline structure
- * @on: passed as the s_stream call argument
+ * @on: passed as the s_stream() callback argument
  */
 static int __fimc_pipeline_s_stream(struct fimc_pipeline *p, bool on)
 {
-   int i, ret;
+   static const u8 seq[2][IDX_MAX] = {
+   { IDX_FIMC, IDX_SENSOR, IDX_IS_ISP, IDX_CSIS, IDX_FLITE },
+   { IDX_CSIS, IDX_FLITE, IDX_FIMC, IDX_SENSOR, IDX_IS_ISP },
+   };
+   int i, ret = 0;
 
if (p-subdevs[IDX_SENSOR] == NULL)
return -ENODEV;
 
for (i = 0; i  IDX_MAX; i++) {
-   unsigned int idx = on ? (IDX_MAX - 1) - i : i;
+   unsigned int idx = seq[on][i];
 
ret = v4l2_subdev_call(p-subdevs[idx], video, s_stream, on);
 
if (ret  0  ret != -ENOIOCTLCMD  ret != -ENODEV)
-   return ret;
+   goto error;
}
-
return 0;
-
+error:
+   for (; i = 0; i--) {
+   unsigned int idx = seq[on][i];
+   v4l2_subdev_call(p-subdevs[idx], video, s_stream, !on);
+   }
+   return ret;
 }
 
 /* Media pipeline operations for the FIMC/FIMC-LITE video device driver */
-- 
1.7.9.5

--
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 v2 08/10] s5p-fimc: Ensure proper s_power() call order in the ISP datapaths

2013-03-26 Thread Sylwester Nawrocki
Since the FIMC-IS firmware communicates with an image sensor directly
through the ISP I2C bus controllers the sub-devices power supplies
cannot be simply enabled from left to right or disabled from right
to left along the processing pipeline. Thus a subdev index to call
s_power() on is looked up from a table, rather than doing the op call
based on increasing/decreasing indexes.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/platform/s5p-fimc/fimc-mdevice.c |   26 
 1 file changed, 18 insertions(+), 8 deletions(-)

diff --git a/drivers/media/platform/s5p-fimc/fimc-mdevice.c 
b/drivers/media/platform/s5p-fimc/fimc-mdevice.c
index 53bfd20..06d1eb4 100644
--- a/drivers/media/platform/s5p-fimc/fimc-mdevice.c
+++ b/drivers/media/platform/s5p-fimc/fimc-mdevice.c
@@ -128,23 +128,33 @@ static int __subdev_set_power(struct v4l2_subdev *sd, int 
on)
  *
  * Needs to be called with the graph mutex held.
  */
-static int fimc_pipeline_s_power(struct fimc_pipeline *p, bool state)
+static int fimc_pipeline_s_power(struct fimc_pipeline *p, bool on)
 {
-   unsigned int i;
-   int ret;
+   static const u8 seq[2][IDX_MAX - 1] = {
+   { IDX_IS_ISP, IDX_SENSOR, IDX_CSIS, IDX_FLITE },
+   { IDX_CSIS, IDX_FLITE, IDX_SENSOR, IDX_IS_ISP },
+   };
+   int i, ret = 0;
 
if (p-subdevs[IDX_SENSOR] == NULL)
return -ENXIO;
 
-   for (i = 0; i  IDX_MAX; i++) {
-   unsigned int idx = state ? (IDX_MAX - 1) - i : i;
+   for (i = 0; i  IDX_MAX - 1; i++) {
+   unsigned int idx = seq[on][i];
+
+   ret = __subdev_set_power(p-subdevs[idx], on);
+
 
-   ret = __subdev_set_power(p-subdevs[idx], state);
if (ret  0  ret != -ENXIO)
-   return ret;
+   goto error;
}
-
return 0;
+error:
+   for (; i = 0; i--) {
+   unsigned int idx = seq[on][i];
+   __subdev_set_power(p-subdevs[idx], !on);
+   }
+   return ret;
 }
 
 /**
-- 
1.7.9.5

--
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 v2 09/10] s5p-fimc: Remove dependency on fimc-core.h in fimc-lite driver

2013-03-26 Thread Sylwester Nawrocki
Drop fimc-lite.h header inclusion to make the exynos-fimc-lite
module independent on other modules. Move struct fimc_fmt
declaration to the driver's private headers as it is used in
multiple modules.

Reported-by: Shaik Ameer Basha shaik.am...@samsung.com
Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/platform/s5p-fimc/fimc-core.h |   31 
 drivers/media/platform/s5p-fimc/fimc-lite.c |1 -
 drivers/media/platform/s5p-fimc/fimc-lite.h |3 +--
 include/media/s5p_fimc.h|   34 +++
 4 files changed, 35 insertions(+), 34 deletions(-)

diff --git a/drivers/media/platform/s5p-fimc/fimc-core.h 
b/drivers/media/platform/s5p-fimc/fimc-core.h
index 6355b33..79a 100644
--- a/drivers/media/platform/s5p-fimc/fimc-core.h
+++ b/drivers/media/platform/s5p-fimc/fimc-core.h
@@ -137,37 +137,6 @@ enum fimc_color_fmt {
 #defineFIMC_COLOR_RANGE_NARROW (1  3)
 
 /**
- * struct fimc_fmt - the driver's internal color format data
- * @mbus_code: Media Bus pixel code, -1 if not applicable
- * @name: format description
- * @fourcc: the fourcc code for this format, 0 if not applicable
- * @color: the corresponding fimc_color_fmt
- * @memplanes: number of physically non-contiguous data planes
- * @colplanes: number of physically contiguous data planes
- * @depth: per plane driver's private 'number of bits per pixel'
- * @mdataplanes: bitmask indicating meta data plane(s), (1  plane_no)
- * @flags: flags indicating which operation mode format applies to
- */
-struct fimc_fmt {
-   enum v4l2_mbus_pixelcode mbus_code;
-   char*name;
-   u32 fourcc;
-   u32 color;
-   u16 memplanes;
-   u16 colplanes;
-   u8  depth[VIDEO_MAX_PLANES];
-   u16 mdataplanes;
-   u16 flags;
-#define FMT_FLAGS_CAM  (1  0)
-#define FMT_FLAGS_M2M_IN   (1  1)
-#define FMT_FLAGS_M2M_OUT  (1  2)
-#define FMT_FLAGS_M2M  (1  1 | 1  2)
-#define FMT_HAS_ALPHA  (1  3)
-#define FMT_FLAGS_COMPRESSED   (1  4)
-#define FMT_FLAGS_WRITEBACK(1  5)
-};
-
-/**
  * struct fimc_dma_offset - pixel offset information for DMA
  * @y_h:   y value horizontal offset
  * @y_v:   y value vertical offset
diff --git a/drivers/media/platform/s5p-fimc/fimc-lite.c 
b/drivers/media/platform/s5p-fimc/fimc-lite.c
index c76a9d6..ca78ac0 100644
--- a/drivers/media/platform/s5p-fimc/fimc-lite.c
+++ b/drivers/media/platform/s5p-fimc/fimc-lite.c
@@ -32,7 +32,6 @@
 #include media/s5p_fimc.h
 
 #include fimc-mdevice.h
-#include fimc-core.h
 #include fimc-lite.h
 #include fimc-lite-reg.h
 
diff --git a/drivers/media/platform/s5p-fimc/fimc-lite.h 
b/drivers/media/platform/s5p-fimc/fimc-lite.h
index 7085761..4c234508 100644
--- a/drivers/media/platform/s5p-fimc/fimc-lite.h
+++ b/drivers/media/platform/s5p-fimc/fimc-lite.h
@@ -20,12 +20,11 @@
 
 #include media/media-entity.h
 #include media/videobuf2-core.h
+#include media/v4l2-ctrls.h
 #include media/v4l2-device.h
 #include media/v4l2-mediabus.h
 #include media/s5p_fimc.h
 
-#include fimc-core.h
-
 #define FIMC_LITE_DRV_NAME exynos-fimc-lite
 #define FLITE_CLK_NAME flite
 #define FIMC_LITE_MAX_DEVS 2
diff --git a/include/media/s5p_fimc.h b/include/media/s5p_fimc.h
index e2434bb..2363aff 100644
--- a/include/media/s5p_fimc.h
+++ b/include/media/s5p_fimc.h
@@ -13,6 +13,7 @@
 #define S5P_FIMC_H_
 
 #include media/media-entity.h
+#include media/v4l2-mediabus.h
 
 /*
  * Enumeration of data inputs to the camera subsystem.
@@ -93,6 +94,39 @@ struct s5p_platform_fimc {
  */
 #define S5P_FIMC_TX_END_NOTIFY _IO('e', 0)
 
+#define FIMC_MAX_PLANES3
+
+/**
+ * struct fimc_fmt - color format data structure
+ * @mbus_code: media bus pixel code, -1 if not applicable
+ * @name: format description
+ * @fourcc: fourcc code for this format, 0 if not applicable
+ * @color: the driver's private color format id
+ * @memplanes: number of physically non-contiguous data planes
+ * @colplanes: number of physically contiguous data planes
+ * @depth: per plane driver's private 'number of bits per pixel'
+ * @mdataplanes: bitmask indicating meta data plane(s), (1  plane_no)
+ * @flags: flags indicating which operation mode format applies to
+ */
+struct fimc_fmt {
+   enum v4l2_mbus_pixelcode mbus_code;
+   char*name;
+   u32 fourcc;
+   u32 color;
+   u16 memplanes;
+   u16 colplanes;
+   u8  depth[FIMC_MAX_PLANES];
+   u16 mdataplanes;
+   u16 flags;
+#define FMT_FLAGS_CAM  (1  0)
+#define FMT_FLAGS_M2M_IN   (1  1)
+#define FMT_FLAGS_M2M_OUT  (1  2)
+#define FMT_FLAGS_M2M  (1  1 | 1  2)
+#define FMT_HAS_ALPHA  (1  3)
+#define FMT_FLAGS_COMPRESSED   (1  4)
+#define FMT_FLAGS_WRITEBACK(1  5)
+};
+
 enum fimc_subdev_index {
IDX_SENSOR,
IDX_CSIS,
-- 
1.7.9.5

--
To 

[PATCH v2 10/10] s5p-fimc: Change the driver directory name to exynos4-is

2013-03-26 Thread Sylwester Nawrocki
The s5p-fimc directory now contains drivers for multiple IP blocks
found in multiple Samsung application processors. This includes FIMC
(CAMIF), MIPI CSIS and FIMC LITE. FIMC-IS (Imaging Subsystem) driver
is going to be put into same directory. Hence we rename it to
exynos4-is as s5p-fimc was only relevant for early version of this
driver, when it only supported FIMC IP block.

The imaging subsystem drivers for Exynos4 SoC series and S5PV210 will
be included in drivers/media/platform/exynos4-is directory, with some
modules shared with exynos5 series, while the rest of exynos5 specific
modules will find their home in drivers/media/platform/exynos5-is.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/platform/Kconfig |2 +-
 drivers/media/platform/Makefile|2 +-
 .../platform/{s5p-fimc = exynos4-is}/Kconfig  |8 
 .../platform/{s5p-fimc = exynos4-is}/Makefile |2 +-
 .../{s5p-fimc = exynos4-is}/fimc-capture.c|2 +-
 .../platform/{s5p-fimc = exynos4-is}/fimc-core.c  |2 +-
 .../platform/{s5p-fimc = exynos4-is}/fimc-core.h  |0
 .../{s5p-fimc = exynos4-is}/fimc-lite-reg.c   |0
 .../{s5p-fimc = exynos4-is}/fimc-lite-reg.h   |0
 .../platform/{s5p-fimc = exynos4-is}/fimc-lite.c  |2 +-
 .../platform/{s5p-fimc = exynos4-is}/fimc-lite.h  |0
 .../platform/{s5p-fimc = exynos4-is}/fimc-m2m.c   |3 +--
 .../platform/{s5p-fimc = exynos4-is}/fimc-reg.c   |2 +-
 .../platform/{s5p-fimc = exynos4-is}/fimc-reg.h   |0
 .../fimc-mdevice.c = exynos4-is/media-dev.c}  |2 +-
 .../fimc-mdevice.h = exynos4-is/media-dev.h}  |0
 .../platform/{s5p-fimc = exynos4-is}/mipi-csis.c  |0
 .../platform/{s5p-fimc = exynos4-is}/mipi-csis.h  |0
 18 files changed, 13 insertions(+), 14 deletions(-)
 rename drivers/media/platform/{s5p-fimc = exynos4-is}/Kconfig (87%)
 rename drivers/media/platform/{s5p-fimc = exynos4-is}/Makefile (94%)
 rename drivers/media/platform/{s5p-fimc = exynos4-is}/fimc-capture.c (99%)
 rename drivers/media/platform/{s5p-fimc = exynos4-is}/fimc-core.c (99%)
 rename drivers/media/platform/{s5p-fimc = exynos4-is}/fimc-core.h (100%)
 rename drivers/media/platform/{s5p-fimc = exynos4-is}/fimc-lite-reg.c (100%)
 rename drivers/media/platform/{s5p-fimc = exynos4-is}/fimc-lite-reg.h (100%)
 rename drivers/media/platform/{s5p-fimc = exynos4-is}/fimc-lite.c (99%)
 rename drivers/media/platform/{s5p-fimc = exynos4-is}/fimc-lite.h (100%)
 rename drivers/media/platform/{s5p-fimc = exynos4-is}/fimc-m2m.c (99%)
 rename drivers/media/platform/{s5p-fimc = exynos4-is}/fimc-reg.c (99%)
 rename drivers/media/platform/{s5p-fimc = exynos4-is}/fimc-reg.h (100%)
 rename drivers/media/platform/{s5p-fimc/fimc-mdevice.c = 
exynos4-is/media-dev.c} (99%)
 rename drivers/media/platform/{s5p-fimc/fimc-mdevice.h = 
exynos4-is/media-dev.h} (100%)
 rename drivers/media/platform/{s5p-fimc = exynos4-is}/mipi-csis.c (100%)
 rename drivers/media/platform/{s5p-fimc = exynos4-is}/mipi-csis.h (100%)

diff --git a/drivers/media/platform/Kconfig b/drivers/media/platform/Kconfig
index 3dcfea6..7813b2a 100644
--- a/drivers/media/platform/Kconfig
+++ b/drivers/media/platform/Kconfig
@@ -122,7 +122,7 @@ config VIDEO_S3C_CAMIF
  will be called s3c-camif.
 
 source drivers/media/platform/soc_camera/Kconfig
-source drivers/media/platform/s5p-fimc/Kconfig
+source drivers/media/platform/exynos4-is/Kconfig
 source drivers/media/platform/s5p-tv/Kconfig
 
 endif # V4L_PLATFORM_DRIVERS
diff --git a/drivers/media/platform/Makefile b/drivers/media/platform/Makefile
index 4817d28..8d691fe 100644
--- a/drivers/media/platform/Makefile
+++ b/drivers/media/platform/Makefile
@@ -28,7 +28,7 @@ obj-$(CONFIG_VIDEO_CODA)  += coda.o
 obj-$(CONFIG_VIDEO_MEM2MEM_DEINTERLACE)+= m2m-deinterlace.o
 
 obj-$(CONFIG_VIDEO_S3C_CAMIF)  += s3c-camif/
-obj-$(CONFIG_VIDEO_SAMSUNG_S5P_FIMC)   += s5p-fimc/
+obj-$(CONFIG_VIDEO_SAMSUNG_EXYNOS4_IS) += exynos4-is/
 obj-$(CONFIG_VIDEO_SAMSUNG_S5P_JPEG)   += s5p-jpeg/
 obj-$(CONFIG_VIDEO_SAMSUNG_S5P_MFC)+= s5p-mfc/
 obj-$(CONFIG_VIDEO_SAMSUNG_S5P_TV) += s5p-tv/
diff --git a/drivers/media/platform/s5p-fimc/Kconfig 
b/drivers/media/platform/exynos4-is/Kconfig
similarity index 87%
rename from drivers/media/platform/s5p-fimc/Kconfig
rename to drivers/media/platform/exynos4-is/Kconfig
index 64c1116..ed96dbc 100644
--- a/drivers/media/platform/s5p-fimc/Kconfig
+++ b/drivers/media/platform/exynos4-is/Kconfig
@@ -1,6 +1,6 @@
 
-config VIDEO_SAMSUNG_S5P_FIMC
-   bool Samsung S5P/EXYNOS SoC camera interface driver (experimental)
+config VIDEO_SAMSUNG_EXYNOS4_IS
+   bool Samsung S5P/EXYNOS4 SoC series Camera Subsystem driver
depends on VIDEO_V4L2  VIDEO_V4L2_SUBDEV_API  PLAT_S5P  PM_RUNTIME
depends on EXPERIMENTAL
depends on MFD_SYSCON
@@ -8,7 +8,7 @@ config 

[PATCH v2 03/10] s5p-fimc: Update graph traversal for entities with multiple source pads

2013-03-26 Thread Sylwester Nawrocki
We cannot assume that the passed entity the fimc_pipeline_prepare()
function is supposed to start the media graph traversal from will
always have its sink pad at pad index 0. Find the starting media
entity's sink pad by iterating over its all pads and checking the
pad flags. This ensures proper handling of FIMC, FIMC-LITE and
FIMC-IS-ISP subdevs that have more than one sink and one source pad.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/platform/s5p-fimc/fimc-mdevice.c |   24 +++-
 1 file changed, 15 insertions(+), 9 deletions(-)

diff --git a/drivers/media/platform/s5p-fimc/fimc-mdevice.c 
b/drivers/media/platform/s5p-fimc/fimc-mdevice.c
index b689166..abd3ad3 100644
--- a/drivers/media/platform/s5p-fimc/fimc-mdevice.c
+++ b/drivers/media/platform/s5p-fimc/fimc-mdevice.c
@@ -40,14 +40,13 @@ static int __fimc_md_set_camclk(struct fimc_md *fmd,
bool on);
 /**
  * fimc_pipeline_prepare - update pipeline information with subdevice pointers
- * @fimc: fimc device terminating the pipeline
+ * @me: media entity terminating the pipeline
  *
  * Caller holds the graph mutex.
  */
 static void fimc_pipeline_prepare(struct fimc_pipeline *p,
  struct media_entity *me)
 {
-   struct media_pad *pad = me-pads[0];
struct v4l2_subdev *sd;
int i;
 
@@ -55,15 +54,21 @@ static void fimc_pipeline_prepare(struct fimc_pipeline *p,
p-subdevs[i] = NULL;
 
while (1) {
-   if (!(pad-flags  MEDIA_PAD_FL_SINK))
-   break;
+   struct media_pad *pad = NULL;
+
+   /* Find remote source pad */
+   for (i = 0; i  me-num_pads; i++) {
+   struct media_pad *spad = me-pads[i];
+   if (!(spad-flags  MEDIA_PAD_FL_SINK))
+   continue;
+   pad = media_entity_remote_source(spad);
+   if (pad)
+   break;
+   }
 
-   /* source pad */
-   pad = media_entity_remote_source(pad);
if (pad == NULL ||
media_entity_type(pad-entity) != MEDIA_ENT_T_V4L2_SUBDEV)
break;
-
sd = media_entity_to_v4l2_subdev(pad-entity);
 
switch (sd-grp_id) {
@@ -84,8 +89,9 @@ static void fimc_pipeline_prepare(struct fimc_pipeline *p,
pr_warn(%s: Unknown subdev grp_id: %#x\n,
__func__, sd-grp_id);
}
-   /* sink pad */
-   pad = sd-entity.pads[0];
+   me = sd-entity;
+   if (me-num_pads == 1)
+   break;
}
 }
 
-- 
1.7.9.5

--
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 v2 05/10] s5p-fimc: Add support for ISP Writeback data input bus type

2013-03-26 Thread Sylwester Nawrocki
A second sink pad is added to each FIMC.N subdev that will be used
to link it to the FIMC-IS-ISP subdev. Only V4L2_MBUS_FMT_YUV10_1X30
format is supported at this pad (FIMC_SD_PAD_SINK_FIFO).

The routine checking for mismatch in the image formats at sides of
the links is updated to account for the fact FIMC.X subdevs now have
sink pads at the pad indexes 0, 1 and source pad at pad index 2.

If link to FIMC.X pad 1 is activated we switch FIMC input data bus
type to the ISP Writeback. Only a single active link to FIMC.X pad 0
or 1 will be allowed at any time.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---

Changes since v1:

 - Use the syscon interface for SYSREG block registers access,
 - updated fimc_validate_pipeline() function to properly walk
   whole pipeline.
---
 drivers/media/platform/s5p-fimc/Kconfig|1 +
 drivers/media/platform/s5p-fimc/fimc-capture.c |  177 
 drivers/media/platform/s5p-fimc/fimc-core.c|   10 ++
 drivers/media/platform/s5p-fimc/fimc-core.h|   19 ++-
 drivers/media/platform/s5p-fimc/fimc-mdevice.c |7 +-
 drivers/media/platform/s5p-fimc/fimc-reg.c |   75 --
 drivers/media/platform/s5p-fimc/fimc-reg.h |   11 ++
 7 files changed, 221 insertions(+), 79 deletions(-)

diff --git a/drivers/media/platform/s5p-fimc/Kconfig 
b/drivers/media/platform/s5p-fimc/Kconfig
index c16b20d..64c1116 100644
--- a/drivers/media/platform/s5p-fimc/Kconfig
+++ b/drivers/media/platform/s5p-fimc/Kconfig
@@ -3,6 +3,7 @@ config VIDEO_SAMSUNG_S5P_FIMC
bool Samsung S5P/EXYNOS SoC camera interface driver (experimental)
depends on VIDEO_V4L2  VIDEO_V4L2_SUBDEV_API  PLAT_S5P  PM_RUNTIME
depends on EXPERIMENTAL
+   depends on MFD_SYSCON
help
  Say Y here to enable camera host interface devices for
  Samsung S5P and EXYNOS SoC series.
diff --git a/drivers/media/platform/s5p-fimc/fimc-capture.c 
b/drivers/media/platform/s5p-fimc/fimc-capture.c
index 3f3ceb2..4d79d64 100644
--- a/drivers/media/platform/s5p-fimc/fimc-capture.c
+++ b/drivers/media/platform/s5p-fimc/fimc-capture.c
@@ -33,26 +33,27 @@
 
 static int fimc_capture_hw_init(struct fimc_dev *fimc)
 {
+   struct fimc_source_info *si = fimc-vid_cap.source_config;
struct fimc_ctx *ctx = fimc-vid_cap.ctx;
-   struct fimc_pipeline *p = fimc-pipeline;
-   struct fimc_sensor_info *sensor;
+   int ret;
unsigned long flags;
-   int ret = 0;
 
-   if (p-subdevs[IDX_SENSOR] == NULL || ctx == NULL)
-   return -ENXIO;
-   if (ctx-s_frame.fmt == NULL)
+   if (ctx == NULL || ctx-s_frame.fmt == NULL)
return -EINVAL;
 
-   sensor = v4l2_get_subdev_hostdata(p-subdevs[IDX_SENSOR]);
+   if (si-fimc_bus_type == FIMC_BUS_TYPE_ISP_WRITEBACK) {
+   ret = fimc_hw_camblk_cfg_writeback(fimc);
+   if (ret  0)
+   return ret;
+   }
 
spin_lock_irqsave(fimc-slock, flags);
fimc_prepare_dma_offset(ctx, ctx-d_frame);
fimc_set_yuv_order(ctx);
 
-   fimc_hw_set_camera_polarity(fimc, sensor-pdata);
-   fimc_hw_set_camera_type(fimc, sensor-pdata);
-   fimc_hw_set_camera_source(fimc, sensor-pdata);
+   fimc_hw_set_camera_polarity(fimc, si);
+   fimc_hw_set_camera_type(fimc, si);
+   fimc_hw_set_camera_source(fimc, si);
fimc_hw_set_camera_offset(fimc, ctx-s_frame);
 
ret = fimc_set_scaler_info(ctx);
@@ -606,18 +607,22 @@ static struct fimc_fmt *fimc_capture_try_format(struct 
fimc_ctx *ctx,
fimc_fmt_is_user_defined(ctx-s_frame.fmt-color))
*code = ctx-s_frame.fmt-mbus_code;
 
-   if (fourcc  *fourcc != V4L2_PIX_FMT_JPEG  pad != FIMC_SD_PAD_SINK)
+   if (fourcc  *fourcc != V4L2_PIX_FMT_JPEG  pad == FIMC_SD_PAD_SOURCE)
mask |= FMT_FLAGS_M2M;
 
+   if (pad == FIMC_SD_PAD_SINK_FIFO)
+   mask = FMT_FLAGS_WRITEBACK;
+
ffmt = fimc_find_format(fourcc, code, mask, 0);
if (WARN_ON(!ffmt))
return NULL;
+
if (code)
*code = ffmt-mbus_code;
if (fourcc)
*fourcc = ffmt-fourcc;
 
-   if (pad == FIMC_SD_PAD_SINK) {
+   if (pad != FIMC_SD_PAD_SOURCE) {
max_w = fimc_fmt_is_user_defined(ffmt-color) ?
pl-scaler_dis_w : pl-scaler_en_w;
/* Apply the camera input interface pixel constraints */
@@ -851,7 +856,7 @@ static int fimc_pipeline_try_format(struct fimc_ctx *ctx,
tfmt-width  = mf-width;
tfmt-height = mf-height;
ffmt = fimc_capture_try_format(ctx, tfmt-width, tfmt-height,
-   NULL, fcc, FIMC_SD_PAD_SINK);
+   NULL, fcc, FIMC_SD_PAD_SINK_CAM);
ffmt = fimc_capture_try_format(ctx, tfmt-width, tfmt-height,
  

[PATCH v2 0/7] V4L2 driver for Exynos4x12 Imaging Subsystem

2013-03-26 Thread Sylwester Nawrocki
This iteration includes couple bug fixes and minor cleanup comparing
to the original version (original cover letter can be found below).
A patch adding ISP capture node has been removed as I'll need more
time to enable this feature and I'd like to possibly have this series
included in 3.10.
   ---

This patch series is an initial version of a driver for the camera ISP
subsystem (FIMC-IS) found in Samsung Exynos4x12 SoCs.

The FIMC-IS subsystem is build around a ARM Cortex-A5 CPU that controls
its dedicated peripherals, like I2C, SPI, UART, PWM, ADC,...  and the
ISP chain. There are 3 hardware image processing blocks: ISP, DRC
(dynamic range compression) and FD (face detection) that are normally
controlled by the Cortex-A5 firmware.

The driver currently exposes two additional sub-devices to user space:
the image sensor and FIMC-IS-ISP sub-device. Another one might be
added in future for the FD features.

The FIMC-IS has various data inputs, it can capture data from memory
or from other SoC IP blocks (FIMC-LITE). It is currently plugged
between FIMC-LITE and FIMC IP blocks, so there is a media pipeline
like:

sensor - MIPI-CSIS - FIMC-LITE - FIMC-IS-ISP - FIMC - memory

A raw Bayer image data can be captured from the ISP block which has
it's own DMA engines. Support for this is not really included in
this series though, only a video capture node driver stubs are added.

This is a bit complicated code, nevertheless I would really appreciate
any review comments you might have.

And this is just a basic set of futures this patch series addresses.
Others include input/output DMA support for the DRC and FD blocks,
support for more ISP controls, etc.


Full git tree with all dependencies can be found at:
http://git.linuxtv.org/snawrocki/samsung.git/exynos4-fimc-is-v2

Sylwester Nawrocki (7):
  exynos4-is: Add Exynos4x12 FIMC-IS driver
  exynos4-is: Add FIMC-IS ISP I2C bus driver
  exynos4-is: Add FIMC-IS parameter region definitions
  exynos4-is: Add common FIMC-IS image sensor driver
  exynos4-is: Add Exynos4x12 FIMC-IS device tree bindings documentation
  s5p-fimc: Add fimc-is subdevs registration
  s5p-fimc: Create media links for the FIMC-IS entities

 .../devicetree/bindings/media/exynos4-fimc-is.txt  |   45 +
 drivers/media/platform/exynos4-is/Kconfig  |   13 +
 drivers/media/platform/exynos4-is/Makefile |3 +
 .../media/platform/exynos4-is/fimc-is-command.h|  147 +++
 drivers/media/platform/exynos4-is/fimc-is-errno.c  |  272 ++
 drivers/media/platform/exynos4-is/fimc-is-errno.h  |  248 +
 drivers/media/platform/exynos4-is/fimc-is-i2c.c|   81 ++
 drivers/media/platform/exynos4-is/fimc-is-i2c.h|   15 +
 drivers/media/platform/exynos4-is/fimc-is-param.c  |  971 +++
 drivers/media/platform/exynos4-is/fimc-is-param.h  | 1022 
 drivers/media/platform/exynos4-is/fimc-is-regs.c   |  242 +
 drivers/media/platform/exynos4-is/fimc-is-regs.h   |  164 
 drivers/media/platform/exynos4-is/fimc-is-sensor.c |  307 ++
 drivers/media/platform/exynos4-is/fimc-is-sensor.h |   80 ++
 drivers/media/platform/exynos4-is/fimc-is.c|  962 ++
 drivers/media/platform/exynos4-is/fimc-is.h|  340 +++
 drivers/media/platform/exynos4-is/fimc-isp.c   |  707 ++
 drivers/media/platform/exynos4-is/fimc-isp.h   |  181 
 drivers/media/platform/exynos4-is/media-dev.c  |  120 ++-
 drivers/media/platform/exynos4-is/media-dev.h  |   13 +
 20 files changed, 5911 insertions(+), 22 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/media/exynos4-fimc-is.txt
 create mode 100644 drivers/media/platform/exynos4-is/fimc-is-command.h
 create mode 100644 drivers/media/platform/exynos4-is/fimc-is-errno.c
 create mode 100644 drivers/media/platform/exynos4-is/fimc-is-errno.h
 create mode 100644 drivers/media/platform/exynos4-is/fimc-is-i2c.c
 create mode 100644 drivers/media/platform/exynos4-is/fimc-is-i2c.h
 create mode 100644 drivers/media/platform/exynos4-is/fimc-is-param.c
 create mode 100644 drivers/media/platform/exynos4-is/fimc-is-param.h
 create mode 100644 drivers/media/platform/exynos4-is/fimc-is-regs.c
 create mode 100644 drivers/media/platform/exynos4-is/fimc-is-regs.h
 create mode 100644 drivers/media/platform/exynos4-is/fimc-is-sensor.c
 create mode 100644 drivers/media/platform/exynos4-is/fimc-is-sensor.h
 create mode 100644 drivers/media/platform/exynos4-is/fimc-is.c
 create mode 100644 drivers/media/platform/exynos4-is/fimc-is.h
 create mode 100644 drivers/media/platform/exynos4-is/fimc-isp.c
 create mode 100644 drivers/media/platform/exynos4-is/fimc-isp.h

--
1.7.9.5

--
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 v2 2/7] exynos4-is: Add FIMC-IS ISP I2C bus driver

2013-03-26 Thread Sylwester Nawrocki
This patch adds the ISP I2C bus controller driver files.

Creating a standard I2C bus adapter, even if the driver doesn't
actually communicates with the hardware and it is instead used
by the ISP firmware running on the Cortex-A5, allows to use
standard hardware description in the device tree. As the sensor
would have actually had a standard V4L2 sub-device driver run
on the host CPU.

This approach allows to adapt the driver with a relatively small
effort should the Imaging Subsystem architecture change so that
the I2C bus is controlled by the host CPU, rather than the
internal FIMC-IS ARM CPU. The image sensor drivers can be
standard I2C client driver, as in case of most existing image
sensor driver.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/platform/exynos4-is/fimc-is-i2c.c |   81 +++
 drivers/media/platform/exynos4-is/fimc-is-i2c.h |   15 +
 2 files changed, 96 insertions(+)
 create mode 100644 drivers/media/platform/exynos4-is/fimc-is-i2c.c
 create mode 100644 drivers/media/platform/exynos4-is/fimc-is-i2c.h

diff --git a/drivers/media/platform/exynos4-is/fimc-is-i2c.c 
b/drivers/media/platform/exynos4-is/fimc-is-i2c.c
new file mode 100644
index 000..d4c75dc
--- /dev/null
+++ b/drivers/media/platform/exynos4-is/fimc-is-i2c.c
@@ -0,0 +1,81 @@
+/*
+ * Samsung EXYNOS4x12 FIMC-IS (Imaging Subsystem) driver
+ *
+ * Copyright (C) 2013 Samsung Electronics Co., Ltd.
+ * Sylwester Nawrocki s.nawro...@samsung.com
+ *
+ * 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.
+ */
+#define pr_fmt(fmt) %s:%d  fmt, __func__, __LINE__
+
+#include linux/module.h
+#include linux/of_i2c.h
+#include linux/platform_device.h
+#include fimc-is-i2c.h
+
+/*
+ * An empty algorithm is used as the actual I2C bus controller driver
+ * is implemented in the FIMC-IS subsystem firmware and the host CPU
+ * doesn't touch the hardware.
+ */
+static const struct i2c_algorithm fimc_is_i2c_algorithm;
+
+static int fimc_is_i2c_probe(struct platform_device *pdev)
+{
+   struct device_node *node = pdev-dev.of_node;
+   struct i2c_adapter *i2c_adap;
+   int ret;
+
+   i2c_adap = devm_kzalloc(pdev-dev, sizeof(*i2c_adap), GFP_KERNEL);
+
+   i2c_adap-dev.of_node = node;
+   i2c_adap-dev.parent = pdev-dev;
+   strlcpy(i2c_adap-name, exynos4x12-is-i2c, sizeof(i2c_adap-name));
+   i2c_adap-owner = THIS_MODULE;
+   i2c_adap-algo = fimc_is_i2c_algorithm;
+   i2c_adap-class = I2C_CLASS_SPD;
+
+   ret = i2c_add_adapter(i2c_adap);
+   if (ret  0) {
+   dev_err(pdev-dev, failed to add I2C bus %s\n,
+   node-full_name);
+   return ret;
+   }
+   of_i2c_register_devices(i2c_adap);
+
+   return 0;
+}
+
+static int fimc_is_i2c_remove(struct platform_device *pdev)
+{
+   return 0;
+}
+
+static const struct of_device_id fimc_is_i2c_of_match[] = {
+   { .compatible = FIMC_IS_I2C_COMPATIBLE },
+   { },
+};
+MODULE_DEVICE_TABLE(of, fimc_is_i2c_of_match);
+
+static struct platform_driver fimc_is_i2c_driver = {
+   .probe  = fimc_is_i2c_probe,
+   .remove = fimc_is_i2c_remove,
+   .driver = {
+   .of_match_table = fimc_is_i2c_of_match,
+   .name   = fimc-is-i2c,
+   .owner  = THIS_MODULE,
+   }
+};
+
+int fimc_is_register_i2c_driver(void)
+{
+   return platform_driver_register(fimc_is_i2c_driver);
+}
+
+void fimc_is_unregister_i2c_driver(void)
+{
+   platform_driver_unregister(fimc_is_i2c_driver);
+}
+
diff --git a/drivers/media/platform/exynos4-is/fimc-is-i2c.h 
b/drivers/media/platform/exynos4-is/fimc-is-i2c.h
new file mode 100644
index 000..0d38d6b
--- /dev/null
+++ b/drivers/media/platform/exynos4-is/fimc-is-i2c.h
@@ -0,0 +1,15 @@
+/*
+ * Samsung EXYNOS4x12 FIMC-IS (Imaging Subsystem) driver
+ *
+ * Copyright (C) 2013 Samsung Electronics Co., Ltd.
+ * Sylwester Nawrocki s.nawro...@samsung.com
+ *
+ * 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.
+ */
+
+#define FIMC_IS_I2C_COMPATIBLE samsung,exynos4212-i2c-isp
+
+int fimc_is_register_i2c_driver(void);
+void fimc_is_unregister_i2c_driver(void);
-- 
1.7.9.5

--
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 v2 3/7] exynos4-is: Add FIMC-IS parameter region definitions

2013-03-26 Thread Sylwester Nawrocki
This patch adds ISP processing parameters interface files.

Signed-off-by: Younghwan Joo yhwan@samsung.com
Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/platform/exynos4-is/fimc-is-param.c |  971 
 drivers/media/platform/exynos4-is/fimc-is-param.h | 1022 +
 2 files changed, 1993 insertions(+)
 create mode 100644 drivers/media/platform/exynos4-is/fimc-is-param.c
 create mode 100644 drivers/media/platform/exynos4-is/fimc-is-param.h

diff --git a/drivers/media/platform/exynos4-is/fimc-is-param.c 
b/drivers/media/platform/exynos4-is/fimc-is-param.c
new file mode 100644
index 000..5674c3b
--- /dev/null
+++ b/drivers/media/platform/exynos4-is/fimc-is-param.c
@@ -0,0 +1,971 @@
+/*
+ * Samsung EXYNOS4x12 FIMC-IS (Imaging Subsystem) driver
+ *
+ * Copyright (C) 2013 Samsung Electronics Co., Ltd.
+ *
+ * Authors: Younghwan Joo yhwan@samsung.com
+ *  Sylwester Nawrocki s.nawro...@samsung.com
+ *
+ * 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.
+ */
+#define pr_fmt(fmt) %s:%d  fmt, __func__, __LINE__
+
+#include linux/bug.h
+#include linux/device.h
+#include linux/delay.h
+#include linux/errno.h
+#include linux/firmware.h
+#include linux/gpio.h
+#include plat/gpio-cfg.h
+#include linux/interrupt.h
+#include linux/kernel.h
+#include linux/list.h
+#include linux/module.h
+#include linux/types.h
+#include linux/platform_device.h
+#include linux/pm_runtime.h
+#include linux/slab.h
+#include linux/videodev2.h
+
+#include media/v4l2-device.h
+#include media/v4l2-ioctl.h
+#include media/v4l2-mem2mem.h
+#include media/videobuf2-core.h
+#include media/videobuf2-dma-contig.h
+
+#include fimc-is.h
+#include fimc-is-command.h
+#include fimc-is-errno.h
+#include fimc-is-param.h
+#include fimc-is-regs.h
+#include fimc-is-sensor.h
+
+static void __hw_param_copy(void *dst, void *src)
+{
+   memcpy(dst, src, FIMC_IS_PARAM_MAX_SIZE);
+}
+
+void __fimc_is_hw_update_param_global_shotmode(struct fimc_is *is)
+{
+   struct param_global_shotmode *dst, *src;
+
+   dst = is-is_p_region-parameter.global.shotmode;
+   src = is-cfg_param[is-scenario_id].global.shotmode;
+   __hw_param_copy(dst, src);
+}
+
+void __fimc_is_hw_update_param_sensor_framerate(struct fimc_is *is)
+{
+   struct param_sensor_framerate *dst, *src;
+
+   dst = is-is_p_region-parameter.sensor.frame_rate;
+   src = is-cfg_param[is-scenario_id].sensor.frame_rate;
+   __hw_param_copy(dst, src);
+}
+
+int __fimc_is_hw_update_param(struct fimc_is *is, u32 offset)
+{
+   struct is_param_region *par = is-is_p_region-parameter;
+   struct is_config_param *cfg = is-cfg_param[is-scenario_id];
+
+   switch (offset) {
+   case PARAM_ISP_CONTROL:
+   __hw_param_copy(par-isp.control, cfg-isp.control);
+   break;
+
+   case PARAM_ISP_OTF_INPUT:
+   __hw_param_copy(par-isp.otf_input, cfg-isp.otf_input);
+   break;
+
+   case PARAM_ISP_DMA1_INPUT:
+   __hw_param_copy(par-isp.dma1_input, cfg-isp.dma1_input);
+   break;
+
+   case PARAM_ISP_DMA2_INPUT:
+   __hw_param_copy(par-isp.dma2_input, cfg-isp.dma2_input);
+   break;
+
+   case PARAM_ISP_AA:
+   __hw_param_copy(par-isp.aa, cfg-isp.aa);
+   break;
+
+   case PARAM_ISP_FLASH:
+   __hw_param_copy(par-isp.flash, cfg-isp.flash);
+   break;
+
+   case PARAM_ISP_AWB:
+   __hw_param_copy(par-isp.awb, cfg-isp.awb);
+   break;
+
+   case PARAM_ISP_IMAGE_EFFECT:
+   __hw_param_copy(par-isp.effect, cfg-isp.effect);
+   break;
+
+   case PARAM_ISP_ISO:
+   __hw_param_copy(par-isp.iso, cfg-isp.iso);
+   break;
+
+   case PARAM_ISP_ADJUST:
+   __hw_param_copy(par-isp.adjust, cfg-isp.adjust);
+   break;
+
+   case PARAM_ISP_METERING:
+   __hw_param_copy(par-isp.metering, cfg-isp.metering);
+   break;
+
+   case PARAM_ISP_AFC:
+   __hw_param_copy(par-isp.afc, cfg-isp.afc);
+   break;
+
+   case PARAM_ISP_OTF_OUTPUT:
+   __hw_param_copy(par-isp.otf_output, cfg-isp.otf_output);
+   break;
+
+   case PARAM_ISP_DMA1_OUTPUT:
+   __hw_param_copy(par-isp.dma1_output, cfg-isp.dma1_output);
+   break;
+
+   case PARAM_ISP_DMA2_OUTPUT:
+   __hw_param_copy(par-isp.dma2_output, cfg-isp.dma2_output);
+   break;
+
+   case PARAM_DRC_CONTROL:
+   __hw_param_copy(par-drc.control, cfg-drc.control);
+   break;
+
+   case PARAM_DRC_OTF_INPUT:
+   __hw_param_copy(par-drc.otf_input, 

[PATCH v2 4/7] exynos4-is: Add common FIMC-IS image sensor driver

2013-03-26 Thread Sylwester Nawrocki
This patch adds a common image sensor driver and Makefile/Kconfig
to enable cpmpilation of the whole IS drives.

The sensor subdev driver currently only handles an image sensor's
power supplies and reset signal. There is no an I2C communication
as it is handled by the ISP's firmware.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/platform/exynos4-is/Kconfig  |   13 +
 drivers/media/platform/exynos4-is/Makefile |3 +
 drivers/media/platform/exynos4-is/fimc-is-sensor.c |  307 
 drivers/media/platform/exynos4-is/fimc-is-sensor.h |   80 +
 4 files changed, 403 insertions(+)
 create mode 100644 drivers/media/platform/exynos4-is/fimc-is-sensor.c
 create mode 100644 drivers/media/platform/exynos4-is/fimc-is-sensor.h

diff --git a/drivers/media/platform/exynos4-is/Kconfig 
b/drivers/media/platform/exynos4-is/Kconfig
index ed96dbc..c72d6b5 100644
--- a/drivers/media/platform/exynos4-is/Kconfig
+++ b/drivers/media/platform/exynos4-is/Kconfig
@@ -47,4 +47,17 @@ config VIDEO_EXYNOS_FIMC_LITE
  module will be called exynos-fimc-lite.
 endif
 
+if (SOC_EXYNOS4212 || SOC_EXYNOS4412)  OF  !ARCH_MULTIPLATFORM
+
+config VIDEO_EXYNOS4_FIMC_IS
+   tristate EXYNOS4x12 FIMC-IS (Imaging Subsystem) driver
+   select VIDEOBUF2_DMA_CONTIG
+   help
+ This is a V4L2 driver for Samsung EXYNOS4x12 SoC series
+ FIMC-IS (Imaging Subsystem).
+
+ To compile this driver as a module, choose M here: the
+ module will be called exynos4-fimc-is.
+endif
+
 endif # VIDEO_SAMSUNG_S5P_FIMC
diff --git a/drivers/media/platform/exynos4-is/Makefile 
b/drivers/media/platform/exynos4-is/Makefile
index 8c67441..f25f463 100644
--- a/drivers/media/platform/exynos4-is/Makefile
+++ b/drivers/media/platform/exynos4-is/Makefile
@@ -1,7 +1,10 @@
 s5p-fimc-objs := fimc-core.o fimc-reg.o fimc-m2m.o fimc-capture.o media-dev.o
 exynos-fimc-lite-objs += fimc-lite-reg.o fimc-lite.o
+exynos-fimc-is-objs := fimc-is.o fimc-isp.o fimc-is-sensor.o fimc-is-regs.o
+exynos-fimc-is-objs += fimc-is-param.o fimc-is-errno.o fimc-is-i2c.o
 s5p-csis-objs := mipi-csis.o
 
 obj-$(CONFIG_VIDEO_S5P_MIPI_CSIS)  += s5p-csis.o
 obj-$(CONFIG_VIDEO_EXYNOS_FIMC_LITE)   += exynos-fimc-lite.o
+obj-$(CONFIG_VIDEO_EXYNOS4_FIMC_IS)+= exynos-fimc-is.o
 obj-$(CONFIG_VIDEO_S5P_FIMC)   += s5p-fimc.o
diff --git a/drivers/media/platform/exynos4-is/fimc-is-sensor.c 
b/drivers/media/platform/exynos4-is/fimc-is-sensor.c
new file mode 100644
index 000..9084437
--- /dev/null
+++ b/drivers/media/platform/exynos4-is/fimc-is-sensor.c
@@ -0,0 +1,307 @@
+/*
+ * Samsung EXYNOS4x12 FIMC-IS (Imaging Subsystem) driver
+ *
+ * Copyright (C) 2013 Samsung Electronics Co., Ltd.
+ * Sylwester Nawrocki s.nawro...@samsung.com
+ *
+ * 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/device.h
+#include linux/errno.h
+#include linux/gpio.h
+#include linux/interrupt.h
+#include linux/io.h
+#include linux/irq.h
+#include linux/kernel.h
+#include linux/memory.h
+#include linux/module.h
+#include linux/of_gpio.h
+#include linux/regulator/consumer.h
+#include linux/slab.h
+#include media/v4l2-subdev.h
+
+#include fimc-is.h
+#include fimc-is-sensor.h
+
+#define DRIVER_NAME FIMC-IS-SENSOR
+
+static const char * const sensor_supply_names[] = {
+   svdda,
+   svddio,
+};
+
+static const struct v4l2_mbus_framefmt fimc_is_sensor_formats[] = {
+   {
+   .code = V4L2_MBUS_FMT_SGRBG10_1X10,
+   .colorspace = V4L2_COLORSPACE_SRGB,
+   .field = V4L2_FIELD_NONE,
+   }
+};
+
+static struct fimc_is_sensor *sd_to_fimc_is_sensor(struct v4l2_subdev *sd)
+{
+   return container_of(sd, struct fimc_is_sensor, subdev);
+}
+
+static const struct v4l2_mbus_framefmt *find_sensor_format(
+   struct v4l2_mbus_framefmt *mf)
+{
+   int i;
+
+   for (i = 0; i  ARRAY_SIZE(fimc_is_sensor_formats); i++)
+   if (mf-code == fimc_is_sensor_formats[i].code)
+   return fimc_is_sensor_formats[i];
+
+   return fimc_is_sensor_formats[0];
+}
+
+static int fimc_is_sensor_enum_mbus_code(struct v4l2_subdev *sd,
+ struct v4l2_subdev_fh *fh,
+ struct v4l2_subdev_mbus_code_enum *code)
+{
+   if (code-index = ARRAY_SIZE(fimc_is_sensor_formats))
+   return -EINVAL;
+
+   code-code = fimc_is_sensor_formats[code-index].code;
+   return 0;
+}
+
+static void fimc_is_sensor_try_format(struct fimc_is_sensor *sensor,
+ struct v4l2_mbus_framefmt *mf)
+{
+   const struct sensor_drv_data *dd = sensor-drvdata;
+   const struct v4l2_mbus_framefmt *fmt;
+
+   fmt = 

[PATCH v2 5/7] exynos4-is: Add Exynos4x12 FIMC-IS device tree bindings documentation

2013-03-26 Thread Sylwester Nawrocki
Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 .../devicetree/bindings/media/exynos4-fimc-is.txt  |   45 
 1 file changed, 45 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/media/exynos4-fimc-is.txt

diff --git a/Documentation/devicetree/bindings/media/exynos4-fimc-is.txt 
b/Documentation/devicetree/bindings/media/exynos4-fimc-is.txt
new file mode 100644
index 000..476eac8
--- /dev/null
+++ b/Documentation/devicetree/bindings/media/exynos4-fimc-is.txt
@@ -0,0 +1,45 @@
+Exynos4x12 SoC series Imaging Subsystem (FIMC-IS)
+
+The FIMC-IS is a subsystem for processing image signal from an image sensor.
+The Exynos4x12 SoC series FIMC-IS V1.5 comprises of a dedicated ARM Cortex-A5
+processor, ISP, DRC and FD IP blocks and peripheral devices such as UART, I2C
+and SPI bus controllers, PWM and ADC.
+
+fimc-is node
+
+
+Required properties:
+
+- compatible   : should be samsung,exynos4212-fimc-is for Exynos4212 and
+ Exynos4412 SoCs;
+- reg  : physical base address and size of the device memory mapped
+ registers;
+- interrupts   : should contain FIMC-IS interrupts;
+- clocks   : list of clock specifiers, corresponding to entries in
+ clock-names property;
+- clock-names  : must contain ppmuispx, ppmuispx, flite0, flite1
+ entries, matching entries in the clocks property.
+
+pmu subnode
+---
+
+Required properties:
+ - reg : should contain PMU physical base address and size of the memory
+ mapped registers, size should be 0x3000.
+
+
+The following are the FIMC-IS peripheral device nodes and can be specified
+either standalone or as the fimc-is node child nodes.
+
+i2c-isp (ISP I2C bus controller) nodes
+--
+
+Required properties:
+
+- compatible   : should be samsung,exynos4212-i2c-isp for Exynos4212 and
+ Exynos4412 SoCs;
+- reg  : physical base address and size of the device memory mapped
+ registers;
+
+For the above nodes it is required to specify a pinctrl state named default,
+according to the pinctrl bindings defined in ../pinctrl/pinctrl-bindings.txt.
-- 
1.7.9.5

--
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 v2 7/7] s5p-fimc: Create media links for the FIMC-IS entities

2013-03-26 Thread Sylwester Nawrocki
Create disabled links from the FIMC-LITE subdevs to the FIMC-IS-ISP
subdev and from FIMC-IS-ISP to all FIMC subdevs.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/platform/exynos4-is/media-dev.c |   83 +++--
 1 file changed, 64 insertions(+), 19 deletions(-)

diff --git a/drivers/media/platform/exynos4-is/media-dev.c 
b/drivers/media/platform/exynos4-is/media-dev.c
index 5e1c28e..e5e0c37 100644
--- a/drivers/media/platform/exynos4-is/media-dev.c
+++ b/drivers/media/platform/exynos4-is/media-dev.c
@@ -836,12 +836,19 @@ static int __fimc_md_create_fimc_sink_links(struct 
fimc_md *fmd,
struct v4l2_subdev *sensor,
int pad, int link_mask)
 {
-   struct fimc_sensor_info *s_info = NULL;
+   struct fimc_sensor_info *si = NULL;
struct media_entity *sink;
unsigned int flags = 0;
-   int ret, i;
+   int i, ret = 0;
 
-   for (i = 0; i  FIMC_MAX_DEVS; i++) {
+   if (sensor) {
+   si = v4l2_get_subdev_hostdata(sensor);
+   /* Skip direct FIMC links in the logical FIMC-IS sensor path */
+   if (si  si-pdata.fimc_bus_type == 
FIMC_BUS_TYPE_ISP_WRITEBACK)
+   ret = 1;
+   }
+
+   for (i = 0; !ret  i  FIMC_MAX_DEVS; i++) {
if (!fmd-fimc[i])
continue;
/*
@@ -870,11 +877,11 @@ static int __fimc_md_create_fimc_sink_links(struct 
fimc_md *fmd,
 
if (flags == 0 || sensor == NULL)
continue;
-   s_info = v4l2_get_subdev_hostdata(sensor);
-   if (!WARN_ON(s_info == NULL)) {
+
+   if (!WARN_ON(si == NULL)) {
unsigned long irq_flags;
spin_lock_irqsave(fmd-slock, irq_flags);
-   s_info-host = fmd-fimc[i];
+   si-host = fmd-fimc[i];
spin_unlock_irqrestore(fmd-slock, irq_flags);
}
}
@@ -883,25 +890,20 @@ static int __fimc_md_create_fimc_sink_links(struct 
fimc_md *fmd,
if (!fmd-fimc_lite[i])
continue;
 
-   if (link_mask  (1  (i + FIMC_MAX_DEVS)))
-   flags = MEDIA_LNK_FL_ENABLED;
-   else
-   flags = 0;
-
sink = fmd-fimc_lite[i]-subdev.entity;
ret = media_entity_create_link(source, pad, sink,
-  FLITE_SD_PAD_SINK, flags);
+  FLITE_SD_PAD_SINK, 0);
if (ret)
return ret;
 
/* Notify FIMC-LITE subdev entity */
ret = media_entity_call(sink, link_setup, sink-pads[0],
-   source-pads[pad], flags);
+   source-pads[pad], 0);
if (ret)
break;
 
-   v4l2_info(fmd-v4l2_dev, created link [%s] %c [%s]\n,
- source-name, flags ? '=' : '-', sink-name);
+   v4l2_info(fmd-v4l2_dev, created link [%s] - [%s]\n,
+ source-name, sink-name);
}
return 0;
 }
@@ -910,26 +912,59 @@ static int __fimc_md_create_fimc_sink_links(struct 
fimc_md *fmd,
 static int __fimc_md_create_flite_source_links(struct fimc_md *fmd)
 {
struct media_entity *source, *sink;
-   unsigned int flags = MEDIA_LNK_FL_ENABLED;
int i, ret = 0;
 
for (i = 0; i  FIMC_LITE_MAX_DEVS; i++) {
struct fimc_lite *fimc = fmd-fimc_lite[i];
+
if (fimc == NULL)
continue;
+
source = fimc-subdev.entity;
sink = fimc-vfd.entity;
/* FIMC-LITE's subdev and video node */
ret = media_entity_create_link(source, FLITE_SD_PAD_SOURCE_DMA,
-  sink, 0, flags);
+  sink, 0, 0);
+   if (ret)
+   break;
+   /* Link from FIMC-LITE to IS-ISP subdev */
+   sink = fmd-fimc_is-isp.subdev.entity;
+   ret = media_entity_create_link(source, FLITE_SD_PAD_SOURCE_ISP,
+  sink, 0, 0);
if (ret)
break;
-   /* TODO: create links to other entities */
}
 
return ret;
 }
 
+/* Create FIMC-IS links */
+static int __fimc_md_create_fimc_is_links(struct fimc_md *fmd)
+{
+   struct media_entity *source, *sink;
+   int i, ret;
+
+   source = fmd-fimc_is-isp.subdev.entity;
+
+   for (i = 0; i  FIMC_MAX_DEVS; i++) {
+   if (fmd-fimc[i] == NULL)
+   

[PATCH v2 6/7] s5p-fimc: Add fimc-is subdevs registration

2013-03-26 Thread Sylwester Nawrocki
This patch allows to register FIMC-IS device represented by FIMC-IS-ISP
subdev to the top level media device driver. The use_isp platform data
structure field allows to select whether the fimc-is ISP subdev should
be tried to be registered or not.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Andrzej Hajda a.ha...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/platform/exynos4-is/media-dev.c |   37 +++--
 drivers/media/platform/exynos4-is/media-dev.h |   13 +
 2 files changed, 47 insertions(+), 3 deletions(-)

diff --git a/drivers/media/platform/exynos4-is/media-dev.c 
b/drivers/media/platform/exynos4-is/media-dev.c
index 6048290..5e1c28e 100644
--- a/drivers/media/platform/exynos4-is/media-dev.c
+++ b/drivers/media/platform/exynos4-is/media-dev.c
@@ -32,6 +32,7 @@
 
 #include media-dev.h
 #include fimc-core.h
+#include fimc-is.h
 #include fimc-lite.h
 #include mipi-csis.h
 
@@ -85,9 +86,11 @@ static void fimc_pipeline_prepare(struct fimc_pipeline *p,
case GRP_ID_FIMC:
/* No need to control FIMC subdev through subdev ops */
break;
+   case GRP_ID_FIMC_IS:
+   p-subdevs[IDX_IS_ISP] = sd;
+   break;
default:
-   pr_warn(%s: Unknown subdev grp_id: %#x\n,
-   __func__, sd-grp_id);
+   break;
}
me = sd-entity;
if (me-num_pads == 1)
@@ -322,6 +325,7 @@ static void fimc_md_unregister_sensor(struct v4l2_subdev 
*sd)
 
if (!client)
return;
+
v4l2_device_unregister_subdev(sd);
 
if (!client-dev.of_node) {
@@ -372,7 +376,11 @@ static int fimc_md_of_add_sensor(struct fimc_md *fmd,
goto mod_put;
 
v4l2_set_subdev_hostdata(sd, si);
-   sd-grp_id = GRP_ID_SENSOR;
+   if (si-pdata.fimc_bus_type == FIMC_BUS_TYPE_ISP_WRITEBACK)
+   sd-grp_id = GRP_ID_FIMC_IS_SENSOR;
+   else
+   sd-grp_id = GRP_ID_SENSOR;
+
si-subdev = sd;
v4l2_info(fmd-v4l2_dev, Registered sensor subdevice: %s (%d)\n,
  sd-name, fmd-num_sensors);
@@ -650,6 +658,22 @@ static int register_csis_entity(struct fimc_md *fmd,
return ret;
 }
 
+static int register_fimc_is_entity(struct fimc_md *fmd, struct fimc_is *is)
+{
+   struct v4l2_subdev *sd = is-isp.subdev;
+   int ret;
+
+   ret = v4l2_device_register_subdev(fmd-v4l2_dev, sd);
+   if (ret) {
+   v4l2_err(fmd-v4l2_dev,
+Failed to register FIMC-ISP (%d)\n, ret);
+   return ret;
+   }
+
+   fmd-fimc_is = is;
+   return 0;
+}
+
 static int fimc_md_register_platform_entity(struct fimc_md *fmd,
struct platform_device *pdev,
int plat_entity)
@@ -677,6 +701,9 @@ static int fimc_md_register_platform_entity(struct fimc_md 
*fmd,
case IDX_CSIS:
ret = register_csis_entity(fmd, pdev, drvdata);
break;
+   case IDX_IS_ISP:
+   ret = register_fimc_is_entity(fmd, drvdata);
+   break;
default:
ret = -ENODEV;
}
@@ -740,6 +767,8 @@ static int fimc_md_register_of_platform_entities(struct 
fimc_md *fmd,
/* If driver of any entity isn't ready try all again later. */
if (!strcmp(node-name, CSIS_OF_NODE_NAME))
plat_entity = IDX_CSIS;
+   else if (!strcmp(node-name, FIMC_IS_OF_NODE_NAME))
+   plat_entity = IDX_IS_ISP;
else if (!strcmp(node-name, FIMC_LITE_OF_NODE_NAME))
plat_entity = IDX_FLITE;
else if (!strcmp(node-name, FIMC_OF_NODE_NAME) 
@@ -1306,6 +1335,8 @@ static int fimc_md_probe(struct platform_device *pdev)
v4l2_dev-notify = fimc_sensor_notify;
strlcpy(v4l2_dev-name, s5p-fimc-md, sizeof(v4l2_dev-name));
 
+   fmd-use_isp = fimc_md_is_isp_available(dev-of_node);
+
ret = v4l2_device_register(dev, fmd-v4l2_dev);
if (ret  0) {
v4l2_err(v4l2_dev, Failed to register v4l2_device: %d\n, ret);
diff --git a/drivers/media/platform/exynos4-is/media-dev.h 
b/drivers/media/platform/exynos4-is/media-dev.h
index 1d5cea5..0b14cd5 100644
--- a/drivers/media/platform/exynos4-is/media-dev.h
+++ b/drivers/media/platform/exynos4-is/media-dev.h
@@ -12,6 +12,7 @@
 #include linux/clk.h
 #include linux/platform_device.h
 #include linux/mutex.h
+#include linux/of.h
 #include linux/pinctrl/consumer.h
 #include media/media-device.h
 #include media/media-entity.h
@@ -80,6 +81,7 @@ struct fimc_sensor_info {
  * @num_sensors: actual number of registered 

[PATCH v2 0/4] exynos4-is updates

2013-03-26 Thread Sylwester Nawrocki
This patch series includes YUV order handling fix for the FIMC
and FIMC-LITE, a fix for media entity ref_count issue, minor
refactoring and removal of some static data that will no longer
be needed since starting from 3.10 Exynos platform is going to
be DT only.

All dependencies of this series are available at:
git://linuxtv.org/snawrocki/samsung.git exynos4-fimc-is-v2

Sylwester Nawrocki (5):
  exynos4-is: Remove static driver data for Exynos4210 FIMC variants
  exynos4-is: Use common driver data for all FIMC-LITE IP instances
  exynos4-is: Allow colorspace conversion at fimc-lite
  exynos4-is: Correct input DMA YUV order configuration
  exynos4-is: Ensure proper media pipeline state on device close

 drivers/media/platform/exynos4-is/fimc-capture.c  |   18 ++-
 drivers/media/platform/exynos4-is/fimc-core.c |   51 ++---
 drivers/media/platform/exynos4-is/fimc-core.h |1 +
 drivers/media/platform/exynos4-is/fimc-lite-reg.c |4 +-
 drivers/media/platform/exynos4-is/fimc-lite-reg.h |8 +-
 drivers/media/platform/exynos4-is/fimc-lite.c |  127 +
 drivers/media/platform/exynos4-is/fimc-lite.h |   15 +--
 drivers/media/platform/exynos4-is/fimc-reg.c  |3 +-
 drivers/media/platform/exynos4-is/fimc-reg.h  |   16 +--
 include/media/s5p_fimc.h  |2 +
 10 files changed, 124 insertions(+), 121 deletions(-)

--
1.7.9.5

--
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 v2 1/5] exynos4-is: Remove static driver data for Exynos4210 FIMC variants

2013-03-26 Thread Sylwester Nawrocki
All Exynos4210 based boards files using FIMC are going to be removed
in 3.10 and corresponding device trees are to be used instead.
The FIMC variant data will be parsed directly form the device tree
for those SoCs as well. Hence now unused static data is removed.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/platform/exynos4-is/fimc-core.c |   35 -
 1 file changed, 35 deletions(-)

diff --git a/drivers/media/platform/exynos4-is/fimc-core.c 
b/drivers/media/platform/exynos4-is/fimc-core.c
index 1248cdd..2e153bb 100644
--- a/drivers/media/platform/exynos4-is/fimc-core.c
+++ b/drivers/media/platform/exynos4-is/fimc-core.c
@@ -1141,14 +1141,6 @@ static const struct fimc_pix_limit s5p_pix_limit[4] = {
.out_rot_en_w   = 1280,
.out_rot_dis_w  = 1920,
},
-   [3] = {
-   .scaler_en_w= 1920,
-   .scaler_dis_w   = 8192,
-   .in_rot_en_h= 1366,
-   .in_rot_dis_w   = 8192,
-   .out_rot_en_w   = 1366,
-   .out_rot_dis_w  = 1920,
-   },
 };
 
 static const struct fimc_variant fimc0_variant_s5p = {
@@ -1203,27 +1195,6 @@ static const struct fimc_variant fimc2_variant_s5pv210 = 
{
.pix_limit   = s5p_pix_limit[2],
 };
 
-static const struct fimc_variant fimc0_variant_exynos4210 = {
-   .has_inp_rot = 1,
-   .has_out_rot = 1,
-   .has_cam_if  = 1,
-   .has_mainscaler_ext = 1,
-   .min_inp_pixsize = 16,
-   .min_out_pixsize = 16,
-   .hor_offs_align  = 2,
-   .min_vsize_align = 1,
-   .pix_limit   = s5p_pix_limit[1],
-};
-
-static const struct fimc_variant fimc3_variant_exynos4210 = {
-   .has_mainscaler_ext = 1,
-   .min_inp_pixsize = 16,
-   .min_out_pixsize = 16,
-   .hor_offs_align  = 2,
-   .min_vsize_align = 1,
-   .pix_limit   = s5p_pix_limit[3],
-};
-
 /* S5PC100 */
 static const struct fimc_drvdata fimc_drvdata_s5p = {
.variant = {
@@ -1251,12 +1222,6 @@ static const struct fimc_drvdata fimc_drvdata_s5pv210 = {
 
 /* EXYNOS4210, S5PV310, S5PC210 */
 static const struct fimc_drvdata fimc_drvdata_exynos4210 = {
-   .variant = {
-   [0] = fimc0_variant_exynos4210,
-   [1] = fimc0_variant_exynos4210,
-   [2] = fimc0_variant_exynos4210,
-   [3] = fimc3_variant_exynos4210,
-   },
.num_entities   = 4,
.lclk_frequency = 16600UL,
.dma_pix_hoff   = 1,
-- 
1.7.9.5

--
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 v2 2/4] exynos4-is: Allow colorspace conversion at fimc-lite

2013-03-26 Thread Sylwester Nawrocki
The FIMC-LITE output DMA allows to configure different YUV order
than the order at the camera input interface. Thus there is some
limited colorspace conversion possible. This patch makes the
color format variable be per FIMC-LITE input/output, rather than
a global per device. This also fixes incorrect behavior where
color format at the FIMC-LITE.N subdev's source pad is modified
by VIDIOC_S_FMT ioctl on the related video node.

YUV order definitions are corrected so that we use notation:

 | byte3 | byte2 | byte1 | byte0
  ---+---+---+---+--
  YCBYCR | CR| Y | CB| Y
  YCRYCB | CB| Y | CR| Y
  CBYCRY | Y | CR| Y | CB
  CRYCBY | Y | CB| Y | CR

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/platform/exynos4-is/fimc-lite-reg.c |4 +-
 drivers/media/platform/exynos4-is/fimc-lite-reg.h |8 +--
 drivers/media/platform/exynos4-is/fimc-lite.c |   76 ++---
 drivers/media/platform/exynos4-is/fimc-lite.h |4 +-
 include/media/s5p_fimc.h  |2 +
 5 files changed, 61 insertions(+), 33 deletions(-)

diff --git a/drivers/media/platform/exynos4-is/fimc-lite-reg.c 
b/drivers/media/platform/exynos4-is/fimc-lite-reg.c
index ac9663c..8cc0d39 100644
--- a/drivers/media/platform/exynos4-is/fimc-lite-reg.c
+++ b/drivers/media/platform/exynos4-is/fimc-lite-reg.c
@@ -127,7 +127,7 @@ static const u32 src_pixfmt_map[8][3] = {
 /* Set camera input pixel format and resolution */
 void flite_hw_set_source_format(struct fimc_lite *dev, struct flite_frame *f)
 {
-   enum v4l2_mbus_pixelcode pixelcode = dev-fmt-mbus_code;
+   enum v4l2_mbus_pixelcode pixelcode = f-fmt-mbus_code;
int i = ARRAY_SIZE(src_pixfmt_map);
u32 cfg;
 
@@ -227,7 +227,7 @@ static void flite_hw_set_out_order(struct fimc_lite *dev, 
struct flite_frame *f)
int i = ARRAY_SIZE(pixcode);
 
while (--i = 0)
-   if (pixcode[i][0] == dev-fmt-mbus_code)
+   if (pixcode[i][0] == f-fmt-mbus_code)
break;
cfg = ~FLITE_REG_CIODMAFMT_YCBCR_ORDER_MASK;
writel(cfg | pixcode[i][1], dev-regs + FLITE_REG_CIODMAFMT);
diff --git a/drivers/media/platform/exynos4-is/fimc-lite-reg.h 
b/drivers/media/platform/exynos4-is/fimc-lite-reg.h
index 0e34584..3903839 100644
--- a/drivers/media/platform/exynos4-is/fimc-lite-reg.h
+++ b/drivers/media/platform/exynos4-is/fimc-lite-reg.h
@@ -72,10 +72,10 @@
 #define FLITE_REG_CIODMAFMT0x18
 #define FLITE_REG_CIODMAFMT_RAW_CON(1  15)
 #define FLITE_REG_CIODMAFMT_PACK12 (1  14)
-#define FLITE_REG_CIODMAFMT_CRYCBY (0  4)
-#define FLITE_REG_CIODMAFMT_CBYCRY (1  4)
-#define FLITE_REG_CIODMAFMT_YCRYCB (2  4)
-#define FLITE_REG_CIODMAFMT_YCBYCR (3  4)
+#define FLITE_REG_CIODMAFMT_YCBYCR (0  4)
+#define FLITE_REG_CIODMAFMT_YCRYCB (1  4)
+#define FLITE_REG_CIODMAFMT_CBYCRY (2  4)
+#define FLITE_REG_CIODMAFMT_CRYCBY (3  4)
 #define FLITE_REG_CIODMAFMT_YCBCR_ORDER_MASK   (0x3  4)
 
 /* Camera Output Canvas */
diff --git a/drivers/media/platform/exynos4-is/fimc-lite.c 
b/drivers/media/platform/exynos4-is/fimc-lite.c
index ba35328..b11e358 100644
--- a/drivers/media/platform/exynos4-is/fimc-lite.c
+++ b/drivers/media/platform/exynos4-is/fimc-lite.c
@@ -46,6 +46,7 @@ static const struct fimc_fmt fimc_lite_formats[] = {
.color  = FIMC_FMT_YCBYCR422,
.memplanes  = 1,
.mbus_code  = V4L2_MBUS_FMT_YUYV8_2X8,
+   .flags  = FMT_FLAGS_YUV,
}, {
.name   = YUV 4:2:2 packed, CbYCrY,
.fourcc = V4L2_PIX_FMT_UYVY,
@@ -53,6 +54,7 @@ static const struct fimc_fmt fimc_lite_formats[] = {
.color  = FIMC_FMT_CBYCRY422,
.memplanes  = 1,
.mbus_code  = V4L2_MBUS_FMT_UYVY8_2X8,
+   .flags  = FMT_FLAGS_YUV,
}, {
.name   = YUV 4:2:2 packed, CrYCbY,
.fourcc = V4L2_PIX_FMT_VYUY,
@@ -60,6 +62,7 @@ static const struct fimc_fmt fimc_lite_formats[] = {
.color  = FIMC_FMT_CRYCBY422,
.memplanes  = 1,
.mbus_code  = V4L2_MBUS_FMT_VYUY8_2X8,
+   .flags  = FMT_FLAGS_YUV,
}, {
.name   = YUV 4:2:2 packed, YCrYCb,
.fourcc = V4L2_PIX_FMT_YVYU,
@@ -67,6 +70,7 @@ static const struct fimc_fmt fimc_lite_formats[] = {
.color  = FIMC_FMT_YCRYCB422,
.memplanes  = 1,
.mbus_code  = V4L2_MBUS_FMT_YVYU8_2X8,
+   .flags  = FMT_FLAGS_YUV,
}, {
.name

[PATCH v2 2/5] exynos4-is: Use common driver data for all FIMC-LITE IP instances

2013-03-26 Thread Sylwester Nawrocki
There is no need to use separate variant data structure for each
FIMC-LITE IP instance. According to my knowledge there are no
differences across them on Exynos4 as well as Exynos5 SoCs. Drop
flite_variant data structure and use struct flite_drvdata instead.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/platform/exynos4-is/fimc-lite.c |   35 ++---
 drivers/media/platform/exynos4-is/fimc-lite.h |   10 +++
 2 files changed, 17 insertions(+), 28 deletions(-)

diff --git a/drivers/media/platform/exynos4-is/fimc-lite.c 
b/drivers/media/platform/exynos4-is/fimc-lite.c
index 70c0cc2..ba35328 100644
--- a/drivers/media/platform/exynos4-is/fimc-lite.c
+++ b/drivers/media/platform/exynos4-is/fimc-lite.c
@@ -528,7 +528,7 @@ static const struct fimc_fmt *fimc_lite_try_format(struct 
fimc_lite *fimc,
u32 *width, u32 *height,
u32 *code, u32 *fourcc, int pad)
 {
-   struct flite_variant *variant = fimc-variant;
+   struct flite_drvdata *dd = fimc-dd;
const struct fimc_fmt *fmt;
 
fmt = fimc_lite_find_format(fourcc, code, 0);
@@ -541,12 +541,12 @@ static const struct fimc_fmt *fimc_lite_try_format(struct 
fimc_lite *fimc,
*fourcc = fmt-fourcc;
 
if (pad == FLITE_SD_PAD_SINK) {
-   v4l_bound_align_image(width, 8, variant-max_width,
- ffs(variant-out_width_align) - 1,
- height, 0, variant-max_height, 0, 0);
+   v4l_bound_align_image(width, 8, dd-max_width,
+ ffs(dd-out_width_align) - 1,
+ height, 0, dd-max_height, 0, 0);
} else {
v4l_bound_align_image(width, 8, fimc-inp_frame.rect.width,
- ffs(variant-out_width_align) - 1,
+ ffs(dd-out_width_align) - 1,
  height, 0, fimc-inp_frame.rect.height,
  0, 0);
}
@@ -566,7 +566,7 @@ static void fimc_lite_try_crop(struct fimc_lite *fimc, 
struct v4l2_rect *r)
 
/* Adjust left/top if cropping rectangle got out of bounds */
r-left = clamp_t(u32, r-left, 0, frame-f_width - r-width);
-   r-left = round_down(r-left, fimc-variant-win_hor_offs_align);
+   r-left = round_down(r-left, fimc-dd-win_hor_offs_align);
r-top  = clamp_t(u32, r-top, 0, frame-f_height - r-height);
 
v4l2_dbg(1, debug, fimc-subdev, (%d,%d)/%dx%d, sink fmt: %dx%d\n,
@@ -586,7 +586,7 @@ static void fimc_lite_try_compose(struct fimc_lite *fimc, 
struct v4l2_rect *r)
 
/* Adjust left/top if the composing rectangle got out of bounds */
r-left = clamp_t(u32, r-left, 0, frame-f_width - r-width);
-   r-left = round_down(r-left, fimc-variant-out_hor_offs_align);
+   r-left = round_down(r-left, fimc-dd-out_hor_offs_align);
r-top  = clamp_t(u32, r-top, 0, fimc-out_frame.f_height - r-height);
 
v4l2_dbg(1, debug, fimc-subdev, (%d,%d)/%dx%d, source fmt: %dx%d\n,
@@ -647,8 +647,8 @@ static int fimc_lite_try_fmt(struct fimc_lite *fimc,
 struct v4l2_pix_format_mplane *pixm,
 const struct fimc_fmt **ffmt)
 {
-   struct flite_variant *variant = fimc-variant;
u32 bpl = pixm-plane_fmt[0].bytesperline;
+   struct flite_drvdata *dd = fimc-dd;
const struct fimc_fmt *fmt;
 
fmt = fimc_lite_find_format(pixm-pixelformat, NULL, 0);
@@ -656,9 +656,9 @@ static int fimc_lite_try_fmt(struct fimc_lite *fimc,
return -EINVAL;
if (ffmt)
*ffmt = fmt;
-   v4l_bound_align_image(pixm-width, 8, variant-max_width,
- ffs(variant-out_width_align) - 1,
- pixm-height, 0, variant-max_height, 0, 0);
+   v4l_bound_align_image(pixm-width, 8, dd-max_width,
+ ffs(dd-out_width_align) - 1,
+ pixm-height, 0, dd-max_height, 0, 0);
 
if ((bpl == 0 || ((bpl * 8) / fmt-depth[0])  pixm-width))
pixm-plane_fmt[0].bytesperline = (pixm-width *
@@ -1429,7 +1429,7 @@ static int fimc_lite_probe(struct platform_device *pdev)
if (!drv_data || fimc-index  0 || fimc-index = FIMC_LITE_MAX_DEVS)
return -EINVAL;
 
-   fimc-variant = drv_data-variant[fimc-index];
+   fimc-dd = drv_data;
fimc-pdev = pdev;
 
init_waitqueue_head(fimc-irq_queue);
@@ -1577,7 +1577,8 @@ static const struct dev_pm_ops fimc_lite_pm_ops = {
   NULL)
 };
 
-static struct flite_variant fimc_lite0_variant_exynos4 = {
+/* EXYNOS4212, EXYNOS4412 */
+static struct flite_drvdata fimc_lite_drvdata_exynos4 = {
.max_width   

[PATCH v2 3/5] exynos4-is: Allow colorspace conversion at fimc-lite

2013-03-26 Thread Sylwester Nawrocki
The FIMC-LITE output DMA allows to configure different YUV order
than the order at the camera input interface. Thus there is some
limited colorspace conversion possible. This patch makes the
color format variable be per FIMC-LITE input/output, rather than
a global per device. This also fixes incorrect behavior where
color format at the FIMC-LITE.N subdev's source pad is modified
by VIDIOC_S_FMT ioctl on the related video node.

YUV order definitions are corrected so that we use notation:

 | byte3 | byte2 | byte1 | byte0
  ---+---+---+---+--
  YCBYCR | CR| Y | CB| Y
  YCRYCB | CB| Y | CR| Y
  CBYCRY | Y | CR| Y | CB
  CRYCBY | Y | CB| Y | CR

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/platform/exynos4-is/fimc-lite-reg.c |4 +-
 drivers/media/platform/exynos4-is/fimc-lite-reg.h |8 +--
 drivers/media/platform/exynos4-is/fimc-lite.c |   76 ++---
 drivers/media/platform/exynos4-is/fimc-lite.h |4 +-
 include/media/s5p_fimc.h  |2 +
 5 files changed, 61 insertions(+), 33 deletions(-)

diff --git a/drivers/media/platform/exynos4-is/fimc-lite-reg.c 
b/drivers/media/platform/exynos4-is/fimc-lite-reg.c
index ac9663c..8cc0d39 100644
--- a/drivers/media/platform/exynos4-is/fimc-lite-reg.c
+++ b/drivers/media/platform/exynos4-is/fimc-lite-reg.c
@@ -127,7 +127,7 @@ static const u32 src_pixfmt_map[8][3] = {
 /* Set camera input pixel format and resolution */
 void flite_hw_set_source_format(struct fimc_lite *dev, struct flite_frame *f)
 {
-   enum v4l2_mbus_pixelcode pixelcode = dev-fmt-mbus_code;
+   enum v4l2_mbus_pixelcode pixelcode = f-fmt-mbus_code;
int i = ARRAY_SIZE(src_pixfmt_map);
u32 cfg;
 
@@ -227,7 +227,7 @@ static void flite_hw_set_out_order(struct fimc_lite *dev, 
struct flite_frame *f)
int i = ARRAY_SIZE(pixcode);
 
while (--i = 0)
-   if (pixcode[i][0] == dev-fmt-mbus_code)
+   if (pixcode[i][0] == f-fmt-mbus_code)
break;
cfg = ~FLITE_REG_CIODMAFMT_YCBCR_ORDER_MASK;
writel(cfg | pixcode[i][1], dev-regs + FLITE_REG_CIODMAFMT);
diff --git a/drivers/media/platform/exynos4-is/fimc-lite-reg.h 
b/drivers/media/platform/exynos4-is/fimc-lite-reg.h
index 0e34584..3903839 100644
--- a/drivers/media/platform/exynos4-is/fimc-lite-reg.h
+++ b/drivers/media/platform/exynos4-is/fimc-lite-reg.h
@@ -72,10 +72,10 @@
 #define FLITE_REG_CIODMAFMT0x18
 #define FLITE_REG_CIODMAFMT_RAW_CON(1  15)
 #define FLITE_REG_CIODMAFMT_PACK12 (1  14)
-#define FLITE_REG_CIODMAFMT_CRYCBY (0  4)
-#define FLITE_REG_CIODMAFMT_CBYCRY (1  4)
-#define FLITE_REG_CIODMAFMT_YCRYCB (2  4)
-#define FLITE_REG_CIODMAFMT_YCBYCR (3  4)
+#define FLITE_REG_CIODMAFMT_YCBYCR (0  4)
+#define FLITE_REG_CIODMAFMT_YCRYCB (1  4)
+#define FLITE_REG_CIODMAFMT_CBYCRY (2  4)
+#define FLITE_REG_CIODMAFMT_CRYCBY (3  4)
 #define FLITE_REG_CIODMAFMT_YCBCR_ORDER_MASK   (0x3  4)
 
 /* Camera Output Canvas */
diff --git a/drivers/media/platform/exynos4-is/fimc-lite.c 
b/drivers/media/platform/exynos4-is/fimc-lite.c
index ba35328..b11e358 100644
--- a/drivers/media/platform/exynos4-is/fimc-lite.c
+++ b/drivers/media/platform/exynos4-is/fimc-lite.c
@@ -46,6 +46,7 @@ static const struct fimc_fmt fimc_lite_formats[] = {
.color  = FIMC_FMT_YCBYCR422,
.memplanes  = 1,
.mbus_code  = V4L2_MBUS_FMT_YUYV8_2X8,
+   .flags  = FMT_FLAGS_YUV,
}, {
.name   = YUV 4:2:2 packed, CbYCrY,
.fourcc = V4L2_PIX_FMT_UYVY,
@@ -53,6 +54,7 @@ static const struct fimc_fmt fimc_lite_formats[] = {
.color  = FIMC_FMT_CBYCRY422,
.memplanes  = 1,
.mbus_code  = V4L2_MBUS_FMT_UYVY8_2X8,
+   .flags  = FMT_FLAGS_YUV,
}, {
.name   = YUV 4:2:2 packed, CrYCbY,
.fourcc = V4L2_PIX_FMT_VYUY,
@@ -60,6 +62,7 @@ static const struct fimc_fmt fimc_lite_formats[] = {
.color  = FIMC_FMT_CRYCBY422,
.memplanes  = 1,
.mbus_code  = V4L2_MBUS_FMT_VYUY8_2X8,
+   .flags  = FMT_FLAGS_YUV,
}, {
.name   = YUV 4:2:2 packed, YCrYCb,
.fourcc = V4L2_PIX_FMT_YVYU,
@@ -67,6 +70,7 @@ static const struct fimc_fmt fimc_lite_formats[] = {
.color  = FIMC_FMT_YCRYCB422,
.memplanes  = 1,
.mbus_code  = V4L2_MBUS_FMT_YVYU8_2X8,
+   .flags  = FMT_FLAGS_YUV,
}, {
.name

[PATCH v2 3/4] exynos4-is: Correct input DMA YUV order configuration

2013-03-26 Thread Sylwester Nawrocki
This patch fixes erroneous setup of the YUV order caused by not
clearing FIMC_REG_MSCTRL_ORDER422_MASK bit field before setting
proper FIMC_REG_MSCTRL_ORDER422 bits. This resulted in false
colors for YUYV, YVYU, UYVY, VYUY color formats, depending in
what sequence those were configured by user space.

YUV order definitions are corrected so that following convention
is used:

| byte3 | byte2 | byte1 | byte0
 ---+---+---+---+--
 YCBYCR | CR| Y | CB| Y
 YCRYCB | CB| Y | CR| Y
 CBYCRY | Y | CR| Y | CB
 CRYCBY | Y | CB| Y | CR

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/platform/exynos4-is/fimc-core.c |   16 
 drivers/media/platform/exynos4-is/fimc-reg.c  |3 ++-
 drivers/media/platform/exynos4-is/fimc-reg.h  |   16 
 3 files changed, 18 insertions(+), 17 deletions(-)

diff --git a/drivers/media/platform/exynos4-is/fimc-core.c 
b/drivers/media/platform/exynos4-is/fimc-core.c
index 2e153bb..f6efa47 100644
--- a/drivers/media/platform/exynos4-is/fimc-core.c
+++ b/drivers/media/platform/exynos4-is/fimc-core.c
@@ -412,34 +412,34 @@ void fimc_set_yuv_order(struct fimc_ctx *ctx)
/* Set order for 1 plane input formats. */
switch (ctx-s_frame.fmt-color) {
case FIMC_FMT_YCRYCB422:
-   ctx-in_order_1p = FIMC_REG_MSCTRL_ORDER422_CBYCRY;
+   ctx-in_order_1p = FIMC_REG_MSCTRL_ORDER422_YCRYCB;
break;
case FIMC_FMT_CBYCRY422:
-   ctx-in_order_1p = FIMC_REG_MSCTRL_ORDER422_YCRYCB;
+   ctx-in_order_1p = FIMC_REG_MSCTRL_ORDER422_CBYCRY;
break;
case FIMC_FMT_CRYCBY422:
-   ctx-in_order_1p = FIMC_REG_MSCTRL_ORDER422_YCBYCR;
+   ctx-in_order_1p = FIMC_REG_MSCTRL_ORDER422_CRYCBY;
break;
case FIMC_FMT_YCBYCR422:
default:
-   ctx-in_order_1p = FIMC_REG_MSCTRL_ORDER422_CRYCBY;
+   ctx-in_order_1p = FIMC_REG_MSCTRL_ORDER422_YCBYCR;
break;
}
dbg(ctx-in_order_1p= %d, ctx-in_order_1p);
 
switch (ctx-d_frame.fmt-color) {
case FIMC_FMT_YCRYCB422:
-   ctx-out_order_1p = FIMC_REG_CIOCTRL_ORDER422_CBYCRY;
+   ctx-out_order_1p = FIMC_REG_CIOCTRL_ORDER422_YCRYCB;
break;
case FIMC_FMT_CBYCRY422:
-   ctx-out_order_1p = FIMC_REG_CIOCTRL_ORDER422_YCRYCB;
+   ctx-out_order_1p = FIMC_REG_CIOCTRL_ORDER422_CBYCRY;
break;
case FIMC_FMT_CRYCBY422:
-   ctx-out_order_1p = FIMC_REG_CIOCTRL_ORDER422_YCBYCR;
+   ctx-out_order_1p = FIMC_REG_CIOCTRL_ORDER422_CRYCBY;
break;
case FIMC_FMT_YCBYCR422:
default:
-   ctx-out_order_1p = FIMC_REG_CIOCTRL_ORDER422_CRYCBY;
+   ctx-out_order_1p = FIMC_REG_CIOCTRL_ORDER422_YCBYCR;
break;
}
dbg(ctx-out_order_1p= %d, ctx-out_order_1p);
diff --git a/drivers/media/platform/exynos4-is/fimc-reg.c 
b/drivers/media/platform/exynos4-is/fimc-reg.c
index c276eb8..fd144a1 100644
--- a/drivers/media/platform/exynos4-is/fimc-reg.c
+++ b/drivers/media/platform/exynos4-is/fimc-reg.c
@@ -449,7 +449,8 @@ void fimc_hw_set_in_dma(struct fimc_ctx *ctx)
 | FIMC_REG_MSCTRL_IN_BURST_COUNT_MASK
 | FIMC_REG_MSCTRL_INPUT_MASK
 | FIMC_REG_MSCTRL_C_INT_IN_MASK
-| FIMC_REG_MSCTRL_2P_IN_ORDER_MASK);
+| FIMC_REG_MSCTRL_2P_IN_ORDER_MASK
+| FIMC_REG_MSCTRL_ORDER422_MASK);
 
cfg |= (FIMC_REG_MSCTRL_IN_BURST_COUNT(4)
| FIMC_REG_MSCTRL_INPUT_MEMORY
diff --git a/drivers/media/platform/exynos4-is/fimc-reg.h 
b/drivers/media/platform/exynos4-is/fimc-reg.h
index 01da7f3..6c97798 100644
--- a/drivers/media/platform/exynos4-is/fimc-reg.h
+++ b/drivers/media/platform/exynos4-is/fimc-reg.h
@@ -95,10 +95,10 @@
 /* Output DMA control */
 #define FIMC_REG_CIOCTRL   0x4c
 #define FIMC_REG_CIOCTRL_ORDER422_MASK (3  0)
-#define FIMC_REG_CIOCTRL_ORDER422_CRYCBY   (0  0)
-#define FIMC_REG_CIOCTRL_ORDER422_CBYCRY   (1  0)
-#define FIMC_REG_CIOCTRL_ORDER422_YCRYCB   (2  0)
-#define FIMC_REG_CIOCTRL_ORDER422_YCBYCR   (3  0)
+#define FIMC_REG_CIOCTRL_ORDER422_YCBYCR   (0  0)
+#define FIMC_REG_CIOCTRL_ORDER422_YCRYCB   (1  0)
+#define FIMC_REG_CIOCTRL_ORDER422_CBYCRY   (2  0)
+#define FIMC_REG_CIOCTRL_ORDER422_CRYCBY   (3  0)
 #define FIMC_REG_CIOCTRL_LASTIRQ_ENABLE(1  2)
 #define FIMC_REG_CIOCTRL_YCBCR_3PLANE  (0  3)
 #define FIMC_REG_CIOCTRL_YCBCR_2PLANE  (1  3)
@@ -220,10 +220,10 @@
 #define FIMC_REG_MSCTRL_FLIP_180   (3  13)
 #define FIMC_REG_MSCTRL_FIFO_CTRL_FULL (1  12)
 #define 

[PATCH v2 4/5] exynos4-is: Correct input DMA YUV order configuration

2013-03-26 Thread Sylwester Nawrocki
This patch fixes erroneous setup of the YUV order caused by not
clearing FIMC_REG_MSCTRL_ORDER422_MASK bit field before setting
proper FIMC_REG_MSCTRL_ORDER422 bits. This resulted in false
colors for YUYV, YVYU, UYVY, VYUY color formats, depending in
what sequence those were configured by user space.

YUV order definitions are corrected so that following convention
is used:

| byte3 | byte2 | byte1 | byte0
 ---+---+---+---+--
 YCBYCR | CR| Y | CB| Y
 YCRYCB | CB| Y | CR| Y
 CBYCRY | Y | CR| Y | CB
 CRYCBY | Y | CB| Y | CR

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/platform/exynos4-is/fimc-core.c |   16 
 drivers/media/platform/exynos4-is/fimc-reg.c  |3 ++-
 drivers/media/platform/exynos4-is/fimc-reg.h  |   16 
 3 files changed, 18 insertions(+), 17 deletions(-)

diff --git a/drivers/media/platform/exynos4-is/fimc-core.c 
b/drivers/media/platform/exynos4-is/fimc-core.c
index 2e153bb..f6efa47 100644
--- a/drivers/media/platform/exynos4-is/fimc-core.c
+++ b/drivers/media/platform/exynos4-is/fimc-core.c
@@ -412,34 +412,34 @@ void fimc_set_yuv_order(struct fimc_ctx *ctx)
/* Set order for 1 plane input formats. */
switch (ctx-s_frame.fmt-color) {
case FIMC_FMT_YCRYCB422:
-   ctx-in_order_1p = FIMC_REG_MSCTRL_ORDER422_CBYCRY;
+   ctx-in_order_1p = FIMC_REG_MSCTRL_ORDER422_YCRYCB;
break;
case FIMC_FMT_CBYCRY422:
-   ctx-in_order_1p = FIMC_REG_MSCTRL_ORDER422_YCRYCB;
+   ctx-in_order_1p = FIMC_REG_MSCTRL_ORDER422_CBYCRY;
break;
case FIMC_FMT_CRYCBY422:
-   ctx-in_order_1p = FIMC_REG_MSCTRL_ORDER422_YCBYCR;
+   ctx-in_order_1p = FIMC_REG_MSCTRL_ORDER422_CRYCBY;
break;
case FIMC_FMT_YCBYCR422:
default:
-   ctx-in_order_1p = FIMC_REG_MSCTRL_ORDER422_CRYCBY;
+   ctx-in_order_1p = FIMC_REG_MSCTRL_ORDER422_YCBYCR;
break;
}
dbg(ctx-in_order_1p= %d, ctx-in_order_1p);
 
switch (ctx-d_frame.fmt-color) {
case FIMC_FMT_YCRYCB422:
-   ctx-out_order_1p = FIMC_REG_CIOCTRL_ORDER422_CBYCRY;
+   ctx-out_order_1p = FIMC_REG_CIOCTRL_ORDER422_YCRYCB;
break;
case FIMC_FMT_CBYCRY422:
-   ctx-out_order_1p = FIMC_REG_CIOCTRL_ORDER422_YCRYCB;
+   ctx-out_order_1p = FIMC_REG_CIOCTRL_ORDER422_CBYCRY;
break;
case FIMC_FMT_CRYCBY422:
-   ctx-out_order_1p = FIMC_REG_CIOCTRL_ORDER422_YCBYCR;
+   ctx-out_order_1p = FIMC_REG_CIOCTRL_ORDER422_CRYCBY;
break;
case FIMC_FMT_YCBYCR422:
default:
-   ctx-out_order_1p = FIMC_REG_CIOCTRL_ORDER422_CRYCBY;
+   ctx-out_order_1p = FIMC_REG_CIOCTRL_ORDER422_YCBYCR;
break;
}
dbg(ctx-out_order_1p= %d, ctx-out_order_1p);
diff --git a/drivers/media/platform/exynos4-is/fimc-reg.c 
b/drivers/media/platform/exynos4-is/fimc-reg.c
index c276eb8..fd144a1 100644
--- a/drivers/media/platform/exynos4-is/fimc-reg.c
+++ b/drivers/media/platform/exynos4-is/fimc-reg.c
@@ -449,7 +449,8 @@ void fimc_hw_set_in_dma(struct fimc_ctx *ctx)
 | FIMC_REG_MSCTRL_IN_BURST_COUNT_MASK
 | FIMC_REG_MSCTRL_INPUT_MASK
 | FIMC_REG_MSCTRL_C_INT_IN_MASK
-| FIMC_REG_MSCTRL_2P_IN_ORDER_MASK);
+| FIMC_REG_MSCTRL_2P_IN_ORDER_MASK
+| FIMC_REG_MSCTRL_ORDER422_MASK);
 
cfg |= (FIMC_REG_MSCTRL_IN_BURST_COUNT(4)
| FIMC_REG_MSCTRL_INPUT_MEMORY
diff --git a/drivers/media/platform/exynos4-is/fimc-reg.h 
b/drivers/media/platform/exynos4-is/fimc-reg.h
index 01da7f3..6c97798 100644
--- a/drivers/media/platform/exynos4-is/fimc-reg.h
+++ b/drivers/media/platform/exynos4-is/fimc-reg.h
@@ -95,10 +95,10 @@
 /* Output DMA control */
 #define FIMC_REG_CIOCTRL   0x4c
 #define FIMC_REG_CIOCTRL_ORDER422_MASK (3  0)
-#define FIMC_REG_CIOCTRL_ORDER422_CRYCBY   (0  0)
-#define FIMC_REG_CIOCTRL_ORDER422_CBYCRY   (1  0)
-#define FIMC_REG_CIOCTRL_ORDER422_YCRYCB   (2  0)
-#define FIMC_REG_CIOCTRL_ORDER422_YCBYCR   (3  0)
+#define FIMC_REG_CIOCTRL_ORDER422_YCBYCR   (0  0)
+#define FIMC_REG_CIOCTRL_ORDER422_YCRYCB   (1  0)
+#define FIMC_REG_CIOCTRL_ORDER422_CBYCRY   (2  0)
+#define FIMC_REG_CIOCTRL_ORDER422_CRYCBY   (3  0)
 #define FIMC_REG_CIOCTRL_LASTIRQ_ENABLE(1  2)
 #define FIMC_REG_CIOCTRL_YCBCR_3PLANE  (0  3)
 #define FIMC_REG_CIOCTRL_YCBCR_2PLANE  (1  3)
@@ -220,10 +220,10 @@
 #define FIMC_REG_MSCTRL_FLIP_180   (3  13)
 #define FIMC_REG_MSCTRL_FIFO_CTRL_FULL (1  12)
 #define 

[PATCH v2 4/4] exynos4-is: Ensure proper media pipeline state on device close

2013-03-26 Thread Sylwester Nawrocki
Make sure media_entity_pipeline_stop() is called on video device
close in cases where there was VIDIOC_STREAMON ioctl and no
VIDIOC_STREAMOFF. This patch fixes media entities stream_count
state which could prevent links from being disconnected, due to
non-zero stream_count.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/platform/exynos4-is/fimc-capture.c |   18 +-
 drivers/media/platform/exynos4-is/fimc-core.h|1 +
 drivers/media/platform/exynos4-is/fimc-lite.c|   18 ++
 drivers/media/platform/exynos4-is/fimc-lite.h|1 +
 4 files changed, 29 insertions(+), 9 deletions(-)

diff --git a/drivers/media/platform/exynos4-is/fimc-capture.c 
b/drivers/media/platform/exynos4-is/fimc-capture.c
index b9c0817..0ae6bdb 100644
--- a/drivers/media/platform/exynos4-is/fimc-capture.c
+++ b/drivers/media/platform/exynos4-is/fimc-capture.c
@@ -551,6 +551,7 @@ unlock:
 static int fimc_capture_release(struct file *file)
 {
struct fimc_dev *fimc = video_drvdata(file);
+   struct fimc_vid_cap *vc = fimc-vid_cap;
int ret;
 
dbg(pid: %d, state: 0x%lx, task_pid_nr(current), fimc-state);
@@ -558,6 +559,10 @@ static int fimc_capture_release(struct file *file)
mutex_lock(fimc-lock);
 
if (v4l2_fh_is_singular_file(file)) {
+   if (vc-streaming) {
+   media_entity_pipeline_stop(vc-vfd.entity);
+   vc-streaming = false;
+   }
clear_bit(ST_CAPT_BUSY, fimc-state);
fimc_stop_capture(fimc, false);
fimc_pipeline_call(fimc, close, fimc-pipeline);
@@ -1243,8 +1248,10 @@ static int fimc_cap_streamon(struct file *file, void 
*priv,
}
 
ret = vb2_ioctl_streamon(file, priv, type);
-   if (!ret)
+   if (!ret) {
+   vc-streaming = true;
return ret;
+   }
 
 err_p_stop:
media_entity_pipeline_stop(entity);
@@ -1258,11 +1265,12 @@ static int fimc_cap_streamoff(struct file *file, void 
*priv,
int ret;
 
ret = vb2_ioctl_streamoff(file, priv, type);
+   if (ret  0)
+   return ret;
 
-   if (ret == 0)
-   media_entity_pipeline_stop(fimc-vid_cap.vfd.entity);
-
-   return ret;
+   media_entity_pipeline_stop(fimc-vid_cap.vfd.entity);
+   fimc-vid_cap.streaming = false;
+   return 0;
 }
 
 static int fimc_cap_reqbufs(struct file *file, void *priv,
diff --git a/drivers/media/platform/exynos4-is/fimc-core.h 
b/drivers/media/platform/exynos4-is/fimc-core.h
index 79a..de2b57e 100644
--- a/drivers/media/platform/exynos4-is/fimc-core.h
+++ b/drivers/media/platform/exynos4-is/fimc-core.h
@@ -318,6 +318,7 @@ struct fimc_vid_cap {
int buf_index;
unsigned intframe_count;
unsigned intreqbufs_count;
+   boolstreaming;
int input_index;
int refcnt;
u32 input;
diff --git a/drivers/media/platform/exynos4-is/fimc-lite.c 
b/drivers/media/platform/exynos4-is/fimc-lite.c
index b11e358..cb196b8 100644
--- a/drivers/media/platform/exynos4-is/fimc-lite.c
+++ b/drivers/media/platform/exynos4-is/fimc-lite.c
@@ -507,6 +507,10 @@ static int fimc_lite_release(struct file *file)
 
if (v4l2_fh_is_singular_file(file) 
atomic_read(fimc-out_path) == FIMC_IO_DMA) {
+   if (fimc-streaming) {
+   media_entity_pipeline_stop(fimc-vfd.entity);
+   fimc-streaming = false;
+   }
clear_bit(ST_FLITE_IN_USE, fimc-state);
fimc_lite_stop_capture(fimc, false);
fimc_pipeline_call(fimc, close, fimc-pipeline);
@@ -798,8 +802,11 @@ static int fimc_lite_streamon(struct file *file, void 
*priv,
goto err_p_stop;
 
ret = vb2_ioctl_streamon(file, priv, type);
-   if (!ret)
+   if (!ret) {
+   fimc-streaming = true;
return ret;
+   }
+
 err_p_stop:
media_entity_pipeline_stop(entity);
return 0;
@@ -812,9 +819,12 @@ static int fimc_lite_streamoff(struct file *file, void 
*priv,
int ret;
 
ret = vb2_ioctl_streamoff(file, priv, type);
-   if (ret == 0)
-   media_entity_pipeline_stop(fimc-vfd.entity);
-   return ret;
+   if (ret  0)
+   return ret;
+
+   media_entity_pipeline_stop(fimc-vfd.entity);
+   fimc-streaming = false;
+   return 0;
 }
 
 static int fimc_lite_reqbufs(struct file *file, void *priv,
diff --git a/drivers/media/platform/exynos4-is/fimc-lite.h 
b/drivers/media/platform/exynos4-is/fimc-lite.h
index 8a8d26f..71fed51 100644
--- a/drivers/media/platform/exynos4-is/fimc-lite.h
+++ 

Re: [PATCH v2 0/4] exynos4-is updates

2013-03-26 Thread Sylwester Nawrocki
On 03/26/2013 07:38 PM, Sylwester Nawrocki wrote:
 This patch series includes YUV order handling fix for the FIMC
 and FIMC-LITE, a fix for media entity ref_count issue, minor
 refactoring and removal of some static data that will no longer
 be needed since starting from 3.10 Exynos platform is going to
 be DT only.

Sorry for spamming with this double patch series. Will try to
be more careful next time.

 Sylwester Nawrocki (5):
   exynos4-is: Remove static driver data for Exynos4210 FIMC variants
   exynos4-is: Use common driver data for all FIMC-LITE IP instances
   exynos4-is: Allow colorspace conversion at fimc-lite
   exynos4-is: Correct input DMA YUV order configuration
   exynos4-is: Ensure proper media pipeline state on device close

-- 
Thanks,
Sylwester
--
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


Re: [PATCH 4/6] pci: Add PCIe driver for Samsung Exynos

2013-03-26 Thread Rob Herring
On 03/22/2013 11:07 PM, Jingoo Han wrote:
 Exynos5440 has a PCIe controller which can be used as Root Complex.
 This driver supports a PCIe controller as Root Complex mode.
 
 Signed-off-by: Surendranath Gurivireddy Balla suren.re...@samsung.com
 Signed-off-by: Siva Reddy Kallam siva.kal...@samsung.com
 Signed-off-by: Jingoo Han jg1@samsung.com
 ---
  .../devicetree/bindings/pci/exynos-pcie.txt|   56 +
  drivers/pci/host/Kconfig   |5 +
  drivers/pci/host/Makefile  |1 +
  drivers/pci/host/pci-exynos.c  | 1139 
 
  4 files changed, 1201 insertions(+), 0 deletions(-)
  create mode 100644 Documentation/devicetree/bindings/pci/exynos-pcie.txt
  create mode 100644 drivers/pci/host/Makefile
  create mode 100644 drivers/pci/host/pci-exynos.c

[...]

 +
 +/* synopsis specific PCIE configuration registers*/

If this is a standard IP block, then the driver naming should reflect
that. I suspect there are several others with the same IP block.

Rob
--
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 v6 0/7] move s3c24xx-irq to drivers/irqchip and add dt support

2013-03-26 Thread Heiko Stübner
This v6 addresses more comments from Arnd Bergmann, setting the compatible
property to the first supported SoC (s3c2410) instead of using the s3c24xx
wildcard. It also switches the parent-irq and controller irq in the dt
irq descriptor bringing it to a format of

  ctrl_num parent_irq ctrl_irq type


Heiko Stuebner (7):
  ARM: S3C24XX: move irq driver to drivers/irqchip
  irqchip: s3c24xx: fix comments on some camera interrupts
  irqchip: s3c24xx: fix irqlist of second s3c2416 controller
  irqchip: s3c24xx: add irq_set_type callback for basic interrupt types
  irqchip: s3c24xx: globally keep track of the created intc instances
  irqchip: s3c24xx: make interrupt handling independent of irq_domain structure
  irqchip: s3c24xx: add devicetree support

 .../interrupt-controller/samsung,s3c24xx-irq.txt   |   53 +++
 arch/arm/mach-s3c24xx/Makefile |2 +-
 drivers/irqchip/Makefile   |1 +
 .../irq.c = drivers/irqchip/irq-s3c24xx.c |  388 
 4 files changed, 373 insertions(+), 71 deletions(-)
 create mode 100644 
Documentation/devicetree/bindings/interrupt-controller/samsung,s3c24xx-irq.txt
 rename arch/arm/mach-s3c24xx/irq.c = drivers/irqchip/irq-s3c24xx.c (78%)

-- 
1.7.10.4

--
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 v6 1/7] ARM: S3C24XX: move irq driver to drivers/irqchip

2013-03-26 Thread Heiko Stübner
This move is necessary to make use of the irqchip infrastructure
for the following devicetree support for s3c24xx architectures.

Signed-off-by: Heiko Stuebner he...@sntech.de
---
 arch/arm/mach-s3c24xx/Makefile   |2 +-
 drivers/irqchip/Makefile |1 +
 arch/arm/mach-s3c24xx/irq.c = drivers/irqchip/irq-s3c24xx.c |0
 3 files changed, 2 insertions(+), 1 deletion(-)
 rename arch/arm/mach-s3c24xx/irq.c = drivers/irqchip/irq-s3c24xx.c (100%)

diff --git a/arch/arm/mach-s3c24xx/Makefile b/arch/arm/mach-s3c24xx/Makefile
index be6e4d0..6f46ecf 100644
--- a/arch/arm/mach-s3c24xx/Makefile
+++ b/arch/arm/mach-s3c24xx/Makefile
@@ -14,7 +14,7 @@ obj-  :=
 
 # core
 
-obj-y  += common.o irq.o
+obj-y  += common.o
 
 obj-$(CONFIG_CPU_S3C2410)  += s3c2410.o
 obj-$(CONFIG_S3C2410_CPUFREQ)  += cpufreq-s3c2410.o
diff --git a/drivers/irqchip/Makefile b/drivers/irqchip/Makefile
index 98e3b87..4d65a21 100644
--- a/drivers/irqchip/Makefile
+++ b/drivers/irqchip/Makefile
@@ -2,6 +2,7 @@ obj-$(CONFIG_IRQCHIP)   += irqchip.o
 
 obj-$(CONFIG_ARCH_BCM2835) += irq-bcm2835.o
 obj-$(CONFIG_ARCH_EXYNOS)  += exynos-combiner.o
+obj-$(CONFIG_ARCH_S3C24XX) += irq-s3c24xx.o
 obj-$(CONFIG_METAG)+= irq-metag-ext.o
 obj-$(CONFIG_METAG_PERFCOUNTER_IRQS)   += irq-metag.o
 obj-$(CONFIG_ARCH_SUNXI)   += irq-sunxi.o
diff --git a/arch/arm/mach-s3c24xx/irq.c b/drivers/irqchip/irq-s3c24xx.c
similarity index 100%
rename from arch/arm/mach-s3c24xx/irq.c
rename to drivers/irqchip/irq-s3c24xx.c
-- 
1.7.10.4

--
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 v6 2/7] irqchip: s3c24xx: fix comments on some camera interrupts

2013-03-26 Thread Heiko Stübner
Might be confusing for people to read the code without having the
datasheet nearby.

Signed-off-by: Heiko Stuebner he...@sntech.de
---
 drivers/irqchip/irq-s3c24xx.c |8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/irqchip/irq-s3c24xx.c b/drivers/irqchip/irq-s3c24xx.c
index 5c9f8b7..84afbc1 100644
--- a/drivers/irqchip/irq-s3c24xx.c
+++ b/drivers/irqchip/irq-s3c24xx.c
@@ -916,8 +916,8 @@ static struct s3c_irq_data init_s3c2440subint[32] = {
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 15 }, /* UART2-ERR */
{ .type = S3C_IRQTYPE_EDGE, .parent_irq = 31 }, /* TC */
{ .type = S3C_IRQTYPE_EDGE, .parent_irq = 31 }, /* ADC */
-   { .type = S3C_IRQTYPE_LEVEL, .parent_irq = 6 }, /* TC */
-   { .type = S3C_IRQTYPE_LEVEL, .parent_irq = 6 }, /* ADC */
+   { .type = S3C_IRQTYPE_LEVEL, .parent_irq = 6 }, /* CAM_C */
+   { .type = S3C_IRQTYPE_LEVEL, .parent_irq = 6 }, /* CAM_P */
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 9 }, /* WDT */
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 9 }, /* AC97 */
 };
@@ -991,8 +991,8 @@ static struct s3c_irq_data init_s3c2442subint[32] = {
{ .type = S3C_IRQTYPE_LEVEL, .parent_irq = 15 }, /* UART2-ERR */
{ .type = S3C_IRQTYPE_EDGE, .parent_irq = 31 }, /* TC */
{ .type = S3C_IRQTYPE_EDGE, .parent_irq = 31 }, /* ADC */
-   { .type = S3C_IRQTYPE_LEVEL, .parent_irq = 6 }, /* TC */
-   { .type = S3C_IRQTYPE_LEVEL, .parent_irq = 6 }, /* ADC */
+   { .type = S3C_IRQTYPE_LEVEL, .parent_irq = 6 }, /* CAM_C */
+   { .type = S3C_IRQTYPE_LEVEL, .parent_irq = 6 }, /* CAM_P */
 };
 
 void __init s3c2442_init_irq(void)
-- 
1.7.10.4

--
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 v6 3/7] irqchip: s3c24xx: fix irqlist of second s3c2416 controller

2013-03-26 Thread Heiko Stübner
The list in used was from the s3c2450, a close cousin of the s3c2416.
As it's not possible to distinguish between the s3c2416 and s3c2450
the additional interrupts of the s3c2450 will only be available thru
devicetree later.

Signed-off-by: Heiko Stuebner he...@sntech.de
---
 drivers/irqchip/irq-s3c24xx.c |5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/irqchip/irq-s3c24xx.c b/drivers/irqchip/irq-s3c24xx.c
index 84afbc1..a565eb8 100644
--- a/drivers/irqchip/irq-s3c24xx.c
+++ b/drivers/irqchip/irq-s3c24xx.c
@@ -835,13 +835,12 @@ static struct s3c_irq_data init_s3c2416subint[32] = {
 
 static struct s3c_irq_data init_s3c2416_second[32] = {
{ .type = S3C_IRQTYPE_EDGE }, /* 2D */
-   { .type = S3C_IRQTYPE_EDGE }, /* IIC1 */
+   { .type = S3C_IRQTYPE_NONE }, /* reserved */
{ .type = S3C_IRQTYPE_NONE }, /* reserved */
{ .type = S3C_IRQTYPE_NONE }, /* reserved */
{ .type = S3C_IRQTYPE_EDGE }, /* PCM0 */
-   { .type = S3C_IRQTYPE_EDGE }, /* PCM1 */
+   { .type = S3C_IRQTYPE_NONE }, /* reserved */
{ .type = S3C_IRQTYPE_EDGE }, /* I2S0 */
-   { .type = S3C_IRQTYPE_EDGE }, /* I2S1 */
 };
 
 void __init s3c2416_init_irq(void)
-- 
1.7.10.4

--
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 v6 4/7] irqchip: s3c24xx: add irq_set_type callback for basic interrupt types

2013-03-26 Thread Heiko Stübner
Enables post-init setting of the desired typehandler for the interrupt.

Signed-off-by: Heiko Stuebner he...@sntech.de
---
 drivers/irqchip/irq-s3c24xx.c |   24 
 1 file changed, 24 insertions(+)

diff --git a/drivers/irqchip/irq-s3c24xx.c b/drivers/irqchip/irq-s3c24xx.c
index a565eb8..7cba4f0 100644
--- a/drivers/irqchip/irq-s3c24xx.c
+++ b/drivers/irqchip/irq-s3c24xx.c
@@ -123,6 +123,28 @@ static inline void s3c_irq_ack(struct irq_data *data)
__raw_writel(bitval, intc-reg_intpnd);
 }
 
+static int s3c_irq_type(struct irq_data *data, unsigned int type)
+{
+   switch (type) {
+   case IRQ_TYPE_NONE:
+   break;
+   case IRQ_TYPE_EDGE_RISING:
+   case IRQ_TYPE_EDGE_FALLING:
+   case IRQ_TYPE_EDGE_BOTH:
+   irq_set_handler(data-irq, handle_edge_irq);
+   break;
+   case IRQ_TYPE_LEVEL_LOW:
+   case IRQ_TYPE_LEVEL_HIGH:
+   irq_set_handler(data-irq, handle_level_irq);
+   break;
+   default:
+   pr_err(No such irq type %d, type);
+   return -EINVAL;
+   }
+
+   return 0;
+}
+
 static int s3c_irqext_type_set(void __iomem *gpcon_reg,
   void __iomem *extint_reg,
   unsigned long gpcon_offset,
@@ -228,6 +250,7 @@ static struct irq_chip s3c_irq_chip = {
.irq_ack= s3c_irq_ack,
.irq_mask   = s3c_irq_mask,
.irq_unmask = s3c_irq_unmask,
+   .irq_set_type   = s3c_irq_type,
.irq_set_wake   = s3c_irq_wake
 };
 
@@ -236,6 +259,7 @@ static struct irq_chip s3c_irq_level_chip = {
.irq_mask   = s3c_irq_mask,
.irq_unmask = s3c_irq_unmask,
.irq_ack= s3c_irq_ack,
+   .irq_set_type   = s3c_irq_type,
 };
 
 static struct irq_chip s3c_irqext_chip = {
-- 
1.7.10.4

--
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 v6 5/7] irqchip: s3c24xx: globally keep track of the created intc instances

2013-03-26 Thread Heiko Stübner
For dt-enabled machines we want to use a big irq_domain over all controllers
and therefore need to access not only the main controllers but the
sub-controller as well.

Signed-off-by: Heiko Stuebner he...@sntech.de
---
 drivers/irqchip/irq-s3c24xx.c |   99 +
 1 file changed, 50 insertions(+), 49 deletions(-)

diff --git a/drivers/irqchip/irq-s3c24xx.c b/drivers/irqchip/irq-s3c24xx.c
index 7cba4f0..9914abd 100644
--- a/drivers/irqchip/irq-s3c24xx.c
+++ b/drivers/irqchip/irq-s3c24xx.c
@@ -69,6 +69,14 @@ struct s3c_irq_intc {
struct s3c_irq_data *irqs;
 };
 
+/*
+ * Array holding pointers to the global controller structs
+ * [0] ... main_intc
+ * [1] ... sub_intc
+ * [2] ... main_intc2 on s3c2416
+ */
+static struct s3c_irq_intc *s3c_intc[3];
+
 static void s3c_irq_mask(struct irq_data *data)
 {
struct s3c_irq_intc *intc = data-domain-host_data;
@@ -307,9 +315,6 @@ static void s3c_irq_demux(unsigned int irq, struct irq_desc 
*desc)
chained_irq_exit(chip, desc);
 }
 
-static struct s3c_irq_intc *main_intc;
-static struct s3c_irq_intc *main_intc2;
-
 static inline int s3c24xx_handle_intc(struct s3c_irq_intc *intc,
  struct pt_regs *regs)
 {
@@ -345,12 +350,12 @@ static inline int s3c24xx_handle_intc(struct s3c_irq_intc 
*intc,
 asmlinkage void __exception_irq_entry s3c24xx_handle_irq(struct pt_regs *regs)
 {
do {
-   if (likely(main_intc))
-   if (s3c24xx_handle_intc(main_intc, regs))
+   if (likely(s3c_intc[0]))
+   if (s3c24xx_handle_intc(s3c_intc[0], regs))
continue;
 
-   if (main_intc2)
-   if (s3c24xx_handle_intc(main_intc2, regs))
+   if (s3c_intc[2])
+   if (s3c24xx_handle_intc(s3c_intc[2], regs))
continue;
 
break;
@@ -577,11 +582,6 @@ static struct s3c_irq_intc *s3c24xx_init_intc(struct 
device_node *np,
goto err;
}
 
-   if (address == 0x4a00)
-   main_intc = intc;
-   else if (address == 0x4a40)
-   main_intc2 = intc;
-
set_handle_irq(s3c24xx_handle_irq);
 
return intc;
@@ -670,20 +670,20 @@ static struct s3c_irq_data init_s3c2410subint[32] = {
 
 void __init s3c2410_init_irq(void)
 {
-   struct s3c_irq_intc *main_intc;
-
 #ifdef CONFIG_FIQ
init_FIQ(FIQ_START);
 #endif
 
-   main_intc = s3c24xx_init_intc(NULL, init_s3c2410base[0], NULL, 
0x4a00);
-   if (IS_ERR(main_intc)) {
+   s3c_intc[0] = s3c24xx_init_intc(NULL, init_s3c2410base[0], NULL,
+   0x4a00);
+   if (IS_ERR(s3c_intc[0])) {
pr_err(irq: could not create main interrupt controller\n);
return;
}
 
-   s3c24xx_init_intc(NULL, init_s3c2410subint[0], main_intc, 0x4a18);
-   s3c24xx_init_intc(NULL, init_eint[0], main_intc, 0x56a4);
+   s3c_intc[1] = s3c24xx_init_intc(NULL, init_s3c2410subint[0],
+   s3c_intc[0], 0x4a18);
+   s3c24xx_init_intc(NULL, init_eint[0], s3c_intc[0], 0x56a4);
 }
 #endif
 
@@ -770,22 +770,22 @@ static struct s3c_irq_data init_s3c2412subint[32] = {
 
 void s3c2412_init_irq(void)
 {
-   struct s3c_irq_intc *main_intc;
-
pr_info(S3C2412: IRQ Support\n);
 
 #ifdef CONFIG_FIQ
init_FIQ(FIQ_START);
 #endif
 
-   main_intc = s3c24xx_init_intc(NULL, init_s3c2412base[0], NULL, 
0x4a00);
-   if (IS_ERR(main_intc)) {
+   s3c_intc[0] = s3c24xx_init_intc(NULL, init_s3c2412base[0], NULL,
+   0x4a00);
+   if (IS_ERR(s3c_intc[0])) {
pr_err(irq: could not create main interrupt controller\n);
return;
}
 
-   s3c24xx_init_intc(NULL, init_s3c2412eint[0], main_intc, 0x56a4);
-   s3c24xx_init_intc(NULL, init_s3c2412subint[0], main_intc, 0x4a18);
+   s3c24xx_init_intc(NULL, init_s3c2412eint[0], s3c_intc[0], 0x56a4);
+   s3c_intc[1] = s3c24xx_init_intc(NULL, init_s3c2412subint[0],
+   s3c_intc[0], 0x4a18);
 }
 #endif
 
@@ -869,24 +869,25 @@ static struct s3c_irq_data init_s3c2416_second[32] = {
 
 void __init s3c2416_init_irq(void)
 {
-   struct s3c_irq_intc *main_intc;
-
pr_info(S3C2416: IRQ Support\n);
 
 #ifdef CONFIG_FIQ
init_FIQ(FIQ_START);
 #endif
 
-   main_intc = s3c24xx_init_intc(NULL, init_s3c2416base[0], NULL, 
0x4a00);
-   if (IS_ERR(main_intc)) {
+   s3c_intc[0] = s3c24xx_init_intc(NULL, init_s3c2416base[0], NULL,
+   0x4a00);
+   if (IS_ERR(s3c_intc[0])) {
pr_err(irq: could not create main interrupt controller\n);
return;
}
 
-   s3c24xx_init_intc(NULL, 

[PATCH v6 6/7] irqchip: s3c24xx: make interrupt handling independent of irq_domain structure

2013-03-26 Thread Heiko Stübner
Keep a pointer to the corresponding s3c_irq_data struct as irq_chip_data.
This removes the need to fetch the intc struct from the irq_domains
host_data, thus making it independent of the underlying irq_domain
structure.

Also keep the real register offset of the interrupt in the s3c_irq_data
struct to make it independent of the hwirq structure in the irq_domain

Signed-off-by: Heiko Stuebner he...@sntech.de
---
 drivers/irqchip/irq-s3c24xx.c |   25 +++--
 1 file changed, 15 insertions(+), 10 deletions(-)

diff --git a/drivers/irqchip/irq-s3c24xx.c b/drivers/irqchip/irq-s3c24xx.c
index 9914abd..02b82db 100644
--- a/drivers/irqchip/irq-s3c24xx.c
+++ b/drivers/irqchip/irq-s3c24xx.c
@@ -43,6 +43,7 @@
 
 struct s3c_irq_data {
unsigned int type;
+   unsigned long offset;
unsigned long parent_irq;
 
/* data gets filled during init */
@@ -79,15 +80,15 @@ static struct s3c_irq_intc *s3c_intc[3];
 
 static void s3c_irq_mask(struct irq_data *data)
 {
-   struct s3c_irq_intc *intc = data-domain-host_data;
+   struct s3c_irq_data *irq_data = irq_data_get_irq_chip_data(data);
+   struct s3c_irq_intc *intc = irq_data-intc;
struct s3c_irq_intc *parent_intc = intc-parent;
-   struct s3c_irq_data *irq_data = intc-irqs[data-hwirq];
struct s3c_irq_data *parent_data;
unsigned long mask;
unsigned int irqno;
 
mask = __raw_readl(intc-reg_mask);
-   mask |= (1UL  data-hwirq);
+   mask |= (1UL  irq_data-offset);
__raw_writel(mask, intc-reg_mask);
 
if (parent_intc) {
@@ -104,14 +105,14 @@ static void s3c_irq_mask(struct irq_data *data)
 
 static void s3c_irq_unmask(struct irq_data *data)
 {
-   struct s3c_irq_intc *intc = data-domain-host_data;
+   struct s3c_irq_data *irq_data = irq_data_get_irq_chip_data(data);
+   struct s3c_irq_intc *intc = irq_data-intc;
struct s3c_irq_intc *parent_intc = intc-parent;
-   struct s3c_irq_data *irq_data = intc-irqs[data-hwirq];
unsigned long mask;
unsigned int irqno;
 
mask = __raw_readl(intc-reg_mask);
-   mask = ~(1UL  data-hwirq);
+   mask = ~(1UL  irq_data-offset);
__raw_writel(mask, intc-reg_mask);
 
if (parent_intc) {
@@ -123,8 +124,9 @@ static void s3c_irq_unmask(struct irq_data *data)
 
 static inline void s3c_irq_ack(struct irq_data *data)
 {
-   struct s3c_irq_intc *intc = data-domain-host_data;
-   unsigned long bitval = 1UL  data-hwirq;
+   struct s3c_irq_data *irq_data = irq_data_get_irq_chip_data(data);
+   struct s3c_irq_intc *intc = irq_data-intc;
+   unsigned long bitval = 1UL  irq_data-offset;
 
__raw_writel(bitval, intc-reg_pending);
if (intc-reg_intpnd)
@@ -291,8 +293,7 @@ static struct irq_chip s3c_irq_eint0t4 = {
 static void s3c_irq_demux(unsigned int irq, struct irq_desc *desc)
 {
struct irq_chip *chip = irq_desc_get_chip(desc);
-   struct s3c_irq_intc *intc = desc-irq_data.domain-host_data;
-   struct s3c_irq_data *irq_data = intc-irqs[desc-irq_data.hwirq];
+   struct s3c_irq_data *irq_data = irq_desc_get_chip_data(desc);
struct s3c_irq_intc *sub_intc = irq_data-sub_intc;
unsigned long src;
unsigned long msk;
@@ -406,6 +407,7 @@ static int s3c24xx_irq_map(struct irq_domain *h, unsigned 
int virq,
 
/* attach controller pointer to irq_data */
irq_data-intc = intc;
+   irq_data-offset = hw;
 
parent_intc = intc-parent;
 
@@ -444,6 +446,9 @@ static int s3c24xx_irq_map(struct irq_domain *h, unsigned 
int virq,
pr_err(irq-s3c24xx: unsupported irqtype %d\n, irq_data-type);
return -EINVAL;
}
+
+   irq_set_chip_data(virq, irq_data);
+
set_irq_flags(virq, IRQF_VALID);
 
if (parent_intc  irq_data-type != S3C_IRQTYPE_NONE) {
-- 
1.7.10.4

--
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 v6 7/7] irqchip: s3c24xx: add devicetree support

2013-03-26 Thread Heiko Stübner
Add the necessary code to initialize the interrupt controller
thru devicetree data using the irqchip infrastructure.

Signed-off-by: Heiko Stuebner he...@sntech.de
---
 .../interrupt-controller/samsung,s3c24xx-irq.txt   |   53 +
 drivers/irqchip/irq-s3c24xx.c  |  231 +++-
 2 files changed, 278 insertions(+), 6 deletions(-)
 create mode 100644 
Documentation/devicetree/bindings/interrupt-controller/samsung,s3c24xx-irq.txt

diff --git 
a/Documentation/devicetree/bindings/interrupt-controller/samsung,s3c24xx-irq.txt
 
b/Documentation/devicetree/bindings/interrupt-controller/samsung,s3c24xx-irq.txt
new file mode 100644
index 000..c54c5a9
--- /dev/null
+++ 
b/Documentation/devicetree/bindings/interrupt-controller/samsung,s3c24xx-irq.txt
@@ -0,0 +1,53 @@
+Samsung S3C24XX Interrupt Controllers
+
+The S3C24XX SoCs contain a custom set of interrupt controllers providing a
+varying number of interrupt sources. The set consists of a main- and sub-
+controller and on newer SoCs even a second main controller.
+
+Required properties:
+- compatible: Compatible property value should be samsung,s3c2410-irq
+  for machines before s3c2416 and samsung,s3c2416-irq for s3c2416 and later.
+
+- reg: Physical base address of the controller and length of memory mapped
+  region.
+
+- interrupt-controller : Identifies the node as an interrupt controller
+
+- #interrupt-cells : Specifies the number of cells needed to encode an
+  interrupt source. The value shall be 4 and interrupt descriptor shall
+  have the following format:
+  ctrl_num parent_irq ctrl_irq type
+
+  ctrl_num contains the controller to use:
+  - 0 ... main controller
+  - 1 ... sub controller
+  - 2 ... second main controller on s3c2416 and s3c2450
+  parent_irq contains the parent bit in the main controller and will be
+ ignored in main controllers
+  ctrl_irq contains the interrupt bit of the controller
+  type contains the trigger type to use
+
+Example:
+
+   interrupt-controller@4a00 {
+   compatible = samsung,s3c2410-irq;
+   reg = 0x4a00 0x100;
+   interrupt-controller;
+   #interrupt-cells=4;
+   };
+
+   [...]
+
+   serial@5000 {
+   compatible = samsung,s3c2410-uart;
+   reg = 0x5000 0x4000;
+   interrupt-parent = subintc;
+   interrupts = 1 28 0 4, 1 28 1 4;
+   };
+
+   rtc@5700 {
+   compatible = samsung,s3c2410-rtc;
+   reg = 0x5700 0x100;
+   interrupt-parent = intc;
+   interrupts = 0 30 0 3, 0 8 0 3;
+   };
diff --git a/drivers/irqchip/irq-s3c24xx.c b/drivers/irqchip/irq-s3c24xx.c
index 02b82db..5e40b34 100644
--- a/drivers/irqchip/irq-s3c24xx.c
+++ b/drivers/irqchip/irq-s3c24xx.c
@@ -25,6 +25,9 @@
 #include linux/ioport.h
 #include linux/device.h
 #include linux/irqdomain.h
+#include linux/of.h
+#include linux/of_irq.h
+#include linux/of_address.h
 
 #include asm/exception.h
 #include asm/mach/irq.h
@@ -36,6 +39,8 @@
 #include plat/regs-irqtype.h
 #include plat/pm.h
 
+#include irqchip.h
+
 #define S3C_IRQTYPE_NONE   0
 #define S3C_IRQTYPE_EINT   1
 #define S3C_IRQTYPE_EDGE   2
@@ -94,7 +99,10 @@ static void s3c_irq_mask(struct irq_data *data)
if (parent_intc) {
parent_data = parent_intc-irqs[irq_data-parent_irq];
 
-   /* check to see if we need to mask the parent IRQ */
+   /* check to see if we need to mask the parent IRQ
+* The parent_irq is always in main_intc, so the hwirq
+* for find_mapping does not need an offset in any case.
+*/
if ((mask  parent_data-sub_bits) == parent_data-sub_bits) {
irqno = irq_find_mapping(parent_intc-domain,
 irq_data-parent_irq);
@@ -294,10 +302,18 @@ static void s3c_irq_demux(unsigned int irq, struct 
irq_desc *desc)
 {
struct irq_chip *chip = irq_desc_get_chip(desc);
struct s3c_irq_data *irq_data = irq_desc_get_chip_data(desc);
+   struct s3c_irq_intc *intc = irq_data-intc;
struct s3c_irq_intc *sub_intc = irq_data-sub_intc;
unsigned long src;
unsigned long msk;
unsigned int n;
+   unsigned int offset;
+
+   /* we're using individual domains for the non-dt case
+* and one big domain for the dt case where the subintc
+* starts at hwirq number 32.
+*/
+   offset = (intc-domain-of_node) ? 32 : 0;
 
chained_irq_enter(chip, desc);
 
@@ -310,14 +326,15 @@ static void s3c_irq_demux(unsigned int irq, struct 
irq_desc *desc)
while (src) {
n = __ffs(src);
src = ~(1  n);
-   generic_handle_irq(irq_find_mapping(sub_intc-domain, n));
+   irq = irq_find_mapping(sub_intc-domain, offset + n);
+   

Re: [RFC 01/12] exynos-fimc-is: Adding device tree nodes

2013-03-26 Thread Sylwester Nawrocki

On 03/26/2013 01:17 PM, Arun Kumar K wrote:

+Sensor sub-nodes:
+
+FIMC-IS IP supports custom built sensors to be controlled exclusively by
+the FIMC-IS firmware. These sensor properties are to be defined here.


[snip]


Defining image sensor nodes in a standard way as ISP I2C bus controller
nodes has an disadvantage that we need dummy I2C bus controller driver,
at least this is how I have written the driver for Exynos4x12. In some
version of it I had sensor nodes put in a isp-i2c fimc-is sub-node, but
then there was an issue that this was not a fully specified I2C bus
controller node.

You can refer to my exynos4 fimc-is patch series for details on how this
is now implemented.

Handling the image sensor in a standard way, as regular I2C client devices
has an advantage that we can put pinctrl properties in relevant device
nodes,
where available, which more closely describes the hardware structure.

I'm not really sure in 100% if all this complication is required. It would
allow to use same DT blob for different Imaging Subsystem SW architecture.
For example some parts of functionality handled currently by FIMC-IS (ARM
Cortex-A5) could be moved to host CPU, without any change in the device
tree structure. The kernel could decide e.g. if it uses image sensor driver
implemented in the ISP firmware, or a driver run on the host CPU.

What do you think ?


I have seen your Exynos4 FIMC-IS patchset and you have made a dummy
I2C sensor driver there.
That mode would work fine in Exynos4 since the sensor and ISP will be used
by the same media controller pipeline. So the ISP component in the pipeline
will ensure that the HW is initialized and sensor is working.

But in Exynos5, we are using sensor in pipeline0 and ISP in pipeline1.
So there is a possibility of using sensor subdev independently
without using pipeline1 ISP components.

So with the driver I sent, the pipeline0 can still work like this --

ISP sensor ---  MIPI-CSIS ---  FIMC-LITE ---  Memory

This cannot be done if a dummy I2C driver is made for ISP sensor.


Why not ? I'm not sure what the problem is here.

I realize that describing image sensors in DT as standard I2C slave devices
is not helpful with current firmware architecture. It adds some unnecessary
complication, OTOH it could simplify the sensors registration and media 
graph

initialization code, by unifying it for the firmware based ISP specific
sensors and the external ones with a built-in ISP. Also we could avoid 
having

the bindings defined by current architecture of the driver.

Nevertheless, coming back to your question, the I2C controller driver would
be in same module as the FIMC-IS driver. From user space perspective nothing
changes when you add I2C bus driver and register the sensor in a 
standard way.

What exactly couldn't be done in the kernel ?
--
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


Re: [PATCH v6 1/7] media: V4L2: add temporary clock helpers

2013-03-26 Thread Laurent Pinchart
Hello,

On Tuesday 19 March 2013 10:52:29 Sylwester Nawrocki wrote:
 On 03/19/2013 08:32 AM, Guennadi Liakhovetski wrote:
  On Mon, 18 Mar 2013, Sylwester Nawrocki wrote:
  On 03/15/2013 10:27 PM, Guennadi Liakhovetski wrote:
 [...]
 
  diff --git a/drivers/media/v4l2-core/v4l2-clk.c
  b/drivers/media/v4l2-core/v4l2-clk.c
  new file mode 100644
  index 000..3505972
  --- /dev/null
  +++ b/drivers/media/v4l2-core/v4l2-clk.c

[snip]

  +static struct v4l2_clk *v4l2_clk_find(const struct v4l2_subdev *sd,
  +   const char *dev_id, const char *id)
  +{
  + struct v4l2_clk *clk;
  +
  + list_for_each_entry(clk,clk_list, list) {
  + if (!sd || !(sd-flags  V4L2_SUBDEV_FL_IS_I2C)) {
  + if (strcmp(dev_id, clk-dev_id))
  + continue;
  + } else {
  + char *i2c = strstr(dev_id, clk-dev_id);
  + if (!i2c || i2c == dev_id || *(i2c - 1) != ' ')
  + continue;
  + }
  +
  + if (!id || !clk-id || !strcmp(clk-id, id))
  + return clk;
  + }
  +
  + return ERR_PTR(-ENODEV);
  +}
  +
  +struct v4l2_clk *v4l2_clk_get(struct v4l2_subdev *sd, const char *id)
  +{
  + struct v4l2_clk *clk;
  +
  + mutex_lock(clk_lock);
  + clk = v4l2_clk_find(sd, sd-name, id);
  
  Couldn't we just pass the I2C client's struct device name to this
  function ?
  
  Certainly not. This is a part of the generic V4L2 clock API, it's not I2C
  specific.
 
 I have been thinking about something like dev_name(sd-dev), but struct
 v4l2_subdev doesn't have struct device associated with it.

But the caller of v4l2_clk_get() will have a struct device * available, so I 
think it would make sense to pass a struct device * to v4l2_clk_get() and call 
dev_name() on it internally. Clocks would be registered with the device ID as 
well. This requires knowledge of the clock user device in the clock provider, 
but no knowledge of the clock user module name.
 
  And if the host driver that registers a clock for its sub-device knows
  the type of device (I2C, SPI client, etc.) why we need to even bother
  with checking the subdev/bus type in v4l2_clk_find() function above, when
  the host could properly format dev_id when it registers a clock ?
  
  This has been discussed. The host doesn't know the name of the I2C driver,
  that would attach to this subdevice at the time, it registers the clock.
  This is the easiest way to oversome this problem.
 
 OK, thanks for reminding. It would be probably much easier to associate
 the clock with struct device, not with subdev driver. Devices have more
 clear naming rules (at last I2C, SPI clients). And most host drivers
 already have information about I2C bus id, just I2C slave address would
 need to be passed to the host driver so it can register a clock for its
 subdev.
 
  Then the subdev would just pass its struct device pointer to this API to
  find its clock. What am I missing here ?
  I don't think there's a 1-to-1 correspondence between devices and V4L2
  subdevices.
 
 I would expect at least a subdev that needs a clock to have struct device
 associated with it. It would be also much easier this way to use generic
 clocks API in the device tree instantiated systems.

I agree. Let's not overdesign the v4l2-clock API to support clock users 
without a struct device. This is a transitional API only after all.

  + if (!IS_ERR(clk)  !try_module_get(clk-ops-owner))
  + clk = ERR_PTR(-ENODEV);
  + mutex_unlock(clk_lock);
  +
  + if (!IS_ERR(clk)) {
  + clk-subdev = sd;
  
  Why is this needed ? It seems a strange addition that might potentially
  make transition to the common clocks API more difficult.
  
  We got rid of the v4l2_clk_bind() function and the .bind() callback. Now I
  need a pointer to subdevice _before_ v4l2_clk_register() (former
  v4l2_clk_bound()), that's why I have to store it here.
 
 Hmm, sorry, I'm not following. How can we store a subdev pointer in the
 clock data structure that has not been registered yet and thus cannot be
 found with v4l2_clk_find() ?
 
  + atomic_inc(clk-use_count);
  + }
  +
  + return clk;
  +}
  +EXPORT_SYMBOL(v4l2_clk_get);

-- 
Regards,

Laurent Pinchart

--
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


Re: [PATCH v6 1/7] media: V4L2: add temporary clock helpers

2013-03-26 Thread Laurent Pinchart
Hi Guennadi,

On Tuesday 19 March 2013 11:27:56 Guennadi Liakhovetski wrote:
 On Tue, 19 Mar 2013, Sylwester Nawrocki wrote:
   +   if (!IS_ERR(clk)  !try_module_get(clk-ops-owner))
   +   clk = ERR_PTR(-ENODEV);
   +   mutex_unlock(clk_lock);
   +
   +   if (!IS_ERR(clk)) {
   +   clk-subdev = sd;
   
   Why is this needed ? It seems a strange addition that might potentially
   make transition to the common clocks API more difficult.
   
   We got rid of the v4l2_clk_bind() function and the .bind() callback. Now
   I need a pointer to subdevice _before_ v4l2_clk_register() (former
   v4l2_clk_bound()), that's why I have to store it here.
  
  Hmm, sorry, I'm not following. How can we store a subdev pointer in the
  clock data structure that has not been registered yet and thus cannot be
  found with v4l2_clk_find() ?
 
 sorry, I meant v4l2_async_subdev_register(), not v4l2_clk_register(), my
 mistake. And I meant v4l2_async_subdev_bind(), v4l2_async_subdev_unbind().
 Before we had in the subdev driver (see imx074 example)
 
   /* Tell the bridge the subdevice is about to bind */
   v4l2_async_subdev_bind();
 
   /* get a clock */
   clk = v4l2_clk_get();
   if (IS_ERR(clk))
   return -EPROBE_DEFER;
 
   /*
* enable the clock - this needs a subdev pointer, that we passed
* to the bridge with v4l2_async_subdev_bind() above
*/
   v4l2_clk_enable(clk);
   do_probe();
   v4l2_clk_disable(clk);
 
   /* inform the bridge: binding successful */
   v4l2_async_subdev_bound();
 
 Now we have just
 
   /* get a clock */
   clk = v4l2_clk_get();
   if (IS_ERR(clk))
   return -EPROBE_DEFER;
 
   /*
* enable the clock - this needs a subdev pointer, that we stored
* in the clock object for the bridge driver to use with
* v4l2_clk_get() above
*/
   v4l2_clk_enable(clk);
   do_probe();
   v4l2_clk_disable(clk);

I'm sorry, but I still don't understand why you need a pointer to the subdev 
in the clock provider implementation of v4l2_clk_enable/disable() :-)

   /* inform the bridge: binding successful */
   v4l2_async_subdev_bound();

-- 
Regards,

Laurent Pinchart

--
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


Re: RE: [PATCH v2 0/4] clk: samsung: pm fixes and multiple aliases

2013-03-26 Thread Mike Turquette
Quoting Kukjin Kim (2013-03-25 02:26:34)
 Heiko Stübner wrote:
  
  Second version of the fixes to address comments gathered from the first
  version, like not entering the dt code on non-dt platforms even if
  dt-support is present in the kernel.
  
  Patch 1 and 3 got Reviewed-by tags but I only included the one for
  patch 1, because patch 3 changed due to the changes in patch 2.
  
  Heiko Stuebner (4):
clk: samsung: register clk_div_tables for divider clocks
clk: samsung: fix pm init on non-dt platforms
clk: samsung: always allocate the clk_table
clk: samsung: add infrastructure to add separate aliases
  
   drivers/clk/samsung/clk.c |   72 +++--
  ---
   drivers/clk/samsung/clk.h |   34 ++--
   2 files changed, 87 insertions(+), 19 deletions(-)
  
  --
  1.7.2.3
 
 Looks good to me and applied into samsung tree based on samsung common clock 
 by Thomas P Abraham for testing.
 
 But would be helpful to me if I could get Mike's ack on this series.
 

Acked-by: Mike Turquette mturque...@linaro.org

 Thanks.
 
 - Kukjin
--
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


Re: [PATCH 4/6] pci: Add PCIe driver for Samsung Exynos

2013-03-26 Thread Jingoo Han
On Wednesday, March 27, 2013 6:33 AM, Rob Herring wrote:
 
 On 03/22/2013 11:07 PM, Jingoo Han wrote:
  Exynos5440 has a PCIe controller which can be used as Root Complex.
  This driver supports a PCIe controller as Root Complex mode.
 
  Signed-off-by: Surendranath Gurivireddy Balla suren.re...@samsung.com
  Signed-off-by: Siva Reddy Kallam siva.kal...@samsung.com
  Signed-off-by: Jingoo Han jg1@samsung.com
  ---
   .../devicetree/bindings/pci/exynos-pcie.txt|   56 +
   drivers/pci/host/Kconfig   |5 +
   drivers/pci/host/Makefile  |1 +
   drivers/pci/host/pci-exynos.c  | 1139 
  
   4 files changed, 1201 insertions(+), 0 deletions(-)
   create mode 100644 Documentation/devicetree/bindings/pci/exynos-pcie.txt
   create mode 100644 drivers/pci/host/Makefile
   create mode 100644 drivers/pci/host/pci-exynos.c
 
 [...]
 
  +
  +/* synopsis specific PCIE configuration registers*/
 
 If this is a standard IP block, then the driver naming should reflect
 that. I suspect there are several others with the same IP block.

Sorry, I don't think so.
Only core block is a standard IP block, other parts are Exynos-specific.
So, it is hard to share with other PCIe IPs using synopsis core.

Best regards,
Jingoo Han

 
 Rob

--
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


Re: [PATCH] arm:exynos5250: Restore CLK_SRC_TOP3 register via CCF

2013-03-26 Thread Mike Turquette
Quoting Tomasz Figa (2013-03-26 04:28:13)
 Hi Prasanna,
 
 On Tuesday 26 of March 2013 10:12:15 Prasanna Kumar wrote:
  From: Prasanna Kumar prasanna...@samsung.com
  
  This patch adds support for restoring CLK_SRC_TOP3 register
  which gets modified while powergating corresponding power domains
  after a cycle of Suspend-to-Resume.
  
  Please refer below URL to know the background of this issue.
  http://www.mail-archive.com/linux-samsung-soc@vger.kernel.org/msg14347.html.
  
  This is based on Common Clock Framework defined for exynos5250 and
  patch mentioned here
  http://www.mail-archive.com/linux-samsung-soc@vger.kernel.org/msg16739.html
  
  Signed-off-by: Prasanna Kumar prasanna...@samsung.com
  ---
   arch/arm/mach-exynos/pm_domains.c |   43
  + 1 files changed, 43 insertions(+), 0
  deletions(-)
  
  diff --git a/arch/arm/mach-exynos/pm_domains.c
  b/arch/arm/mach-exynos/pm_domains.c index 9f1351d..b5ed384 100644
  --- a/arch/arm/mach-exynos/pm_domains.c
  +++ b/arch/arm/mach-exynos/pm_domains.c
 
 First of all, why this is happening in power domain driver? It does not (and 
 should not) know anything about clocks. I'm sure you can find a better place 
 for this.
 
  @@ -21,8 +21,11 @@
   #include linux/of_address.h
   #include linux/of_platform.h
   #include linux/sched.h
  +#include linux/clk.h
  +#include linux/clk-private.h
 
 This header is _not_ supposed included outside clock core and clock drivers.
 

Yeah, big NACK on usage of clk-private.h.

Regards,
Mike

  
   #include mach/regs-pmu.h
  +#include plat/cpu.h
   #include plat/devs.h
  
   /*
  @@ -35,6 +38,43 @@ struct exynos_pm_domain {
struct generic_pm_domain pd;
   };
  +static int exynos_pdclk_restore(struct exynos_pm_domain *domain)
  +{
  + int i = 0;
  + struct clk *p_clk;
  + struct clk_hw *hw_clk;
  + const struct clk_ops *p_ops;
  +
  + const char *pdclks[][2] = {
  + { gsc-power-domain,
  + m_sub_aclk266 },
  + { gsc-power-domain,
  + m_sub_aclk300 },
  + { mfc-power-domain,
  + m_sub_aclk333 },
  + };
  +
  + for (i = 0; i  ARRAY_SIZE(pdclks); i++) {
  + if (!strcmp(domain-name, pdclks[i][0])) {
  + p_clk = clk_get(NULL, pdclks[i][1]);
  + if (IS_ERR(p_clk)) {
  + pr_err(failed to get base clk\n);
  + return PTR_ERR(p_clk);
  + }
  +
  + hw_clk = __clk_get_hw(p_clk);
  + if (IS_ERR(hw_clk)) {
  + pr_err(failed to get hw_clk\n);
  + return PTR_ERR(hw_clk);
  + }
 
 This is completely wrong: hw_clk is an internal structure that should be used 
 only inside the driver of this particular clock and clock core, nowhere else.
 
  + p_ops = p_clk-ops;
  + if (p_ops != NULL  p_ops-set_parent != NULL)
  + p_clk-ops-set_parent(hw_clk, 1);
 
 Same goes here: p_clk is an opaque pointer to something that can _not_ be 
 dereferenced outside clock core.
 
  + }
  + }
  + return 0;
  +}
  +
 
 NAK.
 
 This code contains so many Linux kernel development antipatterns, that it's 
 missing only IS_ERR_OR_NULL to be placed on top of hall of fame of such, if 
 one exists.
 
   static int exynos_pd_power(struct generic_pm_domain *domain, bool power_on)
  {
struct exynos_pm_domain *pd;
  @@ -61,6 +101,9 @@ static int exynos_pd_power(struct generic_pm_domain
  *domain, bool power_on) cpu_relax();
usleep_range(80, 100);
}
  +
  + if (!power_on  soc_is_exynos5250())
  + exynos_pdclk_restore(pd);
return 0;
   }
 
 Best regards,
 -- 
 Tomasz Figa
 Samsung Poland RD Center
 SW Solution Development, Kernel and System Framework
--
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


Re: [PATCH] [media] s5p-mfc: Change MFC clock reference w.r.t Common Clock Framework

2013-03-26 Thread Mike Turquette
Quoting Prasanna Kumar (2013-03-25 22:20:51)
 From: Prasanna Kumar prasanna...@samsung.com
 
 According to Common Clock framework , modified the method of getting
 clock for MFC Block.
 
 Signed-off-by: Prasanna Kumar prasanna...@samsung.com
 ---
  drivers/media/platform/s5p-mfc/s5p_mfc_pm.c |2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)
 
 diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_pm.c 
 b/drivers/media/platform/s5p-mfc/s5p_mfc_pm.c
 index 6aa38a5..b8ac8f6 100644
 --- a/drivers/media/platform/s5p-mfc/s5p_mfc_pm.c
 +++ b/drivers/media/platform/s5p-mfc/s5p_mfc_pm.c
 @@ -50,7 +50,7 @@ int s5p_mfc_init_pm(struct s5p_mfc_dev *dev)
 goto err_p_ip_clk;
 }
  
 -   pm-clock = clk_get(dev-plat_dev-dev, dev-variant-mclk_name);
 +   pm-clock = clk_get_parent(pm-clock_gate);

Ok, I'll bite.  Why make this change?  Was there an issue using
clkdev/clk_get to get the clock you needed?

Regards,
Mike

 if (IS_ERR(pm-clock)) {
 mfc_err(Failed to get MFC clock\n);
 ret = PTR_ERR(pm-clock);
 -- 
 1.7.5.4
 
 
 ___
 linux-arm-kernel mailing list
 linux-arm-ker...@lists.infradead.org
 http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
--
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