Re: [PATCH v4] ARM: EXYNOS: Add MFC device tree support

2012-09-24 Thread Karol Lewandowski
On 09/22/2012 08:07 PM, Arun Kumar K wrote:

 This patch adds device tree entry for MFC v6 in the Exynos5
 SoC. Makes the required changes in the clock files and adds
 MFC to the DT device list.
 
 Signed-off-by: Naveen Krishna Chatradhi ch.nav...@samsung.com
 Signed-off-by: Arun Kumar K arun...@samsung.com


Looks good for me. FWIW, I could probably add

Acked-by: Karol Lewandowski k.lewando...@samsung.com

Regards,
-- 
Karol Lewandowski | Samsung Poland RD Center | Linux/Platform
--
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 v3] ARM: EXYNOS: Add MFC device tree support

2012-09-19 Thread Karol Lewandowski
On 09/14/2012 05:38 PM, Arun Kumar K wrote:

 This patch adds device tree entry for MFC v6 in the Exynos5
 SoC. Makes the required changes in the clock files and adds
 MFC to the DT device list.


Hi!

Thanks for working on this patch. Please allow me to add few
comments.


 diff --git a/arch/arm/boot/dts/exynos5250.dtsi 
 b/arch/arm/boot/dts/exynos5250.dtsi
 index b55794b..5df2f99 100644
 --- a/arch/arm/boot/dts/exynos5250.dtsi
 +++ b/arch/arm/boot/dts/exynos5250.dtsi
 @@ -62,6 +62,12 @@
   interrupts = 0 42 0;
   };
  
 + mfc {


Nitpick - shouldn't node names be generic?  MFC is strictly
samsung specific, something like codec/video-codec would make
more sense (IMVHO). I would prefer to see address too (e.g.
codec@0x1100).

However, I do see that rtc below doesn't specify address in node too,
so maybe I'm missing something here.


  
 +struct mfc_dt_meminfo {
 + unsigned long loff;
 + unsigned long lsize;
 + unsigned long roff;
 + unsigned long rsize;


  char *compatible;

 +};
 +
 +int fdt_find_mfc_mem(unsigned long node, const char *uname, int depth,
 + void *data)
 +{
 + __be32 *prop;
 + unsigned long len;
 + struct mfc_dt_meminfo *mfc_mem = data;
 +
 + if (!of_flat_dt_is_compatible(node, samsung,mfc-v6))
 + return 0;


  if (!of_flat_dt_is_compatible(node, mfc_mem-compatible))
return 0;

 +
 + prop = of_get_flat_dt_prop(node, samsung,mfc-l, len);
 + if (!prop)
 + return 0;
 + mfc_mem-loff = of_read_ulong(prop, len/4);
 +
 + prop = of_get_flat_dt_prop(node, samsung,mfc-l-size, len);
 + if (!prop)
 + return 0;
 + mfc_mem-lsize = of_read_ulong(prop, len/4);
 +
 + prop = of_get_flat_dt_prop(node, samsung,mfc-r, len);
 + if (!prop)
 + return 0;
 + mfc_mem-roff = of_read_ulong(prop, len/4);
 +
 + prop = of_get_flat_dt_prop(node, samsung,mfc-r-size, len);
 + if (!prop)
 + return 0;
 + mfc_mem-rsize = of_read_ulong(prop, len/4);
 +
 + return 1;
 +}


Above function could be reused for mfc-v5 (exynos4-dt.c) if compatible
string weren't hardcoded. Thus, please consider changing that and
moving this function to some common(.c?) file - you can see one possible
solution inline.

 +
 +static void __init exynos5_reserve(void)
 +{
 + struct mfc_dt_meminfo mfc_mem;


mfc_mem.compatible = samsung,mfc-v6;

 +
 + /* Reserve memory for MFC only if it's available */
 + if (of_scan_flat_dt(fdt_find_mfc_mem, mfc_mem))
 + s5p_mfc_reserve_mem(mfc_mem.roff, mfc_mem.rsize, mfc_mem.loff,
 + mfc_mem.lsize);
 +}
 +
  DT_MACHINE_START(EXYNOS5_DT, SAMSUNG EXYNOS5 (Flattened Device Tree))
   /* Maintainer: Kukjin Kim kgene@samsung.com */
   .init_irq   = exynos5_init_irq,
 @@ -94,4 +148,5 @@ DT_MACHINE_START(EXYNOS5_DT, SAMSUNG EXYNOS5 (Flattened 
 Device Tree))
   .timer  = exynos4_timer,
   .dt_compat  = exynos5250_dt_compat,
   .restart= exynos5_restart,
 + .reserve= exynos5_reserve,
  MACHINE_END


Regards,
-- 
Karol Lewandowski | Samsung Poland RD Center | Linux/Platform
--
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: EXYNOS: Add MFC device tree support

2012-09-04 Thread Karol Lewandowski
On 08/28/2012 07:08 PM, Arun Kumar K wrote:

 Hi Karol,
 Thanks for your comments. 
 Please find my response inline.

Hi... and sorry for so much delayed response.

 +
 +static void __init exynos5_reserve(void)
 +{
 + s5p_mfc_reserve_mem(0x4300, 8  20, 0x5100, 8  20);


 I think it would make sense to make this memory reservation dependent
 on mfc* node being present in DTS.  It's to early to use of_* functions
 (because tree is not populated at this stage) but fdt_* family of functions
 work just fine.

 
 As I can see the fdt_* functions are not used in any of the ARM based SoC
 init codes. Though I can see some references in powerpc.
 The implementation and includes are present in arch/arm/boot/compressed/
 which I think cannot be used directly in mach-exynos unless we make some
 comon makefile changes. 


It looks like I was writing from memory, and I actually mixed things 
up.  To be clear this time - we can't use regular device tree handling
functions in reserve() as it's too early.  Namely, flattened device tree
is not yet converted to kernel's-natural representation.  However, 
I think we can scan fdt just fine.  To do so one just needs to use
functions declared here

  #include linux/of_fdt.h

Actual architecture-independent code is in drivers/of/fdt.c.  This
provides of_fdt_ family of functions. Please see below for example.


 Please clarify whether its ok to use fdt_* functions to parse the dts in 
 exynos machine init or please point me to some sample implementations
 which I can refer to.


It should be ok to use anything that works on flattened device tree
rather than its uncompressed version.  I've experimented a bit and
something like this worked for me just fine (it was around 3.3-kernel
timeframe, but I don't think that fdt api has changed):

[mach-exynos4-dt.c]

#include linux/of_fdt.h

int fdt_find_compat(unsigned long node, const char *uname, int depth, void 
*data)
{
if (of_flat_dt_is_compatible(node, (char *)data))
return 1;

return 0;
}

static void __init exynos4210_dt_reserve(void)
{
/* Reserve memory for MFC only if it's available */
if (of_scan_flat_dt(fdt_find_compat, samsung,s5pv210-mfc)) {
printk(KERN_NOTICE exynos4-dt: mfc device node found - setting 
up memory area for dma\n);
s5p_mfc_reserve_mem(0x4300, 8  20, 0x5100, 8  20);
}
}

[.dts]

 codec@some-addr {
  compatible = samsung,s5pv210-mfc;
 };


So, in above code fragment I just check if mfc was defined in dts.
This could probably stay as it is.

Then I allocate _predefined_ region - and this part should be fixed.

If you have nodes like mfc-r-size/offset, then you could just get
this information directly from (f)dt rather than hardcoding it in the code.
Precisely, after we find compatible node we could do something like
following (untested):

unsigned long lsize, loff, rsize, roff len;
__be32 *prop;

prop = of_get_flat_dt_prop(node, samsung,mfc-l-size, len);
if (!prop)
   return;
lsize = of_read_ulong(prop, len/4);
...

Regards,
-- 
Karol Lewandowski | Samsung Poland RD Center | Linux/Platform
--
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: EXYNOS: Add MFC device tree support

2012-08-20 Thread Karol Lewandowski
On 08/16/2012 08:42 PM, Thomas Abraham wrote:
 On 16 August 2012 18:01, Arun Kumar K arun.kk ... @public.gmane.org wrote:

 +  - interrupts : MFC interupt number to the CPU.
 +
 +  - samsung,mfc-r : Base address of the first memory bank used by MFC
 +   for DMA contiguous memory allocation.
 +
 +  - samsung,mfc-r-size : Size of the first memory bank.
 
 It is not allowed to pass buffer base address and size from device
 tree. Device tree node should describe only the MFC controller
 hardware. Any memory management related information should be handled
 outside of device tree. This helps the bindings to be reusable across
 multiple operating systems.

The question is where elsewhere this should be described as this is strictly
board-dependent option (number and size of RAM banks are important here).

I agree that base addresses are bad, but I'm not aware of any functionality
that would allow driver (actually, its platform dependent part in
exynosN_reserve() function) to enumerate available memory banks and grab
memory chunks from two distinct banks.

My (lack of) knowledge ARM might be to blame here but I simply don't know
how to achieve this. Any suggestions?


On 08/16/2012 09:31 PM, Arun Kumar K wrote:

 +static void s5p_mfc_reserve_mem(phys_addr_t rbase, unsigned int rsize,
 + phys_addr_t lbase, unsigned int lsize) {
 +
 + if (memblock_remove(lbase, lsize)) {
 + pr_err(Failed to reserve bank1 memory for MFC device\n);
 + WARN_ON(1);
 + }
 +
 + if (memblock_remove(rbase, rsize)) {
 + pr_err(Failed to reserve bank2 memory for MFC device\n);
 + WARN_ON(1);
 + }
 +}


non-static function with the same name is already defined in
arch/arm/plat-samsung/s5p-dev-mfc.c. Please don't duplicate it,
especially that you seem to be trying to do that twice!


 diff --git a/arch/arm/mach-exynos/mach-exynos5-dt.c 
 b/arch/arm/mach-exynos/mach-exynos5-dt.c

 index ef770bc..898d2de 100644
 --- a/arch/arm/mach-exynos/mach-exynos5-dt.c
 +++ b/arch/arm/mach-exynos/mach-exynos5-dt.c
...
 +static void s5p_mfc_reserve_mem(phys_addr_t rbase, unsigned int rsize,
 + phys_addr_t lbase, unsigned int lsize) {
 +
 + if (memblock_remove(lbase, lsize)) {
 + pr_err(Failed to reserve bank1 memory for MFC device\n);
 + WARN_ON(1);
 + }
 +
 + if (memblock_remove(rbase, rsize)) {
 + pr_err(Failed to reserve bank2 memory for MFC device\n);
 + WARN_ON(1);
 + }
 +}


See above.

 +
 +static void __init exynos5_reserve(void)
 +{
 + s5p_mfc_reserve_mem(0x4300, 8  20, 0x5100, 8  20);


I think it would make sense to make this memory reservation dependent
on mfc* node being present in DTS.  It's to early to use of_* functions
(because tree is not populated at this stage) but fdt_* family of functions
work just fine.

Regards,
-- 
Karol Lewandowski | Samsung Poland RD Center | Linux/Platform
--
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 1/2] i2c-s3c2410: Rework device type handling

2012-04-25 Thread Karol Lewandowski
On 24.04.2012 16:44, Wolfram Sang wrote:

 On Tue, Apr 24, 2012 at 10:40:49AM +0200, Karol Lewandowski wrote:
 On 23.04.2012 20:20, Wolfram Sang wrote:


 +  if (pdev-dev.of_node) {
 +  const struct of_device_id *match;
 +  match = of_match_node(s3c24xx_i2c_match, pdev-dev.of_node);

 I'd appreciate a comment explaining why match can't be NULL here (as to
 my understanding, it can't). Or just check for it, but this way it looks
 a bit fishy and people (hopefully ;)) will ask about it.


 My understanding is that it can't be null for exactly same reason why
 platform_get_device_id(pdev) can't be null either (see below).

 I.e. prerequisite for this code to be run at all (as it's called from
 driver's .probe()) is to be already matched against very same match
 table.
 
 Yes, I agree. Yet, this is not obvious and people might try to fix it
 (especially since programs like smatch report it as potentially
 dangerous). Ah, whatever, I could simply apply the fix then :) OK.


Great! I hope it won't cause any problems. :)

Regards,
-- 
Karol Lewandowski | Samsung Poland RD Center | Linux/Platform
--
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 1/2] i2c-s3c2410: Rework device type handling

2012-04-24 Thread Karol Lewandowski
On 23.04.2012 20:20, Wolfram Sang wrote:

Hi!

 -static inline int s3c24xx_i2c_is2440(struct s3c24xx_i2c *i2c)
 +static inline unsigned int s3c24xx_get_device_quirks(struct platform_device 
 *pdev)
  {
 -struct platform_device *pdev = to_platform_device(i2c-dev);
 -enum s3c24xx_i2c_type type;
 -
 -#ifdef CONFIG_OF
 -if (i2c-dev-of_node)
 -return of_device_is_compatible(i2c-dev-of_node,
 -samsung,s3c2440-i2c);
 -#endif
 +if (pdev-dev.of_node) {
 +const struct of_device_id *match;
 +match = of_match_node(s3c24xx_i2c_match, pdev-dev.of_node);
 
 I'd appreciate a comment explaining why match can't be NULL here (as to
 my understanding, it can't). Or just check for it, but this way it looks
 a bit fishy and people (hopefully ;)) will ask about it.


My understanding is that it can't be null for exactly same reason why
platform_get_device_id(pdev) can't be null either (see below).

I.e. prerequisite for this code to be run at all (as it's called from
driver's .probe()) is to be already matched against very same match
table.

As far I can see the only possibility for it to fail is to have
dev.of_node pointing to device tree node and NOT being instantiated
from DT description...

 +return (unsigned int)match-data;
 +}
  
 -type = platform_get_device_id(pdev)-driver_data;
 -return type == TYPE_S3C2440;
 +return platform_get_device_id(pdev)-driver_data;
  }


Regards,

-- 

Karol Lewandowski | Samsung Poland RD Center | Linux/Platform
--
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 3/3] i2c-s3c2410: Add HDMIPHY quirk for S3C2440

2012-04-23 Thread Karol Lewandowski
On 23.04.2012 12:01, Wolfram Sang wrote:

 Hi Karol,
 Tomasz had similar doubts when I've posted patch that checked these
 quirks only for S3C2440:

   http://permalink.gmane.org/gmane.linux.drivers.i2c/10305

 Thus, I've chosen properties and not separate type.
 
 I understand this reasoning. I still differ, though. Think about my
 above example about things getting worse. Then, you'd need another
 quirk-property for $FLAW. Later, $FLAW is still there, but the timeout
 issue was fixed. That would mean, the poor device-tree making person has
 to know which quirks to select for this version of the controller. Just
 specifying that it is the HDMI-phy and not a regular I2C controller is
 much more convenient, and the driver will figure the rest.



 It's easy to introduce compat string (see below), but given above
 I'm afraid that we might end up adding -hdmiphy- variant for every
 new version of i2c controller.
 
 I'd be fine with that, given that the upcoming hdmiphy versions will not
 need all the same set of quirk-flags. I think we want that quirk lookup
 table fixed in the driver and not encoded in the device tree where
 people could get it wrong. Also, the quirks are nothing a board maker
 can select from; it is implicit as soons as you want the HDMIPHY on that
 SoC, thus the compatible-entry should be enough of a description.


Fair point, from integrator/board maker POV this makes much more sense.

 I am not the ultimate expert about bindings, though, and am open for
 corrections (I feel kinda confident on this issue, though ;))


I'm quite happy with doing it the way you just described.

I'll resend whole patchset in a minute.

Thanks!
-- 
Karol Lewandowski | Samsung Poland RD Center | Linux/Platform
--
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 v4 0/2] i2c-s3c2410: Updates for exynos4210 and DT-based systems

2012-04-23 Thread Karol Lewandowski
Changes since v3:
 - Replace DT-visible quirks with new controller type
   [Suggested by Wolfram Sang]
 - Dropped already merged of_match_ptr()-patch

Changes since v2:
 - Merge device type and flags into flat bitmask named quirks -
   Consequently, treat s3c24xx as baseline hardware platform and
   support all hw variations via quirks [Suggested by Mark Brown]

Changes since v1:
 - Move unrelated code fragment to separate patch (of_match_ptr())
   [Suggested by Thomas Abracham]
 - Move device-type handling to separate function and rework its
   internals a bit [likewise]

This patchset reworks i2c-s3c2410 driver a bit to better handle
device tree-enabled platforms and adds two quirks required by
exynos4210-specific I2C controller used by s5p-hdmi driver.

This patchset is based on i2c-bjdooks/for-34/i2c/i2c-samsung branch
taken from:

  git://git.fluff.org/bjdooks/linux.git


Karol Lewandowski (2):
  i2c-s3c2410: Rework device type handling
  i2c-s3c2410: Add HDMIPHY quirk for S3C2440

 .../devicetree/bindings/i2c/samsung-i2c.txt|8 +-
 drivers/i2c/busses/i2c-s3c2410.c   |  105 
 2 files changed, 70 insertions(+), 43 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 1/2] i2c-s3c2410: Rework device type handling

2012-04-23 Thread Karol Lewandowski
Reorganize driver a bit to better handle device tree-based systems:

 - move machine type to driver's private structure instead of
   quering platform device variants in runtime

 - replace s3c24xx_i2c_type enum with unsigned int that holds
   bitmask with revision-specific quirks

Signed-off-by: Karol Lewandowski k.lewando...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/i2c/busses/i2c-s3c2410.c |   75 +-
 1 file changed, 34 insertions(+), 41 deletions(-)

diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
index 85e3664..23736ff 100644
--- a/drivers/i2c/busses/i2c-s3c2410.c
+++ b/drivers/i2c/busses/i2c-s3c2410.c
@@ -44,8 +44,10 @@
 #include plat/regs-iic.h
 #include plat/iic.h
 
-/* i2c controller state */
+/* Treat S3C2410 as baseline hardware, anything else is supported via quirks */
+#define QUIRK_S3C2440  (1  0)
 
+/* i2c controller state */
 enum s3c24xx_i2c_state {
STATE_IDLE,
STATE_START,
@@ -54,14 +56,10 @@ enum s3c24xx_i2c_state {
STATE_STOP
 };
 
-enum s3c24xx_i2c_type {
-   TYPE_S3C2410,
-   TYPE_S3C2440,
-};
-
 struct s3c24xx_i2c {
spinlock_t  lock;
wait_queue_head_t   wait;
+   unsigned intquirks;
unsigned intsuspended:1;
 
struct i2c_msg  *msg;
@@ -88,26 +86,40 @@ struct s3c24xx_i2c {
 #endif
 };
 
-/* default platform data removed, dev should always carry data. */
+static struct platform_device_id s3c24xx_driver_ids[] = {
+   {
+   .name   = s3c2410-i2c,
+   .driver_data= 0,
+   }, {
+   .name   = s3c2440-i2c,
+   .driver_data= QUIRK_S3C2440,
+   }, { },
+};
+MODULE_DEVICE_TABLE(platform, s3c24xx_driver_ids);
+
+#ifdef CONFIG_OF
+static const struct of_device_id s3c24xx_i2c_match[] = {
+   { .compatible = samsung,s3c2410-i2c, .data = (void *)0 },
+   { .compatible = samsung,s3c2440-i2c, .data = (void *)QUIRK_S3C2440 },
+   {},
+};
+MODULE_DEVICE_TABLE(of, s3c24xx_i2c_match);
+#endif
 
-/* s3c24xx_i2c_is2440()
+/* s3c24xx_get_device_quirks
  *
- * return true is this is an s3c2440
+ * Get controller type either from device tree or platform device variant.
 */
 
-static inline int s3c24xx_i2c_is2440(struct s3c24xx_i2c *i2c)
+static inline unsigned int s3c24xx_get_device_quirks(struct platform_device 
*pdev)
 {
-   struct platform_device *pdev = to_platform_device(i2c-dev);
-   enum s3c24xx_i2c_type type;
-
-#ifdef CONFIG_OF
-   if (i2c-dev-of_node)
-   return of_device_is_compatible(i2c-dev-of_node,
-   samsung,s3c2440-i2c);
-#endif
+   if (pdev-dev.of_node) {
+   const struct of_device_id *match;
+   match = of_match_node(s3c24xx_i2c_match, pdev-dev.of_node);
+   return (unsigned int)match-data;
+   }
 
-   type = platform_get_device_id(pdev)-driver_data;
-   return type == TYPE_S3C2440;
+   return platform_get_device_id(pdev)-driver_data;
 }
 
 /* s3c24xx_i2c_master_complete
@@ -676,7 +688,7 @@ static int s3c24xx_i2c_clockrate(struct s3c24xx_i2c *i2c, 
unsigned int *got)
 
writel(iiccon, i2c-regs + S3C2410_IICCON);
 
-   if (s3c24xx_i2c_is2440(i2c)) {
+   if (i2c-quirks  QUIRK_S3C2440) {
unsigned long sda_delay;
 
if (pdata-sda_delay) {
@@ -906,6 +918,7 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
goto err_noclk;
}
 
+   i2c-quirks = s3c24xx_get_device_quirks(pdev);
if (pdata)
memcpy(i2c-pdata, pdata, sizeof(*pdata));
else
@@ -1110,26 +1123,6 @@ static const struct dev_pm_ops s3c24xx_i2c_dev_pm_ops = {
 
 /* device driver for platform bus bits */
 
-static struct platform_device_id s3c24xx_driver_ids[] = {
-   {
-   .name   = s3c2410-i2c,
-   .driver_data= TYPE_S3C2410,
-   }, {
-   .name   = s3c2440-i2c,
-   .driver_data= TYPE_S3C2440,
-   }, { },
-};
-MODULE_DEVICE_TABLE(platform, s3c24xx_driver_ids);
-
-#ifdef CONFIG_OF
-static const struct of_device_id s3c24xx_i2c_match[] = {
-   { .compatible = samsung,s3c2410-i2c },
-   { .compatible = samsung,s3c2440-i2c },
-   {},
-};
-MODULE_DEVICE_TABLE(of, s3c24xx_i2c_match);
-#endif
-
 static struct platform_driver s3c24xx_i2c_driver = {
.probe  = s3c24xx_i2c_probe,
.remove = s3c24xx_i2c_remove,
-- 
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 2/2] i2c-s3c2410: Add HDMIPHY quirk for S3C2440

2012-04-23 Thread Karol Lewandowski
This patch adds support for s3c2440 I2C bus controller dedicated HDMIPHY device 
on
Exynos4 platform. Some quirks are introduced due to differences between HDMIPHY
and other I2C controllers on Exynos4.  These differences are:
- no GPIOs, HDMIPHY is inside the SoC and the controller is connected
  internally
- due to unknown reason (probably HW bug in HDMIPHY and/or the controller) a
  transfer fails to finish. The controller hangs after sending the last byte,
  the workaround for this bug is resetting the controller after each transfer

Signed-off-by: Tomasz Stanislawski t.stanisl...@samsung.com
Signed-off-by: Karol Lewandowski k.lewando...@samsung.com
Tested-by: Tomasz Stanislawski t.stanisl...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 .../devicetree/bindings/i2c/samsung-i2c.txt|8 --
 drivers/i2c/busses/i2c-s3c2410.c   |   30 
 2 files changed, 36 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/i2c/samsung-i2c.txt 
b/Documentation/devicetree/bindings/i2c/samsung-i2c.txt
index 38832c7..b6cb5a1 100644
--- a/Documentation/devicetree/bindings/i2c/samsung-i2c.txt
+++ b/Documentation/devicetree/bindings/i2c/samsung-i2c.txt
@@ -6,14 +6,18 @@ Required properties:
   - compatible: value should be either of the following.
   (a) samsung, s3c2410-i2c, for i2c compatible with s3c2410 i2c.
   (b) samsung, s3c2440-i2c, for i2c compatible with s3c2440 i2c.
+  (c) samsung, s3c2440-hdmiphy-i2c, for s3c2440-like i2c used
+  inside HDMIPHY block found on several samsung SoCs
   - reg: physical base address of the controller and length of memory mapped
 region.
   - interrupts: interrupt number to the cpu.
   - samsung,i2c-sda-delay: Delay (in ns) applied to data line (SDA) edges.
-  - gpios: The order of the gpios should be the following: SDA, SCL.
-The gpio specifier depends on the gpio controller.
 
 Optional properties:
+  - gpios: The order of the gpios should be the following: SDA, SCL.
+The gpio specifier depends on the gpio controller. Required in all
+cases except for samsung,s3c2440-hdmiphy-i2c whose input/output
+lines are permanently wired to the respective client
   - samsung,i2c-slave-addr: Slave address in multi-master enviroment. If not
 specified, default value is 0.
   - samsung,i2c-max-bus-freq: Desired frequency in Hz of the bus. If not
diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
index 23736ff..fa0b134 100644
--- a/drivers/i2c/busses/i2c-s3c2410.c
+++ b/drivers/i2c/busses/i2c-s3c2410.c
@@ -46,6 +46,8 @@
 
 /* Treat S3C2410 as baseline hardware, anything else is supported via quirks */
 #define QUIRK_S3C2440  (1  0)
+#define QUIRK_HDMIPHY  (1  1)
+#define QUIRK_NO_GPIO  (1  2)
 
 /* i2c controller state */
 enum s3c24xx_i2c_state {
@@ -93,6 +95,9 @@ static struct platform_device_id s3c24xx_driver_ids[] = {
}, {
.name   = s3c2440-i2c,
.driver_data= QUIRK_S3C2440,
+   }, {
+   .name   = s3c2440-hdmiphy-i2c,
+   .driver_data= QUIRK_S3C2440 | QUIRK_HDMIPHY | QUIRK_NO_GPIO,
}, { },
 };
 MODULE_DEVICE_TABLE(platform, s3c24xx_driver_ids);
@@ -101,6 +106,8 @@ MODULE_DEVICE_TABLE(platform, s3c24xx_driver_ids);
 static const struct of_device_id s3c24xx_i2c_match[] = {
{ .compatible = samsung,s3c2410-i2c, .data = (void *)0 },
{ .compatible = samsung,s3c2440-i2c, .data = (void *)QUIRK_S3C2440 },
+   { .compatible = samsung,s3c2440-hdmiphy-i2c,
+ .data = (void *)(QUIRK_S3C2440 | QUIRK_HDMIPHY | QUIRK_NO_GPIO) },
{},
 };
 MODULE_DEVICE_TABLE(of, s3c24xx_i2c_match);
@@ -483,6 +490,13 @@ static int s3c24xx_i2c_set_master(struct s3c24xx_i2c *i2c)
unsigned long iicstat;
int timeout = 400;
 
+   /* the timeout for HDMIPHY is reduced to 10 ms because
+* the hangup is expected to happen, so waiting 400 ms
+* causes only unnecessary system hangup
+*/
+   if (i2c-quirks  QUIRK_HDMIPHY)
+   timeout = 10;
+
while (timeout--  0) {
iicstat = readl(i2c-regs + S3C2410_IICSTAT);
 
@@ -492,6 +506,15 @@ static int s3c24xx_i2c_set_master(struct s3c24xx_i2c *i2c)
msleep(1);
}
 
+   /* hang-up of bus dedicated for HDMIPHY occurred, resetting */
+   if (i2c-quirks  QUIRK_HDMIPHY) {
+   writel(0, i2c-regs + S3C2410_IICCON);
+   writel(0, i2c-regs + S3C2410_IICSTAT);
+   writel(0, i2c-regs + S3C2410_IICDS);
+
+   return 0;
+   }
+
return -ETIMEDOUT;
 }
 
@@ -773,6 +796,9 @@ static int s3c24xx_i2c_parse_dt_gpio(struct s3c24xx_i2c 
*i2c)
 {
int idx, gpio, ret;
 
+   if (i2c-quirks  QUIRK_NO_GPIO)
+   return 0;
+
for (idx = 0; idx  2; idx++) {
gpio = of_get_gpio(i2c-dev-of_node

Re: [PATCH 2/3] i2c-s3c2410: Rework device type handling

2012-04-18 Thread Karol Lewandowski
On 17.04.2012 19:31, Wolfram Sang wrote:

 Hi,


Hi Wolfram!

 
 On Wed, Mar 21, 2012 at 08:11:52PM +0100, Karol Lewandowski wrote:
 Reorganize driver a bit to better handle device tree-based systems:

  - move machine type to driver's private structure instead of
quering platform device variants in runtime

  - replace s3c24xx_i2c_type enum with unsigned int that holds
bitmask with revision-specific quirks

 Signed-off-by: Karol Lewandowski k.lewando...@samsung.com
 Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
 
 Okay, so this driver needs to the 'data' field from either
 platform_device_id or of_device_id and implements a function for that,
 namely s3c24xx_get_device_quirks(). Grant, Rob: I'd think there might be
 more drivers in need of that, so maybe it makes sense to have a generic
 of-helper function?
 
 ---
  drivers/i2c/busses/i2c-s3c2410.c |   47 
 ++---
  1 files changed, 23 insertions(+), 24 deletions(-)

 diff --git a/drivers/i2c/busses/i2c-s3c2410.c 
 b/drivers/i2c/busses/i2c-s3c2410.c
 index 85e3664..f7b6a14 100644
 --- a/drivers/i2c/busses/i2c-s3c2410.c
 +++ b/drivers/i2c/busses/i2c-s3c2410.c
 @@ -44,8 +44,14 @@
  #include plat/regs-iic.h
  #include plat/iic.h
  
 -/* i2c controller state */
 +#ifdef CONFIG_OF
 +static const struct of_device_id s3c24xx_i2c_match[];
 +#endif
 
 Uh, forward declaration with #ifdef. I'd think we should get this simply
 to the front.


Ok, as I think it's better to have dt and non-dt definitions together
I'll move both of_device_id and platform_device_id to the top.

 +/* Treat S3C2410 as baseline hardware, anything else is supported via 
 quirks */
 +#define QUIRK_S3C2440   (1  0)
 
 Minor: Is it really a quirk being s3c2440? Maybe FLAG_*, dunno.


In first version[1] of this patch I've used TYPEs for device types
and FLAGS for quirks. However, I've squashed these into quirks after
discussion with Mark[2].

[1] http://permalink.gmane.org/gmane.linux.kernel/1266759
[2] http://permalink.gmane.org/gmane.linux.kernel.samsung-soc/10255


 -static inline int s3c24xx_i2c_is2440(struct s3c24xx_i2c *i2c)
 +static inline unsigned int s3c24xx_get_device_quirks(struct platform_device 
 *pdev)
  {
 -struct platform_device *pdev = to_platform_device(i2c-dev);
 -enum s3c24xx_i2c_type type;
 -
  #ifdef CONFIG_OF
 -if (i2c-dev-of_node)
 -return of_device_is_compatible(i2c-dev-of_node,
 -samsung,s3c2440-i2c);
 +if (pdev-dev.of_node) {
 +const struct of_device_id *match;
 +match = of_match_node(s3c24xx_i2c_match[0], pdev-dev.of_node);
 
 Minor: I think it is more readable to drop the [0]


I prefer explicit version, but I'll drop [] as both you and Thomas
found implicit version more readable.

[ I'll also drop above CONFIG_OF ifdef, as of_match_node() seem
  to be always defined since v3.2-rc1. ]

Thanks for review!  I'll resubmit updated version shortly.

Regards,
-- 
Karol Lewandowski | Samsung Poland RD Center | Linux/Platform
--
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 3/3] i2c-s3c2410: Add HDMIPHY quirk for S3C2440

2012-04-18 Thread Karol Lewandowski
(struct device_node *np, struct 
s3c24xx_i2c *i2c)
 
pdata-bus_num = -1; /* i2c bus number is dynamically assigned */
 
-   if (of_get_property(np, samsung,i2c-quirk-hdmiphy, NULL))
-   i2c-quirks |= QUIRK_HDMIPHY;
-
-   if (of_get_property(np, samsung,i2c-no-gpio, NULL))
-   i2c-quirks |= QUIRK_NO_GPIO;
-
of_property_read_u32(np, samsung,i2c-sda-delay, pdata-sda_delay);
of_property_read_u32(np, samsung,i2c-slave-addr, pdata-slave_addr);
of_property_read_u32(np, samsung,i2c-max-bus-freq,


Regards,
-- 
Karol Lewandowski | Samsung Poland RD Center | Linux/Platform
--
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 v3 0/3] i2c-s3c2410: Updates for exynos4210 and DT-based systems

2012-04-13 Thread Karol Lewandowski
On 21.03.2012 20:11, Karol Lewandowski wrote:

 Changes since v2:
  - Merge device type and flags into flat bitmask named quirks -
Consequently, treat s3c24xx as baseline hardware platform and
support all hw variations via quirks [Suggested by Mark Brown]
 
 Changes since v1:
  - Move unrelated code fragment to separate patch (of_match_ptr())
[Suggested by Thomas Abraham]
  - Move device-type handling to separate function and rework its
internals a bit [likewise]
 
 This patchset reworks i2c-s3c2410 driver a bit to better handle
 device tree-enabled platforms and adds two quirks required by
 exynos4210-specific I2C controller used by s5p-hdmi driver.
 
 This patchset is based on i2c-bjdooks/for-34/i2c/i2c-samsung branch
 taken from:
 
   git://git.fluff.org/bjdooks/linux.git
 
 Karol Lewandowski (3):
   i2c-s3c2410: Drop unused define
   i2c-s3c2410: Rework device type handling
   i2c-s3c2410: Add HDMIPHY quirk for S3C2440
 
  .../devicetree/bindings/i2c/samsung-i2c.txt|   11 ++-
  drivers/i2c/busses/i2c-s3c2410.c   |   86 +--
  2 files changed, 68 insertions(+), 29 deletions(-)


Wolfram,

Is there anything I can do to have these patches in -next
(and, consequently, in 3.5-rc1)?

Regards,
-- 
Karol Lewandowski | Samsung Poland RD Center | Linux/Platform
--
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 02/13] ARM: Add document to list devices with trivial DT description

2012-04-12 Thread Karol Lewandowski
Add arm/trivial-devices.txt to enumerate devices for which only
basic resources are provided (compat, address and irq line).

This is based on i2c's trivial-devices.txt by Olof Johansson.

Signed-off-by: Karol Lewandowski k.lewando...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
Cc: Grant Likely grant.lik...@secretlab.ca
---
 .../devicetree/bindings/arm/trivial-devices.txt|   10 ++
 1 files changed, 10 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/arm/trivial-devices.txt

diff --git a/Documentation/devicetree/bindings/arm/trivial-devices.txt 
b/Documentation/devicetree/bindings/arm/trivial-devices.txt
new file mode 100644
index 000..443814a
--- /dev/null
+++ b/Documentation/devicetree/bindings/arm/trivial-devices.txt
@@ -0,0 +1,10 @@
+This is a list of trivial devices that have simple device tree
+bindings, consisting only of a compatible field, an address and
+possibly an interrupt line.
+
+If a device needs more specific bindings, such as properties to
+describe some aspect of it, there needs to be a specific binding
+document for it just like any other devices.
+
+Compatible  Vendor / Chip
+=
-- 
1.7.9.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 04/13] i2c-pxa: Drop leftover comment

2012-04-12 Thread Karol Lewandowski
Commit 488bf314b (i2c: Allow i2c_add_numbered_adapter() to assign a
bus id) reworked i2c-pxa driver leaving obsolete comment.

This commit simply drops it.

Signed-off-by: Karol Lewandowski k.lewando...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
Cc: Wolfram Sang w.s...@pengutronix.de
---
 drivers/i2c/busses/i2c-pxa.c |5 -
 1 files changed, 0 insertions(+), 5 deletions(-)

diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
index f673326..a997c7d 100644
--- a/drivers/i2c/busses/i2c-pxa.c
+++ b/drivers/i2c/busses/i2c-pxa.c
@@ -1131,11 +1131,6 @@ static int i2c_pxa_probe(struct platform_device *dev)
spin_lock_init(i2c-lock);
init_waitqueue_head(i2c-wait);
 
-   /*
-* If dev-id is negative we consider it as zero.
-* The reason to do so is to avoid sysfs names that only make
-* sense when there are multiple adapters.
-*/
i2c-adap.nr = dev-id;
snprintf(i2c-adap.name, sizeof(i2c-adap.name), pxa_i2c-i2c.%u,
 i2c-adap.nr);
-- 
1.7.9.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 01/13] regulator: Fix DT node name checking in max8997-pmic

2012-04-12 Thread Karol Lewandowski
Avoid hard lockup when someone provides non-supported regulator
name.

Signed-off-by: Karol Lewandowski k.lewando...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
Cc: Thomas Abraham thomas.abra...@linaro.org
---
 drivers/regulator/max8997.c |7 +++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/drivers/regulator/max8997.c b/drivers/regulator/max8997.c
index dce8aaf..c20fd72 100644
--- a/drivers/regulator/max8997.c
+++ b/drivers/regulator/max8997.c
@@ -1011,6 +1011,13 @@ static int max8997_pmic_dt_parse_pdata(struct 
max8997_dev *iodev,
for (i = 0; i  ARRAY_SIZE(regulators); i++)
if (!of_node_cmp(reg_np-name, regulators[i].name))
break;
+
+   if (i == ARRAY_SIZE(regulators)) {
+   dev_warn(iodev-dev, don't know how to configure 
regulator %s\n,
+reg_np-name);
+   continue;
+   }
+
rdata-id = i;
rdata-initdata = of_get_regulator_init_data(
iodev-dev, reg_np);
-- 
1.7.9.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 13/13] ARM: dts: Add initial dts for Samsung's NURI board based on Exynos4210

2012-04-12 Thread Karol Lewandowski
This commit is combination of following patches squashed together to
produce one patch which provides complete DTS for NURI

 - ARM: dts: Add sdhci nodes for NURI
 - ARM: dts: Add i2c-gpio entry for max17042_battery
 - ARM: dts: Add nodes for fixed regulators available on NURI
 - ARM: dts: Add device entry for s5p-g2d on Nuri
 - ARM: dts: Add device node for MFC to Nuri
 - ARM: dts: Add Exynos' wakeup_eint interrupt controller
 - ARM: dts: Add basic max8997-pmic description to NURI's dts
 - ARM: dts: Add special max8997-pmic regulators
   [ This adds non-buck, non-ldo special purpose regulators
 like CHARGER* as well as 32kHz oscillator. ]
 - ARM: dts: Add node for s3c-udc to NURI's dts
 - ARM: dts: Add nodes for s5p-tv drivers (hdmi, hdmiphy, sii9234, tvmixer)
 - ARM: dts: Add node for atmel's mxt224 to NURI's dts
 - ARM: dts: Specify EINT controller base address

Signed-off-by: Karol Lewandowski k.lewando...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
Cc: Thomas Abraham thomas.abra...@linaro.org
---
 arch/arm/boot/dts/exynos4210-nuri.dts |  527 +
 1 files changed, 527 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/boot/dts/exynos4210-nuri.dts

diff --git a/arch/arm/boot/dts/exynos4210-nuri.dts 
b/arch/arm/boot/dts/exynos4210-nuri.dts
new file mode 100644
index 000..6e8d68b
--- /dev/null
+++ b/arch/arm/boot/dts/exynos4210-nuri.dts
@@ -0,0 +1,527 @@
+/*
+ * Samsung Nuri board device tree source
+ *
+ * Copyright (C) 2012  Samsung Electronics Co., Ltd.
+ * Author: Karol Lewandowski k.lewando...@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.
+ */
+
+/dts-v1/;
+/include/ exynos4210.dtsi
+
+/ {
+   model = Samsung Nuri based on Exynos4210;
+   compatible = samsung,nuri, samsung,exynos4210;
+
+   memory {
+   reg = 0x4000 0x4000;
+   };
+
+   chosen {
+   bootargs =console=ttySAC2,115200 fbmem=24M@0x6680 
lcd=nt39411 lpj=3981312;
+   };
+
+   wakeup_eint: interrupt-controller-wakeup-eint {
+   compatible = samsung,exynos4210-wakeup-eint;
+   reg = 0x1100 0x1000;
+   #interrupt-cells = 2;
+   interrupt-controller;
+   interrupts =0 16 0, 0 17 0, 0 18 0, 0 19 0,
+   0 20 0, 0 21 0, 0 22 0, 0 23 0,
+   0 24 0, 0 25 0, 0 26 0, 0 27 0,
+   0 28 0, 0 29 0, 0 30 0, 0 31 0,
+   0 32 0;
+   };
+
+   /* fixed regulators */
+
+   vemmc_reg: voltage-regulator@0 {
+   compatible = regulator-fixed;
+   regulator-name = VMEM_VDD_2.8V;
+   regulator-min-microvolt = 280;
+   regulator-max-microvolt = 280;
+   regulator-always-on;
+   gpio = gpl1 1 1 0 0;
+   };
+
+   max8903_reg: voltage-regulator@1 {
+   compatible = regulator-fixed;
+   regulator-name = VOUT_CHARGER;
+   regulator-min-microvolt = 500;
+   regulator-max-microvolt = 500;
+   regulator-always-on;
+   regulator-boot-on;
+   gpio = gpy4 5 1 0 0;
+   };
+
+   camvdda_reg: voltage-regulator@2 {
+   compatible = regulator-fixed;
+   regulator-name = CAM_IO_EN;
+   regulator-min-microvolt = 280;
+   regulator-max-microvolt = 280;
+   regulator-always-on;
+   enable-active-high;
+   gpio = gpe2 1 1 0 0;
+   };
+
+   camv1_2_reg: voltage-regulator@3 {
+   compatible = regulator-fixed;
+   regulator-name = 8M_1.2V;
+   regulator-min-microvolt = 120;
+   regulator-max-microvolt = 120;
+   regulator-always-on;
+   enable-active-high;
+   gpio = gpe2 2 1 0 0;
+   };
+
+   camv1_5_reg: voltage-regulator@4 {
+   compatible = regulator-fixed;
+   regulator-name = VT_CAM_1.5V;
+   regulator-min-microvolt = 150;
+   regulator-max-microvolt = 150;
+   regulator-always-on;
+   enable-active-high;
+   gpio = gpe2 5 1 0 0;
+   };
+
+   hdmi_reg: voltage-regulator@5 {
+   compatible = regulator-fixed;
+   regulator-name = HDMI_5V;
+   regulator-min-microvolt = 500;
+   regulator-max-microvolt = 500;
+   gpio = gpx2 4 1 0 0;
+   enable-active-high;
+   };
+
+   sdhci_emmc: sdhci@1251 {
+   /* eMMC */
+   samsung,sdhci-cd-permanent;
+   gpio-cd = gpk0 2 2 3 3;
+
+   samsung,sdhci-bus

[PATCH 11/13] ARM: Exynos4: dts: Specify address and size cells for i2c controllers

2012-04-12 Thread Karol Lewandowski
Signed-off-by: Karol Lewandowski k.lewando...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
Cc: Thomas Abraham thomas.abra...@linaro.org
---
 arch/arm/boot/dts/exynos4210.dtsi |   16 
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/arch/arm/boot/dts/exynos4210.dtsi 
b/arch/arm/boot/dts/exynos4210.dtsi
index a1dd2ee..be3c57c 100644
--- a/arch/arm/boot/dts/exynos4210.dtsi
+++ b/arch/arm/boot/dts/exynos4210.dtsi
@@ -100,48 +100,64 @@
};
 
i2c@1386 {
+   #address-cells = 1;
+   #size-cells = 0;
compatible = samsung,s3c2440-i2c;
reg = 0x1386 0x100;
interrupts = 0 58 0;
};
 
i2c@1387 {
+   #address-cells = 1;
+   #size-cells = 0;
compatible = samsung,s3c2440-i2c;
reg = 0x1387 0x100;
interrupts = 0 59 0;
};
 
i2c@1388 {
+   #address-cells = 1;
+   #size-cells = 0;
compatible = samsung,s3c2440-i2c;
reg = 0x1388 0x100;
interrupts = 0 60 0;
};
 
i2c@1389 {
+   #address-cells = 1;
+   #size-cells = 0;
compatible = samsung,s3c2440-i2c;
reg = 0x1389 0x100;
interrupts = 0 61 0;
};
 
i2c@138A {
+   #address-cells = 1;
+   #size-cells = 0;
compatible = samsung,s3c2440-i2c;
reg = 0x138A 0x100;
interrupts = 0 62 0;
};
 
i2c@138B {
+   #address-cells = 1;
+   #size-cells = 0;
compatible = samsung,s3c2440-i2c;
reg = 0x138B 0x100;
interrupts = 0 63 0;
};
 
i2c@138C {
+   #address-cells = 1;
+   #size-cells = 0;
compatible = samsung,s3c2440-i2c;
reg = 0x138C 0x100;
interrupts = 0 64 0;
};
 
i2c@138D {
+   #address-cells = 1;
+   #size-cells = 0;
compatible = samsung,s3c2440-i2c;
reg = 0x138D 0x100;
interrupts = 0 65 0;
-- 
1.7.9.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 10/13] s5p-tv: Add DT-support for HDMI driver

2012-04-12 Thread Karol Lewandowski
Includes v4l2/dt helper function (hdmi_of_get_i2c_subdev() that probably
should be implemented in v4l2 core itself.

Signed-off-by: Karol Lewandowski k.lewando...@samsung.com
Cc: Tomasz Stanislawski t.stanisl...@samsung.com
---
 drivers/media/video/s5p-tv/hdmi_drv.c |   68 -
 1 files changed, 67 insertions(+), 1 deletions(-)

diff --git a/drivers/media/video/s5p-tv/hdmi_drv.c 
b/drivers/media/video/s5p-tv/hdmi_drv.c
index fff3cab..a402e8f 100644
--- a/drivers/media/video/s5p-tv/hdmi_drv.c
+++ b/drivers/media/video/s5p-tv/hdmi_drv.c
@@ -29,6 +29,8 @@
 #include linux/pm_runtime.h
 #include linux/clk.h
 #include linux/regulator/consumer.h
+#include linux/of.h
+#include linux/of_i2c.h
 
 #include media/s5p_hdmi.h
 #include media/v4l2-common.h
@@ -712,6 +714,56 @@ static int hdmi_enum_dv_presets(struct v4l2_subdev *sd,
return v4l_fill_dv_preset_info(hdmi_conf[preset-index].preset, preset);
 }
 
+#ifdef CONFIG_OF
+/* Heavily based[1] on v4l2_i2c_new_subdev_board()
+ *
+ * [1] Copy-pasted, that is
+ */
+struct v4l2_subdev *hdmi_of_get_i2c_subdev(struct v4l2_device *v4l2_dev,
+   struct device_node *np, const char *propname)
+{
+   struct v4l2_subdev *sd = NULL;
+   struct i2c_client *client;
+   struct device_node *cnp;
+
+   BUG_ON(!v4l2_dev);
+
+   cnp = of_parse_phandle(np, propname, 0);
+   if (!cnp) {
+   dev_err(v4l2_dev-dev, Can't find subdev %s\n, propname);
+   goto err;
+   }
+
+   client = of_find_i2c_device_by_node(cnp);
+   if (!client) {
+   dev_err(v4l2_dev-dev, subdev %s doesn't reference correct 
node\n,
+   propname);
+   goto err;
+   }
+
+   if (client == NULL || client-driver == NULL)
+   goto err;
+
+   /* Lock the module so we can safely get the v4l2_subdev pointer */
+   if (!try_module_get(client-driver-driver.owner))
+   goto err;
+   sd = i2c_get_clientdata(client);
+
+   /* Register with the v4l2_device which increases the module's
+  use count as well. */
+   if (v4l2_device_register_subdev(v4l2_dev, sd)) {
+   printk(KERN_ERR %s: failed to register subdev\n, __func__);
+   sd = NULL;
+   }
+   /* Decrease the module use count to match the first try_module_get. */
+   module_put(client-driver-driver.owner);
+err:
+   of_node_put(cnp);
+
+   return sd;
+}
+#endif
+
 static const struct v4l2_subdev_core_ops hdmi_sd_core_ops = {
.s_power = hdmi_s_power,
 };
@@ -875,6 +927,12 @@ static struct v4l2_subdev *hdmi_get_subdev(
struct i2c_adapter *adapter;
struct device *dev = hdmi_dev-dev;
 
+#ifdef CONFIG_OF
+   if (dev-of_node)
+   return hdmi_of_get_i2c_subdev(hdmi_dev-v4l2_dev,
+  dev-of_node, propname);
+#endif
+
if (!bdinfo) {
dev_err(dev, %s info is missing in platform data\n,
propname);
@@ -913,7 +971,7 @@ static int __devinit hdmi_probe(struct platform_device 
*pdev)
 
dev_dbg(dev, probe start\n);
 
-   if (!pdata) {
+   if (!pdata  !dev-of_node) {
dev_err(dev, platform data is missing\n);
ret = -ENODEV;
goto fail;
@@ -1037,6 +1095,13 @@ static int __devexit hdmi_remove(struct platform_device 
*pdev)
return 0;
 }
 
+#ifdef CONFIG_OF
+static struct of_device_id hdmi_dt_match[] = {
+   { .compatible = samsung,s5pv210-hdmi },
+   { },
+};
+#endif
+
 static struct platform_driver hdmi_driver __refdata = {
.probe = hdmi_probe,
.remove = __devexit_p(hdmi_remove),
@@ -1045,6 +1110,7 @@ static struct platform_driver hdmi_driver __refdata = {
.name = s5p-hdmi,
.owner = THIS_MODULE,
.pm = hdmi_pm_ops,
+   .of_match_table = of_match_ptr(hdmi_dt_match),
}
 };
 
-- 
1.7.9.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 07/13] s5p-tv: Add initial DT-support for TV mixer

2012-04-12 Thread Karol Lewandowski
Signed-off-by: Karol Lewandowski k.lewando...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
Cc: Tomasz Stanislawski t.stanisl...@samsung.com
---
 .../devicetree/bindings/arm/exynos/tvmixer.txt |   26 
 drivers/media/video/s5p-tv/mixer_drv.c |9 +++
 2 files changed, 35 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/arm/exynos/tvmixer.txt

diff --git a/Documentation/devicetree/bindings/arm/exynos/tvmixer.txt 
b/Documentation/devicetree/bindings/arm/exynos/tvmixer.txt
new file mode 100644
index 000..5b4f02e
--- /dev/null
+++ b/Documentation/devicetree/bindings/arm/exynos/tvmixer.txt
@@ -0,0 +1,26 @@
+* Samsung video/graphics mixer and blender
+
+Mixer blends graphics data from multiple sources and sends resulting
+data to TVOUT module.
+
+
+Required properties:
+
+ - compatible : samsung,s5pv210-tvmixer
+ - reg : shall contain memory addresses and sizes of mixer and video
+   processor devices
+ - reg-names : mxr for mixer's address/size and vp to for video
+   processor's.
+ - interrupt-names : shall contain irq
+
+
+Example:
+
+   tvmixer@12c1 {
+   compatible = samsung,s5pv210-tvmixer;
+   reg = 0x12c1 0x1,
+ 0x12c0 0x1;
+   reg-names = mxr, vp;
+   interrupts = 0 123 0;
+   interrupt-names = irq;
+   };
diff --git a/drivers/media/video/s5p-tv/mixer_drv.c 
b/drivers/media/video/s5p-tv/mixer_drv.c
index a2c0c25..80b7755 100644
--- a/drivers/media/video/s5p-tv/mixer_drv.c
+++ b/drivers/media/video/s5p-tv/mixer_drv.c
@@ -448,6 +448,14 @@ static int __devexit mxr_remove(struct platform_device 
*pdev)
return 0;
 }
 
+#ifdef CONFIG_OF
+static const struct of_device_id mxr_dt_match[] = {
+   { .compatible = samsung,s5pv210-tvmixer },
+   { },
+};
+MODULE_DEVICE_TABLE(of, mxr_dt_match);
+#endif
+
 static struct platform_driver mxr_driver __refdata = {
.probe = mxr_probe,
.remove = __devexit_p(mxr_remove),
@@ -455,6 +463,7 @@ static struct platform_driver mxr_driver __refdata = {
.name = MXR_DRIVER_NAME,
.owner = THIS_MODULE,
.pm = mxr_pm_ops,
+   .of_match_table = of_match_ptr(mxr_dt_match),
}
 };
 
-- 
1.7.9.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 09/13] s5p-tv: Move HDMIPHY and MHL subdev probing to dedicated function

2012-04-12 Thread Karol Lewandowski
Signed-off-by: Karol Lewandowski k.lewando...@samsung.com
Cc: Tomasz Stanislawski t.stanisl...@samsung.com
---
 drivers/media/video/s5p-tv/hdmi_drv.c |   90 ++---
 1 files changed, 49 insertions(+), 41 deletions(-)

diff --git a/drivers/media/video/s5p-tv/hdmi_drv.c 
b/drivers/media/video/s5p-tv/hdmi_drv.c
index 4865d25..fff3cab 100644
--- a/drivers/media/video/s5p-tv/hdmi_drv.c
+++ b/drivers/media/video/s5p-tv/hdmi_drv.c
@@ -865,11 +865,47 @@ fail:
return -ENODEV;
 }
 
+static struct v4l2_subdev *hdmi_get_subdev(
+   struct hdmi_device *hdmi_dev,
+   struct i2c_board_info *bdinfo,
+   int bus,
+   const char *propname)
+{
+   struct v4l2_subdev *sd = NULL;
+   struct i2c_adapter *adapter;
+   struct device *dev = hdmi_dev-dev;
+
+   if (!bdinfo) {
+   dev_err(dev, %s info is missing in platform data\n,
+   propname);
+   return ERR_PTR(-ENXIO);
+   }
+
+   adapter = i2c_get_adapter(bus);
+   if (adapter == NULL) {
+   dev_err(dev, %s adapter request failed, name\n,
+   propname);
+   return ERR_PTR(-ENXIO);
+   }
+
+   sd = v4l2_i2c_new_subdev_board(hdmi_dev-v4l2_dev,
+  adapter, bdinfo, NULL);
+
+   /* on failure or not adapter is no longer useful */
+   i2c_put_adapter(adapter);
+
+   if (sd == NULL) {
+   dev_err(dev, missing subdev for %s\n, propname);
+   return ERR_PTR(-ENODEV);
+   }
+
+   return sd;
+}
+
 static int __devinit hdmi_probe(struct platform_device *pdev)
 {
struct device *dev = pdev-dev;
struct resource *res;
-   struct i2c_adapter *adapter;
struct v4l2_subdev *sd;
struct hdmi_device *hdmi_dev = NULL;
struct s5p_hdmi_platform_data *pdata = dev-platform_data;
@@ -937,51 +973,23 @@ static int __devinit hdmi_probe(struct platform_device 
*pdev)
goto fail_init;
}
 
-   /* testing if hdmiphy info is present */
-   if (!pdata-hdmiphy_info) {
-   dev_err(dev, hdmiphy info is missing in platform data\n);
-   ret = -ENXIO;
+   hdmi_dev-phy_sd = hdmi_get_subdev(hdmi_dev,
+  pdata ? pdata-hdmiphy_info : NULL,
+  pdata ? pdata-hdmiphy_bus : -1,
+  phy);
+   if (IS_ERR_OR_NULL(hdmi_dev-phy_sd)) {
+   ret = PTR_ERR(hdmi_dev-phy_sd);
goto fail_vdev;
}
-
-   adapter = i2c_get_adapter(pdata-hdmiphy_bus);
-   if (adapter == NULL) {
-   dev_err(dev, hdmiphy adapter request failed\n);
-   ret = -ENXIO;
+   hdmi_dev-mhl_sd = hdmi_get_subdev(hdmi_dev,
+  pdata ? pdata-mhl_info : NULL ,
+  pdata ? pdata-mhl_bus : -1,
+  mhl);
+   if (IS_ERR_OR_NULL(hdmi_dev-mhl_sd)) {
+   ret = PTR_ERR(hdmi_dev-mhl_sd);
goto fail_vdev;
}
 
-   hdmi_dev-phy_sd = v4l2_i2c_new_subdev_board(hdmi_dev-v4l2_dev,
-   adapter, pdata-hdmiphy_info, NULL);
-   /* on failure or not adapter is no longer useful */
-   i2c_put_adapter(adapter);
-   if (hdmi_dev-phy_sd == NULL) {
-   dev_err(dev, missing subdev for hdmiphy\n);
-   ret = -ENODEV;
-   goto fail_vdev;
-   }
-
-   /* initialization of MHL interface if present */
-   if (pdata-mhl_info) {
-   adapter = i2c_get_adapter(pdata-mhl_bus);
-   if (adapter == NULL) {
-   dev_err(dev, MHL adapter request failed\n);
-   ret = -ENXIO;
-   goto fail_vdev;
-   }
-
-   hdmi_dev-mhl_sd = v4l2_i2c_new_subdev_board(
-   hdmi_dev-v4l2_dev, adapter,
-   pdata-mhl_info, NULL);
-   /* on failure or not adapter is no longer useful */
-   i2c_put_adapter(adapter);
-   if (hdmi_dev-mhl_sd == NULL) {
-   dev_err(dev, missing subdev for MHL\n);
-   ret = -ENODEV;
-   goto fail_vdev;
-   }
-   }
-
clk_enable(hdmi_dev-res.hdmi);
 
pm_runtime_enable(dev);
-- 
1.7.9.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 06/13] s5p-tv: Add initial DT-support for SiI9234

2012-04-12 Thread Karol Lewandowski
Make it possible to instantiate SiI9234, Mobile HD Link driver (MHL),
from regular device tree description.

Signed-off-by: Karol Lewandowski k.lewando...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
Cc: Tomasz Stanislawski t.stanisl...@samsung.com
---
 .../devicetree/bindings/i2c/sil-mhl9234.txt|   14 +
 drivers/media/video/s5p-tv/sii9234_drv.c   |   21 +++-
 2 files changed, 34 insertions(+), 1 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/i2c/sil-mhl9234.txt

diff --git a/Documentation/devicetree/bindings/i2c/sil-mhl9234.txt 
b/Documentation/devicetree/bindings/i2c/sil-mhl9234.txt
new file mode 100644
index 000..b5d92ea
--- /dev/null
+++ b/Documentation/devicetree/bindings/i2c/sil-mhl9234.txt
@@ -0,0 +1,14 @@
+* Silicon Image Mobile HD Link (MHL) 9234
+
+Required properties :
+ - compatible : sil,mhl-9234
+ - reg: i2c device address
+ - gpio-reset : gpio line used to reset IC
+
+Example:
+
+   mhl@39 {
+   compatible = sil,mhl-9234;
+   reg = 0x39;
+   gpio-reset = gpf3 4 0 0 0;
+   };
diff --git a/drivers/media/video/s5p-tv/sii9234_drv.c 
b/drivers/media/video/s5p-tv/sii9234_drv.c
index 0f31ecc..05df5e8 100644
--- a/drivers/media/video/s5p-tv/sii9234_drv.c
+++ b/drivers/media/video/s5p-tv/sii9234_drv.c
@@ -22,6 +22,8 @@
 #include linux/pm_runtime.h
 #include linux/regulator/machine.h
 #include linux/slab.h
+#include linux/of.h
+#include linux/of_gpio.h
 
 #include mach/gpio.h
 #include plat/gpio-cfg.h
@@ -338,7 +340,16 @@ static int __devinit sii9234_probe(struct i2c_client 
*client,
goto fail_ctx;
}
 
-   ctx-gpio_n_reset = pdata-gpio_n_reset;
+   if (dev-of_node) {
+   ctx-gpio_n_reset = of_get_named_gpio(dev-of_node, 
gpio-reset, 0);
+   if (!gpio_is_valid(ctx-gpio_n_reset)) {
+   ret = -ENODEV;
+   goto fail_power;
+   }
+   } else {
+   ctx-gpio_n_reset = pdata-gpio_n_reset;
+   }
+
ret = gpio_request(ctx-gpio_n_reset, MHL_RST);
if (ret) {
dev_err(dev, failed to acquire MHL_RST gpio\n);
@@ -401,6 +412,13 @@ static int __devexit sii9234_remove(struct i2c_client 
*client)
return 0;
 }
 
+#ifdef CONFIG_OF
+static const struct of_device_id sii9234_dt_match[] = {
+   { .compatible = sil,mhl-9234 },
+   { },
+};
+MODULE_DEVICE_TABLE(of, sii9234_dt_match);
+#endif
 
 static const struct i2c_device_id sii9234_id[] = {
{ SII9234, 0 },
@@ -413,6 +431,7 @@ static struct i2c_driver sii9234_driver = {
.name   = sii9234,
.owner  = THIS_MODULE,
.pm = sii9234_pm_ops,
+   .of_match_table = of_match_ptr(sii9234_dt_match),
},
.probe  = sii9234_probe,
.remove = __devexit_p(sii9234_remove),
-- 
1.7.9.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 03/13] s5p-g2d: Make it possible to instantiate driver from DT

2012-04-12 Thread Karol Lewandowski
This driver requires standard properties like (address and irq)
which are automatically marshalled for drivers by OF core.

Signed-off-by: Karol Lewandowski k.lewando...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
Cc: Kamil Debski k.deb...@samsung.com
---
 .../devicetree/bindings/arm/trivial-devices.txt|1 +
 drivers/media/video/s5p-g2d/g2d.c  |   10 ++
 2 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/Documentation/devicetree/bindings/arm/trivial-devices.txt 
b/Documentation/devicetree/bindings/arm/trivial-devices.txt
index 443814a..d0f6c45 100644
--- a/Documentation/devicetree/bindings/arm/trivial-devices.txt
+++ b/Documentation/devicetree/bindings/arm/trivial-devices.txt
@@ -8,3 +8,4 @@ document for it just like any other devices.
 
 Compatible  Vendor / Chip
 =
+samsung,s5pv210-g2d2D graphics accelerator found on s5pv210+ SoCs
diff --git a/drivers/media/video/s5p-g2d/g2d.c 
b/drivers/media/video/s5p-g2d/g2d.c
index 789de74..96fd584 100644
--- a/drivers/media/video/s5p-g2d/g2d.c
+++ b/drivers/media/video/s5p-g2d/g2d.c
@@ -20,6 +20,7 @@
 #include linux/interrupt.h
 
 #include linux/platform_device.h
+#include linux/of.h
 #include media/v4l2-mem2mem.h
 #include media/v4l2-device.h
 #include media/v4l2-ioctl.h
@@ -832,12 +833,21 @@ static int g2d_remove(struct platform_device *pdev)
return 0;
 }
 
+#ifdef CONFIG_OF
+static struct of_device_id g2d_dt_match[] = {
+   { .compatible = samsung,s5pv210-g2d },
+   {},
+};
+MODULE_DEVICE_TABLE(of, g2d_dt_match);
+#endif
+
 static struct platform_driver g2d_pdrv = {
.probe  = g2d_probe,
.remove = g2d_remove,
.driver = {
.name = G2D_NAME,
.owner = THIS_MODULE,
+   .of_match_table = of_match_ptr(g2d_dt_match),
},
 };
 
-- 
1.7.9.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 05/13] i2c: Dynamically assign adapter id if it wasn't explictly specified

2012-04-12 Thread Karol Lewandowski
Commit 488bf314b (i2c: Allow i2c_add_numbered_adapter() to assign a
bus id) reworked i2c_add_numbered_adapter() to call i2c_add_adapter()
if requested bus was -1.

This allows to simplify driver's initialization procedure by using
just one function for static and dynamic adapter id registration.

This patch updates few more drivers (missed out in original patch)
to use this functionality.

Signed-off-by: Karol Lewandowski k.lewando...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
Cc: Wolfram Sang w.s...@pengutronix.de
---
 drivers/i2c/busses/i2c-gpio.c |7 +--
 drivers/i2c/busses/i2c-pca-platform.c |2 +-
 drivers/i2c/busses/i2c-versatile.c|9 ++---
 3 files changed, 4 insertions(+), 14 deletions(-)

diff --git a/drivers/i2c/busses/i2c-gpio.c b/drivers/i2c/busses/i2c-gpio.c
index c0330a4..e62d2d9 100644
--- a/drivers/i2c/busses/i2c-gpio.c
+++ b/drivers/i2c/busses/i2c-gpio.c
@@ -190,12 +190,7 @@ static int __devinit i2c_gpio_probe(struct platform_device 
*pdev)
adap-dev.parent = pdev-dev;
adap-dev.of_node = pdev-dev.of_node;
 
-   /*
-* If dev-id is negative we consider it as zero.
-* The reason to do so is to avoid sysfs names that only make
-* sense when there are multiple adapters.
-*/
-   adap-nr = (pdev-id != -1) ? pdev-id : 0;
+   adap-nr = pdev-id;
ret = i2c_bit_add_numbered_bus(adap);
if (ret)
goto err_add_bus;
diff --git a/drivers/i2c/busses/i2c-pca-platform.c 
b/drivers/i2c/busses/i2c-pca-platform.c
index 2adbf1a..675878f 100644
--- a/drivers/i2c/busses/i2c-pca-platform.c
+++ b/drivers/i2c/busses/i2c-pca-platform.c
@@ -171,7 +171,7 @@ static int __devinit i2c_pca_pf_probe(struct 
platform_device *pdev)
i2c-io_size = resource_size(res);
i2c-irq = irq;
 
-   i2c-adap.nr = pdev-id = 0 ? pdev-id : 0;
+   i2c-adap.nr = pdev-id;
i2c-adap.owner = THIS_MODULE;
snprintf(i2c-adap.name, sizeof(i2c-adap.name),
 PCA9564/PCA9665 at 0x%08lx,
diff --git a/drivers/i2c/busses/i2c-versatile.c 
b/drivers/i2c/busses/i2c-versatile.c
index f585aea..eec20db 100644
--- a/drivers/i2c/busses/i2c-versatile.c
+++ b/drivers/i2c/busses/i2c-versatile.c
@@ -104,13 +104,8 @@ static int i2c_versatile_probe(struct platform_device *dev)
i2c-algo = i2c_versatile_algo;
i2c-algo.data = i2c;
 
-   if (dev-id = 0) {
-   /* static bus numbering */
-   i2c-adap.nr = dev-id;
-   ret = i2c_bit_add_numbered_bus(i2c-adap);
-   } else
-   /* dynamic bus numbering */
-   ret = i2c_bit_add_bus(i2c-adap);
+   i2c-adap.nr = dev-id;
+   ret = i2c_bit_add_numbered_bus(i2c-adap);
if (ret = 0) {
platform_set_drvdata(dev, i2c);
of_i2c_register_devices(i2c-adap);
-- 
1.7.9.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 v4 2/2] regulator: add device tree support for max8997

2012-03-28 Thread Karol Lewandowski
On 24.03.2012 10:49, Thomas Abraham wrote:

Hi Thomas!

 Add device tree based discovery support for max8997.
... 
 +Regulators: The regulators of max8997 that have to be instantiated should be
 +included in a sub-node named 'regulators'. Regulator nodes included in this
 +sub-node should be of the format as below. Note: The 'n' in LDOn and BUCKn
 +represents the LDO or BUCK number as per the datasheet of max8997.
 +
 +For LDO's:
 + LDOn {
 + standard regulator bindings here
 + };
 +
 +For BUCK's:
 + BUCKn {
 + standard regulator bindings here
 + };
 +


Small note - driver supports[1] configuring following regulators by
using respective DT node names:

 - EN32KHz_AP
 - EN32KHz_CP
 - ENVICHG
 - ESAFEOUT1
 - ESAFEOUT2
 - CHARGER
 - CHARGER_CV
 - CHARGER_TOPOFF

I wonder if these should be mentioned in documentation too.

[1] These are used in e.g. mach-nuri.c

 diff --git a/drivers/regulator/max8997.c b/drivers/regulator/max8997.c index 
 9657929..dce8aaf 100644

 --- a/drivers/regulator/max8997.c
 +++ b/drivers/regulator/max8997.c
..
 +static int max8997_pmic_dt_parse_pdata(struct max8997_dev *iodev,
 + struct max8997_platform_data *pdata)
 +{
 + struct device_node *pmic_np, *regulators_np, *reg_np;
 + struct max8997_regulator_data *rdata;
 + unsigned int i, dvs_voltage_nr = 1, ret;
 +
 + pmic_np = iodev-dev-of_node;
 + if (!pmic_np) {
 + dev_err(iodev-dev, could not find pmic sub-node\n);
 + return -ENODEV;
 + }
 +
 + regulators_np = of_find_node_by_name(pmic_np, regulators);
 + if (!regulators_np) {
 + dev_err(iodev-dev, could not find regulators sub-node\n);
 + return -EINVAL;
 + }
 +
 + /* count the number of regulators to be supported in pmic */
 + pdata-num_regulators = 0;
 + for_each_child_of_node(regulators_np, reg_np)
 + pdata-num_regulators++;
 +
 + rdata = devm_kzalloc(iodev-dev, sizeof(*rdata) *
 + pdata-num_regulators, GFP_KERNEL);
 + if (!rdata) {
 + dev_err(iodev-dev, could not allocate memory for 
 + regulator data\n);
 + return -ENOMEM;
 + }

 + pdata-regulators = rdata;

 + for_each_child_of_node(regulators_np, reg_np) {
 + for (i = 0; i  ARRAY_SIZE(regulators); i++)
 + if (!of_node_cmp(reg_np-name, regulators[i].name))
 + break;
 + rdata-id = i;


rdata-id will be equal to ARRAY_SIZE(regulators) when one adds DT node
name (below regulators) which is different from what can be found in
regulators[] table.

On my test machine this results in hard lockup - possibly because
something tries to access regulators[ARRAY_SIZE(regulators)]
later on.

Following patch fixes this on my machine (using DTS with misspelled LDO1 for 
LDx1):

diff --git a/drivers/regulator/max8997.c b/drivers/regulator/max8997.c
index dce8aaf..c20fd72 100644
--- a/drivers/regulator/max8997.c
+++ b/drivers/regulator/max8997.c
@@ -1011,6 +1011,13 @@ static int max8997_pmic_dt_parse_pdata(struct 
max8997_dev *iodev,
for (i = 0; i  ARRAY_SIZE(regulators); i++)
if (!of_node_cmp(reg_np-name, regulators[i].name))
break;
+
+   if (i == ARRAY_SIZE(regulators)) {
+   dev_warn(iodev-dev, don't know how to configure 
regulator %s\n,
+reg_np-name);
+   continue;
+   }
+
rdata-id = i;
rdata-initdata = of_get_regulator_init_data(
iodev-dev, reg_np);


Regards,
-- 
Karol Lewandowski | Samsung Poland RD Center | Linux/Platform
--
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 2/3] i2c-s3c2410: Rework device type handling

2012-03-21 Thread Karol Lewandowski
On 19.03.2012 20:55, Mark Brown wrote:

 On Thu, Mar 15, 2012 at 05:54:33PM +0100, Karol Lewandowski wrote:
 
 If you consider code to be inherently less readable because of this
 approach I'll rework it.  If it's not a such big deal for you I would
 prefer to keep it as is.
 
 The thing that was causing me to think the code was funny was mainly the
 fact that we're now combining both quirk based selection and chip type
 based selection into the same bitmask.  If the chip types were quirks
 it'd probably not have looked odd, and that might just be a case of
 renaming them - I can't remember what they do.


What do you think about following changes, then?

diff --git a/drivers/i2c/busses/i2c-s3c2410.c
b/drivers/i2c/busses/i2c-s3c2410.c
index fa5f8c4..18c9760 100644
--- a/drivers/i2c/busses/i2c-s3c2410.c
+++ b/drivers/i2c/busses/i2c-s3c2410.c
@@ -48,12 +48,9 @@
 static const struct of_device_id s3c24xx_i2c_match[];
 #endif

-/* reserve lower 8 bits for device type, use remaining space for hw
quirks */
-#define TYPE_BITS  0x00ff
-#define TYPE_S3C2410   0x0001
-#define TYPE_S3C2440   0x0002
-#define FLAG_HDMIPHY   0x0100
-#define FLAG_NO_GPIO   0x0200
+#define QUIRK_S3C2440  (1  0)
+#define QUIRK_HDMIPHY  (1  1)
+#define QUIRK_NO_GPIO  (1  2)

 /* i2c controller state */
 enum s3c24xx_i2c_state {
@@ -67,7 +64,7 @@ enum s3c24xx_i2c_state {
 struct s3c24xx_i2c {
spinlock_t  lock;
wait_queue_head_t   wait;
-   unsigned inttype;
+   unsigned intquirks;
unsigned intsuspended:1;

struct i2c_msg  *msg;
@@ -94,22 +91,12 @@ struct s3c24xx_i2c {
 #endif
 };

-/* s3c24xx_i2c_is_type()
- *
- * return true if this controller is of specified type
-*/
-
-static inline int s3c24xx_i2c_is_type(struct s3c24xx_i2c *i2c, unsigned
int type)
-{
-   return (i2c-type  TYPE_BITS) == type;
-}
-
-/* s3c24xx_get_device_type
+/* s3c24xx_get_device_quirks
  *
  * Get controller type either from device tree or platform device variant.
 */

-static inline unsigned int s3c24xx_get_device_type(struct
platform_device *pdev)
+static inline unsigned int s3c24xx_get_device_quirks(struct
platform_device *pdev)
 {
 #ifdef CONFIG_OF
 if (pdev-dev.of_node) {
@@ -487,7 +474,7 @@ static int s3c24xx_i2c_set_master(struct s3c24xx_i2c
*i2c)
 * the hangup is expected to happen, so waiting 400 ms
 * causes only unnecessary system hangup
 */
-   if (i2c-type  FLAG_HDMIPHY)
+   if (i2c-quirks  QUIRK_HDMIPHY)
timeout = 10;

while (timeout--  0) {
@@ -500,7 +487,7 @@ static int s3c24xx_i2c_set_master(struct s3c24xx_i2c
*i2c)
}

/* hang-up of bus dedicated for HDMIPHY occurred, resetting */
-   if (i2c-type  FLAG_HDMIPHY) {
+   if (i2c-quirks  QUIRK_HDMIPHY) {
writel(0, i2c-regs + S3C2410_IICCON);
writel(0, i2c-regs + S3C2410_IICSTAT);
writel(0, i2c-regs + S3C2410_IICDS);
@@ -704,7 +691,7 @@ static int s3c24xx_i2c_clockrate(struct s3c24xx_i2c
*i2c, unsigned int *got)

writel(iiccon, i2c-regs + S3C2410_IICCON);

-   if (s3c24xx_i2c_is_type(i2c, TYPE_S3C2440)) {
+   if (i2c-quirks  QUIRK_S3C2440) {
unsigned long sda_delay;

if (pdata-sda_delay) {
@@ -789,7 +776,7 @@ static int s3c24xx_i2c_parse_dt_gpio(struct
s3c24xx_i2c *i2c)
 {
int idx, gpio, ret;

-   if (i2c-type  FLAG_NO_GPIO)
+   if (i2c-quirks  QUIRK_NO_GPIO)
return 0;

for (idx = 0; idx  2; idx++) {
@@ -817,7 +804,7 @@ static void s3c24xx_i2c_dt_gpio_free(struct
s3c24xx_i2c *i2c)
 {
unsigned int idx;

-   if (i2c-type  FLAG_NO_GPIO)
+   if (i2c-quirks  QUIRK_NO_GPIO)
return;

for (idx = 0; idx  2; idx++)
@@ -898,10 +885,10 @@ s3c24xx_i2c_parse_dt(struct device_node *np,
struct s3c24xx_i2c *i2c)
pdata-bus_num = -1; /* i2c bus number is dynamically assigned */

if (of_get_property(np, samsung,i2c-quirk-hdmiphy, NULL))
-   i2c-type |= FLAG_HDMIPHY;
+   i2c-quirks |= QUIRK_HDMIPHY;

if (of_get_property(np, samsung,i2c-no-gpio, NULL))
-   i2c-type |= FLAG_NO_GPIO;
+   i2c-quirks |= QUIRK_NO_GPIO;

of_property_read_u32(np, samsung,i2c-sda-delay, pdata-sda_delay);
of_property_read_u32(np, samsung,i2c-slave-addr, pdata-slave_addr);
@@ -948,7 +935,7 @@ static int s3c24xx_i2c_probe(struct platform_device
*pdev)
goto err_noclk;
}

-   i2c-type = s3c24xx_get_device_type(pdev);
+   i2c-quirks = s3c24xx_get_device_quirks(pdev);
if (pdata)
memcpy(i2c-pdata, pdata, sizeof(*pdata));
else
@@ -1156,21 +1143,21 @@ static const struct dev_pm_ops
s3c24xx_i2c_dev_pm_ops = {
 static struct platform_device_id s3c24xx_driver_ids

Re: [PATCH 2/3] i2c-s3c2410: Rework device type handling

2012-03-21 Thread Karol Lewandowski
On 21.03.2012 12:50, Mark Brown wrote:

 On Wed, Mar 21, 2012 at 11:33:58AM +0100, Karol Lewandowski wrote:
 
 What do you think about following changes, then?
 
 That looks reasonable.


Thanks. I'll incorporate this change and post whole patchset again.

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


[PATCH 2/3] i2c-s3c2410: Rework device type handling

2012-03-21 Thread Karol Lewandowski
Reorganize driver a bit to better handle device tree-based systems:

 - move machine type to driver's private structure instead of
   quering platform device variants in runtime

 - replace s3c24xx_i2c_type enum with unsigned int that holds
   bitmask with revision-specific quirks

Signed-off-by: Karol Lewandowski k.lewando...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/i2c/busses/i2c-s3c2410.c |   47 ++---
 1 files changed, 23 insertions(+), 24 deletions(-)

diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
index 85e3664..f7b6a14 100644
--- a/drivers/i2c/busses/i2c-s3c2410.c
+++ b/drivers/i2c/busses/i2c-s3c2410.c
@@ -44,8 +44,14 @@
 #include plat/regs-iic.h
 #include plat/iic.h
 
-/* i2c controller state */
+#ifdef CONFIG_OF
+static const struct of_device_id s3c24xx_i2c_match[];
+#endif
 
+/* Treat S3C2410 as baseline hardware, anything else is supported via quirks */
+#define QUIRK_S3C2440  (1  0)
+
+/* i2c controller state */
 enum s3c24xx_i2c_state {
STATE_IDLE,
STATE_START,
@@ -54,14 +60,10 @@ enum s3c24xx_i2c_state {
STATE_STOP
 };
 
-enum s3c24xx_i2c_type {
-   TYPE_S3C2410,
-   TYPE_S3C2440,
-};
-
 struct s3c24xx_i2c {
spinlock_t  lock;
wait_queue_head_t   wait;
+   unsigned intquirks;
unsigned intsuspended:1;
 
struct i2c_msg  *msg;
@@ -88,26 +90,22 @@ struct s3c24xx_i2c {
 #endif
 };
 
-/* default platform data removed, dev should always carry data. */
-
-/* s3c24xx_i2c_is2440()
+/* s3c24xx_get_device_quirks
  *
- * return true is this is an s3c2440
+ * Get controller type either from device tree or platform device variant.
 */
 
-static inline int s3c24xx_i2c_is2440(struct s3c24xx_i2c *i2c)
+static inline unsigned int s3c24xx_get_device_quirks(struct platform_device 
*pdev)
 {
-   struct platform_device *pdev = to_platform_device(i2c-dev);
-   enum s3c24xx_i2c_type type;
-
 #ifdef CONFIG_OF
-   if (i2c-dev-of_node)
-   return of_device_is_compatible(i2c-dev-of_node,
-   samsung,s3c2440-i2c);
+if (pdev-dev.of_node) {
+   const struct of_device_id *match;
+   match = of_match_node(s3c24xx_i2c_match[0], pdev-dev.of_node);
+   return (unsigned int)match-data;
+}
 #endif
 
-   type = platform_get_device_id(pdev)-driver_data;
-   return type == TYPE_S3C2440;
+   return platform_get_device_id(pdev)-driver_data;
 }
 
 /* s3c24xx_i2c_master_complete
@@ -676,7 +674,7 @@ static int s3c24xx_i2c_clockrate(struct s3c24xx_i2c *i2c, 
unsigned int *got)
 
writel(iiccon, i2c-regs + S3C2410_IICCON);
 
-   if (s3c24xx_i2c_is2440(i2c)) {
+   if (i2c-quirks  QUIRK_S3C2440) {
unsigned long sda_delay;
 
if (pdata-sda_delay) {
@@ -906,6 +904,7 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
goto err_noclk;
}
 
+   i2c-quirks = s3c24xx_get_device_quirks(pdev);
if (pdata)
memcpy(i2c-pdata, pdata, sizeof(*pdata));
else
@@ -1113,18 +1112,18 @@ static const struct dev_pm_ops s3c24xx_i2c_dev_pm_ops = 
{
 static struct platform_device_id s3c24xx_driver_ids[] = {
{
.name   = s3c2410-i2c,
-   .driver_data= TYPE_S3C2410,
+   .driver_data= 0,
}, {
.name   = s3c2440-i2c,
-   .driver_data= TYPE_S3C2440,
+   .driver_data= QUIRK_S3C2440,
}, { },
 };
 MODULE_DEVICE_TABLE(platform, s3c24xx_driver_ids);
 
 #ifdef CONFIG_OF
 static const struct of_device_id s3c24xx_i2c_match[] = {
-   { .compatible = samsung,s3c2410-i2c },
-   { .compatible = samsung,s3c2440-i2c },
+   { .compatible = samsung,s3c2410-i2c, .data = (void *)0 },
+   { .compatible = samsung,s3c2440-i2c, .data = (void *)QUIRK_S3C2440 },
{},
 };
 MODULE_DEVICE_TABLE(of, s3c24xx_i2c_match);
-- 
1.7.9

--
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 v3 0/3] i2c-s3c2410: Updates for exynos4210 and DT-based systems

2012-03-21 Thread Karol Lewandowski
Changes since v2:
 - Merge device type and flags into flat bitmask named quirks -
   Consequently, treat s3c24xx as baseline hardware platform and
   support all hw variations via quirks [Suggested by Mark Brown]

Changes since v1:
 - Move unrelated code fragment to separate patch (of_match_ptr())
   [Suggested by Thomas Abracham]
 - Move device-type handling to separate function and rework its
   internals a bit [likewise]

This patchset reworks i2c-s3c2410 driver a bit to better handle
device tree-enabled platforms and adds two quirks required by
exynos4210-specific I2C controller used by s5p-hdmi driver.

This patchset is based on i2c-bjdooks/for-34/i2c/i2c-samsung branch
taken from:

  git://git.fluff.org/bjdooks/linux.git

Karol Lewandowski (3):
  i2c-s3c2410: Drop unused define
  i2c-s3c2410: Rework device type handling
  i2c-s3c2410: Add HDMIPHY quirk for S3C2440

 .../devicetree/bindings/i2c/samsung-i2c.txt|   11 ++-
 drivers/i2c/busses/i2c-s3c2410.c   |   86 +--
 2 files changed, 68 insertions(+), 29 deletions(-)

-- 
1.7.9

--
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/3] i2c-s3c2410: Drop unused define

2012-03-21 Thread Karol Lewandowski
Use standard of_match_ptr() to avoid defining variable unused
in non device tree builds.

Signed-off-by: Karol Lewandowski k.lewando...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
Acked-by: Grant Likely grant.lik...@secretlab.ca
---
 drivers/i2c/busses/i2c-s3c2410.c |4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)

diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
index 737f721..85e3664 100644
--- a/drivers/i2c/busses/i2c-s3c2410.c
+++ b/drivers/i2c/busses/i2c-s3c2410.c
@@ -1128,8 +1128,6 @@ static const struct of_device_id s3c24xx_i2c_match[] = {
{},
 };
 MODULE_DEVICE_TABLE(of, s3c24xx_i2c_match);
-#else
-#define s3c24xx_i2c_match NULL
 #endif
 
 static struct platform_driver s3c24xx_i2c_driver = {
@@ -1140,7 +1138,7 @@ static struct platform_driver s3c24xx_i2c_driver = {
.owner  = THIS_MODULE,
.name   = s3c-i2c,
.pm = S3C24XX_DEV_PM_OPS,
-   .of_match_table = s3c24xx_i2c_match,
+   .of_match_table = of_match_ptr(s3c24xx_i2c_match),
},
 };
 
-- 
1.7.9

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


[PATCH 3/3] i2c-s3c2410: Add HDMIPHY quirk for S3C2440

2012-03-21 Thread Karol Lewandowski
This patch adds support for s3c2440 I2C bus controller dedicated HDMIPHY device 
on
Exynos4 platform. Some quirks are introduced due to differences between HDMIPHY
and other I2C controllers on Exynos4.  These differences are:
- no GPIOs, HDMIPHY is inside the SoC and the controller is connected
  internally
- due to unknown reason (probably HW bug in HDMIPHY and/or the controller) a
  transfer fails to finish. The controller hangs after sending the last byte,
  the workaround for this bug is resetting the controller after each transfer

Signed-off-by: Tomasz Stanislawski t.stanisl...@samsung.com
Signed-off-by: Karol Lewandowski k.lewando...@samsung.com
Tested-by: Tomasz Stanislawski t.stanisl...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 .../devicetree/bindings/i2c/samsung-i2c.txt|   11 +-
 drivers/i2c/busses/i2c-s3c2410.c   |   35 
 2 files changed, 44 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/i2c/samsung-i2c.txt 
b/Documentation/devicetree/bindings/i2c/samsung-i2c.txt
index 38832c7..c6670f9 100644
--- a/Documentation/devicetree/bindings/i2c/samsung-i2c.txt
+++ b/Documentation/devicetree/bindings/i2c/samsung-i2c.txt
@@ -10,14 +10,21 @@ Required properties:
 region.
   - interrupts: interrupt number to the cpu.
   - samsung,i2c-sda-delay: Delay (in ns) applied to data line (SDA) edges.
-  - gpios: The order of the gpios should be the following: SDA, SCL.
-The gpio specifier depends on the gpio controller.
 
 Optional properties:
+  - gpios: The order of the gpios should be the following: SDA, SCL.
+The gpio specifier depends on the gpio controller. Required in all cases
+except when samsung,i2c-no-gpio is also specified.
+  - samsung,i2c-no-gpio: input/output lines of the controller are
+permanently wired to the respective client, there are no gpio
+lines that need to be configured to enable this controller
   - samsung,i2c-slave-addr: Slave address in multi-master enviroment. If not
 specified, default value is 0.
   - samsung,i2c-max-bus-freq: Desired frequency in Hz of the bus. If not
 specified, the default value in Hz is 10.
+  - samsung,i2c-quirk-hdmiphy: Quirk for HDMI PHY block found on
+Exynos4 platform - reduce timeout and reset controller after each
+transfer
 
 Example:
 
diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
index f7b6a14..e50f523 100644
--- a/drivers/i2c/busses/i2c-s3c2410.c
+++ b/drivers/i2c/busses/i2c-s3c2410.c
@@ -50,6 +50,8 @@ static const struct of_device_id s3c24xx_i2c_match[];
 
 /* Treat S3C2410 as baseline hardware, anything else is supported via quirks */
 #define QUIRK_S3C2440  (1  0)
+#define QUIRK_HDMIPHY  (1  1)
+#define QUIRK_NO_GPIO  (1  2)
 
 /* i2c controller state */
 enum s3c24xx_i2c_state {
@@ -469,6 +471,13 @@ static int s3c24xx_i2c_set_master(struct s3c24xx_i2c *i2c)
unsigned long iicstat;
int timeout = 400;
 
+   /* the timeout for HDMIPHY is reduced to 10 ms because
+* the hangup is expected to happen, so waiting 400 ms
+* causes only unnecessary system hangup
+*/
+   if (i2c-quirks  QUIRK_HDMIPHY)
+   timeout = 10;
+
while (timeout--  0) {
iicstat = readl(i2c-regs + S3C2410_IICSTAT);
 
@@ -478,6 +487,15 @@ static int s3c24xx_i2c_set_master(struct s3c24xx_i2c *i2c)
msleep(1);
}
 
+   /* hang-up of bus dedicated for HDMIPHY occurred, resetting */
+   if (i2c-quirks  QUIRK_HDMIPHY) {
+   writel(0, i2c-regs + S3C2410_IICCON);
+   writel(0, i2c-regs + S3C2410_IICSTAT);
+   writel(0, i2c-regs + S3C2410_IICDS);
+
+   return 0;
+   }
+
return -ETIMEDOUT;
 }
 
@@ -759,6 +777,9 @@ static int s3c24xx_i2c_parse_dt_gpio(struct s3c24xx_i2c 
*i2c)
 {
int idx, gpio, ret;
 
+   if (i2c-quirks  QUIRK_NO_GPIO)
+   return 0;
+
for (idx = 0; idx  2; idx++) {
gpio = of_get_gpio(i2c-dev-of_node, idx);
if (!gpio_is_valid(gpio)) {
@@ -783,6 +804,10 @@ free_gpio:
 static void s3c24xx_i2c_dt_gpio_free(struct s3c24xx_i2c *i2c)
 {
unsigned int idx;
+
+   if (i2c-quirks  QUIRK_NO_GPIO)
+   return;
+
for (idx = 0; idx  2; idx++)
gpio_free(i2c-gpios[idx]);
 }
@@ -859,6 +884,13 @@ s3c24xx_i2c_parse_dt(struct device_node *np, struct 
s3c24xx_i2c *i2c)
return;
 
pdata-bus_num = -1; /* i2c bus number is dynamically assigned */
+
+   if (of_get_property(np, samsung,i2c-quirk-hdmiphy, NULL))
+   i2c-quirks |= QUIRK_HDMIPHY;
+
+   if (of_get_property(np, samsung,i2c-no-gpio, NULL))
+   i2c-quirks |= QUIRK_NO_GPIO;
+
of_property_read_u32(np, samsung,i2c-sda-delay, pdata-sda_delay);
of_property_read_u32(np, samsung,i2c-slave-addr

Re: [PATCH 2/3] i2c-s3c2410: Rework device type handling

2012-03-15 Thread Karol Lewandowski
On 14.03.2012 18:29, Mark Brown wrote:

 On Tue, Mar 13, 2012 at 05:54:38PM +0100, Karol Lewandowski wrote:
 
  - replace s3c24xx_i2c_type enum with plain unsigned int that can
hold not only device type but also hw revision-specific quirks
 
 Would it not be clearer to just have explicit flags for the quirks (eg,
 as a set of bitfield flags)?


That would work on runtime but we also need to initialize this
somehow.  The way it was done today on non-dt platforms is via platform
device variants, i.e. (taken from 3rd patch):

@@ -1128,6 +1161,9 @@ static struct platform_device_id s3c24xx_driver_ids[] = {
}, {
.name   = s3c2440-i2c,
.driver_data= TYPE_S3C2440,
+   }, {
+   .name   = s3c2440-hdmiphy-i2c,
+   .driver_data= TYPE_S3C2440 | FLAG_HDMIPHY | FLAG_NO_GPIO,

Ability to address above scenario was sole motivation for this change.
Without it one would need either need separate type (e.g. 
TYPE_S3C2440_HDMIPHY) or setting flags based just on device name.

Introducing separate type (TYPE_S3C2440_HDMIPHY) has been our original
attempt to solve this issue.  However, this required adding explicit
checks to driver code all over the place (if (type == S3C2400 ||
type == S3c2440_HDMIPHY).

Thus, I felt that sqeezing quirks into type is a bit cleaner approach.

Regards,
-- 
Karol Lewandowski | Samsung Poland RD Center | Linux/Platform
--
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 2/3] i2c-s3c2410: Rework device type handling

2012-03-15 Thread Karol Lewandowski
On 15.03.2012 13:56, Mark Brown wrote:

 On Thu, Mar 15, 2012 at 11:04:56AM +0100, Karol Lewandowski wrote:
 
 Introducing separate type (TYPE_S3C2440_HDMIPHY) has been our original
 attempt to solve this issue.  However, this required adding explicit
 checks to driver code all over the place (if (type == S3C2400 ||
 type == S3c2440_HDMIPHY).
 
 Another option is to change the type to be a pointer to a struct with
 quirk flags in it.


Sure, that's possible.   However, I don't find it any simpler than
using  bitmasks.  Quite to contrary - I consider it redundant to
bring new structure into existence when simple uint does the trick
just fine (IMHO, of course).

If you consider code to be inherently less readable because of this
approach I'll rework it.  If it's not a such big deal for you I would
prefer to keep it as is.

Thanks!
-- 
Karol Lewandowski | Samsung Poland RD Center | Linux/Platform
--
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/3 v2] Updates for exynos4210 and DT-based systems

2012-03-13 Thread Karol Lewandowski
Changes since v1:
 - Move unrelated code fragment to separate patch (of_match_ptr())
 - Move device-type handling to separate function and rework its
   internals a bit

This patchset reworks i2c-s3c2410 driver a bit to better handle
device tree-enabled platforms and adds two quirks required by
exynos4210-specific I2C controller used by s5p-hdmi driver.

This patchset is based on i2c-bjdooks/for-34/i2c/i2c-samsung branch
taken from:

  git://git.fluff.org/bjdooks/linux.git

Karol Lewandowski (3):
  i2c-s3c2410: Drop unused define
  i2c-s3c2410: Rework device type handling
  i2c-s3c2410: Add HDMIPHY quirk for S3C2440

 .../devicetree/bindings/i2c/samsung-i2c.txt|   10 ++-
 drivers/i2c/busses/i2c-s3c2410.c   |   93 +++-
 2 files changed, 77 insertions(+), 26 deletions(-)

-- 
1.7.9

--
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/3] i2c-s3c2410: Drop unused define

2012-03-13 Thread Karol Lewandowski
Use standard of_match_ptr() to avoid defining variable unused
in non device tree builds.

Signed-off-by: Karol Lewandowski k.lewando...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/i2c/busses/i2c-s3c2410.c |4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)

diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
index 737f721..85e3664 100644
--- a/drivers/i2c/busses/i2c-s3c2410.c
+++ b/drivers/i2c/busses/i2c-s3c2410.c
@@ -1128,8 +1128,6 @@ static const struct of_device_id s3c24xx_i2c_match[] = {
{},
 };
 MODULE_DEVICE_TABLE(of, s3c24xx_i2c_match);
-#else
-#define s3c24xx_i2c_match NULL
 #endif
 
 static struct platform_driver s3c24xx_i2c_driver = {
@@ -1140,7 +1138,7 @@ static struct platform_driver s3c24xx_i2c_driver = {
.owner  = THIS_MODULE,
.name   = s3c-i2c,
.pm = S3C24XX_DEV_PM_OPS,
-   .of_match_table = s3c24xx_i2c_match,
+   .of_match_table = of_match_ptr(s3c24xx_i2c_match),
},
 };
 
-- 
1.7.9

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


[PATCH 2/3] i2c-s3c2410: Rework device type handling

2012-03-13 Thread Karol Lewandowski
Reorganize driver a bit to better handle device tree-based systems:

 - move machine type to driver's private structure instead of
   quering platform device variants in runtime

 - replace s3c24xx_i2c_type enum with plain unsigned int that can
   hold not only device type but also hw revision-specific quirks

Signed-off-by: Karol Lewandowski k.lewando...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/i2c/busses/i2c-s3c2410.c |   53 +++---
 1 files changed, 32 insertions(+), 21 deletions(-)

diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
index 85e3664..f84d26f 100644
--- a/drivers/i2c/busses/i2c-s3c2410.c
+++ b/drivers/i2c/busses/i2c-s3c2410.c
@@ -44,8 +44,16 @@
 #include plat/regs-iic.h
 #include plat/iic.h
 
-/* i2c controller state */
+#ifdef CONFIG_OF
+static const struct of_device_id s3c24xx_i2c_match[];
+#endif
+
+/* reserve lower 8 bits for device type, use remaining space for hw quirks */
+#define TYPE_BITS  0x00ff
+#define TYPE_S3C2410   0x0001
+#define TYPE_S3C2440   0x0002
 
+/* i2c controller state */
 enum s3c24xx_i2c_state {
STATE_IDLE,
STATE_START,
@@ -54,14 +62,10 @@ enum s3c24xx_i2c_state {
STATE_STOP
 };
 
-enum s3c24xx_i2c_type {
-   TYPE_S3C2410,
-   TYPE_S3C2440,
-};
-
 struct s3c24xx_i2c {
spinlock_t  lock;
wait_queue_head_t   wait;
+   unsigned inttype;
unsigned intsuspended:1;
 
struct i2c_msg  *msg;
@@ -88,26 +92,32 @@ struct s3c24xx_i2c {
 #endif
 };
 
-/* default platform data removed, dev should always carry data. */
-
-/* s3c24xx_i2c_is2440()
+/* s3c24xx_i2c_is_type()
  *
- * return true is this is an s3c2440
+ * return true if this controller is of specified type
 */
 
-static inline int s3c24xx_i2c_is2440(struct s3c24xx_i2c *i2c)
+static inline int s3c24xx_i2c_is_type(struct s3c24xx_i2c *i2c, unsigned int 
type)
 {
-   struct platform_device *pdev = to_platform_device(i2c-dev);
-   enum s3c24xx_i2c_type type;
+   return (i2c-type  TYPE_BITS) == type;
+}
+
+/* s3c24xx_get_device_type
+ *
+ * Get controller type either from device tree or platform device variant.
+*/
 
+static inline unsigned int s3c24xx_get_device_type(struct platform_device 
*pdev)
+{
 #ifdef CONFIG_OF
-   if (i2c-dev-of_node)
-   return of_device_is_compatible(i2c-dev-of_node,
-   samsung,s3c2440-i2c);
+   if (pdev-dev.of_node) {
+   const struct of_device_id *match;
+   match = of_match_node(s3c24xx_i2c_match[0], pdev-dev.of_node);
+   return (unsigned int)match-data;
+   }
 #endif
 
-   type = platform_get_device_id(pdev)-driver_data;
-   return type == TYPE_S3C2440;
+   return platform_get_device_id(pdev)-driver_data;
 }
 
 /* s3c24xx_i2c_master_complete
@@ -676,7 +686,7 @@ static int s3c24xx_i2c_clockrate(struct s3c24xx_i2c *i2c, 
unsigned int *got)
 
writel(iiccon, i2c-regs + S3C2410_IICCON);
 
-   if (s3c24xx_i2c_is2440(i2c)) {
+   if (s3c24xx_i2c_is_type(i2c, TYPE_S3C2440)) {
unsigned long sda_delay;
 
if (pdata-sda_delay) {
@@ -906,6 +916,7 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
goto err_noclk;
}
 
+   i2c-type = s3c24xx_get_device_type(pdev);
if (pdata)
memcpy(i2c-pdata, pdata, sizeof(*pdata));
else
@@ -1123,8 +1134,8 @@ MODULE_DEVICE_TABLE(platform, s3c24xx_driver_ids);
 
 #ifdef CONFIG_OF
 static const struct of_device_id s3c24xx_i2c_match[] = {
-   { .compatible = samsung,s3c2410-i2c },
-   { .compatible = samsung,s3c2440-i2c },
+   { .compatible = samsung,s3c2410-i2c, .data = (void *)TYPE_S3C2410 },
+   { .compatible = samsung,s3c2440-i2c, .data = (void *)TYPE_S3C2440 },
{},
 };
 MODULE_DEVICE_TABLE(of, s3c24xx_i2c_match);
-- 
1.7.9

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


[PATCH 3/3] i2c-s3c2410: Add HDMIPHY quirk for S3C2440

2012-03-13 Thread Karol Lewandowski
This patch adds support for s3c2440 I2C bus controller dedicated HDMIPHY device 
on
Exynos4 platform. Some quirks are introduced due to differences between HDMIPHY
and other I2C controllers on Exynos4.  These differences are:
- no GPIOs, HDMIPHY is inside the SoC and the controller is connected
  internally
- due to unknown reason (probably HW bug in HDMIPHY and/or the controller) a
  transfer fails to finish. The controller hangs after sending the last byte,
  the workaround for this bug is resetting the controller after each transfer

Signed-off-by: Tomasz Stanislawski t.stanisl...@samsung.com
Signed-off-by: Karol Lewandowski k.lewando...@samsung.com
Tested-by: Tomasz Stanislawski t.stanisl...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 .../devicetree/bindings/i2c/samsung-i2c.txt|   10 -
 drivers/i2c/busses/i2c-s3c2410.c   |   36 
 2 files changed, 44 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/i2c/samsung-i2c.txt 
b/Documentation/devicetree/bindings/i2c/samsung-i2c.txt
index 38832c7..ac0917c 100644
--- a/Documentation/devicetree/bindings/i2c/samsung-i2c.txt
+++ b/Documentation/devicetree/bindings/i2c/samsung-i2c.txt
@@ -10,14 +10,20 @@ Required properties:
 region.
   - interrupts: interrupt number to the cpu.
   - samsung,i2c-sda-delay: Delay (in ns) applied to data line (SDA) edges.
-  - gpios: The order of the gpios should be the following: SDA, SCL.
-The gpio specifier depends on the gpio controller.
 
 Optional properties:
+  - gpios: The order of the gpios should be the following: SDA, SCL.
+The gpio specifier depends on the gpio controller. Required in all cases
+except when samsung,i2c-no-gpio is also specified.
+  - samsung,i2c-no-gpio: input/output lines of the controller are
+permanently wired to the respective client, there are no gpio
+lines that need to be configured to enable this controller
   - samsung,i2c-slave-addr: Slave address in multi-master enviroment. If not
 specified, default value is 0.
   - samsung,i2c-max-bus-freq: Desired frequency in Hz of the bus. If not
 specified, the default value in Hz is 10.
+  - samsung,i2c-quirk-hdmiphy: Quirk for HDMI PHY block on S3C2440 -
+reduce timeout and reset controller when doing transefers
 
 Example:
 
diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
index f84d26f..23bf7fa 100644
--- a/drivers/i2c/busses/i2c-s3c2410.c
+++ b/drivers/i2c/busses/i2c-s3c2410.c
@@ -52,6 +52,8 @@ static const struct of_device_id s3c24xx_i2c_match[];
 #define TYPE_BITS  0x00ff
 #define TYPE_S3C2410   0x0001
 #define TYPE_S3C2440   0x0002
+#define FLAG_HDMIPHY   0x0100
+#define FLAG_NO_GPIO   0x0200
 
 /* i2c controller state */
 enum s3c24xx_i2c_state {
@@ -481,6 +483,13 @@ static int s3c24xx_i2c_set_master(struct s3c24xx_i2c *i2c)
unsigned long iicstat;
int timeout = 400;
 
+   /* the timeout for HDMIPHY is reduced to 10 ms because
+* the hangup is expected to happen, so waiting 400 ms
+* causes only unnecessary system hangup
+*/
+   if (i2c-type  FLAG_HDMIPHY)
+   timeout = 10;
+
while (timeout--  0) {
iicstat = readl(i2c-regs + S3C2410_IICSTAT);
 
@@ -490,6 +499,15 @@ static int s3c24xx_i2c_set_master(struct s3c24xx_i2c *i2c)
msleep(1);
}
 
+   /* hang-up of bus dedicated for HDMIPHY occurred, resetting */
+   if (i2c-type  FLAG_HDMIPHY) {
+   writel(0, i2c-regs + S3C2410_IICCON);
+   writel(0, i2c-regs + S3C2410_IICSTAT);
+   writel(0, i2c-regs + S3C2410_IICDS);
+
+   return 0;
+   }
+
return -ETIMEDOUT;
 }
 
@@ -771,6 +789,9 @@ static int s3c24xx_i2c_parse_dt_gpio(struct s3c24xx_i2c 
*i2c)
 {
int idx, gpio, ret;
 
+   if (i2c-type  FLAG_NO_GPIO)
+   return 0;
+
for (idx = 0; idx  2; idx++) {
gpio = of_get_gpio(i2c-dev-of_node, idx);
if (!gpio_is_valid(gpio)) {
@@ -795,6 +816,10 @@ free_gpio:
 static void s3c24xx_i2c_dt_gpio_free(struct s3c24xx_i2c *i2c)
 {
unsigned int idx;
+
+   if (i2c-type  FLAG_NO_GPIO)
+   return;
+
for (idx = 0; idx  2; idx++)
gpio_free(i2c-gpios[idx]);
 }
@@ -871,6 +896,14 @@ s3c24xx_i2c_parse_dt(struct device_node *np, struct 
s3c24xx_i2c *i2c)
return;
 
pdata-bus_num = -1; /* i2c bus number is dynamically assigned */
+
+   if (s3c24xx_i2c_is_type(i2c, TYPE_S3C2440) 
+   of_get_property(np, samsung,i2c-quirk-hdmiphy, NULL))
+   i2c-type |= FLAG_HDMIPHY;
+
+   if (of_get_property(np, samsung,i2c-no-gpio, NULL))
+   i2c-type |= FLAG_NO_GPIO;
+
of_property_read_u32(np, samsung,i2c-sda-delay, pdata-sda_delay);
of_property_read_u32

Re: [PATCH 3/3] i2c-s3c2410: Add HDMIPHY quirk for S3C2440

2012-03-13 Thread Karol Lewandowski
On 13.03.2012 18:27, Tomasz Stanislawski wrote:

 Hi Karol,
 Please refer to comments below,
 
 Regards,
 Tomasz Stanislawski
 
 On 03/13/2012 05:54 PM, Karol Lewandowski wrote:
 This patch adds support for s3c2440 I2C bus controller dedicated HDMIPHY 
 device on
 Exynos4 platform. Some quirks are introduced due to differences between 
 HDMIPHY
 and other I2C controllers on Exynos4.  These differences are:
 - no GPIOs, HDMIPHY is inside the SoC and the controller is connected
   internally
 - due to unknown reason (probably HW bug in HDMIPHY and/or the controller) a
   transfer fails to finish. The controller hangs after sending the last byte,
   the workaround for this bug is resetting the controller after each transfer

 Signed-off-by: Tomasz Stanislawski t.stanisl...@samsung.com
 Signed-off-by: Karol Lewandowski k.lewando...@samsung.com
 Tested-by: Tomasz Stanislawski t.stanisl...@samsung.com
 Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
 ---
  .../devicetree/bindings/i2c/samsung-i2c.txt|   10 -
  drivers/i2c/busses/i2c-s3c2410.c   |   36 
 
  2 files changed, 44 insertions(+), 2 deletions(-)

 [snip]
 @@ -871,6 +896,14 @@ s3c24xx_i2c_parse_dt(struct device_node *np, struct 
 s3c24xx_i2c *i2c)
  return;
  
  pdata-bus_num = -1; /* i2c bus number is dynamically assigned */
 +
 +if (s3c24xx_i2c_is_type(i2c, TYPE_S3C2440) 
 
 I think that type checking should be removed because hdmiphy quirk is 
 something
 orthogonal to the controller type.


Ok, I'll drop this test and resend patch in a minute.

Thanks!
-- 
Karol Lewandowski | Samsung Poland RD Center | Linux/Platform
--
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] i2c-s3c2410: Add HDMIPHY quirk for S3C2440

2012-03-13 Thread Karol Lewandowski
This patch adds support for s3c2440 I2C bus controller dedicated HDMIPHY device 
on
Exynos4 platform. Some quirks are introduced due to differences between HDMIPHY
and other I2C controllers on Exynos4.  These differences are:
- no GPIOs, HDMIPHY is inside the SoC and the controller is connected
  internally
- due to unknown reason (probably HW bug in HDMIPHY and/or the controller) a
  transfer fails to finish. The controller hangs after sending the last byte,
  the workaround for this bug is resetting the controller after each transfer

Signed-off-by: Tomasz Stanislawski t.stanisl...@samsung.com
Signed-off-by: Karol Lewandowski k.lewando...@samsung.com
Tested-by: Tomasz Stanislawski t.stanisl...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 .../devicetree/bindings/i2c/samsung-i2c.txt|   11 +-
 drivers/i2c/busses/i2c-s3c2410.c   |   35 
 2 files changed, 44 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/i2c/samsung-i2c.txt 
b/Documentation/devicetree/bindings/i2c/samsung-i2c.txt
index 38832c7..c6670f9 100644
--- a/Documentation/devicetree/bindings/i2c/samsung-i2c.txt
+++ b/Documentation/devicetree/bindings/i2c/samsung-i2c.txt
@@ -10,14 +10,21 @@ Required properties:
 region.
   - interrupts: interrupt number to the cpu.
   - samsung,i2c-sda-delay: Delay (in ns) applied to data line (SDA) edges.
-  - gpios: The order of the gpios should be the following: SDA, SCL.
-The gpio specifier depends on the gpio controller.
 
 Optional properties:
+  - gpios: The order of the gpios should be the following: SDA, SCL.
+The gpio specifier depends on the gpio controller. Required in all cases
+except when samsung,i2c-no-gpio is also specified.
+  - samsung,i2c-no-gpio: input/output lines of the controller are
+permanently wired to the respective client, there are no gpio
+lines that need to be configured to enable this controller
   - samsung,i2c-slave-addr: Slave address in multi-master enviroment. If not
 specified, default value is 0.
   - samsung,i2c-max-bus-freq: Desired frequency in Hz of the bus. If not
 specified, the default value in Hz is 10.
+  - samsung,i2c-quirk-hdmiphy: Quirk for HDMI PHY block found on
+Exynos4 platform - reduce timeout and reset controller after each
+transfer
 
 Example:
 
diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
index f84d26f..fa5f8c4 100644
--- a/drivers/i2c/busses/i2c-s3c2410.c
+++ b/drivers/i2c/busses/i2c-s3c2410.c
@@ -52,6 +52,8 @@ static const struct of_device_id s3c24xx_i2c_match[];
 #define TYPE_BITS  0x00ff
 #define TYPE_S3C2410   0x0001
 #define TYPE_S3C2440   0x0002
+#define FLAG_HDMIPHY   0x0100
+#define FLAG_NO_GPIO   0x0200
 
 /* i2c controller state */
 enum s3c24xx_i2c_state {
@@ -481,6 +483,13 @@ static int s3c24xx_i2c_set_master(struct s3c24xx_i2c *i2c)
unsigned long iicstat;
int timeout = 400;
 
+   /* the timeout for HDMIPHY is reduced to 10 ms because
+* the hangup is expected to happen, so waiting 400 ms
+* causes only unnecessary system hangup
+*/
+   if (i2c-type  FLAG_HDMIPHY)
+   timeout = 10;
+
while (timeout--  0) {
iicstat = readl(i2c-regs + S3C2410_IICSTAT);
 
@@ -490,6 +499,15 @@ static int s3c24xx_i2c_set_master(struct s3c24xx_i2c *i2c)
msleep(1);
}
 
+   /* hang-up of bus dedicated for HDMIPHY occurred, resetting */
+   if (i2c-type  FLAG_HDMIPHY) {
+   writel(0, i2c-regs + S3C2410_IICCON);
+   writel(0, i2c-regs + S3C2410_IICSTAT);
+   writel(0, i2c-regs + S3C2410_IICDS);
+
+   return 0;
+   }
+
return -ETIMEDOUT;
 }
 
@@ -771,6 +789,9 @@ static int s3c24xx_i2c_parse_dt_gpio(struct s3c24xx_i2c 
*i2c)
 {
int idx, gpio, ret;
 
+   if (i2c-type  FLAG_NO_GPIO)
+   return 0;
+
for (idx = 0; idx  2; idx++) {
gpio = of_get_gpio(i2c-dev-of_node, idx);
if (!gpio_is_valid(gpio)) {
@@ -795,6 +816,10 @@ free_gpio:
 static void s3c24xx_i2c_dt_gpio_free(struct s3c24xx_i2c *i2c)
 {
unsigned int idx;
+
+   if (i2c-type  FLAG_NO_GPIO)
+   return;
+
for (idx = 0; idx  2; idx++)
gpio_free(i2c-gpios[idx]);
 }
@@ -871,6 +896,13 @@ s3c24xx_i2c_parse_dt(struct device_node *np, struct 
s3c24xx_i2c *i2c)
return;
 
pdata-bus_num = -1; /* i2c bus number is dynamically assigned */
+
+   if (of_get_property(np, samsung,i2c-quirk-hdmiphy, NULL))
+   i2c-type |= FLAG_HDMIPHY;
+
+   if (of_get_property(np, samsung,i2c-no-gpio, NULL))
+   i2c-type |= FLAG_NO_GPIO;
+
of_property_read_u32(np, samsung,i2c-sda-delay, pdata-sda_delay);
of_property_read_u32(np, samsung,i2c-slave-addr, pdata

Re: [PATCH 1/2] i2c-s3c2410: Rework device type handling

2012-03-12 Thread Karol Lewandowski
On 12.03.2012 06:58, Thomas Abraham wrote:

Hi Thomas!

 On 9 March 2012 22:34, Karol Lewandowski k.lewando...@samsung.com wrote:
 Reorganize driver a bit to better handle device tree-based systems:

  - move machine type to driver's private structure instead of
   quering platform device variants in runtime

  - replace s3c24xx_i2c_type enum with plain unsigned int that can
   hold not only device type but also hw revision-specific quirks

 Signed-off-by: Karol Lewandowski k.lewando...@samsung.com
 Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
 ---
  drivers/i2c/busses/i2c-s3c2410.c |   56 
 +
  1 files changed, 20 insertions(+), 36 deletions(-)

 diff --git a/drivers/i2c/busses/i2c-s3c2410.c 
 b/drivers/i2c/busses/i2c-s3c2410.c
 index 737f721..5b400c6 100644
 --- a/drivers/i2c/busses/i2c-s3c2410.c
 +++ b/drivers/i2c/busses/i2c-s3c2410.c
 @@ -44,8 +44,12 @@
  #include plat/regs-iic.h
  #include plat/iic.h

 -/* i2c controller state */
 +/* type */
 +#define TYPE_BITS  0x00ff
 +#define TYPE_S3C2410   0x0001
 +#define TYPE_S3C2440   0x0002

 +/* i2c controller state */
  enum s3c24xx_i2c_state {
STATE_IDLE,
STATE_START,
 @@ -54,14 +58,10 @@ enum s3c24xx_i2c_state {
STATE_STOP
  };

 -enum s3c24xx_i2c_type {
 -   TYPE_S3C2410,
 -   TYPE_S3C2440,
 -};
 -
  struct s3c24xx_i2c {
spinlock_t  lock;
wait_queue_head_t   wait;
 +   unsigned inttype;
unsigned intsuspended:1;

struct i2c_msg  *msg;
 @@ -88,28 +88,6 @@ struct s3c24xx_i2c {
  #endif
  };

 -/* default platform data removed, dev should always carry data. */
 -
 -/* s3c24xx_i2c_is2440()
 - *
 - * return true is this is an s3c2440
 -*/
 -
 -static inline int s3c24xx_i2c_is2440(struct s3c24xx_i2c *i2c)
 -{
 -   struct platform_device *pdev = to_platform_device(i2c-dev);
 -   enum s3c24xx_i2c_type type;
 -
 -#ifdef CONFIG_OF
 -   if (i2c-dev-of_node)
 -   return of_device_is_compatible(i2c-dev-of_node,
 -   samsung,s3c2440-i2c);
 -#endif
 -
 -   type = platform_get_device_id(pdev)-driver_data;
 -   return type == TYPE_S3C2440;
 -}
 -
  /* s3c24xx_i2c_master_complete
  *
  * complete the message and wake up the caller, using the given return code,
 @@ -676,7 +654,7 @@ static int s3c24xx_i2c_clockrate(struct s3c24xx_i2c 
 *i2c, unsigned int *got)

writel(iiccon, i2c-regs + S3C2410_IICCON);

 -   if (s3c24xx_i2c_is2440(i2c)) {
 +   if (i2c-type  TYPE_S3C2440) {
 
 This should be changed to
 if (i2c-type == TYPE_S3C2440)


Equality check won't work here after second patch is applied
(i2c-type might have FLAG_*s set on upper bits).

 
unsigned long sda_delay;

if (pdata-sda_delay) {
 @@ -847,6 +825,8 @@ static int s3c24xx_i2c_init(struct s3c24xx_i2c *i2c)
  }

  #ifdef CONFIG_OF
 +static const struct of_device_id s3c24xx_i2c_match[];
 +
  /* s3c24xx_i2c_parse_dt
  *
  * Parse the device tree node and retreive the platform data.
 @@ -856,11 +836,16 @@ static void
  s3c24xx_i2c_parse_dt(struct device_node *np, struct s3c24xx_i2c *i2c)
  {
struct s3c2410_platform_i2c *pdata = i2c-pdata;
 +   const struct of_device_id *match;

if (!np)
return;

pdata-bus_num = -1; /* i2c bus number is dynamically assigned */
 +
 +   match = of_match_node(s3c24xx_i2c_match[0], np);
 
 This could be
 match = of_match_node(s3c24xx_i2c_match, np);


If you (and Ben, of course) don't mind I would prefer more verbose but
also more explicit version.

 +   i2c-type = (unsigned int)match-data;
 +
 
 This function (s3c24xx_i2c_parse_dt) is intended to retrieve the data
 from i2c device node. It would be better to not add the determination
 of the i2c type inside this function.
 
of_property_read_u32(np, samsung,i2c-sda-delay, pdata-sda_delay);
of_property_read_u32(np, samsung,i2c-slave-addr, 
 pdata-slave_addr);
of_property_read_u32(np, samsung,i2c-max-bus-freq,
 @@ -906,9 +891,10 @@ static int s3c24xx_i2c_probe(struct platform_device 
 *pdev)
goto err_noclk;
}

 -   if (pdata)
 +   if (pdata) {
memcpy(i2c-pdata, pdata, sizeof(*pdata));
 -   else
 +   i2c-type = platform_get_device_id(pdev)-driver_data;
 +   } else
s3c24xx_i2c_parse_dt(pdev-dev.of_node, i2c);
 
 It would be better to move the task of retrieving the driver data to a
 separate function. An example of this listed below (copied from the
 samsung uart driver).


Well, I was under impression that #ifdefs inside functions were quite
disliked by kernel devs.  Now I see that these are quite common in kernel..
Thus, I will happily use your suggestion, thanks.

 
 static inline struct s3c24xx_serial_drv_data *s3c24xx_get_driver_data(
 struct

[PATCH 0/2] i2c-s3c2410: Updates for exynos4210 and DT-based systems

2012-03-09 Thread Karol Lewandowski
Hi,

This patchset reworks i2c-s3c2410 driver a bit to better handle
device tree-enabled platforms and adds two quirks required by
exynos4210-specific I2C controller used by s5p-hdmi driver.

This patchset is based on i2c-bjdooks/for-34/i2c/i2c-samsung branch
taken from:

  git://git.fluff.org/bjdooks/linux.git

Karol Lewandowski (1):
  i2c-s3c2410: Rework device type handling

Tomasz Stanislawski (1):
  i2c-s3c2410: Add HDMIPHY quirk for S3C2440

 .../devicetree/bindings/i2c/samsung-i2c.txt|   10 ++-
 drivers/i2c/busses/i2c-s3c2410.c   |   90 
 2 files changed, 62 insertions(+), 38 deletions(-)

-- 
1.7.9

--
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/2] i2c-s3c2410: Add HDMIPHY quirk for S3C2440

2012-03-09 Thread Karol Lewandowski
From: Tomasz Stanislawski t.stanisl...@samsung.com

This patch adds support for s3c2440 I2C bus controller dedicated HDMIPHY device 
on
Exynos4 platform. Some quirks are introduced due to differences between HDMIPHY
and other I2C controllers on Exynos4.  These differences are:
- no GPIOs, HDMIPHY is inside the SoC and the controller is connected
  internally
- due to unknown reason (probably HW bug in HDMIPHY and/or the controller) a
  transfer fails to finish. The controller hangs after sending the last byte,
  the workaround for this bug is resetting the controller after each transfer

Signed-off-by: Tomasz Stanislawski t.stanisl...@samsung.com
Signed-off-by: Karol Lewandowski k.lewando...@samsung.com
Tested-by: Tomasz Stanislawski t.stanisl...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 .../devicetree/bindings/i2c/samsung-i2c.txt|   10 +-
 drivers/i2c/busses/i2c-s3c2410.c   |   34 
 2 files changed, 42 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/i2c/samsung-i2c.txt 
b/Documentation/devicetree/bindings/i2c/samsung-i2c.txt
index 38832c7..ac0917c 100644
--- a/Documentation/devicetree/bindings/i2c/samsung-i2c.txt
+++ b/Documentation/devicetree/bindings/i2c/samsung-i2c.txt
@@ -10,14 +10,20 @@ Required properties:
 region.
   - interrupts: interrupt number to the cpu.
   - samsung,i2c-sda-delay: Delay (in ns) applied to data line (SDA) edges.
-  - gpios: The order of the gpios should be the following: SDA, SCL.
-The gpio specifier depends on the gpio controller.
 
 Optional properties:
+  - gpios: The order of the gpios should be the following: SDA, SCL.
+The gpio specifier depends on the gpio controller. Required in all cases
+except when samsung,i2c-no-gpio is also specified.
+  - samsung,i2c-no-gpio: input/output lines of the controller are
+permanently wired to the respective client, there are no gpio
+lines that need to be configured to enable this controller
   - samsung,i2c-slave-addr: Slave address in multi-master enviroment. If not
 specified, default value is 0.
   - samsung,i2c-max-bus-freq: Desired frequency in Hz of the bus. If not
 specified, the default value in Hz is 10.
+  - samsung,i2c-quirk-hdmiphy: Quirk for HDMI PHY block on S3C2440 -
+reduce timeout and reset controller when doing transefers
 
 Example:
 
diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
index 5b400c6..9f3be51 100644
--- a/drivers/i2c/busses/i2c-s3c2410.c
+++ b/drivers/i2c/busses/i2c-s3c2410.c
@@ -48,6 +48,8 @@
 #define TYPE_BITS  0x00ff
 #define TYPE_S3C2410   0x0001
 #define TYPE_S3C2440   0x0002
+#define FLAG_HDMIPHY   0x0100
+#define FLAG_NO_GPIO   0x0200
 
 /* i2c controller state */
 enum s3c24xx_i2c_state {
@@ -449,6 +451,13 @@ static int s3c24xx_i2c_set_master(struct s3c24xx_i2c *i2c)
unsigned long iicstat;
int timeout = 400;
 
+   /* the timeout for HDMIPHY is reduced to 10 ms because
+* the hangup is expected to happen, so waiting 400 ms
+* causes only unnecessary system hangup
+*/
+   if (i2c-type  FLAG_HDMIPHY)
+   timeout = 10;
+
while (timeout--  0) {
iicstat = readl(i2c-regs + S3C2410_IICSTAT);
 
@@ -458,6 +467,15 @@ static int s3c24xx_i2c_set_master(struct s3c24xx_i2c *i2c)
msleep(1);
}
 
+   /* hang-up of bus dedicated for HDMIPHY occurred, resetting */
+   if (i2c-type  FLAG_HDMIPHY) {
+   writel(0, i2c-regs + S3C2410_IICCON);
+   writel(0, i2c-regs + S3C2410_IICSTAT);
+   writel(0, i2c-regs + S3C2410_IICDS);
+
+   return 0;
+   }
+
return -ETIMEDOUT;
 }
 
@@ -739,6 +757,9 @@ static int s3c24xx_i2c_parse_dt_gpio(struct s3c24xx_i2c 
*i2c)
 {
int idx, gpio, ret;
 
+   if (i2c-type  FLAG_NO_GPIO)
+   return 0;
+
for (idx = 0; idx  2; idx++) {
gpio = of_get_gpio(i2c-dev-of_node, idx);
if (!gpio_is_valid(gpio)) {
@@ -763,6 +784,10 @@ free_gpio:
 static void s3c24xx_i2c_dt_gpio_free(struct s3c24xx_i2c *i2c)
 {
unsigned int idx;
+
+   if (i2c-type  FLAG_NO_GPIO)
+   return;
+
for (idx = 0; idx  2; idx++)
gpio_free(i2c-gpios[idx]);
 }
@@ -846,6 +871,12 @@ s3c24xx_i2c_parse_dt(struct device_node *np, struct 
s3c24xx_i2c *i2c)
match = of_match_node(s3c24xx_i2c_match[0], np);
i2c-type = (unsigned int)match-data;
 
+   if (i2c-type == TYPE_S3C2440  of_get_property(np, 
samsung,i2c-quirk-hdmiphy, NULL))
+   i2c-type |= FLAG_HDMIPHY;
+
+   if (of_get_property(np, samsung,i2c-no-gpio, NULL))
+   i2c-type |= FLAG_NO_GPIO;
+
of_property_read_u32(np, samsung,i2c-sda-delay, pdata-sda_delay);
of_property_read_u32(np, samsung,i2c-slave

[PATCH 1/2] i2c-s3c2410: Rework device type handling

2012-03-09 Thread Karol Lewandowski
Reorganize driver a bit to better handle device tree-based systems:

 - move machine type to driver's private structure instead of
   quering platform device variants in runtime

 - replace s3c24xx_i2c_type enum with plain unsigned int that can
   hold not only device type but also hw revision-specific quirks

Signed-off-by: Karol Lewandowski k.lewando...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/i2c/busses/i2c-s3c2410.c |   56 +
 1 files changed, 20 insertions(+), 36 deletions(-)

diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
index 737f721..5b400c6 100644
--- a/drivers/i2c/busses/i2c-s3c2410.c
+++ b/drivers/i2c/busses/i2c-s3c2410.c
@@ -44,8 +44,12 @@
 #include plat/regs-iic.h
 #include plat/iic.h
 
-/* i2c controller state */
+/* type */
+#define TYPE_BITS  0x00ff
+#define TYPE_S3C2410   0x0001
+#define TYPE_S3C2440   0x0002
 
+/* i2c controller state */
 enum s3c24xx_i2c_state {
STATE_IDLE,
STATE_START,
@@ -54,14 +58,10 @@ enum s3c24xx_i2c_state {
STATE_STOP
 };
 
-enum s3c24xx_i2c_type {
-   TYPE_S3C2410,
-   TYPE_S3C2440,
-};
-
 struct s3c24xx_i2c {
spinlock_t  lock;
wait_queue_head_t   wait;
+   unsigned inttype;
unsigned intsuspended:1;
 
struct i2c_msg  *msg;
@@ -88,28 +88,6 @@ struct s3c24xx_i2c {
 #endif
 };
 
-/* default platform data removed, dev should always carry data. */
-
-/* s3c24xx_i2c_is2440()
- *
- * return true is this is an s3c2440
-*/
-
-static inline int s3c24xx_i2c_is2440(struct s3c24xx_i2c *i2c)
-{
-   struct platform_device *pdev = to_platform_device(i2c-dev);
-   enum s3c24xx_i2c_type type;
-
-#ifdef CONFIG_OF
-   if (i2c-dev-of_node)
-   return of_device_is_compatible(i2c-dev-of_node,
-   samsung,s3c2440-i2c);
-#endif
-
-   type = platform_get_device_id(pdev)-driver_data;
-   return type == TYPE_S3C2440;
-}
-
 /* s3c24xx_i2c_master_complete
  *
  * complete the message and wake up the caller, using the given return code,
@@ -676,7 +654,7 @@ static int s3c24xx_i2c_clockrate(struct s3c24xx_i2c *i2c, 
unsigned int *got)
 
writel(iiccon, i2c-regs + S3C2410_IICCON);
 
-   if (s3c24xx_i2c_is2440(i2c)) {
+   if (i2c-type  TYPE_S3C2440) {
unsigned long sda_delay;
 
if (pdata-sda_delay) {
@@ -847,6 +825,8 @@ static int s3c24xx_i2c_init(struct s3c24xx_i2c *i2c)
 }
 
 #ifdef CONFIG_OF
+static const struct of_device_id s3c24xx_i2c_match[];
+
 /* s3c24xx_i2c_parse_dt
  *
  * Parse the device tree node and retreive the platform data.
@@ -856,11 +836,16 @@ static void
 s3c24xx_i2c_parse_dt(struct device_node *np, struct s3c24xx_i2c *i2c)
 {
struct s3c2410_platform_i2c *pdata = i2c-pdata;
+   const struct of_device_id *match;
 
if (!np)
return;
 
pdata-bus_num = -1; /* i2c bus number is dynamically assigned */
+
+   match = of_match_node(s3c24xx_i2c_match[0], np);
+   i2c-type = (unsigned int)match-data;
+
of_property_read_u32(np, samsung,i2c-sda-delay, pdata-sda_delay);
of_property_read_u32(np, samsung,i2c-slave-addr, pdata-slave_addr);
of_property_read_u32(np, samsung,i2c-max-bus-freq,
@@ -906,9 +891,10 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
goto err_noclk;
}
 
-   if (pdata)
+   if (pdata) {
memcpy(i2c-pdata, pdata, sizeof(*pdata));
-   else
+   i2c-type = platform_get_device_id(pdev)-driver_data;
+   } else
s3c24xx_i2c_parse_dt(pdev-dev.of_node, i2c);
 
strlcpy(i2c-adap.name, s3c2410-i2c, sizeof(i2c-adap.name));
@@ -1123,13 +1109,11 @@ MODULE_DEVICE_TABLE(platform, s3c24xx_driver_ids);
 
 #ifdef CONFIG_OF
 static const struct of_device_id s3c24xx_i2c_match[] = {
-   { .compatible = samsung,s3c2410-i2c },
-   { .compatible = samsung,s3c2440-i2c },
+   { .compatible = samsung,s3c2410-i2c, .data = (void *)TYPE_S3C2410 },
+   { .compatible = samsung,s3c2440-i2c, .data = (void *)TYPE_S3C2440 },
{},
 };
 MODULE_DEVICE_TABLE(of, s3c24xx_i2c_match);
-#else
-#define s3c24xx_i2c_match NULL
 #endif
 
 static struct platform_driver s3c24xx_i2c_driver = {
@@ -1140,7 +1124,7 @@ static struct platform_driver s3c24xx_i2c_driver = {
.owner  = THIS_MODULE,
.name   = s3c-i2c,
.pm = S3C24XX_DEV_PM_OPS,
-   .of_match_table = s3c24xx_i2c_match,
+   .of_match_table = of_match_ptr(s3c24xx_i2c_match),
},
 };
 
-- 
1.7.9

--
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 1/3] [media] s5p-tv: Add initial DT-support for sii9234

2012-03-01 Thread Karol Lewandowski
On 01.03.2012 04:09, Thomas Abraham wrote:

 Hi Karol,


Hi!


 On 29 February 2012 20:21, Karol Lewandowski k.lewando...@samsung.com wrote:
 Make it possible to instantiate sii9234, HDMI's MHL, from regular
 device tree description.

 Signed-off-by: Karol Lewandowski k.lewando...@samsung.com
 Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
 ---
  Documentation/devicetree/bindings/i2c/sii9234.txt |   14 ++
  drivers/media/video/s5p-tv/sii9234_drv.c  |   20 
 +++-
  2 files changed, 33 insertions(+), 1 deletions(-)
  create mode 100644 Documentation/devicetree/bindings/i2c/sii9234.txt

 diff --git a/Documentation/devicetree/bindings/i2c/sii9234.txt 
 b/Documentation/devicetree/bindings/i2c/sii9234.txt
 new file mode 100644
 index 000..7bb7636
 --- /dev/null
 +++ b/Documentation/devicetree/bindings/i2c/sii9234.txt
 @@ -0,0 +1,14 @@
 +* SII 9234
 +
 
 A minimal description about this device would be helpful here.
 
 +Required properties :
 + - compatible : sii,9234
 
 To be more informative, can this be changed to sil,mhl-9234.


Thanks for pointing this out - I'll fix compat string and add description.

 
 + - reg: i2c device address
 + - gpio-reset : gpio line used to reset IC
 +
 +Example:
 +
 +   mhl@39 {
 +   compatible = sii,9234;
 +   reg = 0x39;
 +   gpio-reset = gpf3 4 0 0 0;
 +   };
 diff --git a/drivers/media/video/s5p-tv/sii9234_drv.c 
 b/drivers/media/video/s5p-tv/sii9234_drv.c
 index 0f31ecc..0a1511a 100644
 --- a/drivers/media/video/s5p-tv/sii9234_drv.c
 +++ b/drivers/media/video/s5p-tv/sii9234_drv.c
 @@ -22,6 +22,8 @@
  #include linux/pm_runtime.h
  #include linux/regulator/machine.h
  #include linux/slab.h
 +#include linux/of.h
 +#include linux/of_gpio.h

  #include mach/gpio.h
  #include plat/gpio-cfg.h
 @@ -338,7 +340,15 @@ static int __devinit sii9234_probe(struct i2c_client 
 *client,
goto fail_ctx;
}

 -   ctx-gpio_n_reset = pdata-gpio_n_reset;
 +   if (dev-of_node) {
 +   ctx-gpio_n_reset = of_get_named_gpio(dev-of_node, 
 gpio-reset, 0);
 +   if (ctx-gpio_n_reset  0) {
 
 if (gpio_is_valid(ctx-gpio_n_reset)) can be used here.


Will fix, I wasn't aware of this either.

 
 +   ret = -ENODEV;
 +   goto fail_power;
 +   }
 +   } else
 +   ctx-gpio_n_reset = pdata-gpio_n_reset;
 
 linux coding style suggests to have braces for 'else' branch when
 braces are used for the 'if' branch.


Ok.

 
 +
ret = gpio_request(ctx-gpio_n_reset, MHL_RST);
if (ret) {
dev_err(dev, failed to acquire MHL_RST gpio\n);
 @@ -401,6 +411,13 @@ static int __devexit sii9234_remove(struct i2c_client 
 *client)
return 0;
  }

 +#ifdef CONFIG_OF
 +static const struct of_device_id sii9234_dt_match[] = {
 +   { .compatible = sii,9234 },
 +   { },
 +};
 +MODULE_DEVICE_TABLE(of, sii9234_dt_match);
 +#endif

  static const struct i2c_device_id sii9234_id[] = {
{ SII9234, 0 },
 @@ -413,6 +430,7 @@ static struct i2c_driver sii9234_driver = {
.name   = sii9234,
.owner  = THIS_MODULE,
.pm = sii9234_pm_ops,
 +   .of_match_table = of_match_ptr(sii9234_dt_match),
},
.probe  = sii9234_probe,
.remove = __devexit_p(sii9234_remove),
 --
 1.7.8.3

 
 Thanks,
 Thomas.


Thanks for reviewing this!

Regards,
-- 
Karol Lewandowski | Samsung Poland RD Center | Linux/Platform
--
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 3/3] [media] s5p-tv: Add initial DT-support for TV mixer

2012-03-01 Thread Karol Lewandowski
On 01.03.2012 04:18, Thomas Abraham wrote:

 On 29 February 2012 20:21, Karol Lewandowski k.lewando...@samsung.com wrote:
 ---
  drivers/media/video/s5p-tv/mixer_drv.c |9 +
  1 files changed, 9 insertions(+), 0 deletions(-)

 diff --git a/drivers/media/video/s5p-tv/mixer_drv.c 
 b/drivers/media/video/s5p-tv/mixer_drv.c
 index a2c0c25..6bf4a9e 100644
 --- a/drivers/media/video/s5p-tv/mixer_drv.c
 +++ b/drivers/media/video/s5p-tv/mixer_drv.c
 @@ -448,6 +448,14 @@ static int __devexit mxr_remove(struct platform_device 
 *pdev)
return 0;
  }

 +#ifdef CONFIG_OF
 +static const struct of_device_id mxr_dt_match[] = {
 +   { .compatible = samsung,exynos4210-tvmixer },
 
 If the tvmixer module is also available in SoC's prior to Exynos4210,
 and if tvmixer in Exynos4210 is similar to tvmixer found on prior
 SoC's, the base version should indicate that. For instance, if the
 tvmixer started to appear from s5pv210 onwards, then the compatible
 value should be samsung,s5pv210-tvmixer. The compatible string
 should indicate the base version.


Fair point, although I'm afraid that chosing base version might be
tricky sometimes (e.g. while g2d seems to be available on s5pv210 driver
itself have been tested only on s5pv310/exynos4210 - chosing s5pv210 as
base doesn't look like best idea.)

I'll resend fixed patches later.

Thank you very much for review!

Regards,
-- 
Karol Lewandowski | Samsung Poland RD Center | Linux/Platform
--
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] [media] s5p-g2d: Make it possible to instantiate driver from DT

2012-02-29 Thread Karol Lewandowski
This driver requires standard properties only (address and irq)
which are automatically marshalled into plain old resources by OF core.

Signed-off-by: Karol Lewandowski k.lewando...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/video/s5p-g2d/g2d.c |9 +
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/drivers/media/video/s5p-g2d/g2d.c 
b/drivers/media/video/s5p-g2d/g2d.c
index febaa67..e7c0020 100644
--- a/drivers/media/video/s5p-g2d/g2d.c
+++ b/drivers/media/video/s5p-g2d/g2d.c
@@ -20,6 +20,7 @@
 #include linux/interrupt.h
 
 #include linux/platform_device.h
+#include linux/of.h
 #include media/v4l2-mem2mem.h
 #include media/v4l2-device.h
 #include media/v4l2-ioctl.h
@@ -795,12 +796,20 @@ static int g2d_remove(struct platform_device *pdev)
return 0;
 }
 
+#ifdef CONFIG_OF
+static struct of_device_id g2d_dt_match[] = {
+   { .compatible = samsung,exynos4210-g2d },
+   {},
+};
+#endif
+
 static struct platform_driver g2d_pdrv = {
.probe  = g2d_probe,
.remove = g2d_remove,
.driver = {
.name = G2D_NAME,
.owner = THIS_MODULE,
+   .of_match_table = of_match_ptr(g2d_dt_match),
},
 };
 
-- 
1.7.8.3

--
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/3] [media] s5p-tv: Add initial DT-support to s5p-tv's subdevices

2012-02-29 Thread Karol Lewandowski
This patchset adds initial device tree support to drivers used by
s5p-tv on Exynos4.

DT support for s5p-tv driver itself would benefit from changes to v4l
core (missing OF helper functions) and thus, will be sent later in
separate patchset.

Karol Lewandowski (3):
  [media] s5p-tv: Add initial DT-support for sii9234
  [media] s5p-tv: Add initial DT-support for HDMIPHY
  [media] s5p-tv: Add initial DT-support for TV mixer

 Documentation/devicetree/bindings/i2c/sii9234.txt |   14 ++
 drivers/media/video/s5p-tv/hdmiphy_drv.c  |   10 ++
 drivers/media/video/s5p-tv/mixer_drv.c|9 +
 drivers/media/video/s5p-tv/sii9234_drv.c  |   20 +++-
 4 files changed, 52 insertions(+), 1 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/i2c/sii9234.txt

-- 
1.7.8.3

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


[PATCH 3/3] [media] s5p-tv: Add initial DT-support for TV mixer

2012-02-29 Thread Karol Lewandowski
---
 drivers/media/video/s5p-tv/mixer_drv.c |9 +
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/drivers/media/video/s5p-tv/mixer_drv.c 
b/drivers/media/video/s5p-tv/mixer_drv.c
index a2c0c25..6bf4a9e 100644
--- a/drivers/media/video/s5p-tv/mixer_drv.c
+++ b/drivers/media/video/s5p-tv/mixer_drv.c
@@ -448,6 +448,14 @@ static int __devexit mxr_remove(struct platform_device 
*pdev)
return 0;
 }
 
+#ifdef CONFIG_OF
+static const struct of_device_id mxr_dt_match[] = {
+   { .compatible = samsung,exynos4210-tvmixer },
+   { },
+};
+MODULE_DEVICE_TABLE(of, mxr_dt_match);
+#endif
+
 static struct platform_driver mxr_driver __refdata = {
.probe = mxr_probe,
.remove = __devexit_p(mxr_remove),
@@ -455,6 +463,7 @@ static struct platform_driver mxr_driver __refdata = {
.name = MXR_DRIVER_NAME,
.owner = THIS_MODULE,
.pm = mxr_pm_ops,
+   .of_match_table = of_match_ptr(mxr_dt_match),
}
 };
 
-- 
1.7.8.3

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


[PATCH 2/3] [media] s5p-tv: Add initial DT-support for HDMIPHY

2012-02-29 Thread Karol Lewandowski
Make it possible to instantiate driver from device tree description.

Signed-off-by: Karol Lewandowski k.lewando...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/media/video/s5p-tv/hdmiphy_drv.c |   10 ++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/drivers/media/video/s5p-tv/hdmiphy_drv.c 
b/drivers/media/video/s5p-tv/hdmiphy_drv.c
index 6693f4a..77f5caa 100644
--- a/drivers/media/video/s5p-tv/hdmiphy_drv.c
+++ b/drivers/media/video/s5p-tv/hdmiphy_drv.c
@@ -18,6 +18,7 @@
 #include linux/interrupt.h
 #include linux/irq.h
 #include linux/err.h
+#include linux/of.h
 
 #include media/v4l2-subdev.h
 
@@ -165,10 +166,19 @@ static const struct i2c_device_id hdmiphy_id[] = {
 };
 MODULE_DEVICE_TABLE(i2c, hdmiphy_id);
 
+#ifdef CONFIG_OF
+static struct of_device_id hdmiphy_dt_match[] = {
+   { .compatible = samsung,exynos4210-hdmiphy },
+   { },
+};
+MODULE_DEVICE_TABLE(of, hdmiphy_dt_match);
+#endif
+
 static struct i2c_driver hdmiphy_driver = {
.driver = {
.name   = s5p-hdmiphy,
.owner  = THIS_MODULE,
+   .of_match_table = of_match_ptr(hdmiphy_dt_match),
},
.probe  = hdmiphy_probe,
.remove = __devexit_p(hdmiphy_remove),
-- 
1.7.8.3

--
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: EXYNOS: Adds Samsung TRATS board support

2012-02-10 Thread Karol Lewandowski
On 10.02.2012 09:01, Kyungmin Park wrote:

 + Karol for DT support later
 
 On Fri, Feb 10, 2012 at 3:58 AM, Thomas Abraham
 thomas.abra...@linaro.org wrote:
 Dear Mr. HeungJun Kim,

 On 27 January 2012 00:21, HeungJun, Kim riverful@samsung.com wrote:
 This patch adds Samsung Mobile TRATS board support.

 Signed-off-by: HeungJun, Kim riverful@samsung.com
 Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
 ---
  arch/arm/mach-exynos/Kconfig  |   11 ++
  arch/arm/mach-exynos/Makefile |1 +
  arch/arm/mach-exynos/mach-trats.c |  344 
 +
  3 files changed, 356 insertions(+), 0 deletions(-)
  create mode 100644 arch/arm/mach-exynos/mach-trats.c

 The exynos4 dt-enabled board file can support most of the features
 added in this board file. The other option that could be considered
 here would be to add DT support for this board file, and use AUX_DATA
 to supply platform data for drivers that do not have dt support yet.
 It would be better to use dt support for new board support that we
 add.


Thanks to Thomas' work TRATS can be booted today using exynos4-dt.
However, we are still missing some bits needed to make it fully functional:

 - sdhci-s3c patchset[1] is needed for eMMC support

   http://permalink.gmane.org/gmane.linux.kernel.samsung-soc/9216

 - irq-eint[2] and max8997-pmic[3] for regulators

   [2] http://permalink.gmane.org/gmane.linux.kernel.samsung-soc/8197
   [3] http://permalink.gmane.org/gmane.linux.kernel.samsung-soc/8865

These patches (created entirely by Thomas) would allow me to write
description (dts) that should cover what mach-trats.c did.

However, due to ongoing irqdomain and related changes I assume this
might take a while.

Thomas, may I ask about your plans wrt to irqdomains and wakeup/eints
(this [2] patchset)?

Regards,
-- 
Karol Lewandowski | Samsung Poland RD Center | Linux/Platform
--
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: Exynos4: Bring exynos4-dt up to date

2012-02-09 Thread Karol Lewandowski
On 31.01.2012 17:47, Karol Lewandowski wrote:

 This commit brings exynos4-dt in line with recent changes to
 mach-exynos tree, specifically:
 
  - Fixes build break related to replacing plat/exynos4.h with common.h
in commit cc511b8d84d8 (ARM: 7257/1: EXYNOS: introduce
arch/arm/mach-exynos/common.[ch])


 
  - Converts machine to use CONFIG_MULTI_IRQ_HANDLER as done for other
machines in commit 4e44d2cb95bd (ARM: exynos4: convert to
CONFIG_MULTI_IRQ_HANDLER) converted all exynos boards but
exynos4-dt.c.


Minor correction - text from converted all.. shall be deleted, like:

   - Converts machine to use CONFIG_MULTI_IRQ_HANDLER as done for other
 machines in commit 4e44d2cb95bd (ARM: exynos4: convert to
 CONFIG_MULTI_IRQ_HANDLER)

(It's result of not proofreading it carefully enough after squashing all
the patches.)

I don't think such a change is worth sending patch again, but I would be
grateful if you could fix it while merging.

Thanks

-- 
Karol Lewandowski | Samsung Poland RD Center | Linux/Platform


--
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 v3 6/6] mmc: sdhci-s3c: Add device tree support

2012-02-01 Thread Karol Lewandowski

On 31.01.2012 18:56, Thomas Abraham wrote:

Add device tree based discovery support for Samsung's sdhci controller


Works fine on nuri hardware using exynos4-dt (with custom dts).

Thanks
--
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] gpio: samsung: adapt to changes in gpio specifier translator function declaration

2012-02-01 Thread Karol Lewandowski

On 01.02.2012 14:02, Thomas Abraham wrote:

Commit 15c9a0acc3f7 (of: create of_phandle_args to simplify return of phandle
parsing data) modifies the parameter list of of_xlate function pointer 
declaration
in gpio_chip. Adapt the gpio specifier translate function for this change.

Reported-by: Tushar Beheratushar.beh...@linaro.org
Signed-off-by: Thomas Abrahamthomas.abra...@linaro.org


Tested-by: Karol Lewandowski k.lewando...@samsung.com

Fixes following Oops in i2c-s3c24xx.

Thanks


1Unable to handle kernel NULL pointer dereference at virtual address 


1pgd = c0004000
1[] *pgd=
0Internal error: Oops: 5 [#1] PREEMPT SMP
dModules linked in:
CPU: 0Tainted: GW (3.3.0-rc1+ #20)
PC is at exynos4_gpio_xlate+0x18/0xe8
LR is at of_get_named_gpio_flags+0xd0/0x190
pc : [c025dd60]lr : [c03423a0]psr: 6013
sp : e9047d88  ip : e9047da8  fp : e9047da4
r10:   r9 :   r8 : c05ecf4c
r7 : c0864ca8  r6 :   r5 : e9047db0  r4 : c025dd48
r3 : 0004  r2 :   r1 : e9047db0  r0 : c05ecf4c
Flags: nZCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment kernel
Control: 10c53c7d  Table: 4000404a  DAC: 0015
0Process swapper/0 (pid: 1, stack limit = 0xe90462f0)
0Stack: (0xe9047d88 to 0xe9048000)
...
[c025dd60] (exynos4_gpio_xlate+0x18/0xe8) from [c03423a0] 
(of_get_named_gpio_flags+0xd0/0x190)
[c03423a0] (of_get_named_gpio_flags+0xd0/0x190) from [c02e77cc] 
(s3c24xx_i2c_init+0x264/0x430)
[c02e77cc] (s3c24xx_i2c_init+0x264/0x430) from [c02e7c24] 
(s3c24xx_i2c_probe+0x1c8/0x4ac)
[c02e7c24] (s3c24xx_i2c_probe+0x1c8/0x4ac) from [c02a4320] 
(platform_drv_probe+0x28/0x2c)


--
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/2] EXYNOS4_DT fixes for 3.3-rc1+ kernels

2012-01-31 Thread Karol Lewandowski
Device Tree-based Exynos4 machine prepared by Thomas Abraham and
included in 3.3-rc1 hasn't been adjusted to changes that have happened
to mach-exynos during 3.3 merge window.

Following patch series fixes one build and one boot error making it
possible to boot system with SMP disabled.

SMP support is still broken for unknown reason, though.

[ To use it it's also required to cherry-pick ARM: EXYNOS: fix
  non-SMP builds for EXYNOS4 already found in kgene's
  linux-samsung.git (branch v3.3-samsung-fixes-2) ]


Karol Lewandowski (2):
  ARM: Exynos4: Make exynos4-dt compile again
  ARM: Exynos4: Convert exynos4-dt to CONFIG_MULTI_IRQ_HANDLER

 arch/arm/mach-exynos/mach-exynos4-dt.c |7 +--
 1 files changed, 5 insertions(+), 2 deletions(-)
-- 
1.7.8.3

--
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/2] ARM: Exynos4: Make exynos4-dt compile again

2012-01-31 Thread Karol Lewandowski
Commit cc511b8d84d8 (ARM: 7257/1: EXYNOS: introduce
arch/arm/mach-exynos/common.[ch]) replaced plat/exynos4.h with
common.h, requiring all boards to be adjusted appropriately.

This commit fixes exynos4-dt.c, missed out in original patch.

Signed-off-by: Karol Lewandowski k.lewando...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
Cc: Thomas Abraham thomas.abra...@linaro.org
Cc: Kukjin Kim kgene@samsung.com
---
 arch/arm/mach-exynos/mach-exynos4-dt.c |5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-exynos/mach-exynos4-dt.c 
b/arch/arm/mach-exynos/mach-exynos4-dt.c
index 85fa027..98e79c9 100644
--- a/arch/arm/mach-exynos/mach-exynos4-dt.c
+++ b/arch/arm/mach-exynos/mach-exynos4-dt.c
@@ -19,7 +19,8 @@
 
 #include plat/cpu.h
 #include plat/regs-serial.h
-#include plat/exynos4.h
+
+#include common.h
 
 /*
  * The following lookup table is used to override device names when devices
@@ -60,7 +61,7 @@ static const struct of_dev_auxdata 
exynos4210_auxdata_lookup[] __initconst = {
 
 static void __init exynos4210_dt_map_io(void)
 {
-   s5p_init_io(NULL, 0, S5P_VA_CHIPID);
+   exynos_init_io(NULL, 0);
s3c24xx_init_clocks(2400);
 }
 
-- 
1.7.8.3

--
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/2] ARM: Exynos4: Convert exynos4-dt to CONFIG_MULTI_IRQ_HANDLER

2012-01-31 Thread Karol Lewandowski
Commit 4e44d2cb95bd (ARM: exynos4: convert to CONFIG_MULTI_IRQ_HANDLER)
converted all exynos boards but exynos4-dt.c.

This commit fixes that omission.

Signed-off-by: Karol Lewandowski k.lewando...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
Cc: Thomas Abraham thomas.abra...@linaro.org
Cc: Kukjin Kim kgene@samsung.com
Cc: Marc Zyngier marc.zyng...@arm.com
---
 arch/arm/mach-exynos/mach-exynos4-dt.c |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-exynos/mach-exynos4-dt.c 
b/arch/arm/mach-exynos/mach-exynos4-dt.c
index 98e79c9..8aef6aa 100644
--- a/arch/arm/mach-exynos/mach-exynos4-dt.c
+++ b/arch/arm/mach-exynos/mach-exynos4-dt.c
@@ -15,6 +15,7 @@
 #include linux/serial_core.h
 
 #include asm/mach/arch.h
+#include asm/hardware/gic.h
 #include mach/map.h
 
 #include plat/cpu.h
@@ -83,4 +84,5 @@ DT_MACHINE_START(EXYNOS4210_DT, Samsung Exynos4 (Flattened 
Device Tree))
.init_machine   = exynos4210_dt_machine_init,
.timer  = exynos4_timer,
.dt_compat  = exynos4210_dt_compat,
+   .handle_irq = gic_handle_irq,
 MACHINE_END
-- 
1.7.8.3

--
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 2/2] ARM: Exynos4: Convert exynos4-dt to CONFIG_MULTI_IRQ_HANDLER

2012-01-31 Thread Karol Lewandowski

On 31.01.2012 11:39, Kyungmin Park wrote:

Dear Mr Park


restart is also required.


Thanks for this catching this omission. I'll add it in next patch.

Regards,


On 1/31/12, Karol Lewandowskik.lewando...@samsung.com  wrote:

Commit 4e44d2cb95bd (ARM: exynos4: convert to CONFIG_MULTI_IRQ_HANDLER)
converted all exynos boards but exynos4-dt.c.

This commit fixes that omission.

Signed-off-by: Karol Lewandowskik.lewando...@samsung.com
Signed-off-by: Kyungmin Parkkyungmin.p...@samsung.com
Cc: Thomas Abrahamthomas.abra...@linaro.org
Cc: Kukjin Kimkgene@samsung.com
Cc: Marc Zyngiermarc.zyng...@arm.com
---
  arch/arm/mach-exynos/mach-exynos4-dt.c |2 ++
  1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-exynos/mach-exynos4-dt.c
b/arch/arm/mach-exynos/mach-exynos4-dt.c
index 98e79c9..8aef6aa 100644
--- a/arch/arm/mach-exynos/mach-exynos4-dt.c
+++ b/arch/arm/mach-exynos/mach-exynos4-dt.c
@@ -15,6 +15,7 @@
  #includelinux/serial_core.h

  #includeasm/mach/arch.h
+#includeasm/hardware/gic.h
  #includemach/map.h

  #includeplat/cpu.h
@@ -83,4 +84,5 @@ DT_MACHINE_START(EXYNOS4210_DT, Samsung Exynos4
(Flattened Device Tree))
.init_machine   = exynos4210_dt_machine_init,
.timer  =exynos4_timer,
.dt_compat  = exynos4210_dt_compat,
+   .handle_irq = gic_handle_irq,
  MACHINE_END
--
1.7.8.3


--
Karol Lewandowski | Samsung Poland RD Center | Linux/Platform
--
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 v2] ARM: Exynos4: Add cpu-offset property in gic device tree node

2012-01-31 Thread Karol Lewandowski

On 31.01.2012 16:29, Thomas Abraham wrote:

Commit db0d4db22a78 ('ARM: gic: allow GIC to support non-banked setups)
requires a cpu-offset property to be specified for non-banked gic
controllers, which is the case for Exynos4.

Reported-by: Karol Lewandowskik.lewandow...@samsung.com


( Minor note - my email address lacks 'i' at the end, i.e. it's
  k.lewandowsk@ :)


Signed-off-by: Thomas Abrahamthomas.abra...@linaro.org
---
This patch solves the issue of boot failure with SMP enabled kernel for
Exynos4 device tree enabled machine.


Tested-by: Karol Lewandowski k.lewando...@samsung.com

Thanks!
--
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] EXYNOS4_DT fixes for 3.3-rc1+ kernels

2012-01-31 Thread Karol Lewandowski
Device Tree-based Exynos4 machine prepared by Thomas Abraham and
included in 3.3-rc1 hasn't been adjusted to changes that have happened
to mach-exynos during 3.3 merge window.

This commit brings exynos4-dt up to date.

Changes since last version (unmarked v1):

 - Added missing .restart handler spotted by Mr. Kyungmin Park
 - Reorganized patch a bit as requested by Mr. Kukjin Kim
 - Squashed all the fixes into one commit


 [ SMP support has been fixed by Thomas Abraham in separate patch:
   http://permalink.gmane.org/gmane.linux.kernel.samsung-soc/9184 ]


Karol Lewandowski (1):
  ARM: Exynos4: Bring exynos4-dt up to date

 arch/arm/mach-exynos/mach-exynos4-dt.c |8 ++--
 1 files changed, 6 insertions(+), 2 deletions(-)

-- 
1.7.8.3

--
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: Exynos4: Bring exynos4-dt up to date

2012-01-31 Thread Karol Lewandowski
This commit brings exynos4-dt in line with recent changes to
mach-exynos tree, specifically:

 - Fixes build break related to replacing plat/exynos4.h with common.h
   in commit cc511b8d84d8 (ARM: 7257/1: EXYNOS: introduce
   arch/arm/mach-exynos/common.[ch])

 - Converts machine to use CONFIG_MULTI_IRQ_HANDLER as done for other
   machines in commit 4e44d2cb95bd (ARM: exynos4: convert to
   CONFIG_MULTI_IRQ_HANDLER) converted all exynos boards but
   exynos4-dt.c.

 - Adds restart specifier as done for other machines in commit
   9eb4859564d6 (ARM: 7262/1: restart: EXYNOS: use new restart hook)

Signed-off-by: Karol Lewandowski k.lewando...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
Cc: Thomas Abraham thomas.abra...@linaro.org
Cc: Kukjin Kim kgene@samsung.com
---
 arch/arm/mach-exynos/mach-exynos4-dt.c |8 ++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-exynos/mach-exynos4-dt.c 
b/arch/arm/mach-exynos/mach-exynos4-dt.c
index 85fa027..e6b02fd 100644
--- a/arch/arm/mach-exynos/mach-exynos4-dt.c
+++ b/arch/arm/mach-exynos/mach-exynos4-dt.c
@@ -15,11 +15,13 @@
 #include linux/serial_core.h
 
 #include asm/mach/arch.h
+#include asm/hardware/gic.h
 #include mach/map.h
 
 #include plat/cpu.h
 #include plat/regs-serial.h
-#include plat/exynos4.h
+
+#include common.h
 
 /*
  * The following lookup table is used to override device names when devices
@@ -60,7 +62,7 @@ static const struct of_dev_auxdata 
exynos4210_auxdata_lookup[] __initconst = {
 
 static void __init exynos4210_dt_map_io(void)
 {
-   s5p_init_io(NULL, 0, S5P_VA_CHIPID);
+   exynos_init_io(NULL, 0);
s3c24xx_init_clocks(2400);
 }
 
@@ -79,7 +81,9 @@ DT_MACHINE_START(EXYNOS4210_DT, Samsung Exynos4 (Flattened 
Device Tree))
/* Maintainer: Thomas Abraham thomas.abra...@linaro.org */
.init_irq   = exynos4_init_irq,
.map_io = exynos4210_dt_map_io,
+   .handle_irq = gic_handle_irq,
.init_machine   = exynos4210_dt_machine_init,
.timer  = exynos4_timer,
.dt_compat  = exynos4210_dt_compat,
+   .restart= exynos4_restart,
 MACHINE_END
-- 
1.7.8.3

--
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 v2 2/2] regulator: add device tree support for max8997

2012-01-27 Thread Karol Lewandowski

On 25.01.2012 12:22, Mark Brown wrote:

The big problem there seems like specifying voltages in the first
place, if we know what device it is we should already know what's
going on.



Driver which handles said regulator might know what's going on, but
that might not be case for its consumers.  Should we limit ability to
query given parameter just because its value is hardcoded in hardware?


I'm sorry, this makes no sense.  Setting a value in the constraints is
not going to have any impact on the value reported by the driver, it
never has.


... with the exception of fixed regulator, that is. This is from where I 
got my flawed understanding.


Looking at other drivers I see that's indeed special case not practiced 
elsewhere.


Thanks for explaining this.

Regards,
--
Karol Lewandowski | Samsung Poland RD Center | Linux/Platform
--
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 v2 2/2] regulator: add device tree support for max8997

2012-01-26 Thread Karol Lewandowski

On 25.01.2012 14:32, Mark Brown wrote:

On Wed, Jan 25, 2012 at 01:02:29PM +0100, Karol Lewandowski wrote:

On 25.01.2012 12:26, Mark Brown wrote:



However, I still find it little problematic that dt and non-dt
versions behave differently when given the same set of parameters
(previously apply_uV wasn't the default and required explicit flag).


Well, they're different things.  Device tree isn't Linux specific at
all.


There is no official platform-agnostic regulator API, nor DT-bindings
document I'm aware of.  Thus, I don't see why, while transitioning to
DT, should we lose ability to describe certain hardware configurations.

On 25.01.2012 12:22, Mark Brown wrote:
 The big problem there seems like specifying voltages in the first
 place, if we know what device it is we should already know what's
 going on.

Driver which handles said regulator might know what's going on, but
that might not be case for its consumers.  Should we limit ability to
query given parameter just because its value is hardcoded in hardware?


My understanding of this whole device tree effort was to provide
ability to describe hardware properties which can't be queried from
hardware itself.

Consequently, if it's property of hardware that it provides fixed
voltage somewhere shouldn't it be possible to describe this fact
in DT?

If device tree isn't good place for it then which one is?

Regards,
--
Karol Lewandowski | Samsung Poland RD Center | Linux/Platform
--
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 v2 2/2] regulator: add device tree support for max8997

2012-01-25 Thread Karol Lewandowski

On 12.01.2012 08:35, Thomas Abraham wrote:

Add device tree based discovery support for max8997.



+static int max8997_pmic_dt_parse_pdata(struct max8997_dev *iodev,
+   struct max8997_platform_data *pdata)
+{



+   pdata-regulators = rdata;
+   for_each_child_of_node(regulators_np, reg_np) {
+   for (i = 0; i  ARRAY_SIZE(regulators); i++)
+   if (!of_node_cmp(reg_np-name, regulators[i].name))
+   break;
+   rdata-id = i;
+   rdata-initdata = of_get_regulator_init_data(
+   iodev-dev, reg_np);


One more thing - of_get_regulator_init_data() will set apply_uV to 1 so 
we need to reset it for BUCK6, which doesn't provide set_voltage() ops, 
like:


if (rdata-initdata  regulators[i].id == MAX8997_BUCK6)
rdata-initdata-constraints.apply_uV = 0;

Thanks
--
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: Exynos4: dts: Specify address and size cells for i2c controllers

2012-01-25 Thread Karol Lewandowski
Signed-off-by: Karol Lewandowski k.lewando...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 arch/arm/boot/dts/exynos4210.dtsi |   16 
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/arch/arm/boot/dts/exynos4210.dtsi 
b/arch/arm/boot/dts/exynos4210.dtsi
index 63d7578..d11e167 100644
--- a/arch/arm/boot/dts/exynos4210.dtsi
+++ b/arch/arm/boot/dts/exynos4210.dtsi
@@ -99,48 +99,64 @@
};
 
i2c@1386 {
+   #address-cells = 1;
+   #size-cells = 0;
compatible = samsung,s3c2440-i2c;
reg = 0x1386 0x100;
interrupts = 0 58 0;
};
 
i2c@1387 {
+   #address-cells = 1;
+   #size-cells = 0;
compatible = samsung,s3c2440-i2c;
reg = 0x1387 0x100;
interrupts = 0 59 0;
};
 
i2c@1388 {
+   #address-cells = 1;
+   #size-cells = 0;
compatible = samsung,s3c2440-i2c;
reg = 0x1388 0x100;
interrupts = 0 60 0;
};
 
i2c@1389 {
+   #address-cells = 1;
+   #size-cells = 0;
compatible = samsung,s3c2440-i2c;
reg = 0x1389 0x100;
interrupts = 0 61 0;
};
 
i2c@138A {
+   #address-cells = 1;
+   #size-cells = 0;
compatible = samsung,s3c2440-i2c;
reg = 0x138A 0x100;
interrupts = 0 62 0;
};
 
i2c@138B {
+   #address-cells = 1;
+   #size-cells = 0;
compatible = samsung,s3c2440-i2c;
reg = 0x138B 0x100;
interrupts = 0 63 0;
};
 
i2c@138C {
+   #address-cells = 1;
+   #size-cells = 0;
compatible = samsung,s3c2440-i2c;
reg = 0x138C 0x100;
interrupts = 0 64 0;
};
 
i2c@138D {
+   #address-cells = 1;
+   #size-cells = 0;
compatible = samsung,s3c2440-i2c;
reg = 0x138D 0x100;
interrupts = 0 65 0;
-- 
1.7.8.3

--
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 v2 2/2] regulator: add device tree support for max8997

2012-01-25 Thread Karol Lewandowski

On 25.01.2012 12:26, Mark Brown wrote:

On Wed, Jan 25, 2012 at 10:55:49AM +0100, Karol Lewandowski wrote:

On 12.01.2012 08:35, Thomas Abraham wrote:

Add device tree based discovery support for max8997.



+   pdata-regulators = rdata;
+   for_each_child_of_node(regulators_np, reg_np) {
+   for (i = 0; i   ARRAY_SIZE(regulators); i++)
+   if (!of_node_cmp(reg_np-name, regulators[i].name))
+   break;
+   rdata-id = i;
+   rdata-initdata = of_get_regulator_init_data(
+   iodev-dev, reg_np);



One more thing - of_get_regulator_init_data() will set apply_uV to 1
so we need to reset it for BUCK6, which doesn't provide
set_voltage() ops, like:



if (rdata-initdata  regulators[i].id == MAX8997_BUCK6)
rdata-initdata-constraints.apply_uV = 0;


So, over in the other thready you were referring to mailing list posts
you made in the past few moments as examples of past issues.  Please at
least mention that there hasn't been any actual discussion when doing
this...


Sorry if this caused confusion.  I'll be more cautious next time.


I don't see a problem here, if the device can't set the voltage then
setting constraints to allow the voltage to be changed is silly and the
user just shouldn't do that.


Agreed.  I've assumed that old platform code done right thing when it 
set buck6 voltage constraints [1].


However, I still find it little problematic that dt and non-dt versions 
behave differently when given the same set of parameters (previously 
apply_uV wasn't the default and required explicit flag).



Thomas, would you mind adding small note to pmic's bindings 
documentation stating that Buck6 is basically on/off switch? (Thus, no 
voltage should nor can be specified).


[1] http://lxr.linux.no/linux+v3.2.1/arch/arm/mach-exynos/mach-nuri.c#L802

Regards,
--
Karol Lewandowski | Samsung Poland RD Center | Linux/Platform
--
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] max8997: Avoid spaces in regulator names

2012-01-24 Thread Karol Lewandowski
max8997-pmic instantiated from device tree uses names, not numerical
ids to distinguish between outputs.

Replace spaces with underscores in said names to make it possible to
describe these outputs as regulators in DTS.

Signed-off-by: Karol Lewandowski k.lewando...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
Cc: Mark Brown broo...@opensource.wolfsonmicro.com
Cc: Thomas Abraham thomas.abra...@linaro.org
---
 drivers/regulator/max8997.c |8 
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/regulator/max8997.c b/drivers/regulator/max8997.c
index 053d0b7..4b572eb 100644
--- a/drivers/regulator/max8997.c
+++ b/drivers/regulator/max8997.c
@@ -910,13 +910,13 @@ static struct regulator_desc regulators[] = {
},
regulator_desc_buck(7),
{
-   .name   = EN32KHz AP,
+   .name   = EN32KHz_AP,
.id = MAX8997_EN32KHZ_AP,
.ops= max8997_fixedvolt_ops,
.type   = REGULATOR_VOLTAGE,
.owner  = THIS_MODULE,
}, {
-   .name   = EN32KHz CP,
+   .name   = EN32KHz_CP,
.id = MAX8997_EN32KHZ_CP,
.ops= max8997_fixedvolt_ops,
.type   = REGULATOR_VOLTAGE,
@@ -940,7 +940,7 @@ static struct regulator_desc regulators[] = {
.type   = REGULATOR_VOLTAGE,
.owner   = THIS_MODULE,
}, {
-   .name   = CHARGER CV,
+   .name   = CHARGER_CV,
.id = MAX8997_CHARGER_CV,
.ops= max8997_fixedstate_ops,
.type   = REGULATOR_VOLTAGE,
@@ -952,7 +952,7 @@ static struct regulator_desc regulators[] = {
.type   = REGULATOR_CURRENT,
.owner   = THIS_MODULE,
}, {
-   .name   = CHARGER TOPOFF,
+   .name   = CHARGER_TOPOFF,
.id = MAX8997_CHARGER_TOPOFF,
.ops= max8997_charger_fixedstate_ops,
.type   = REGULATOR_CURRENT,
-- 
1.7.8.3

--
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 v2 2/2] regulator: add device tree support for max8997

2012-01-23 Thread Karol Lewandowski

On 12.01.2012 08:35, Thomas Abraham wrote:

Hi!


Add device tree based discovery support for max8997.



+static int max8997_pmic_dt_parse_pdata(struct max8997_dev *iodev,
+   struct max8997_platform_data *pdata)
+{

...

+   pdata-regulators = rdata;
+   for_each_child_of_node(regulators_np, reg_np) {
+   for (i = 0; i  ARRAY_SIZE(regulators); i++)
+   if (!of_node_cmp(reg_np-name, regulators[i].name))
+   break;


If I read your patch correctly it would impossible to configure 
following outputs when pmic is instantiated from DT:


enum max8998_regulators {
...
 1MAX8997_EN32KHZ_AP,
 2MAX8997_EN32KHZ_CP,
 3MAX8997_CHARGER_CV,
 4MAX8997_CHARGER_TOPOFF, /* MBCCTRL5 */

This is due to use of embedded spaces in regulator names (which are used 
in comparision).


This can be fixed with trivial patch[1].

What bothers me more, are following regulators:

  MAX8997_EN32KHZ_AP,
  MAX8997_EN32KHZ_CP,
  MAX8997_ENVICHG,
  MAX8997_ESAFEOUT1,
  MAX8997_ESAFEOUT2,

Aren't these fixed? i.e. - is it really needed to configure these either 
by platform data or DT at all?



[1]

From 5cfba526210bc596c7d14e33fea93648baa0a227 Mon Sep 17 00:00:00 2001
From: Karol Lewandowski k.lewando...@samsung.com
Date: Mon, 23 Jan 2012 17:20:25 +0100
Subject: [PATCH] max8997: Avoid spaces in regulator names

max8997-pmic instantiated from device tree uses names,
not numerical ids to distinguish between outputs.

Use names without spaces to make it possible to specify
parameters for said regulators in DTS.

Signed-off-by: Karol Lewandowski k.lewando...@samsung.com
Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/regulator/max8997.c |8 
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/regulator/max8997.c b/drivers/regulator/max8997.c
index 053d0b7..4b572eb 100644
--- a/drivers/regulator/max8997.c
+++ b/drivers/regulator/max8997.c
@@ -910,13 +910,13 @@ static struct regulator_desc regulators[] = {
},
regulator_desc_buck(7),
{
-   .name   = EN32KHz AP,
+   .name   = EN32KHz_AP,
.id = MAX8997_EN32KHZ_AP,
.ops= max8997_fixedvolt_ops,
.type   = REGULATOR_VOLTAGE,
.owner  = THIS_MODULE,
}, {
-   .name   = EN32KHz CP,
+   .name   = EN32KHz_CP,
.id = MAX8997_EN32KHZ_CP,
.ops= max8997_fixedvolt_ops,
.type   = REGULATOR_VOLTAGE,
@@ -940,7 +940,7 @@ static struct regulator_desc regulators[] = {
.type   = REGULATOR_VOLTAGE,
.owner   = THIS_MODULE,
}, {
-   .name   = CHARGER CV,
+   .name   = CHARGER_CV,
.id = MAX8997_CHARGER_CV,
.ops= max8997_fixedstate_ops,
.type   = REGULATOR_VOLTAGE,
@@ -952,7 +952,7 @@ static struct regulator_desc regulators[] = {
.type   = REGULATOR_CURRENT,
.owner   = THIS_MODULE,
}, {
-   .name   = CHARGER TOPOFF,
+   .name   = CHARGER_TOPOFF,
.id = MAX8997_CHARGER_TOPOFF,
.ops= max8997_charger_fixedstate_ops,
.type   = REGULATOR_CURRENT,
--
1.7.8.3

--
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 v2 2/2] regulator: add device tree support for max8997

2012-01-23 Thread Karol Lewandowski

On 01/23/2012 07:20 PM, Mark Brown wrote:

On Mon, Jan 23, 2012 at 06:50:22PM +0100, Karol Lewandowski wrote:


Aren't these fixed? i.e. - is it really needed to configure these
either by platform data or DT at all?


[1]

 From 5cfba526210bc596c7d14e33fea93648baa0a227 Mon Sep 17 00:00:00 2001
From: Karol Lewandowskik.lewando...@samsung.com


Documentation/SubmittingPatches please...


I should have stated explicitly that purpose of this patch (I should 
have called it sniplet) was to show my point only.


IMHO it's still up to debate how above problem should be solved.

I'm not entirely sure that we really need things like e.g. EN32KHz AP 
in DT (nor in platform data, for that matter).  I would like to see 
Thomas' opinion first.


Thanks

Regards,
Karol Lewandowski

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