RE: [PATCH v3] mfd: syscon: Decouple syscon interface from platform devices

2014-09-18 Thread Pankaj Dubey
Hi,

Adding CC to Xiubo Li, Geert Uytterhoeven and Stephen Warren. 

On Thursday, September 18, 2014, Dong Aisheng wrote,
 On Wed, Sep 17, 2014 at 04:50:50PM +0530, Pankaj Dubey wrote:
  Hi,
 
  On Wednesday, September 17, 2014, Dong Aisheng Wrote,
   
+   regmap = regmap_init_mmio(NULL, base,
syscon_regmap_config);
  
   Does a NULL device pointer work?
 
  Yes, it is safe, at least we are able to test on Exynos based SoC.
  I have tested it with kgene/for-next kernel on Exynos3250.
  Also it has been tested on Exynos5250 based Snow board with 3.17-rc5
  based kernel by Vivek Gautam.
 
  Patch V2 also has been tested by Borris Brezillon on AT91 platform.
 
 
 
 The kernel i tested was next-20140915 of linux-next.
 
 please see regmap_get_val_endian called in regmap_init function.
 static enum regmap_endian regmap_get_val_endian(struct device *dev,
 const struct regmap_bus *bus,
 const struct regmap_config
*config) {
 struct device_node *np = dev-of_node;
 enum regmap_endian endian;
 ...
 }
 It will crash at the first line of dev-of_node if dev is NULL.
 
 Can you check if you're using the same code as mine?

No, it's not same.
My bad that I was not using linux-next for testing this patch.
We tested on kgene/for-next where these changes still have not come.
Just now I checked linux-next and found that it will crash at first line of 
regmap_get_val_endian as there is no check for NULL on dev.

I checked git history of regmap.c file and found recently this file has been
modified
for adding DT endianness binding support. Following are set of patches gone
for this

cf673fb regmap: Split regmap_get_endian() in two functions
5844a8b regmap: Fix handling of volatile registers for format_write() chips
45e1a27 regmap: of_regmap_get_endian() cleanup
ba1b53f regmap: Fix DT endianess parsing logic
d647c19 regmap: add DT endianness binding support.

I think there should have been a check for NULL on dev in
regmap_get_val_endian, so that if dev pointer exist then only it makes
sense to get
endianness property from DT. 

I will suggest following fix in regmap.c for this. With following fix I
tested it and it works well
on linux-next also. So if you can confirm following fix is working for you
then I can post this
patch.


Subject: [PATCH] regmap: fix NULL pointer dereference in
 regmap_get_val_endian

Recent commits for getting reg endianess causing NULL pointer
dereference if dev is passed NULL in regmap_init_mmio. This patch
fixes this issue, and allows to parse reg endianess only if dev
and dev-of_node exist.

Signed-off-by: Pankaj Dubey pankaj.du...@samsung.com
---
 drivers/base/regmap/regmap.c |   23 ++-
 1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index f2281af..455a877 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -477,7 +477,7 @@ static enum regmap_endian regmap_get_val_endian(struct
device *dev,
const struct regmap_bus *bus,
const struct regmap_config *config)
 {
-   struct device_node *np = dev-of_node;
+   struct device_node *np;
enum regmap_endian endian;
 
/* Retrieve the endianness specification from the regmap config */
@@ -487,15 +487,20 @@ static enum regmap_endian regmap_get_val_endian(struct
device *dev,
if (endian != REGMAP_ENDIAN_DEFAULT)
return endian;
 
-   /* Parse the device's DT node for an endianness specification */
-   if (of_property_read_bool(np, big-endian))
-   endian = REGMAP_ENDIAN_BIG;
-   else if (of_property_read_bool(np, little-endian))
-   endian = REGMAP_ENDIAN_LITTLE;
+   /* If the dev and dev-of_node exist try to get endianness from DT
*/
+   if (dev  dev-of_node) {
+   np = dev-of_node;
 
-   /* If the endianness was specified in DT, use that */
-   if (endian != REGMAP_ENDIAN_DEFAULT)
-   return endian;
+   /* Parse the device's DT node for an endianness
specification */
+   if (of_property_read_bool(np, big-endian))
+   endian = REGMAP_ENDIAN_BIG;
+   else if (of_property_read_bool(np, little-endian))
+   endian = REGMAP_ENDIAN_LITTLE;
+
+   /* If the endianness was specified in DT, use that */
+   if (endian != REGMAP_ENDIAN_DEFAULT)
+   return endian;
+   }
 
/* Retrieve the endianness specification from the bus config */
if (bus  bus-val_format_endian_default)
--

Thanks,
Pankaj Dubey

 Regards
 Dong Aisheng
 
 
  Thanks,
  Pankaj Dubey
 
   Regards
   Dong Aisheng
  
   
   
___
linux-arm-kernel mailing 

Re: [PATCH] drm/exynos: fix plane-framebuffer linkage

2014-09-18 Thread Daniel Vetter
On Wed, Sep 17, 2014 at 6:41 PM, Daniel Drake dr...@endlessm.com wrote:
 However there is *another* fb reference taken in
 omap_plane_mode_set(). And my patch is modelled to do the same in
 exynos-drm.

This is because omapdrm does _everything_ asynchrously, even plain
modesets. Unfortunately that async modeset support is broken, so the
latest omapdrm patches insert a synchronization point.

So picking omap's mode_set logic as a reference because it also does
fb refcounting is not a good idea - that code does something crazy and
gets it wrong. And really, if you do modeset synchronously the drm
core will take care of your refcounting needs.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
--
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] drm/exynos: fix plane-framebuffer linkage

2014-09-18 Thread Daniel Vetter
On Wed, Sep 17, 2014 at 6:41 PM, Daniel Drake dr...@endlessm.com wrote:
 2. drm_mode_rmfb then calls drm_framebuffer_remove, which calls
 drm_mode_set_config_internal() in order to turn off the CRTC, dropping
 another reference in the process.
 if (tmp-old_fb)
 drm_framebuffer_unreference(tmp-old_fb);

 3. drm_framebuffer_remove calls drm_plane_force_disable() which drops
 another reference:
 /* disconnect the plane from the fb and crtc: */
 __drm_framebuffer_unreference(old_fb);

If 3. here is about the primary plane then this won't happen, since
the primary plane pointerreference has already been cleared in step
2.

And even if their would be a bug in here, you _certainly_ should not
try to paper over this in your driver, but instead fix up the
refcounting done in the drm core.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
--
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: dts: Add rtc_src clk for s3c-rtc on exynos5250-snow

2014-09-18 Thread Javier Martinez Canillas
Hello Doug, Andreas,

On 09/17/2014 05:47 PM, Doug Anderson wrote:

 rtc@101E {
 status = okay;
 +   clocks = clock CLK_RTC, max77686 MAX77686_CLK_AP;
 +   clock-names = rtc, rtc_src;
 
 Wait, seriously?  Snow is still using the rtc@101E syntax?
 Whatever happened to the series that Andreas worked so hard on,
 including https://patchwork.kernel.org/patch/4664801/?


Andreas, I completely forgot about your series when writing this patch even
though I've on my TO-DO to sync the downstream and upstream Snow DTS once your
patches land. Sorry about that.

 
 In any case, there's nothing wrong with Javier's patch other than the
 fact that it will eventually need to get merged with Andreas's, so:
 
 Reviewed-by: Doug Anderson diand...@chromium.org
 

Thanks, I'll re-spin and post again once Kukjin merges Andreas series.

Best regards,
Javier
--
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 5/6] mfd: cros_ec: wait for completion of commands that return IN_PROGRESS

2014-09-18 Thread Javier Martinez Canillas
Hello Lee,

Thanks a lot for your feedback.

On 09/17/2014 06:23 PM, Lee Jones wrote:
  
  mutex_lock(ec_dev-lock);
  ret = ec_dev-cmd_xfer(ec_dev, msg);
 +if (msg-result == EC_RES_IN_PROGRESS) {
 +int i;
 +struct cros_ec_command status_msg;
 +struct ec_response_get_comms_status status;
 +
 +status_msg.version = 0;
 +status_msg.command = EC_CMD_GET_COMMS_STATUS;
 +status_msg.outdata = NULL;
 +status_msg.outsize = 0;
 +status_msg.indata = (uint8_t *)status;
 +status_msg.insize = sizeof(status);
 +
 +/*
 + * Query the EC's status until it's no longer busy or
 + * we encounter an error.
 + */
 +for (i = 0; i  EC_COMMAND_RETRIES; i++) {
 +usleep_range(EC_RETRY_DELAY_MS, EC_RETRY_DELAY_MS + 1);
 
 Remove the EC_RETRY_DELAY_MS define and place the values in raw.


Ok, will do.

 You're now sleeping for 10us.  Did you test the changes?
 

Duh, I must had been sleepy since I thought about changing the define but I
completely missed... which proves your point that raw values are more explicit
than using a define here.

Yes, I'm testing the changes and making sure that it does not add any
regression but I was not able to reproduce the case when an EC command result
is IN_PROGRESS. I'll investigate further on how to properly test that branch
before posting v4.

Best regards,
Javier
--
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] mfd: cros_ec: Instantiate sub-devices from device tree

2014-09-18 Thread Javier Martinez Canillas
Hello Lee,

On 09/17/2014 06:31 PM, Lee Jones wrote:
  
 -static const struct mfd_cell cros_devs[] = {
 -{
 -.name = cros-ec-keyb,
 -.id = 1,
 -.of_compatible = google,cros-ec-keyb,
 -},
 -{
 -.name = cros-ec-i2c-tunnel,
 -.id = 2,
 -.of_compatible = google,cros-ec-i2c-tunnel,
 -},
 -};
 -
  int cros_ec_register(struct cros_ec_device *ec_dev)
  {
  struct device *dev = ec_dev-dev;
 +struct device_node *node = dev-of_node;
  int err = 0;
  
  if (ec_dev-din_size) {
 @@ -140,12 +129,12 @@ int cros_ec_register(struct cros_ec_device *ec_dev)
  
  mutex_init(ec_dev-lock);
  
 -err = mfd_add_devices(dev, 0, cros_devs,
 -  ARRAY_SIZE(cros_devs),
 -  NULL, ec_dev-irq, NULL);
 -if (err) {
 -dev_err(dev, failed to add mfd devices\n);
 -return err;
 
 So these devices will only ever probe with DT now ...


Well, these are preparatory patches to reduce the delta between upstream and
the downstream so the missing functionality could be added. One of the missing
drivers is the cros_ec_dev.c [0] which allows user-space to access the
ChromeOS Embedded Controller using a virtual character device (/dev/cros_ec).

Since that is a virtual device, it does not fit on the DT which only describes
hw and also is used on x86 machines so that subdevice is still probed using
mfd_add_devices() and the mfd_cells array is not empty in the downstream
cros_ec driver [1].

That's why I didn't just made the cros_ec MFD to depend on OF, since I didn't
want to diverge too much from the downstream driver because the idea of the
series was to reduce the difference in order to add the missing bits on top.

 +if (node) {
 
 So it would be wrong for dev-of_node not to be populated.
 

As explained above, DT, non-DT and x86 platforms instantiate the cros-ec-dev
cells but DT platforms can define other child nodes. But I can remove the
conditional if you want and reintroduce it once cros-ec-dev support is added.

 +err = of_platform_populate(node, NULL, NULL, dev);
 +if (err) {
 +dev_err(dev, Failed to register subordinate devices);
 +return err;
 +}
  }
  
  dev_info(dev, Chrome EC device registered\n);
 

Best regards,
Javier

[0]:
https://chromium.googlesource.com/chromiumos/third_party/kernel/+/chromeos-3.8/drivers/mfd/cros_ec_dev.c
[1]:
https://chromium.googlesource.com/chromiumos/third_party/kernel/+/chromeos-3.8/drivers/mfd/cros_ec.c#93
--
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] mfd: syscon: Decouple syscon interface from platform devices

2014-09-18 Thread li.xi...@freescale.com
Hi Pankaj,

One more question:
For example:

regmap_read()
 _regmap_read()
 2112 #ifdef LOG_DEVICE
 2113 if (strcmp(dev_name(map-dev), LOG_DEVICE) 
== 0)
 2114 dev_info(map-dev, %x = %x\n, 
reg, *val);
 2115 #endif 

In dev_name(map-dev) will also encounter the same crash core trace like in
regmap_get_val_endian(dev, ...).

Could there be another method, such as using 'dummy dev' instead of 'NULL dev' ?
Just one suggestion.


BRs
Xiubo


 -Original Message-
 From: Pankaj Dubey [mailto:pankaj.du...@samsung.com]
 Sent: Thursday, September 18, 2014 2:03 PM
 To: Dong Aisheng-B29396
 Cc: linux-arm-ker...@lists.infradead.org; linux-samsung-soc@vger.kernel.org;
 linux-ker...@vger.kernel.org; kgene@samsung.com; li...@arm.linux.org.uk;
 a...@arndb.de; naus...@samsung.com; tomasz.f...@gmail.com; jo...@samsung.com;
 thomas...@samsung.com; vikas.saj...@samsung.com; chow@samsung.com;
 lee.jo...@linaro.org; 'Boris BREZILLON'; Xiubo Li-B47053; 'Geert 
 Uytterhoeven';
 'Stephen Warren'
 Subject: RE: [PATCH v3] mfd: syscon: Decouple syscon interface from platform
 devices
 
 Hi,
 
 Adding CC to Xiubo Li, Geert Uytterhoeven and Stephen Warren.
 
 On Thursday, September 18, 2014, Dong Aisheng wrote,
  On Wed, Sep 17, 2014 at 04:50:50PM +0530, Pankaj Dubey wrote:
   Hi,
  
   On Wednesday, September 17, 2014, Dong Aisheng Wrote,

 + regmap = regmap_init_mmio(NULL, base,
 syscon_regmap_config);
   
Does a NULL device pointer work?
  
   Yes, it is safe, at least we are able to test on Exynos based SoC.
   I have tested it with kgene/for-next kernel on Exynos3250.
   Also it has been tested on Exynos5250 based Snow board with 3.17-rc5
   based kernel by Vivek Gautam.
  
   Patch V2 also has been tested by Borris Brezillon on AT91 platform.
  
  
 
  The kernel i tested was next-20140915 of linux-next.
 
  please see regmap_get_val_endian called in regmap_init function.
  static enum regmap_endian regmap_get_val_endian(struct device *dev,
  const struct regmap_bus *bus,
  const struct regmap_config
 *config) {
  struct device_node *np = dev-of_node;
  enum regmap_endian endian;
  ...
  }
  It will crash at the first line of dev-of_node if dev is NULL.
 
  Can you check if you're using the same code as mine?
 
 No, it's not same.
 My bad that I was not using linux-next for testing this patch.
 We tested on kgene/for-next where these changes still have not come.
 Just now I checked linux-next and found that it will crash at first line of
 regmap_get_val_endian as there is no check for NULL on dev.
 
 I checked git history of regmap.c file and found recently this file has been
 modified
 for adding DT endianness binding support. Following are set of patches gone
 for this
 
 cf673fb regmap: Split regmap_get_endian() in two functions
 5844a8b regmap: Fix handling of volatile registers for format_write() chips
 45e1a27 regmap: of_regmap_get_endian() cleanup
 ba1b53f regmap: Fix DT endianess parsing logic
 d647c19 regmap: add DT endianness binding support.
 
 I think there should have been a check for NULL on dev in
 regmap_get_val_endian, so that if dev pointer exist then only it makes
 sense to get
 endianness property from DT.
 
 I will suggest following fix in regmap.c for this. With following fix I
 tested it and it works well
 on linux-next also. So if you can confirm following fix is working for you
 then I can post this
 patch.
 
 
 Subject: [PATCH] regmap: fix NULL pointer dereference in
  regmap_get_val_endian
 
 Recent commits for getting reg endianess causing NULL pointer
 dereference if dev is passed NULL in regmap_init_mmio. This patch
 fixes this issue, and allows to parse reg endianess only if dev
 and dev-of_node exist.
 
 Signed-off-by: Pankaj Dubey pankaj.du...@samsung.com
 ---
  drivers/base/regmap/regmap.c |   23 ++-
  1 file changed, 14 insertions(+), 9 deletions(-)
 
 diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
 index f2281af..455a877 100644
 --- a/drivers/base/regmap/regmap.c
 +++ b/drivers/base/regmap/regmap.c
 @@ -477,7 +477,7 @@ static enum regmap_endian regmap_get_val_endian(struct
 device *dev,
   const struct regmap_bus *bus,
   const struct regmap_config *config)
  {
 - struct device_node *np = dev-of_node;
 + struct device_node *np;
   enum regmap_endian endian;
 
   /* Retrieve the endianness specification from the regmap config */
 @@ -487,15 +487,20 @@ static enum regmap_endian regmap_get_val_endian(struct
 device *dev,
   if (endian != REGMAP_ENDIAN_DEFAULT)
   return endian;
 
 - /* Parse the device's DT node for an endianness specification */
 - if (of_property_read_bool(np, 

RE: [PATCH v3] mfd: syscon: Decouple syscon interface from platform devices

2014-09-18 Thread li.xi...@freescale.com
Hi,

[...]
  please see regmap_get_val_endian called in regmap_init function.
  static enum regmap_endian regmap_get_val_endian(struct device *dev,
  const struct regmap_bus *bus,
  const struct regmap_config
 *config) {
  struct device_node *np = dev-of_node;
  enum regmap_endian endian;
  ...
  }
  It will crash at the first line of dev-of_node if dev is NULL.
 
  Can you check if you're using the same code as mine?
 
 No, it's not same.
 My bad that I was not using linux-next for testing this patch.
 We tested on kgene/for-next where these changes still have not come.
 Just now I checked linux-next and found that it will crash at first line of
 regmap_get_val_endian as there is no check for NULL on dev.
 
 I checked git history of regmap.c file and found recently this file has been
 modified
 for adding DT endianness binding support. Following are set of patches gone
 for this
 
 cf673fb regmap: Split regmap_get_endian() in two functions
 5844a8b regmap: Fix handling of volatile registers for format_write() chips
 45e1a27 regmap: of_regmap_get_endian() cleanup
 ba1b53f regmap: Fix DT endianess parsing logic
 d647c19 regmap: add DT endianness binding support.
 
 I think there should have been a check for NULL on dev in
 regmap_get_val_endian, so that if dev pointer exist then only it makes
 sense to get
 endianness property from DT.
 
 I will suggest following fix in regmap.c for this. With following fix I
 tested it and it works well
 on linux-next also. So if you can confirm following fix is working for you
 then I can post this
 patch.
 
 
 Subject: [PATCH] regmap: fix NULL pointer dereference in
  regmap_get_val_endian
 
 Recent commits for getting reg endianess causing NULL pointer
 dereference if dev is passed NULL in regmap_init_mmio. This patch
 fixes this issue, and allows to parse reg endianess only if dev
 and dev-of_node exist.
 

Another question:

Then the regmap core cannot deal with the following issue:
Like the patch adding the endianness support for syscon:
[PATCH] mfd: syscon: binding: Add syscon endianness support.

So here just register one dummy syscon device is a good choice I do
think.
:)


Thanks,

BRs
Xiubo



 Signed-off-by: Pankaj Dubey pankaj.du...@samsung.com
 ---
  drivers/base/regmap/regmap.c |   23 ++-
  1 file changed, 14 insertions(+), 9 deletions(-)
 
 diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
 index f2281af..455a877 100644
 --- a/drivers/base/regmap/regmap.c
 +++ b/drivers/base/regmap/regmap.c
 @@ -477,7 +477,7 @@ static enum regmap_endian regmap_get_val_endian(struct
 device *dev,
   const struct regmap_bus *bus,
   const struct regmap_config *config)
  {
 - struct device_node *np = dev-of_node;
 + struct device_node *np;
   enum regmap_endian endian;
 
   /* Retrieve the endianness specification from the regmap config */
 @@ -487,15 +487,20 @@ static enum regmap_endian regmap_get_val_endian(struct
 device *dev,
   if (endian != REGMAP_ENDIAN_DEFAULT)
   return endian;
 
 - /* Parse the device's DT node for an endianness specification */
 - if (of_property_read_bool(np, big-endian))
 - endian = REGMAP_ENDIAN_BIG;
 - else if (of_property_read_bool(np, little-endian))
 - endian = REGMAP_ENDIAN_LITTLE;
 + /* If the dev and dev-of_node exist try to get endianness from DT
 */
 + if (dev  dev-of_node) {
 + np = dev-of_node;
 
 - /* If the endianness was specified in DT, use that */
 - if (endian != REGMAP_ENDIAN_DEFAULT)
 - return endian;
 + /* Parse the device's DT node for an endianness
 specification */
 + if (of_property_read_bool(np, big-endian))
 + endian = REGMAP_ENDIAN_BIG;
 + else if (of_property_read_bool(np, little-endian))
 + endian = REGMAP_ENDIAN_LITTLE;
 +
 + /* If the endianness was specified in DT, use that */
 + if (endian != REGMAP_ENDIAN_DEFAULT)
 + return endian;
 + }
 
   /* Retrieve the endianness specification from the bus config */
   if (bus  bus-val_format_endian_default)
 --
 
 Thanks,
 Pankaj Dubey
 
  Regards
  Dong Aisheng
 
  
   Thanks,
   Pankaj Dubey
  
Regards
Dong Aisheng
   


 ___
 linux-arm-kernel mailing list
 linux-arm-ker...@lists.infradead.org
 http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
  

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


Re: [PATCH v3] mfd: syscon: Decouple syscon interface from platform devices

2014-09-18 Thread Dong Aisheng
On Thu, Sep 18, 2014 at 11:33:26AM +0530, Pankaj Dubey wrote:
 Hi,
 
 Adding CC to Xiubo Li, Geert Uytterhoeven and Stephen Warren. 
 
 On Thursday, September 18, 2014, Dong Aisheng wrote,
  On Wed, Sep 17, 2014 at 04:50:50PM +0530, Pankaj Dubey wrote:
   Hi,
  
   On Wednesday, September 17, 2014, Dong Aisheng Wrote,

 + regmap = regmap_init_mmio(NULL, base,
 syscon_regmap_config);
   
Does a NULL device pointer work?
  
   Yes, it is safe, at least we are able to test on Exynos based SoC.
   I have tested it with kgene/for-next kernel on Exynos3250.
   Also it has been tested on Exynos5250 based Snow board with 3.17-rc5
   based kernel by Vivek Gautam.
  
   Patch V2 also has been tested by Borris Brezillon on AT91 platform.
  
  
  
  The kernel i tested was next-20140915 of linux-next.
  
  please see regmap_get_val_endian called in regmap_init function.
  static enum regmap_endian regmap_get_val_endian(struct device *dev,
  const struct regmap_bus *bus,
  const struct regmap_config
 *config) {
  struct device_node *np = dev-of_node;
  enum regmap_endian endian;
  ...
  }
  It will crash at the first line of dev-of_node if dev is NULL.
  
  Can you check if you're using the same code as mine?
 
 No, it's not same.
 My bad that I was not using linux-next for testing this patch.
 We tested on kgene/for-next where these changes still have not come.
 Just now I checked linux-next and found that it will crash at first line of 
 regmap_get_val_endian as there is no check for NULL on dev.
 
 I checked git history of regmap.c file and found recently this file has been
 modified
 for adding DT endianness binding support. Following are set of patches gone
 for this
 
 cf673fb regmap: Split regmap_get_endian() in two functions
 5844a8b regmap: Fix handling of volatile registers for format_write() chips
 45e1a27 regmap: of_regmap_get_endian() cleanup
 ba1b53f regmap: Fix DT endianess parsing logic
 d647c19 regmap: add DT endianness binding support.
 
 I think there should have been a check for NULL on dev in
 regmap_get_val_endian, so that if dev pointer exist then only it makes
 sense to get
 endianness property from DT. 
 
 I will suggest following fix in regmap.c for this. With following fix I
 tested it and it works well
 on linux-next also. So if you can confirm following fix is working for you
 then I can post this
 patch.
 

I tested the patch work.
But as Xiubo pointed in another mail, it may still cause other issues.
Looking at regmap.c, there're still some other places using the device pointer,
e.g. dev_xxx debug information and some tracepoints also take device pointer
as parameter(not sure if it will break if dev is NULL).
Another thing is that if dev is NULL, we may not be able to use regmap debugfs
feature which seems also not as our expected.

Maybe we could consider create device structure for each syscon compatible
device in syscon driver in of_syscon_register in first time which seems to
be reasonable.

Regards
Dong Aisheng

 
 Subject: [PATCH] regmap: fix NULL pointer dereference in
  regmap_get_val_endian
 
 Recent commits for getting reg endianess causing NULL pointer
 dereference if dev is passed NULL in regmap_init_mmio. This patch
 fixes this issue, and allows to parse reg endianess only if dev
 and dev-of_node exist.
 
 Signed-off-by: Pankaj Dubey pankaj.du...@samsung.com
 ---
  drivers/base/regmap/regmap.c |   23 ++-
  1 file changed, 14 insertions(+), 9 deletions(-)
 
 diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
 index f2281af..455a877 100644
 --- a/drivers/base/regmap/regmap.c
 +++ b/drivers/base/regmap/regmap.c
 @@ -477,7 +477,7 @@ static enum regmap_endian regmap_get_val_endian(struct
 device *dev,
   const struct regmap_bus *bus,
   const struct regmap_config *config)
  {
 - struct device_node *np = dev-of_node;
 + struct device_node *np;
   enum regmap_endian endian;
  
   /* Retrieve the endianness specification from the regmap config */
 @@ -487,15 +487,20 @@ static enum regmap_endian regmap_get_val_endian(struct
 device *dev,
   if (endian != REGMAP_ENDIAN_DEFAULT)
   return endian;
  
 - /* Parse the device's DT node for an endianness specification */
 - if (of_property_read_bool(np, big-endian))
 - endian = REGMAP_ENDIAN_BIG;
 - else if (of_property_read_bool(np, little-endian))
 - endian = REGMAP_ENDIAN_LITTLE;
 + /* If the dev and dev-of_node exist try to get endianness from DT
 */
 + if (dev  dev-of_node) {
 + np = dev-of_node;
  
 - /* If the endianness was specified in DT, use that */
 - if (endian != REGMAP_ENDIAN_DEFAULT)
 - return endian;
 + /* Parse the device's DT node for an 

RE: [PATCH v3] mfd: syscon: Decouple syscon interface from platform devices

2014-09-18 Thread li.xi...@freescale.com
[...]
  I think there should have been a check for NULL on dev in
  regmap_get_val_endian, so that if dev pointer exist then only it makes
  sense to get
  endianness property from DT.
 
  I will suggest following fix in regmap.c for this. With following fix I
  tested it and it works well
  on linux-next also. So if you can confirm following fix is working for you
  then I can post this
  patch.
 
 
 I tested the patch work.
 But as Xiubo pointed in another mail, it may still cause other issues.
 Looking at regmap.c, there're still some other places using the device 
 pointer,
 e.g. dev_xxx debug information and some tracepoints also take device pointer
 as parameter(not sure if it will break if dev is NULL).
 Another thing is that if dev is NULL, we may not be able to use regmap debugfs
 feature which seems also not as our expected.
 
 Maybe we could consider create device structure for each syscon compatible
 device in syscon driver in of_syscon_register in first time which seems to
 be reasonable.
 
 Regards
 Dong Aisheng
 
  
  Subject: [PATCH] regmap: fix NULL pointer dereference in
   regmap_get_val_endian
 
  Recent commits for getting reg endianess causing NULL pointer
  dereference if dev is passed NULL in regmap_init_mmio. This patch
  fixes this issue, and allows to parse reg endianess only if dev
  and dev-of_node exist.
 
  Signed-off-by: Pankaj Dubey pankaj.du...@samsung.com
  ---
   drivers/base/regmap/regmap.c |   23 ++-
   1 file changed, 14 insertions(+), 9 deletions(-)
 
  diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
  index f2281af..455a877 100644
  --- a/drivers/base/regmap/regmap.c
  +++ b/drivers/base/regmap/regmap.c
  @@ -477,7 +477,7 @@ static enum regmap_endian regmap_get_val_endian(struct
  device *dev,
  const struct regmap_bus *bus,
  const struct regmap_config *config)
   {
  -   struct device_node *np = dev-of_node;
  +   struct device_node *np;

And the 'np' must be NULL as default.

Isn't it ?

Thanks,

BRs
Xiubo

  enum regmap_endian endian;
 
  /* Retrieve the endianness specification from the regmap config */
  @@ -487,15 +487,20 @@ static enum regmap_endian regmap_get_val_endian(struct
  device *dev,
  if (endian != REGMAP_ENDIAN_DEFAULT)
  return endian;
 
  -   /* Parse the device's DT node for an endianness specification */
  -   if (of_property_read_bool(np, big-endian))
  -   endian = REGMAP_ENDIAN_BIG;
  -   else if (of_property_read_bool(np, little-endian))
  -   endian = REGMAP_ENDIAN_LITTLE;
  +   /* If the dev and dev-of_node exist try to get endianness from DT
  */
  +   if (dev  dev-of_node) {
  +   np = dev-of_node;
 
  -   /* If the endianness was specified in DT, use that */
  -   if (endian != REGMAP_ENDIAN_DEFAULT)
  -   return endian;
  +   /* Parse the device's DT node for an endianness
  specification */
  +   if (of_property_read_bool(np, big-endian))
  +   endian = REGMAP_ENDIAN_BIG;
  +   else if (of_property_read_bool(np, little-endian))
  +   endian = REGMAP_ENDIAN_LITTLE;
  +
  +   /* If the endianness was specified in DT, use that */
  +   if (endian != REGMAP_ENDIAN_DEFAULT)
  +   return endian;
  +   }
 
  /* Retrieve the endianness specification from the bus config */
  if (bus  bus-val_format_endian_default)
  --
 
  Thanks,
  Pankaj Dubey
 
   Regards
   Dong Aisheng
  
   
Thanks,
Pankaj Dubey
   
 Regards
 Dong Aisheng

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


RE: [PATCH v3] mfd: syscon: Decouple syscon interface from platform devices

2014-09-18 Thread Pankaj Dubey
Hi,

On September 18, 2014 1:26, Dong Aisheng wrote
 On Thu, Sep 18, 2014 at 11:33:26AM +0530, Pankaj Dubey wrote:
  Hi,
 
  Adding CC to Xiubo Li, Geert Uytterhoeven and Stephen Warren.
 
  On Thursday, September 18, 2014, Dong Aisheng wrote,
   On Wed, Sep 17, 2014 at 04:50:50PM +0530, Pankaj Dubey wrote:
Hi,
   
On Wednesday, September 17, 2014, Dong Aisheng Wrote,
 
  +   regmap = regmap_init_mmio(NULL, base,
  syscon_regmap_config);

 Does a NULL device pointer work?
   
Yes, it is safe, at least we are able to test on Exynos based SoC.
I have tested it with kgene/for-next kernel on Exynos3250.
Also it has been tested on Exynos5250 based Snow board with
3.17-rc5 based kernel by Vivek Gautam.
   
Patch V2 also has been tested by Borris Brezillon on AT91
platform.
   
   
  
   The kernel i tested was next-20140915 of linux-next.
  
   please see regmap_get_val_endian called in regmap_init function.
   static enum regmap_endian regmap_get_val_endian(struct device *dev,
   const struct regmap_bus *bus,
   const struct regmap_config
  *config) {
   struct device_node *np = dev-of_node;
   enum regmap_endian endian;
   ...
   }
   It will crash at the first line of dev-of_node if dev is NULL.
  
   Can you check if you're using the same code as mine?
 
  No, it's not same.
  My bad that I was not using linux-next for testing this patch.
  We tested on kgene/for-next where these changes still have not come.
  Just now I checked linux-next and found that it will crash at first
  line of regmap_get_val_endian as there is no check for NULL on dev.
 
  I checked git history of regmap.c file and found recently this file
  has been modified for adding DT endianness binding support. Following
  are set of patches gone for this
 
  cf673fb regmap: Split regmap_get_endian() in two functions 5844a8b
  regmap: Fix handling of volatile registers for format_write() chips
  45e1a27 regmap: of_regmap_get_endian() cleanup ba1b53f regmap: Fix DT
  endianess parsing logic
  d647c19 regmap: add DT endianness binding support.
 
  I think there should have been a check for NULL on dev in
  regmap_get_val_endian, so that if dev pointer exist then only it
  makes sense to get endianness property from DT.
 
  I will suggest following fix in regmap.c for this. With following fix
  I tested it and it works well on linux-next also. So if you can
  confirm following fix is working for you then I can post this patch.
 
 
 I tested the patch work.

Thanks for testing. In that case I will post this change, as I feel this
should be
fixed irrespective of my syscon patch.

 But as Xiubo pointed in another mail, it may still cause other issues.
 Looking at regmap.c, there're still some other places using the device
pointer, e.g.
 dev_xxx debug information and some tracepoints also take device pointer as
 parameter(not sure if it will break if dev is NULL).
 Another thing is that if dev is NULL, we may not be able to use regmap
debugfs
 feature which seems also not as our expected.
 

I would have preferred to check dev for NULL, as it's only at two places and
we could
still have debug prints for NULL dev, as normal pr_info instead of dev_info.

But Xiubo also pointed out that his patch [1] which updates syscon binding
information
will be useless if we pass NULL dev in regmap_init_mmio, which he posted
today,
and it requires dev pointer in regmap_get_val_endian function to read DT
property.

[1]: [PATCH] mfd: syscon: binding: Add syscon endianness support
  https://lkml.org/lkml/2014/9/18/67

So instead of adding dummy device or creating device structure, I would
prefer to get actual
device pointer corresponding to np passed in of_syscon_register function
as shown below:


static struct syscon *of_syscon_register(struct device_node *np)
 {
+   struct platform_device *pdev;
struct syscon *syscon;
struct regmap *regmap;
void __iomem *base;
@@ -142,7 +144,11 @@ static struct syscon *of_syscon_register(struct
device_node *np)
if (!base)
return ERR_PTR(-ENOMEM);
 
-   regmap = regmap_init_mmio(NULL, base, syscon_regmap_config);
+   pdev = of_find_device_by_node(np);
+   if (!(pdev-dev))
+   return ERR_PTR(-ENODEV);
+
+   regmap = regmap_init_mmio(pdev-dev, base, syscon_regmap_config);
if (IS_ERR(regmap)) {
pr_err(regmap init failed\n);
return ERR_CAST(regmap);
---

I have tested this in linux-next and it works well. In this way there won't
be any issues of 
dereferencing NULL pointer in regmap.c and at the same time, if DT has
{big,little}-endian
optional property in syscon device node, it will be taken care.

So I would wait for Arnd's opinion about above mentioned changes and then
post a new
change after addressing Arnd's minor comment along with this fix in next
revision.



RE: [PATCH v3] mfd: syscon: Decouple syscon interface from platform devices

2014-09-18 Thread Pankaj Dubey
Hi,

On September 18, 2014, Li.Xiubo wrote,
 Subject: RE: [PATCH v3] mfd: syscon: Decouple syscon interface from
platform
 devices
 
 [...]
   I think there should have been a check for NULL on dev in
   regmap_get_val_endian, so that if dev pointer exist then only it
   makes sense to get endianness property from DT.
  
   I will suggest following fix in regmap.c for this. With following
   fix I tested it and it works well on linux-next also. So if you can
   confirm following fix is working for you then I can post this patch.
  
 
  I tested the patch work.
  But as Xiubo pointed in another mail, it may still cause other issues.
  Looking at regmap.c, there're still some other places using the device
  pointer, e.g. dev_xxx debug information and some tracepoints also take
  device pointer as parameter(not sure if it will break if dev is NULL).
  Another thing is that if dev is NULL, we may not be able to use regmap
  debugfs feature which seems also not as our expected.
 
  Maybe we could consider create device structure for each syscon
  compatible device in syscon driver in of_syscon_register in first time
  which seems to be reasonable.
 
  Regards
  Dong Aisheng
 
   
   Subject: [PATCH] regmap: fix NULL pointer dereference in
   regmap_get_val_endian
  
   Recent commits for getting reg endianess causing NULL pointer
   dereference if dev is passed NULL in regmap_init_mmio. This patch
   fixes this issue, and allows to parse reg endianess only if dev and
   dev-of_node exist.
  
   Signed-off-by: Pankaj Dubey pankaj.du...@samsung.com
   ---
drivers/base/regmap/regmap.c |   23 ++-
1 file changed, 14 insertions(+), 9 deletions(-)
  
   diff --git a/drivers/base/regmap/regmap.c
   b/drivers/base/regmap/regmap.c index f2281af..455a877 100644
   --- a/drivers/base/regmap/regmap.c
   +++ b/drivers/base/regmap/regmap.c
   @@ -477,7 +477,7 @@ static enum regmap_endian
   regmap_get_val_endian(struct device *dev,
 const struct regmap_bus *bus,
 const struct regmap_config *config)
{
   - struct device_node *np = dev-of_node;
   + struct device_node *np;
 
 And the 'np' must be NULL as default.
 
 Isn't it ?
 


Yes. 

Thanks,
Pankaj Dubey

 Thanks,
 
 BRs
 Xiubo
 
 enum regmap_endian endian;
  
 /* Retrieve the endianness specification from the regmap config */
   @@ -487,15 +487,20 @@ static enum regmap_endian
   regmap_get_val_endian(struct device *dev,
 if (endian != REGMAP_ENDIAN_DEFAULT)
 return endian;
  
   - /* Parse the device's DT node for an endianness specification */
   - if (of_property_read_bool(np, big-endian))
   - endian = REGMAP_ENDIAN_BIG;
   - else if (of_property_read_bool(np, little-endian))
   - endian = REGMAP_ENDIAN_LITTLE;
   + /* If the dev and dev-of_node exist try to get endianness from DT
   */
   + if (dev  dev-of_node) {
   + np = dev-of_node;
  
   - /* If the endianness was specified in DT, use that */
   - if (endian != REGMAP_ENDIAN_DEFAULT)
   - return endian;
   + /* Parse the device's DT node for an endianness
   specification */
   + if (of_property_read_bool(np, big-endian))
   + endian = REGMAP_ENDIAN_BIG;
   + else if (of_property_read_bool(np, little-endian))
   + endian = REGMAP_ENDIAN_LITTLE;
   +
   + /* If the endianness was specified in DT, use that */
   + if (endian != REGMAP_ENDIAN_DEFAULT)
   + return endian;
   + }
  
 /* Retrieve the endianness specification from the bus config */
 if (bus  bus-val_format_endian_default)
   --
  
   Thanks,
   Pankaj Dubey
  
Regards
Dong Aisheng
   

 Thanks,
 Pankaj Dubey

  Regards
  Dong Aisheng
 
  
  
   ___
   linux-arm-kernel mailing list
   linux-arm-ker...@lists.infradead.org
   http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  

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


[PATCH] ASoC: samsung: Remove goni or aquila with the WM8994

2014-09-18 Thread Paul Bolle
On Thu, 2014-09-04 at 18:02 +0200, Arnd Bergmann wrote:
 On Thursday 04 September 2014, Paul Bolle wrote: 
  References to MACH_GONI and MACH_AQUILA can still be seen in v3.17-rc3
  and next-20140903. Note that as consequence SND_SOC_GONI_AQUILA_WM8994
  can not be set anymore.
  
 [...]

 I think it would be nice if you could submit a patch to remove the
 drivers from ASoC, then we can see if anybody complains.

Same thing for v3.17-rc5 and next-20140918. Let's see if we can remove
the goni or aquila with wm8994 driver.

Done on top of next-20140918. Untested.
-8-
From: Paul Bolle pebo...@tiscali.nl

Commit 28c8331d386a (ARM: S5PV210: Remove support for board files)
removed the Kconfig symbols MACH_GONI and MACH_AQUILA. As a result the
dependencies of SND_SOC_GONI_AQUILA_WM8994 can never be met. So remove
the unbuildable SoC I2S Audio support for AQUILA/GONI - WM8994.

Signed-off-by: Paul Bolle pebo...@tiscali.nl
---
 sound/soc/samsung/Kconfig   |  11 --
 sound/soc/samsung/Makefile  |   2 -
 sound/soc/samsung/goni_wm8994.c | 304 
 3 files changed, 317 deletions(-)
 delete mode 100644 sound/soc/samsung/goni_wm8994.c

diff --git a/sound/soc/samsung/Kconfig b/sound/soc/samsung/Kconfig
index 55a38697443d..9d9b149ad977 100644
--- a/sound/soc/samsung/Kconfig
+++ b/sound/soc/samsung/Kconfig
@@ -146,17 +146,6 @@ config SND_SOC_SMARTQ
select SND_SAMSUNG_I2S
select SND_SOC_WM8750
 
-config SND_SOC_GONI_AQUILA_WM8994
-   tristate SoC I2S Audio support for AQUILA/GONI - WM8994
-   depends on SND_SOC_SAMSUNG  (MACH_GONI || MACH_AQUILA)
-   depends on I2C=y
-   select SND_SAMSUNG_I2S
-   select MFD_WM8994
-   select SND_SOC_WM8994
-   help
- Say Y if you want to add support for SoC audio on goni or aquila
- with the WM8994.
-
 config SND_SOC_SAMSUNG_SMDK_SPDIF
tristate SoC S/PDIF Audio support for SMDK
depends on SND_SOC_SAMSUNG
diff --git a/sound/soc/samsung/Makefile b/sound/soc/samsung/Makefile
index 91505ddaaf95..c30293a67176 100644
--- a/sound/soc/samsung/Makefile
+++ b/sound/soc/samsung/Makefile
@@ -35,7 +35,6 @@ snd-soc-smdk-wm8994-objs := smdk_wm8994.o
 snd-soc-snow-objs := snow.o
 snd-soc-smdk-wm9713-objs := smdk_wm9713.o
 snd-soc-s3c64xx-smartq-wm8987-objs := smartq_wm8987.o
-snd-soc-goni-wm8994-objs := goni_wm8994.o
 snd-soc-smdk-spdif-objs := smdk_spdif.o
 snd-soc-smdk-wm8580pcm-objs := smdk_wm8580pcm.o
 snd-soc-smdk-wm8994pcm-objs := smdk_wm8994pcm.o
@@ -62,7 +61,6 @@ obj-$(CONFIG_SND_SOC_SNOW) += snd-soc-snow.o
 obj-$(CONFIG_SND_SOC_SAMSUNG_SMDK_WM9713) += snd-soc-smdk-wm9713.o
 obj-$(CONFIG_SND_SOC_SMARTQ) += snd-soc-s3c64xx-smartq-wm8987.o
 obj-$(CONFIG_SND_SOC_SAMSUNG_SMDK_SPDIF) += snd-soc-smdk-spdif.o
-obj-$(CONFIG_SND_SOC_GONI_AQUILA_WM8994) += snd-soc-goni-wm8994.o
 obj-$(CONFIG_SND_SOC_SMDK_WM8580_PCM) += snd-soc-smdk-wm8580pcm.o
 obj-$(CONFIG_SND_SOC_SMDK_WM8994_PCM) += snd-soc-smdk-wm8994pcm.o
 obj-$(CONFIG_SND_SOC_SPEYSIDE) += snd-soc-speyside.o
diff --git a/sound/soc/samsung/goni_wm8994.c b/sound/soc/samsung/goni_wm8994.c
deleted file mode 100644
index 3b527dcfc0aa..
--- a/sound/soc/samsung/goni_wm8994.c
+++ /dev/null
@@ -1,304 +0,0 @@
-/*
- * goni_wm8994.c
- *
- * Copyright (C) 2010 Samsung Electronics Co.Ltd
- * Author: Chanwoo Choi cw00.c...@samsung.com
- *
- *  This program is free software; you can redistribute  it and/or modify it
- *  under  the terms of  the GNU General  Public License as published by the
- *  Free Software Foundation;  either version 2 of the  License, or (at your
- *  option) any later version.
- *
- */
-
-#include linux/module.h
-#include sound/soc.h
-#include sound/jack.h
-
-#include asm/mach-types.h
-#include mach/gpio-samsung.h
-
-#include ../codecs/wm8994.h
-
-#define MACHINE_NAME   0
-#define CPU_VOICE_DAI  1
-
-static const char *aquila_str[] = {
-   [MACHINE_NAME] = aquila,
-   [CPU_VOICE_DAI] = aquila-voice-dai,
-};
-
-static struct snd_soc_card goni;
-static struct platform_device *goni_snd_device;
-
-/* 3.5 pie jack */
-static struct snd_soc_jack jack;
-
-/* 3.5 pie jack detection DAPM pins */
-static struct snd_soc_jack_pin jack_pins[] = {
-   {
-   .pin = Headset Mic,
-   .mask = SND_JACK_MICROPHONE,
-   }, {
-   .pin = Headset Stereophone,
-   .mask = SND_JACK_HEADPHONE | SND_JACK_MECHANICAL |
-   SND_JACK_AVOUT,
-   },
-};
-
-/* 3.5 pie jack detection gpios */
-static struct snd_soc_jack_gpio jack_gpios[] = {
-   {
-   .gpio = S5PV210_GPH0(6),
-   .name = DET_3.5,
-   .report = SND_JACK_HEADSET | SND_JACK_MECHANICAL |
-   SND_JACK_AVOUT,
-   .debounce_time = 200,
-   },
-};
-
-static const struct snd_soc_dapm_widget goni_dapm_widgets[] = {
-   SND_SOC_DAPM_SPK(Ext Left Spk, NULL),
-   SND_SOC_DAPM_SPK(Ext Right Spk, NULL

Re: [PATCH V6 0/8] drm/exynos: few patches to enhance bridge chip support

2014-09-18 Thread Laurent Pinchart
Hi Ajay,

On Wednesday 17 September 2014 15:43:04 Ajay kumar wrote:
 Hi Laurent,
 
 Please find the latest series here:
 http://www.spinics.net/lists/dri-devel/msg66740.html

Thank you. My comment was meant to be general though, not just for your patch 
series.

 On Wed, Sep 17, 2014 at 3:23 PM, Laurent Pinchart wrote:
  On Wednesday 30 July 2014 11:40:54 Thierry Reding wrote:

[snip]

  One other thing: how does the bridge know which mode to drive? I suspect
  that it can drive more than one mode? Can it freely be configured or
  does it have a predefined set of modes? If the latter, then according to
  what you said above there needs to be a way to configure the bridge (via
  DT?) so that it reports the mode matching the panel. I wonder if that
  should be handled completely in code, so that for example a bridge has a
  panel attached it can use the panel's .get_modes() and select a matching
  mode among the set that it supports.
  
  Yes, pretty please :-) I don't think it would be a good idea to duplicate
  mode information in the bridge DT node, as that's not a property of the
  bridge. Querying the mode at runtime is in my opinion a much better
  option, and would also allow switching between different modes at runtime
  when that makes sense.
  
  Now, I'm not sure whether it should be the bridge driver querying the
  panel driver directly, or the display controller driver doing it and then
  configuring the bridge accordingly. The latter seems more generic to me
  and doesn't rely on the assumption that the bridge output will always be
  directly connected to a panel.

-- 
Regards,

Laurent Pinchart

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


Re: ASoC: samsung: MACH_SMDKC100

2014-09-18 Thread Paul Bolle
Hi Kukjin,

On Sat, 2014-07-19 at 04:03 +0900, Kukjin Kim wrote:
 On 07/18/14 17:55, Paul Bolle wrote:
  On Wed, 2014-07-02 at 10:01 +0200, Paul Bolle wrote:
  Your commit 52ad6582ceb2 (ARM: S5PC100: no more support S5PC100 SoC
  landed in next-20140702. It removed the Kconfig symbol MACH_SMDKC100
  (and a lot of other stuff).
 
  Is the trivial patch to also remove the last two references to
  MACH_SMDKC100 from sound/soc/samsung/Kconfig/ queued somewhere? I don't
  think it was part of the series that included the above commit.
 
  Have you had time to look at this? Those last two references to
  MACH_SMDKC100 can still be seen in next-20140718.
 
 Yeah you're right. The MACH_SMDKC100 is no more required...
 
 I submitted its fixup to Mark and I think he will take it for v3.17.

What ever happened to that fixup? There are still (pointless) references
to MACH_SMDKC100 in v3.17-rc5 and in next-20140918.


Paul Bolle

--
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] ASoC: samsung: Remove PCM support for WM8580 on SMDK

2014-09-18 Thread Paul Bolle
On Thu, 2014-09-04 at 18:02 +0200, Arnd Bergmann wrote:
 On Thursday 04 September 2014, Paul Bolle wrote:
  Ditto for [...] MACH_SMDKC110, and MACH_SMDKV210. Note that
  here SND_SOC_SMDK_WM8580_PCM can not be set anymore.

 [...]
 I think it would be nice if you could submit a patch to remove the
 drivers from ASoC, then we can see if anybody complains.

Also the same thing for v3.17-rc5 and next-20140918. So let's see if we
can remove this driver too.

Done on top of next-20140918. Again untested.
8
From: Paul Bolle pebo...@tiscali.nl

Commit 28c8331d386a (ARM: S5PV210: Remove support for board files)
removed the Kconfig symbols MACH_SMDKC110 and MACH_SMDKV210. As a result
the dependencies of SND_SOC_SMDK_WM8580_PCM can never be met. So remove
the unbuildable SoC PCM Audio support for WM8580 on SMDK.

Signed-off-by: Paul Bolle pebo...@tiscali.nl
---
 sound/soc/samsung/Kconfig  |   9 --
 sound/soc/samsung/Makefile |   2 -
 sound/soc/samsung/smdk_wm8580pcm.c | 186 -
 3 files changed, 197 deletions(-)
 delete mode 100644 sound/soc/samsung/smdk_wm8580pcm.c

diff --git a/sound/soc/samsung/Kconfig b/sound/soc/samsung/Kconfig
index 9d9b149ad977..52fd0a446bdf 100644
--- a/sound/soc/samsung/Kconfig
+++ b/sound/soc/samsung/Kconfig
@@ -153,15 +153,6 @@ config SND_SOC_SAMSUNG_SMDK_SPDIF
help
  Say Y if you want to add support for SoC S/PDIF audio on the SMDK.
 
-config SND_SOC_SMDK_WM8580_PCM
-   tristate SoC PCM Audio support for WM8580 on SMDK
-   depends on SND_SOC_SAMSUNG  (MACH_SMDKV210 || MACH_SMDKC110)
-   depends on REGMAP_I2C
-   select SND_SOC_WM8580
-   select SND_SAMSUNG_PCM
-   help
- Say Y if you want to add support for SoC audio on the SMDK.
-
 config SND_SOC_SMDK_WM8994_PCM
tristate SoC PCM Audio support for WM8994 on SMDK
depends on SND_SOC_SAMSUNG
diff --git a/sound/soc/samsung/Makefile b/sound/soc/samsung/Makefile
index c30293a67176..51b471ace06f 100644
--- a/sound/soc/samsung/Makefile
+++ b/sound/soc/samsung/Makefile
@@ -36,7 +36,6 @@ snd-soc-snow-objs := snow.o
 snd-soc-smdk-wm9713-objs := smdk_wm9713.o
 snd-soc-s3c64xx-smartq-wm8987-objs := smartq_wm8987.o
 snd-soc-smdk-spdif-objs := smdk_spdif.o
-snd-soc-smdk-wm8580pcm-objs := smdk_wm8580pcm.o
 snd-soc-smdk-wm8994pcm-objs := smdk_wm8994pcm.o
 snd-soc-speyside-objs := speyside.o
 snd-soc-tobermory-objs := tobermory.o
@@ -61,7 +60,6 @@ obj-$(CONFIG_SND_SOC_SNOW) += snd-soc-snow.o
 obj-$(CONFIG_SND_SOC_SAMSUNG_SMDK_WM9713) += snd-soc-smdk-wm9713.o
 obj-$(CONFIG_SND_SOC_SMARTQ) += snd-soc-s3c64xx-smartq-wm8987.o
 obj-$(CONFIG_SND_SOC_SAMSUNG_SMDK_SPDIF) += snd-soc-smdk-spdif.o
-obj-$(CONFIG_SND_SOC_SMDK_WM8580_PCM) += snd-soc-smdk-wm8580pcm.o
 obj-$(CONFIG_SND_SOC_SMDK_WM8994_PCM) += snd-soc-smdk-wm8994pcm.o
 obj-$(CONFIG_SND_SOC_SPEYSIDE) += snd-soc-speyside.o
 obj-$(CONFIG_SND_SOC_TOBERMORY) += snd-soc-tobermory.o
diff --git a/sound/soc/samsung/smdk_wm8580pcm.c 
b/sound/soc/samsung/smdk_wm8580pcm.c
deleted file mode 100644
index 63d079303561..
--- a/sound/soc/samsung/smdk_wm8580pcm.c
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- *  sound/soc/samsung/smdk_wm8580pcm.c
- *
- *  Copyright (c) 2011 Samsung Electronics Co. Ltd
- *
- *  This program is free software; you can redistribute  it and/or  modify it
- *  under  the terms of  the GNU General  Public License as published by the
- *  Free Software Foundation;  either version 2 of the  License, or (at your
- *  option) any later version.
- */
-#include linux/module.h
-#include sound/soc.h
-#include sound/pcm_params.h
-#include sound/pcm.h
-
-#include asm/mach-types.h
-
-#include ../codecs/wm8580.h
-#include dma.h
-#include pcm.h
-
-/*
- * Board Settings:
- *  o '1' means 'ON'
- *  o '0' means 'OFF'
- *  o 'X' means 'Don't care'
- *
- * SMDK6410 Base B/D: CFG1-, CFG2-
- * SMDKC110, SMDKV210: CFGB11-100100, CFGB12-
- */
-
-#define SMDK_WM8580_EXT_OSC 1200
-#define SMDK_WM8580_EXT_MCLK 4096000
-#define SMDK_WM8580_EXT_VOICE 2048000
-
-static unsigned long mclk_freq;
-static unsigned long xtal_freq;
-
-/*
- * If MCLK clock directly gets from XTAL, we don't have to use PLL
- * to make MCLK, but if XTAL clock source connects with other codec
- * pin (like XTI), we should have to set codec's PLL to make MCLK.
- * Because Samsung SoC does not support pcmcdclk output like I2S.
- */
-
-static int smdk_wm8580_pcm_hw_params(struct snd_pcm_substream *substream,
- struct snd_pcm_hw_params *params)
-{
-   struct snd_soc_pcm_runtime *rtd = substream-private_data;
-   struct snd_soc_dai *codec_dai = rtd-codec_dai;
-   struct snd_soc_dai *cpu_dai = rtd-cpu_dai;
-   int rfs, ret;
-
-   switch (params_rate(params)) {
-   case 8000:
-   break;
-   default:
-   printk(KERN_ERR %s:%d Sampling Rate %u not supported!\n,
-   __func__, __LINE__, params_rate(params

Re: [PATCH v3] mfd: syscon: Decouple syscon interface from platform devices

2014-09-18 Thread Dong Aisheng
On Thu, Sep 18, 2014 at 03:06:59PM +0530, Pankaj Dubey wrote:
 Hi,
 
 On September 18, 2014 1:26, Dong Aisheng wrote
  On Thu, Sep 18, 2014 at 11:33:26AM +0530, Pankaj Dubey wrote:
   Hi,
  
   Adding CC to Xiubo Li, Geert Uytterhoeven and Stephen Warren.
  
   On Thursday, September 18, 2014, Dong Aisheng wrote,
On Wed, Sep 17, 2014 at 04:50:50PM +0530, Pankaj Dubey wrote:
 Hi,

 On Wednesday, September 17, 2014, Dong Aisheng Wrote,
  
   + regmap = regmap_init_mmio(NULL, base,
   syscon_regmap_config);
 
  Does a NULL device pointer work?

 Yes, it is safe, at least we are able to test on Exynos based SoC.
 I have tested it with kgene/for-next kernel on Exynos3250.
 Also it has been tested on Exynos5250 based Snow board with
 3.17-rc5 based kernel by Vivek Gautam.

 Patch V2 also has been tested by Borris Brezillon on AT91
 platform.


   
The kernel i tested was next-20140915 of linux-next.
   
please see regmap_get_val_endian called in regmap_init function.
static enum regmap_endian regmap_get_val_endian(struct device *dev,
const struct regmap_bus *bus,
const struct regmap_config
   *config) {
struct device_node *np = dev-of_node;
enum regmap_endian endian;
...
}
It will crash at the first line of dev-of_node if dev is NULL.
   
Can you check if you're using the same code as mine?
  
   No, it's not same.
   My bad that I was not using linux-next for testing this patch.
   We tested on kgene/for-next where these changes still have not come.
   Just now I checked linux-next and found that it will crash at first
   line of regmap_get_val_endian as there is no check for NULL on dev.
  
   I checked git history of regmap.c file and found recently this file
   has been modified for adding DT endianness binding support. Following
   are set of patches gone for this
  
   cf673fb regmap: Split regmap_get_endian() in two functions 5844a8b
   regmap: Fix handling of volatile registers for format_write() chips
   45e1a27 regmap: of_regmap_get_endian() cleanup ba1b53f regmap: Fix DT
   endianess parsing logic
   d647c19 regmap: add DT endianness binding support.
  
   I think there should have been a check for NULL on dev in
   regmap_get_val_endian, so that if dev pointer exist then only it
   makes sense to get endianness property from DT.
  
   I will suggest following fix in regmap.c for this. With following fix
   I tested it and it works well on linux-next also. So if you can
   confirm following fix is working for you then I can post this patch.
  
  
  I tested the patch work.
 
 Thanks for testing. In that case I will post this change, as I feel this
 should be
 fixed irrespective of my syscon patch.
 
  But as Xiubo pointed in another mail, it may still cause other issues.
  Looking at regmap.c, there're still some other places using the device
 pointer, e.g.
  dev_xxx debug information and some tracepoints also take device pointer as
  parameter(not sure if it will break if dev is NULL).
  Another thing is that if dev is NULL, we may not be able to use regmap
 debugfs
  feature which seems also not as our expected.
  
 
 I would have preferred to check dev for NULL, as it's only at two places and
 we could
 still have debug prints for NULL dev, as normal pr_info instead of dev_info.
 
 But Xiubo also pointed out that his patch [1] which updates syscon binding
 information
 will be useless if we pass NULL dev in regmap_init_mmio, which he posted
 today,
 and it requires dev pointer in regmap_get_val_endian function to read DT
 property.
 
 [1]: [PATCH] mfd: syscon: binding: Add syscon endianness support
   https://lkml.org/lkml/2014/9/18/67
 
 So instead of adding dummy device or creating device structure, I would
 prefer to get actual
 device pointer corresponding to np passed in of_syscon_register function
 as shown below:
 

I wonder this may not work at early stage before the devices are populated
from device tree.
My initial understanding that one important thing for your patch is
to address this issue, isn't it?
Many people have asked for this feature before.

Regards
Dong Aisheng

 
 static struct syscon *of_syscon_register(struct device_node *np)
  {
 + struct platform_device *pdev;
   struct syscon *syscon;
   struct regmap *regmap;
   void __iomem *base;
 @@ -142,7 +144,11 @@ static struct syscon *of_syscon_register(struct
 device_node *np)
   if (!base)
   return ERR_PTR(-ENOMEM);
  
 - regmap = regmap_init_mmio(NULL, base, syscon_regmap_config);
 + pdev = of_find_device_by_node(np);
 + if (!(pdev-dev))
 + return ERR_PTR(-ENODEV);
 +
 + regmap = regmap_init_mmio(pdev-dev, base, syscon_regmap_config);
   if (IS_ERR(regmap)) {
   pr_err(regmap init failed\n);
   return ERR_CAST(regmap);
 ---

[PATCH] drm/exynos: switch to universal plane API

2014-09-18 Thread Andrzej Hajda
The patch replaces legacy functions
drm_plane_init() / drm_crtc_init() with
drm_universal_plane_init() and drm_crtc_init_with_planes().
It allows to replace fake primary plane with the real one.

Signed-off-by: Andrzej Hajda a.ha...@samsung.com
---
Hi Inki,

I have tested this patch with trats board, it looks OK.
As a side effect it should solve fb refcounting issues
reported by me and Daniel Drake.

Regards
Andrzej
---
 drivers/gpu/drm/exynos/exynos_drm_crtc.c  | 63 ---
 drivers/gpu/drm/exynos/exynos_drm_drv.c   |  5 ++-
 drivers/gpu/drm/exynos/exynos_drm_plane.c | 17 +
 drivers/gpu/drm/exynos/exynos_drm_plane.h |  3 +-
 4 files changed, 47 insertions(+), 41 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos_drm_crtc.c 
b/drivers/gpu/drm/exynos/exynos_drm_crtc.c
index b68e58f..d2f713e 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_crtc.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_crtc.c
@@ -32,7 +32,6 @@ enum exynos_crtc_mode {
  * Exynos specific crtc structure.
  *
  * @drm_crtc: crtc object.
- * @drm_plane: pointer of private plane object for this crtc
  * @manager: the manager associated with this crtc
  * @pipe: a crtc index created at load() with a new crtc object creation
  * and the crtc object would be set to private-crtc array
@@ -46,7 +45,6 @@ enum exynos_crtc_mode {
  */
 struct exynos_drm_crtc {
struct drm_crtc drm_crtc;
-   struct drm_plane*plane;
struct exynos_drm_manager   *manager;
unsigned intpipe;
unsigned intdpms;
@@ -94,12 +92,12 @@ static void exynos_drm_crtc_commit(struct drm_crtc *crtc)
 
exynos_drm_crtc_dpms(crtc, DRM_MODE_DPMS_ON);
 
-   exynos_plane_commit(exynos_crtc-plane);
+   exynos_plane_commit(crtc-primary);
 
if (manager-ops-commit)
manager-ops-commit(manager);
 
-   exynos_plane_dpms(exynos_crtc-plane, DRM_MODE_DPMS_ON);
+   exynos_plane_dpms(crtc-primary, DRM_MODE_DPMS_ON);
 }
 
 static bool
@@ -123,10 +121,9 @@ exynos_drm_crtc_mode_set(struct drm_crtc *crtc, struct 
drm_display_mode *mode,
 {
struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc);
struct exynos_drm_manager *manager = exynos_crtc-manager;
-   struct drm_plane *plane = exynos_crtc-plane;
+   struct drm_framebuffer *fb = crtc-primary-fb;
unsigned int crtc_w;
unsigned int crtc_h;
-   int ret;
 
/*
 * copy the mode data adjusted by mode_fixup() into crtc-mode
@@ -134,29 +131,21 @@ exynos_drm_crtc_mode_set(struct drm_crtc *crtc, struct 
drm_display_mode *mode,
 */
memcpy(crtc-mode, adjusted_mode, sizeof(*adjusted_mode));
 
-   crtc_w = crtc-primary-fb-width - x;
-   crtc_h = crtc-primary-fb-height - y;
+   crtc_w = fb-width - x;
+   crtc_h = fb-height - y;
 
if (manager-ops-mode_set)
manager-ops-mode_set(manager, crtc-mode);
 
-   ret = exynos_plane_mode_set(plane, crtc, crtc-primary-fb, 0, 0, 
crtc_w, crtc_h,
-   x, y, crtc_w, crtc_h);
-   if (ret)
-   return ret;
-
-   plane-crtc = crtc;
-   plane-fb = crtc-primary-fb;
-   drm_framebuffer_reference(plane-fb);
-
-   return 0;
+   return exynos_plane_mode_set(crtc-primary, crtc, fb, 0, 0,
+crtc_w, crtc_h, x, y, crtc_w, crtc_h);
 }
 
 static int exynos_drm_crtc_mode_set_commit(struct drm_crtc *crtc, int x, int y,
  struct drm_framebuffer *old_fb)
 {
struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc);
-   struct drm_plane *plane = exynos_crtc-plane;
+   struct drm_framebuffer *fb = crtc-primary-fb;
unsigned int crtc_w;
unsigned int crtc_h;
int ret;
@@ -167,11 +156,11 @@ static int exynos_drm_crtc_mode_set_commit(struct 
drm_crtc *crtc, int x, int y,
return -EPERM;
}
 
-   crtc_w = crtc-primary-fb-width - x;
-   crtc_h = crtc-primary-fb-height - y;
+   crtc_w = fb-width - x;
+   crtc_h = fb-height - y;
 
-   ret = exynos_plane_mode_set(plane, crtc, crtc-primary-fb, 0, 0, 
crtc_w, crtc_h,
-   x, y, crtc_w, crtc_h);
+   ret = exynos_plane_mode_set(crtc-primary, crtc, fb, 0, 0,
+   crtc_w, crtc_h, x, y, crtc_w, crtc_h);
if (ret)
return ret;
 
@@ -279,6 +268,7 @@ static void exynos_drm_crtc_destroy(struct drm_crtc *crtc)
 
private-crtc[exynos_crtc-pipe] = NULL;
 
+   crtc-primary-funcs-destroy(crtc-primary);
drm_crtc_cleanup(crtc);
kfree(exynos_crtc);
 }
@@ -304,8 +294,7 @@ static int exynos_drm_crtc_set_property(struct drm_crtc 
*crtc,
exynos_drm_crtc_commit(crtc);
break;
case CRTC_MODE_BLANK:
-   

Re: [PATCH] drm/exynos: fix plane-framebuffer linkage

2014-09-18 Thread Daniel Drake
On Thu, Sep 18, 2014 at 12:39 AM, Daniel Vetter dan...@ffwll.ch wrote:
 On Wed, Sep 17, 2014 at 6:41 PM, Daniel Drake dr...@endlessm.com wrote:
 2. drm_mode_rmfb then calls drm_framebuffer_remove, which calls
 drm_mode_set_config_internal() in order to turn off the CRTC, dropping
 another reference in the process.
 if (tmp-old_fb)
 drm_framebuffer_unreference(tmp-old_fb);

 3. drm_framebuffer_remove calls drm_plane_force_disable() which drops
 another reference:
 /* disconnect the plane from the fb and crtc: */
 __drm_framebuffer_unreference(old_fb);

 If 3. here is about the primary plane then this won't happen, since
 the primary plane pointerreference has already been cleared in step
 2.

I just checked - as Joonyoung suspects, the plane being force disabled
in step 3 is the private exynos-drm plane. So thats an issue - but at
least now I have a complete understanding of the problem.

Sounds like that will also be fixed by moving to universal planes.
I'll wait for Andrzej's patch.

Thanks!
Daniel
--
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 1/2] usb: host: ehci-exynos: Remove unnecessary usb-phy support

2014-09-18 Thread Alan Stern
On Thu, 18 Sep 2014, Vivek Gautam wrote:

 Now that we have completely moved from older USB-PHY drivers
 to newer GENERIC-PHY drivers for PHYs available with USB controllers
 on Exynos series of SoCs, we can remove the support for the same
 in our host drivers too.
 
 We also defer the probe for our host in case we end up getting
 EPROBE_DEFER error when getting PHYs.

Better now.  But I didn't notice this the first time:

 + if (IS_ERR(phy)) {
 + ret = PTR_ERR(phy);
 + if (ret == -EPROBE_DEFER) {
 + return ret;
 + } else if (ret != -ENOSYS  ret != -ENODEV) {
 + dev_err(dev,
 + Error retrieving usb2 phy: %d\n, ret);
 + return PTR_ERR(phy);

It doesn't make any real difference, but wouldn't you prefer to say
return ret here?

With or without that change, for both these two patches:

Acked-by: Alan Stern st...@rowland.harvard.edu

--
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/5] Second batch of cleanups for cros_ec

2014-09-18 Thread Javier Martinez Canillas
Hello,

This is a second batch of cleanups patches for the mfd cros_ec
driver and its subdevices drivers. The first batch of cleanups
was posted by Doug Anderson [0] and have already been merged.
The patches were picked from the ChromeOS 3.8 kernel and after
these no cleanups patches for cros_ec are left, only commits
that add cros ec support not yet available in mainline.

This is a fourth version of the patch series that addresses
issues pointed out by Lee Jones on v3 [1]. I dropped patch #6
from this version since that change will make more sense once
the cros_ec_dev driver is added and the cells array isn't empty.

There is almost no functionality added on this series but the
idea is to reduce the delta between the mainline drivers and
the ones in the downstream Chrome OS 3.8 kernel so the missing
functionality can be added on top once these cleanups patches
are merged. The missing functionality currently in mainline is:

- Chrome OS Embedded Controller userspace device interface
- Chrome OS Embedded Controller Low Pin Count (LPC) inteface
- Access to vboot context stored on a block device
- Access to vboot context stored on EC's nvram

The patches in this series are authored by different people
(all on cc) and consist of the following:

Andrew Bresticker (3):
  mfd: cros_ec: stop calling -cmd_xfer() directly
  mfd: cros_ec: move locking into cros_ec_cmd_xfer
  mfd: cros_ec: wait for completion of commands that return IN_PROGRESS

Derek Basehore (1):
  i2c: i2c-cros-ec-tunnel: Set retries to 3

Doug Anderson (1):
  mfd: cros_ec: Delay for 50ms when we see EC_CMD_REBOOT_EC

 drivers/i2c/busses/i2c-cros-ec-tunnel.c |  5 +++-
 drivers/input/keyboard/cros_ec_keyb.c   |  2 +-
 drivers/mfd/cros_ec.c   | 48 +
 drivers/mfd/cros_ec_spi.c   | 20 +++---
 include/linux/mfd/cros_ec.h | 24 -
 5 files changed, 80 insertions(+), 19 deletions(-)

Patches #1 and #2 can be applied independently but patches #3, #4 and #5
rely on the previous one so they should be applied together and in that order.

Best regards,
Javier

[0]: https://www.mail-archive.com/linux-input@vger.kernel.org/msg11385.html
[1]: 
https://www.mail-archive.com/linux-samsung-soc@vger.kernel.org/msg36505.html

--
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 1/5] mfd: cros_ec: Delay for 50ms when we see EC_CMD_REBOOT_EC

2014-09-18 Thread Javier Martinez Canillas
From: Doug Anderson diand...@chromium.org

If someone sends a EC_CMD_REBOOT_EC to the EC, the EC will likely be
unresponsive for quite a while.  Add a delay to the end of the command
to prevent random failures of future commands.

NOTES:
* This could be optimized a bit by simply delaying the next command
  sent, but EC_CMD_REBOOT_EC is such a rare command that the extra
  complexity doesn't seem worth it.
* This is a bit of an ugly hack since the SPI driver is effectively
  snooping on the communication and making a lot of assumptions.  It
  would be nice to architect in some better solution long term.
* This same logic probably needs to be applied to the i2c driver.

Signed-off-by: Doug Anderson diand...@chromium.org
Reviewed-by: Randall Spangler rspang...@chromium.org
Reviewed-by: Vadim Bendebury vben...@chromium.org
Signed-off-by: Javier Martinez Canillas javier.marti...@collabora.co.uk
Acked-by: Lee Jones lee.jo...@linaro.org
---
 drivers/mfd/cros_ec_spi.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/drivers/mfd/cros_ec_spi.c b/drivers/mfd/cros_ec_spi.c
index 588c700..b396705 100644
--- a/drivers/mfd/cros_ec_spi.c
+++ b/drivers/mfd/cros_ec_spi.c
@@ -65,6 +65,12 @@
   */
 #define EC_SPI_RECOVERY_TIME_NS(200 * 1000)
 
+/*
+ * The EC is unresponsive for a time after a reboot command.  Add a
+ * simple delay to make sure that the bus stays locked.
+ */
+#define EC_REBOOT_DELAY_MS 50
+
 /**
  * struct cros_ec_spi - information about a SPI-connected EC
  *
@@ -318,6 +324,9 @@ static int cros_ec_cmd_xfer_spi(struct cros_ec_device 
*ec_dev,
 
ret = len;
 exit:
+   if (ec_msg-command == EC_CMD_REBOOT_EC)
+   msleep(EC_REBOOT_DELAY_MS);
+
mutex_unlock(ec_spi-lock);
return ret;
 }
-- 
2.1.0

--
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 5/5] mfd: cros_ec: wait for completion of commands that return IN_PROGRESS

2014-09-18 Thread Javier Martinez Canillas
From: Andrew Bresticker abres...@chromium.org

When an EC command returns EC_RES_IN_PROGRESS, we need to query
the state of the EC until it indicates that it is no longer busy.
Do this in cros_ec_cmd_xfer() under the EC's mutex so that other
commands (e.g. keyboard, I2C passtru) aren't issued to the EC while
it is working on the in-progress command.

The 10 milliseconds delay and the number of retries are the values
that were used by the flashrom tool when retrying commands.

Signed-off-by: Andrew Bresticker abres...@chromium.org
Reviewed-by: Simon Glass s...@chromium.org
Signed-off-by: Javier Martinez Canillas javier.marti...@collabora.co.uk
---

Changes since v3:
 - Fix us time and use raw values instead of a define. Suggested by Lee Jones.

Changes since v2:
 - Explain in the commit message from where the delay and retry values come 
from.
   Commented by Andrew Bresticker.
 - Move the needed definitions inside the if block. Suggested by Lee Jones.
 - Only check if result is EC_RES_IN_PROGRESS instead of checking also if ret is
   -EAGAIN since the former implies the later. Suggested by Lee Jones.
 - Use usleep_range() instead of msleep() since doesn't handle values between 
1~20.
   Suggested by Lee Jones.

Changes since v1:
 - The *xfer() calls don't modify the passed cros_ec_command so there is
   no need to populate it inside the for loop. Suggested by Lee Jones.

 drivers/mfd/cros_ec.c | 33 +
 1 file changed, 33 insertions(+)

diff --git a/drivers/mfd/cros_ec.c b/drivers/mfd/cros_ec.c
index c53804a..fc0c81e 100644
--- a/drivers/mfd/cros_ec.c
+++ b/drivers/mfd/cros_ec.c
@@ -23,6 +23,9 @@
 #include linux/mfd/core.h
 #include linux/mfd/cros_ec.h
 #include linux/mfd/cros_ec_commands.h
+#include linux/delay.h
+
+#define EC_COMMAND_RETRIES 50
 
 int cros_ec_prepare_tx(struct cros_ec_device *ec_dev,
   struct cros_ec_command *msg)
@@ -69,6 +72,36 @@ int cros_ec_cmd_xfer(struct cros_ec_device *ec_dev,
 
mutex_lock(ec_dev-lock);
ret = ec_dev-cmd_xfer(ec_dev, msg);
+   if (msg-result == EC_RES_IN_PROGRESS) {
+   int i;
+   struct cros_ec_command status_msg;
+   struct ec_response_get_comms_status status;
+
+   status_msg.version = 0;
+   status_msg.command = EC_CMD_GET_COMMS_STATUS;
+   status_msg.outdata = NULL;
+   status_msg.outsize = 0;
+   status_msg.indata = (uint8_t *)status;
+   status_msg.insize = sizeof(status);
+
+   /*
+* Query the EC's status until it's no longer busy or
+* we encounter an error.
+*/
+   for (i = 0; i  EC_COMMAND_RETRIES; i++) {
+   usleep_range(1, 11000);
+
+   ret = ec_dev-cmd_xfer(ec_dev, status_msg);
+   if (ret  0)
+   break;
+
+   msg-result = status_msg.result;
+   if (status_msg.result != EC_RES_SUCCESS)
+   break;
+   if (!(status.flags  EC_COMMS_STATUS_PROCESSING))
+   break;
+   }
+   }
mutex_unlock(ec_dev-lock);
 
return ret;
-- 
2.1.0

--
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 4/5] mfd: cros_ec: move locking into cros_ec_cmd_xfer

2014-09-18 Thread Javier Martinez Canillas
From: Andrew Bresticker abres...@chromium.org

Now that there's a central cros_ec_cmd_xfer(), move the locking
out of the SPI driver.

Signed-off-by: Andrew Bresticker abres...@chromium.org
Reviewed-by: Simon Glass s...@chromium.org
Signed-off-by: Javier Martinez Canillas javier.marti...@collabora.co.uk
Reviewed-by: Doug Anderson diand...@chromium.org
Acked-by: Lee Jones lee.jo...@linaro.org
---

Changes since v1:
 - Remove mention of LPC driver in the commit message since it does not
   exist in mainline yet. Suggested by Doug Anderson.

 drivers/mfd/cros_ec.c | 10 +-
 drivers/mfd/cros_ec_spi.c | 11 ---
 2 files changed, 9 insertions(+), 12 deletions(-)

diff --git a/drivers/mfd/cros_ec.c b/drivers/mfd/cros_ec.c
index a9faebd..c53804a 100644
--- a/drivers/mfd/cros_ec.c
+++ b/drivers/mfd/cros_ec.c
@@ -65,7 +65,13 @@ EXPORT_SYMBOL(cros_ec_check_result);
 int cros_ec_cmd_xfer(struct cros_ec_device *ec_dev,
 struct cros_ec_command *msg)
 {
-   return ec_dev-cmd_xfer(ec_dev, msg);
+   int ret;
+
+   mutex_lock(ec_dev-lock);
+   ret = ec_dev-cmd_xfer(ec_dev, msg);
+   mutex_unlock(ec_dev-lock);
+
+   return ret;
 }
 EXPORT_SYMBOL(cros_ec_cmd_xfer);
 
@@ -98,6 +104,8 @@ int cros_ec_register(struct cros_ec_device *ec_dev)
return -ENOMEM;
}
 
+   mutex_init(ec_dev-lock);
+
err = mfd_add_devices(dev, 0, cros_devs,
  ARRAY_SIZE(cros_devs),
  NULL, ec_dev-irq, NULL);
diff --git a/drivers/mfd/cros_ec_spi.c b/drivers/mfd/cros_ec_spi.c
index b396705..bf6e08e 100644
--- a/drivers/mfd/cros_ec_spi.c
+++ b/drivers/mfd/cros_ec_spi.c
@@ -79,13 +79,11 @@
  * if no record
  * @end_of_msg_delay: used to set the delay_usecs on the spi_transfer that
  *  is sent when we want to turn off CS at the end of a transaction.
- * @lock: mutex to ensure only one user of cros_ec_cmd_xfer_spi at a time
  */
 struct cros_ec_spi {
struct spi_device *spi;
s64 last_transfer_ns;
unsigned int end_of_msg_delay;
-   struct mutex lock;
 };
 
 static void debug_packet(struct device *dev, const char *name, u8 *ptr,
@@ -232,13 +230,6 @@ static int cros_ec_cmd_xfer_spi(struct cros_ec_device 
*ec_dev,
int sum;
int ret = 0, final_ret;
 
-   /*
-* We have the shared ec_dev buffer plus we do lots of separate spi_sync
-* calls, so we need to make sure only one person is using this at a
-* time.
-*/
-   mutex_lock(ec_spi-lock);
-
len = cros_ec_prepare_tx(ec_dev, ec_msg);
dev_dbg(ec_dev-dev, prepared, len=%d\n, len);
 
@@ -327,7 +318,6 @@ exit:
if (ec_msg-command == EC_CMD_REBOOT_EC)
msleep(EC_REBOOT_DELAY_MS);
 
-   mutex_unlock(ec_spi-lock);
return ret;
 }
 
@@ -359,7 +349,6 @@ static int cros_ec_spi_probe(struct spi_device *spi)
if (ec_spi == NULL)
return -ENOMEM;
ec_spi-spi = spi;
-   mutex_init(ec_spi-lock);
ec_dev = devm_kzalloc(dev, sizeof(*ec_dev), GFP_KERNEL);
if (!ec_dev)
return -ENOMEM;
-- 
2.1.0

--
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 3/5] mfd: cros_ec: stop calling -cmd_xfer() directly

2014-09-18 Thread Javier Martinez Canillas
From: Andrew Bresticker abres...@chromium.org

Instead of having users of the ChromeOS EC call the interface-specific
cmd_xfer() callback directly, introduce a central cros_ec_cmd_xfer()
to use instead.  This will allow us to put all the locking and retry
logic in one place instead of duplicating it across the different
drivers.

Signed-off-by: Andrew Bresticker abres...@chromium.org
Reviewed-by: Simon Glass s...@chromium.org
Signed-off-by: Javier Martinez Canillas javier.marti...@collabora.co.uk
Reviewed-by: Doug Anderson diand...@chromium.org
Acked-by: Lee Jones lee.jo...@linaro.org
---
 drivers/i2c/busses/i2c-cros-ec-tunnel.c |  2 +-
 drivers/input/keyboard/cros_ec_keyb.c   |  2 +-
 drivers/mfd/cros_ec.c   |  7 +++
 include/linux/mfd/cros_ec.h | 24 ++--
 4 files changed, 27 insertions(+), 8 deletions(-)

diff --git a/drivers/i2c/busses/i2c-cros-ec-tunnel.c 
b/drivers/i2c/busses/i2c-cros-ec-tunnel.c
index 97e6369..ec5c38d 100644
--- a/drivers/i2c/busses/i2c-cros-ec-tunnel.c
+++ b/drivers/i2c/busses/i2c-cros-ec-tunnel.c
@@ -229,7 +229,7 @@ static int ec_i2c_xfer(struct i2c_adapter *adap, struct 
i2c_msg i2c_msgs[],
msg.indata = response;
msg.insize = response_len;
 
-   result = bus-ec-cmd_xfer(bus-ec, msg);
+   result = cros_ec_cmd_xfer(bus-ec, msg);
if (result  0)
goto exit;
 
diff --git a/drivers/input/keyboard/cros_ec_keyb.c 
b/drivers/input/keyboard/cros_ec_keyb.c
index 8c09b3e..462bfcb 100644
--- a/drivers/input/keyboard/cros_ec_keyb.c
+++ b/drivers/input/keyboard/cros_ec_keyb.c
@@ -157,7 +157,7 @@ static int cros_ec_keyb_get_state(struct cros_ec_keyb 
*ckdev, uint8_t *kb_state)
.insize = ckdev-cols,
};
 
-   return ckdev-ec-cmd_xfer(ckdev-ec, msg);
+   return cros_ec_cmd_xfer(ckdev-ec, msg);
 }
 
 static irqreturn_t cros_ec_keyb_irq(int irq, void *data)
diff --git a/drivers/mfd/cros_ec.c b/drivers/mfd/cros_ec.c
index 4873f9c..a9faebd 100644
--- a/drivers/mfd/cros_ec.c
+++ b/drivers/mfd/cros_ec.c
@@ -62,6 +62,13 @@ int cros_ec_check_result(struct cros_ec_device *ec_dev,
 }
 EXPORT_SYMBOL(cros_ec_check_result);
 
+int cros_ec_cmd_xfer(struct cros_ec_device *ec_dev,
+struct cros_ec_command *msg)
+{
+   return ec_dev-cmd_xfer(ec_dev, msg);
+}
+EXPORT_SYMBOL(cros_ec_cmd_xfer);
+
 static const struct mfd_cell cros_devs[] = {
{
.name = cros-ec-keyb,
diff --git a/include/linux/mfd/cros_ec.h b/include/linux/mfd/cros_ec.h
index fcbe9d1..0e166b9 100644
--- a/include/linux/mfd/cros_ec.h
+++ b/include/linux/mfd/cros_ec.h
@@ -62,10 +62,6 @@ struct cros_ec_command {
  * @dev: Device pointer
  * @was_wake_device: true if this device was set to wake the system from
  * sleep at the last suspend
- * @cmd_xfer: send command to EC and get response
- * Returns the number of bytes received if the communication succeeded, but
- * that doesn't mean the EC was happy with the command. The caller
- * should check msg.result for the EC's result code.
  *
  * @priv: Private data
  * @irq: Interrupt to use
@@ -82,6 +78,10 @@ struct cros_ec_command {
  * @dout_size: size of dout buffer to allocate (zero to use static dout)
  * @parent: pointer to parent device (e.g. i2c or spi device)
  * @wake_enabled: true if this device can wake the system from sleep
+ * @cmd_xfer: send command to EC and get response
+ * Returns the number of bytes received if the communication succeeded, but
+ * that doesn't mean the EC was happy with the command. The caller
+ * should check msg.result for the EC's result code.
  * @lock: one transaction at a time
  */
 struct cros_ec_device {
@@ -92,8 +92,6 @@ struct cros_ec_device {
struct device *dev;
bool was_wake_device;
struct class *cros_class;
-   int (*cmd_xfer)(struct cros_ec_device *ec,
-   struct cros_ec_command *msg);
 
/* These are used to implement the platform-specific interface */
void *priv;
@@ -104,6 +102,8 @@ struct cros_ec_device {
int dout_size;
struct device *parent;
bool wake_enabled;
+   int (*cmd_xfer)(struct cros_ec_device *ec,
+   struct cros_ec_command *msg);
struct mutex lock;
 };
 
@@ -153,6 +153,18 @@ int cros_ec_check_result(struct cros_ec_device *ec_dev,
 struct cros_ec_command *msg);
 
 /**
+ * cros_ec_cmd_xfer - Send a command to the ChromeOS EC
+ *
+ * Call this to send a command to the ChromeOS EC.  This should be used
+ * instead of calling the EC's cmd_xfer() callback directly.
+ *
+ * @ec_dev: EC device
+ * @msg: Message to write
+ */
+int cros_ec_cmd_xfer(struct cros_ec_device *ec_dev,
+struct cros_ec_command *msg);
+
+/**
  * cros_ec_remove - Remove a ChromeOS EC
  *
  * Call this to deregister a ChromeOS EC, then clean up any private data.
-- 
2.1.0

--
To unsubscribe from this list: send the line 

[PATCH v4 2/5] i2c: i2c-cros-ec-tunnel: Set retries to 3

2014-09-18 Thread Javier Martinez Canillas
From: Derek Basehore dbaseh...@chromium.org

Since the i2c bus can get wedged on the EC sometimes, set the number of retries
to 3. Since we un-wedge the bus immediately after the wedge happens, this is the
correct fix since only one transfer will fail.

Signed-off-by: Derek Basehore dbaseh...@chromium.org
Reviewed-by: Doug Anderson diand...@chromium.org
Acked-by: Wolfram Sang w...@the-dreams.de
Signed-off-by: Javier Martinez Canillas javier.marti...@collabora.co.uk
---
 drivers/i2c/busses/i2c-cros-ec-tunnel.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/i2c/busses/i2c-cros-ec-tunnel.c 
b/drivers/i2c/busses/i2c-cros-ec-tunnel.c
index 3c15dcc..97e6369 100644
--- a/drivers/i2c/busses/i2c-cros-ec-tunnel.c
+++ b/drivers/i2c/busses/i2c-cros-ec-tunnel.c
@@ -16,6 +16,8 @@
 #include linux/platform_device.h
 #include linux/slab.h
 
+#define I2C_MAX_RETRIES 3
+
 /**
  * struct ec_i2c_device - Driver data for I2C tunnel
  *
@@ -290,6 +292,7 @@ static int ec_i2c_probe(struct platform_device *pdev)
bus-adap.algo_data = bus;
bus-adap.dev.parent = pdev-dev;
bus-adap.dev.of_node = np;
+   bus-adap.retries = I2C_MAX_RETRIES;
 
err = i2c_add_adapter(bus-adap);
if (err) {
-- 
2.1.0

--
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 00/33] thermal: exynos: convert the driver to use per-SoC type operations

2014-09-18 Thread Bartlomiej Zolnierkiewicz
Hi,

This patch series replaces the hardware registers abstractions in
the Exynos thermal driver by the usage of per-SoC type operations.
Such solution provides simpler, easier to understand code and
allows removal of ~250 LOCs (~11% of the whole source code) from
the driver.  Some other driver improvements are now also possible
thanks to these changes but are scheduled at later time (like
consolidating code for clearing IRQs using INTCLEAR register).

The patchset should not cause any functionality changes.  This
means that unless there are some bugs in the patches itself there
should be no behavior changes for the driver (this also includes
lack of changes in the way hardware is accessed by the driver).

All testing was done on (Exynos4412 SoC based) ODROID U3 board
(some additional patches are needed to make the Exynos thermal
driver work on this hardware).

Depends on:
- 'next' branch of linux-soc-thermal.git kernel tree from Eduardo
- [PATCH] thermal: exynos: use correct offset for TMU_CONTROL
  register on Exynos5260
  (http://www.mail-archive.com/linux-samsung-soc@vger.kernel.org/msg36529.html)

Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung RD Institute Poland
Samsung Electronics


Bartlomiej Zolnierkiewicz (33):
  thermal: exynos: remove needless triminfo_data abstraction
  thermal: exynos: remove needless tmu_status abstraction
  thermal: exynos: remove needless threshold_temp abstraction
  thermal: exynos: remove needless triminfo_ctrl abstraction
  thermal: exynos: remove needless test_mux_addr_shift abstraction
  thermal: exynos: remove needless therm_trip_[mode,mask]_shift
abstractions
  thermal: exynos: remove needless therm_trip_en_shift abstraction
  thermal: exynos: remove needless emul_temp_shift abstraction
  thermal: exynos: remove needless emul_time_shift abstraction
  thermal: exynos: replace tmu_irqstatus check by Exynos5440 one
  thermal: exynos: replace tmu_pmin check by Exynos5440 one
  thermal: exynos: simplify HW_TRIP level setting
  thermal: exynos: replace threshold_falling check by Exynos SoC type
one
  thermal: exynos: remove TMU_SUPPORT_READY_STATUS flag
  thermal: exynos: remove TMU_SUPPORT_TRIM_RELOAD flag
  thermal: exynos: add sanitize_temp_error() helper
  thermal: exynos: add get_th_reg() helper
  thermal: exynos: add -tmu_initialize method
  thermal: exynos: add get_con_reg() helper
  thermal: exynos: add -tmu_control method
  thermal: exynos: add -tmu_read method
  thermal: exynos: add get_emul_con_reg() helper
  thermal: exynos: add -tmu_set_emulation method
  thermal: exynos: add -tmu_clear_irqs method
  thermal: exynos: remove TMU_SUPPORT_FALLING_TRIP flag
  thermal: exynos: remove TMU_SUPPORT_EMUL_TIME flag
  thermal: exynos: remove TMU_SUPPORT_EMULATION flag
  thermal: exynos: remove TMU_SUPPORT_ADDRESS_MULTIPLE flag
  thermal: exynos: remove TMU_SUPPORT_MULTI_INST flag
  thermal: exynos: remove test_mux pdata field
  thermal: exynos: remove SoC type ifdefs
  thermal: exynos: remove __EXYNOS5420_TMU_DATA macro
  thermal: exynos: remove exynos_tmu_data.h include

 drivers/thermal/samsung/exynos_thermal_common.h |   1 -
 drivers/thermal/samsung/exynos_tmu.c| 706 +---
 drivers/thermal/samsung/exynos_tmu.h| 131 +
 drivers/thermal/samsung/exynos_tmu_data.c   | 260 +
 drivers/thermal/samsung/exynos_tmu_data.h   | 174 --
 5 files changed, 509 insertions(+), 763 deletions(-)
 delete mode 100644 drivers/thermal/samsung/exynos_tmu_data.h

-- 
1.8.2.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 09/33] thermal: exynos: remove needless emul_time_shift abstraction

2014-09-18 Thread Bartlomiej Zolnierkiewicz
reg-emul_time_shift is used only in exynos_tmu_set_emulation()
and accessed only if TMU_SUPPORT_EMUL_TIME flag is set.  This
flag is not set for Exynos4210 and Exynos5440 (reg-emul_time_shift
field is not even assigned in exynos[4210,5440]_tmu_registers
and is assigned to identical value for all other SoC types) so
the abstraction is not needed and can be removed.

There should be no functional changes caused by this patch.

Cc: Naveen Krishna Chatradhi ch.nav...@samsung.com
Cc: Amit Daniel Kachhap amit.dan...@samsung.com
Cc: Lukasz Majewski l.majew...@samsung.com
Cc: Eduardo Valentin edubez...@gmail.com
Cc: Zhang Rui rui.zh...@intel.com
Signed-off-by: Bartlomiej Zolnierkiewicz b.zolnier...@samsung.com
Acked-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/thermal/samsung/exynos_tmu.c  | 4 ++--
 drivers/thermal/samsung/exynos_tmu.h  | 2 --
 drivers/thermal/samsung/exynos_tmu_data.c | 4 
 3 files changed, 2 insertions(+), 8 deletions(-)

diff --git a/drivers/thermal/samsung/exynos_tmu.c 
b/drivers/thermal/samsung/exynos_tmu.c
index 974c337..a4ed576 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -365,8 +365,8 @@ static int exynos_tmu_set_emulation(void *drv_data, 
unsigned long temp)
temp /= MCELSIUS;
 
if (TMU_SUPPORTS(pdata, EMUL_TIME)) {
-   val = ~(EXYNOS_EMUL_TIME_MASK  reg-emul_time_shift);
-   val |= (EXYNOS_EMUL_TIME  reg-emul_time_shift);
+   val = ~(EXYNOS_EMUL_TIME_MASK  
EXYNOS_EMUL_TIME_SHIFT);
+   val |= (EXYNOS_EMUL_TIME  EXYNOS_EMUL_TIME_SHIFT);
}
val = ~(EXYNOS_EMUL_DATA_MASK  EXYNOS_EMUL_DATA_SHIFT);
val |= (temp_to_code(data, temp)  EXYNOS_EMUL_DATA_SHIFT) |
diff --git a/drivers/thermal/samsung/exynos_tmu.h 
b/drivers/thermal/samsung/exynos_tmu.h
index 649a654..6567293 100644
--- a/drivers/thermal/samsung/exynos_tmu.h
+++ b/drivers/thermal/samsung/exynos_tmu.h
@@ -96,7 +96,6 @@ enum soc_type {
  * @intclr_rise_mask: mask bits of all rising interrupt bits.
  * @intclr_fall_mask: mask bits of all rising interrupt bits.
  * @emul_con: TMU emulation controller register.
- * @emul_time_shift: shift bits of emulation time.
  * @tmu_irqstatus: register to find which TMU generated interrupts.
  * @tmu_pmin: register to get/set the Pmin value.
  */
@@ -126,7 +125,6 @@ struct exynos_tmu_registers {
u32 intclr_rise_mask;
 
u32 emul_con;
-   u32 emul_time_shift;
 
u32 tmu_irqstatus;
u32 tmu_pmin;
diff --git a/drivers/thermal/samsung/exynos_tmu_data.c 
b/drivers/thermal/samsung/exynos_tmu_data.c
index 3ae0376..b9a3778 100644
--- a/drivers/thermal/samsung/exynos_tmu_data.c
+++ b/drivers/thermal/samsung/exynos_tmu_data.c
@@ -99,7 +99,6 @@ static const struct exynos_tmu_registers 
exynos3250_tmu_registers = {
.intclr_rise_mask = EXYNOS_TMU_RISE_INT_MASK,
.intclr_fall_mask = EXYNOS_TMU_FALL_INT_MASK,
.emul_con = EXYNOS_EMUL_CON,
-   .emul_time_shift = EXYNOS_EMUL_TIME_SHIFT,
 };
 
 #define EXYNOS3250_TMU_DATA \
@@ -175,7 +174,6 @@ static const struct exynos_tmu_registers 
exynos4412_tmu_registers = {
.intclr_rise_mask = EXYNOS_TMU_RISE_INT_MASK,
.intclr_fall_mask = EXYNOS_TMU_FALL_INT_MASK,
.emul_con = EXYNOS_EMUL_CON,
-   .emul_time_shift = EXYNOS_EMUL_TIME_SHIFT,
 };
 
 #define EXYNOS4412_TMU_DATA \
@@ -263,7 +261,6 @@ static const struct exynos_tmu_registers 
exynos5260_tmu_registers = {
.intclr_rise_mask = EXYNOS5260_TMU_RISE_INT_MASK,
.intclr_fall_mask = EXYNOS5260_TMU_FALL_INT_MASK,
.emul_con = EXYNOS5260_EMUL_CON,
-   .emul_time_shift = EXYNOS_EMUL_TIME_SHIFT,
 };
 
 #define __EXYNOS5260_TMU_DATA  \
@@ -341,7 +338,6 @@ static const struct exynos_tmu_registers 
exynos5420_tmu_registers = {
.intclr_rise_mask = EXYNOS_TMU_RISE_INT_MASK,
.intclr_fall_mask = EXYNOS_TMU_FALL_INT_MASK,
.emul_con = EXYNOS_EMUL_CON,
-   .emul_time_shift = EXYNOS_EMUL_TIME_SHIFT,
 };
 
 #define __EXYNOS5420_TMU_DATA  \
-- 
1.8.2.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 19/33] thermal: exynos: add get_con_reg() helper

2014-09-18 Thread Bartlomiej Zolnierkiewicz
Factor out code for preparing TMU_CONTROL register value from
exynos_tmu_control() into get_con_reg().

This is a preparation for introducing per-SoC type tmu_control
method.

There should be no functional changes caused by this patch.

Cc: Naveen Krishna Chatradhi ch.nav...@samsung.com
Cc: Amit Daniel Kachhap amit.dan...@samsung.com
Cc: Lukasz Majewski l.majew...@samsung.com
Cc: Eduardo Valentin edubez...@gmail.com
Cc: Zhang Rui rui.zh...@intel.com
Signed-off-by: Bartlomiej Zolnierkiewicz b.zolnier...@samsung.com
Acked-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/thermal/samsung/exynos_tmu.c | 25 -
 1 file changed, 16 insertions(+), 9 deletions(-)

diff --git a/drivers/thermal/samsung/exynos_tmu.c 
b/drivers/thermal/samsung/exynos_tmu.c
index 8dc5bf6..785a584 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -180,17 +180,9 @@ static int exynos_tmu_initialize(struct platform_device 
*pdev)
return ret;
 }
 
-static void exynos_tmu_control(struct platform_device *pdev, bool on)
+static u32 get_con_reg(struct exynos_tmu_data *data, u32 con)
 {
-   struct exynos_tmu_data *data = platform_get_drvdata(pdev);
struct exynos_tmu_platform_data *pdata = data-pdata;
-   const struct exynos_tmu_registers *reg = pdata-registers;
-   unsigned int con, interrupt_en;
-
-   mutex_lock(data-lock);
-   clk_enable(data-clk);
-
-   con = readl(data-base + reg-tmu_ctrl);
 
if (pdata-test_mux)
con |= (pdata-test_mux  EXYNOS4412_MUX_ADDR_SHIFT);
@@ -206,6 +198,21 @@ static void exynos_tmu_control(struct platform_device 
*pdev, bool on)
con |= (pdata-noise_cancel_mode  EXYNOS_TMU_TRIP_MODE_SHIFT);
}
 
+   return con;
+}
+
+static void exynos_tmu_control(struct platform_device *pdev, bool on)
+{
+   struct exynos_tmu_data *data = platform_get_drvdata(pdev);
+   struct exynos_tmu_platform_data *pdata = data-pdata;
+   const struct exynos_tmu_registers *reg = pdata-registers;
+   unsigned int con, interrupt_en;
+
+   mutex_lock(data-lock);
+   clk_enable(data-clk);
+
+   con = get_con_reg(data, readl(data-base + reg-tmu_ctrl));
+
if (on) {
con |= (1  EXYNOS_TMU_CORE_EN_SHIFT);
interrupt_en =
-- 
1.8.2.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 20/33] thermal: exynos: add -tmu_control method

2014-09-18 Thread Bartlomiej Zolnierkiewicz
Add -tmu_control method to struct exynos_tmu_data and use it
in exynos_tmu_control().  Then add -tmu_control implementations
for Exynos4210+ and Exynos5440.  Finally remove no longer needed
reg-tmu_[ctrl,inten], reg-inten_rise[0,1,2,3]_shift and
reg-inten_fall0_shift abstractions.

There should be no functional changes caused by this patch.

Cc: Naveen Krishna Chatradhi ch.nav...@samsung.com
Cc: Amit Daniel Kachhap amit.dan...@samsung.com
Cc: Lukasz Majewski l.majew...@samsung.com
Cc: Eduardo Valentin edubez...@gmail.com
Cc: Zhang Rui rui.zh...@intel.com
Signed-off-by: Bartlomiej Zolnierkiewicz b.zolnier...@samsung.com
Acked-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/thermal/samsung/exynos_tmu.c  | 81 ++-
 drivers/thermal/samsung/exynos_tmu.h  | 25 +-
 drivers/thermal/samsung/exynos_tmu_data.c | 41 
 3 files changed, 60 insertions(+), 87 deletions(-)

diff --git a/drivers/thermal/samsung/exynos_tmu.c 
b/drivers/thermal/samsung/exynos_tmu.c
index 785a584..5d9d4d5e 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -53,6 +53,7 @@
  * @regulator: pointer to the TMU regulator structure.
  * @reg_conf: pointer to structure to register with core thermal.
  * @tmu_initialize: SoC specific TMU initialization method
+ * @tmu_control: SoC specific TMU control method
  */
 struct exynos_tmu_data {
int id;
@@ -68,6 +69,7 @@ struct exynos_tmu_data {
struct regulator *regulator;
struct thermal_sensor_conf *reg_conf;
int (*tmu_initialize)(struct platform_device *pdev);
+   void (*tmu_control)(struct platform_device *pdev, bool on);
 };
 
 /*
@@ -204,32 +206,10 @@ static u32 get_con_reg(struct exynos_tmu_data *data, u32 
con)
 static void exynos_tmu_control(struct platform_device *pdev, bool on)
 {
struct exynos_tmu_data *data = platform_get_drvdata(pdev);
-   struct exynos_tmu_platform_data *pdata = data-pdata;
-   const struct exynos_tmu_registers *reg = pdata-registers;
-   unsigned int con, interrupt_en;
 
mutex_lock(data-lock);
clk_enable(data-clk);
-
-   con = get_con_reg(data, readl(data-base + reg-tmu_ctrl));
-
-   if (on) {
-   con |= (1  EXYNOS_TMU_CORE_EN_SHIFT);
-   interrupt_en =
-   pdata-trigger_enable[3]  reg-inten_rise3_shift |
-   pdata-trigger_enable[2]  reg-inten_rise2_shift |
-   pdata-trigger_enable[1]  reg-inten_rise1_shift |
-   pdata-trigger_enable[0]  reg-inten_rise0_shift;
-   if (TMU_SUPPORTS(pdata, FALLING_TRIP))
-   interrupt_en |=
-   interrupt_en  reg-inten_fall0_shift;
-   } else {
-   con = ~(1  EXYNOS_TMU_CORE_EN_SHIFT);
-   interrupt_en = 0; /* Disable all interrupts */
-   }
-   writel(interrupt_en, data-base + reg-tmu_inten);
-   writel(con, data-base + reg-tmu_ctrl);
-
+   data-tmu_control(pdev, on);
clk_disable(data-clk);
mutex_unlock(data-lock);
 }
@@ -386,6 +366,58 @@ static int exynos5440_tmu_initialize(struct 
platform_device *pdev)
return ret;
 }
 
+static void exynos4210_tmu_control(struct platform_device *pdev, bool on)
+{
+   struct exynos_tmu_data *data = platform_get_drvdata(pdev);
+   struct exynos_tmu_platform_data *pdata = data-pdata;
+   unsigned int con, interrupt_en;
+
+   con = get_con_reg(data, readl(data-base + EXYNOS_TMU_REG_CONTROL));
+
+   if (on) {
+   con |= (1  EXYNOS_TMU_CORE_EN_SHIFT);
+   interrupt_en =
+   pdata-trigger_enable[3]  
EXYNOS_TMU_INTEN_RISE3_SHIFT |
+   pdata-trigger_enable[2]  
EXYNOS_TMU_INTEN_RISE2_SHIFT |
+   pdata-trigger_enable[1]  
EXYNOS_TMU_INTEN_RISE1_SHIFT |
+   pdata-trigger_enable[0]  
EXYNOS_TMU_INTEN_RISE0_SHIFT;
+   if (TMU_SUPPORTS(pdata, FALLING_TRIP))
+   interrupt_en |=
+   interrupt_en  EXYNOS_TMU_INTEN_FALL0_SHIFT;
+   } else {
+   con = ~(1  EXYNOS_TMU_CORE_EN_SHIFT);
+   interrupt_en = 0; /* Disable all interrupts */
+   }
+   writel(interrupt_en, data-base + EXYNOS_TMU_REG_INTEN);
+   writel(con, data-base + EXYNOS_TMU_REG_CONTROL);
+}
+
+static void exynos5440_tmu_control(struct platform_device *pdev, bool on)
+{
+   struct exynos_tmu_data *data = platform_get_drvdata(pdev);
+   struct exynos_tmu_platform_data *pdata = data-pdata;
+   unsigned int con, interrupt_en;
+
+   con = get_con_reg(data, readl(data-base + EXYNOS5440_TMU_S0_7_CTRL));
+
+   if (on) {
+   con |= (1  EXYNOS_TMU_CORE_EN_SHIFT);
+   interrupt_en =
+   pdata-trigger_enable[3]  
EXYNOS5440_TMU_INTEN_RISE3_SHIFT |
+   

[PATCH 32/33] thermal: exynos: remove __EXYNOS5420_TMU_DATA macro

2014-09-18 Thread Bartlomiej Zolnierkiewicz
__EXYNOS5420_TMU_DATA macro is now identical to __EXYNOS5260_TMU_DATA
one and can be removed.

There should be no functional changes caused by this patch.

Cc: Naveen Krishna Chatradhi ch.nav...@samsung.com
Cc: Amit Daniel Kachhap amit.dan...@samsung.com
Cc: Lukasz Majewski l.majew...@samsung.com
Cc: Eduardo Valentin edubez...@gmail.com
Cc: Zhang Rui rui.zh...@intel.com
Signed-off-by: Bartlomiej Zolnierkiewicz b.zolnier...@samsung.com
Acked-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/thermal/samsung/exynos_tmu_data.c | 40 ++-
 1 file changed, 2 insertions(+), 38 deletions(-)

diff --git a/drivers/thermal/samsung/exynos_tmu_data.c 
b/drivers/thermal/samsung/exynos_tmu_data.c
index 02a1c34..592c470 100644
--- a/drivers/thermal/samsung/exynos_tmu_data.c
+++ b/drivers/thermal/samsung/exynos_tmu_data.c
@@ -216,48 +216,12 @@ struct exynos_tmu_init_data const 
exynos5260_default_tmu_data = {
.tmu_count = 5,
 };
 
-#define __EXYNOS5420_TMU_DATA  \
-   .threshold_falling = 10, \
-   .trigger_levels[0] = 85, \
-   .trigger_levels[1] = 103, \
-   .trigger_levels[2] = 110, \
-   .trigger_levels[3] = 120, \
-   .trigger_enable[0] = true, \
-   .trigger_enable[1] = true, \
-   .trigger_enable[2] = true, \
-   .trigger_enable[3] = false, \
-   .trigger_type[0] = THROTTLE_ACTIVE, \
-   .trigger_type[1] = THROTTLE_ACTIVE, \
-   .trigger_type[2] = SW_TRIP, \
-   .trigger_type[3] = HW_TRIP, \
-   .max_trigger_level = 4, \
-   .non_hw_trigger_levels = 3, \
-   .gain = 8, \
-   .reference_voltage = 16, \
-   .noise_cancel_mode = 4, \
-   .cal_type = TYPE_ONE_POINT_TRIMMING, \
-   .efuse_value = 55, \
-   .min_efuse_value = 40, \
-   .max_efuse_value = 100, \
-   .first_point_trim = 25, \
-   .second_point_trim = 85, \
-   .default_temp_offset = 50, \
-   .freq_tab[0] = { \
-   .freq_clip_max = 800 * 1000, \
-   .temp_level = 85, \
-   }, \
-   .freq_tab[1] = { \
-   .freq_clip_max = 200 * 1000, \
-   .temp_level = 103, \
-   }, \
-   .freq_tab_count = 2, \
-
 #define EXYNOS5420_TMU_DATA \
-   __EXYNOS5420_TMU_DATA \
+   __EXYNOS5260_TMU_DATA \
.type = SOC_ARCH_EXYNOS5420
 
 #define EXYNOS5420_TMU_DATA_SHARED \
-   __EXYNOS5420_TMU_DATA \
+   __EXYNOS5260_TMU_DATA \
.type = SOC_ARCH_EXYNOS5420_TRIMINFO
 
 struct exynos_tmu_init_data const exynos5420_default_tmu_data = {
-- 
1.8.2.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 21/33] thermal: exynos: add -tmu_read method

2014-09-18 Thread Bartlomiej Zolnierkiewicz
Add -tmu_read method to struct exynos_tmu_data and use it
in exynos_tmu_control().  Then add -tmu_read implementations
for Exynos4210, Exynos4412+ and Exynos5440.  Finally remove
no longer needed reg-tmu_cur_temp abstractions.

There should be no functional changes caused by this patch.

Cc: Naveen Krishna Chatradhi ch.nav...@samsung.com
Cc: Amit Daniel Kachhap amit.dan...@samsung.com
Cc: Lukasz Majewski l.majew...@samsung.com
Cc: Eduardo Valentin edubez...@gmail.com
Cc: Zhang Rui rui.zh...@intel.com
Signed-off-by: Bartlomiej Zolnierkiewicz b.zolnier...@samsung.com
Acked-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/thermal/samsung/exynos_tmu.c  | 45 +++
 drivers/thermal/samsung/exynos_tmu.h  |  2 --
 drivers/thermal/samsung/exynos_tmu_data.c |  6 -
 3 files changed, 28 insertions(+), 25 deletions(-)

diff --git a/drivers/thermal/samsung/exynos_tmu.c 
b/drivers/thermal/samsung/exynos_tmu.c
index 5d9d4d5e..a35f045 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -54,6 +54,7 @@
  * @reg_conf: pointer to structure to register with core thermal.
  * @tmu_initialize: SoC specific TMU initialization method
  * @tmu_control: SoC specific TMU control method
+ * @tmu_read: SoC specific TMU temperature read method
  */
 struct exynos_tmu_data {
int id;
@@ -70,6 +71,7 @@ struct exynos_tmu_data {
struct thermal_sensor_conf *reg_conf;
int (*tmu_initialize)(struct platform_device *pdev);
void (*tmu_control)(struct platform_device *pdev, bool on);
+   int (*tmu_read)(struct exynos_tmu_data *data);
 };
 
 /*
@@ -420,29 +422,17 @@ static void exynos5440_tmu_control(struct platform_device 
*pdev, bool on)
 
 static int exynos_tmu_read(struct exynos_tmu_data *data)
 {
-   struct exynos_tmu_platform_data *pdata = data-pdata;
-   const struct exynos_tmu_registers *reg = pdata-registers;
-   u8 temp_code;
-   int temp;
+   int ret;
 
mutex_lock(data-lock);
clk_enable(data-clk);
-
-   temp_code = readb(data-base + reg-tmu_cur_temp);
-
-   if (data-soc == SOC_ARCH_EXYNOS4210)
-   /* temp_code should range between 75 and 175 */
-   if (temp_code  75 || temp_code  175) {
-   temp = -ENODATA;
-   goto out;
-   }
-
-   temp = code_to_temp(data, temp_code);
-out:
+   ret = data-tmu_read(data);
+   if (ret = 0)
+   ret = code_to_temp(data, ret);
clk_disable(data-clk);
mutex_unlock(data-lock);
 
-   return temp;
+   return ret;
 }
 
 #ifdef CONFIG_THERMAL_EMULATION
@@ -492,6 +482,24 @@ static int exynos_tmu_set_emulation(void *drv_data,
unsigned long temp)
{ return -EINVAL; }
 #endif/*CONFIG_THERMAL_EMULATION*/
 
+static int exynos4210_tmu_read(struct exynos_tmu_data *data)
+{
+   int ret = readb(data-base + EXYNOS_TMU_REG_CURRENT_TEMP);
+
+   /* temp_code should range between 75 and 175 */
+   return (ret  75 || ret  175) ? -ENODATA : ret;
+}
+
+static int exynos4412_tmu_read(struct exynos_tmu_data *data)
+{
+   return readb(data-base + EXYNOS_TMU_REG_CURRENT_TEMP);
+}
+
+static int exynos5440_tmu_read(struct exynos_tmu_data *data)
+{
+   return readb(data-base + EXYNOS5440_TMU_S0_7_TEMP);
+}
+
 static void exynos_tmu_work(struct work_struct *work)
 {
struct exynos_tmu_data *data = container_of(work,
@@ -720,6 +728,7 @@ static int exynos_tmu_probe(struct platform_device *pdev)
case SOC_ARCH_EXYNOS4210:
data-tmu_initialize = exynos4210_tmu_initialize;
data-tmu_control = exynos4210_tmu_control;
+   data-tmu_read = exynos4210_tmu_read;
break;
case SOC_ARCH_EXYNOS3250:
case SOC_ARCH_EXYNOS4412:
@@ -729,10 +738,12 @@ static int exynos_tmu_probe(struct platform_device *pdev)
case SOC_ARCH_EXYNOS5420_TRIMINFO:
data-tmu_initialize = exynos4412_tmu_initialize;
data-tmu_control = exynos4210_tmu_control;
+   data-tmu_read = exynos4412_tmu_read;
break;
case SOC_ARCH_EXYNOS5440:
data-tmu_initialize = exynos5440_tmu_initialize;
data-tmu_control = exynos5440_tmu_control;
+   data-tmu_read = exynos5440_tmu_read;
break;
default:
ret = -EINVAL;
diff --git a/drivers/thermal/samsung/exynos_tmu.h 
b/drivers/thermal/samsung/exynos_tmu.h
index 7496b54..9460e6e 100644
--- a/drivers/thermal/samsung/exynos_tmu.h
+++ b/drivers/thermal/samsung/exynos_tmu.h
@@ -70,13 +70,11 @@ enum soc_type {
 /**
  * struct exynos_tmu_register - register descriptors to access registers.
  * The register validity may vary slightly across different exynos SOC's.
- * @tmu_cur_temp: register containing the current temperature of the TMU.
  * @tmu_intstat: Register containing the interrupt status values.
 

[PATCH 33/33] thermal: exynos: remove exynos_tmu_data.h include

2014-09-18 Thread Bartlomiej Zolnierkiewicz
There is no longer need to share defines between exynos_tmu.c
and exynos_tmu_data.c (as they are now only used by the former
file) so move them accordingly.  Then move externs for struct
exynos_tmu_init_data instances to exynos_tmu.h and remove no
longer needed exynos_tmu_data.h include.

There should be no functional changes caused by this patch.

Cc: Naveen Krishna Chatradhi ch.nav...@samsung.com
Cc: Amit Daniel Kachhap amit.dan...@samsung.com
Cc: Lukasz Majewski l.majew...@samsung.com
Cc: Eduardo Valentin edubez...@gmail.com
Cc: Zhang Rui rui.zh...@intel.com
Signed-off-by: Bartlomiej Zolnierkiewicz b.zolnier...@samsung.com
Acked-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/thermal/samsung/exynos_tmu.c  |  97 +-
 drivers/thermal/samsung/exynos_tmu.h  |   8 ++
 drivers/thermal/samsung/exynos_tmu_data.c |   1 -
 drivers/thermal/samsung/exynos_tmu_data.h | 130 --
 4 files changed, 104 insertions(+), 132 deletions(-)
 delete mode 100644 drivers/thermal/samsung/exynos_tmu_data.h

diff --git a/drivers/thermal/samsung/exynos_tmu.c 
b/drivers/thermal/samsung/exynos_tmu.c
index 104fd7c..9e7f720 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -33,7 +33,102 @@
 
 #include exynos_thermal_common.h
 #include exynos_tmu.h
-#include exynos_tmu_data.h
+
+/* Exynos generic registers */
+#define EXYNOS_TMU_REG_TRIMINFO0x0
+#define EXYNOS_TMU_REG_CONTROL 0x20
+#define EXYNOS_TMU_REG_STATUS  0x28
+#define EXYNOS_TMU_REG_CURRENT_TEMP0x40
+#define EXYNOS_TMU_REG_INTEN   0x70
+#define EXYNOS_TMU_REG_INTSTAT 0x74
+#define EXYNOS_TMU_REG_INTCLEAR0x78
+
+#define EXYNOS_TMU_TEMP_MASK   0xff
+#define EXYNOS_TMU_REF_VOLTAGE_SHIFT   24
+#define EXYNOS_TMU_REF_VOLTAGE_MASK0x1f
+#define EXYNOS_TMU_BUF_SLOPE_SEL_MASK  0xf
+#define EXYNOS_TMU_BUF_SLOPE_SEL_SHIFT 8
+#define EXYNOS_TMU_CORE_EN_SHIFT   0
+
+/* Exynos3250 specific registers */
+#define EXYNOS_TMU_TRIMINFO_CON1   0x10
+
+/* Exynos4210 specific registers */
+#define EXYNOS4210_TMU_REG_THRESHOLD_TEMP  0x44
+#define EXYNOS4210_TMU_REG_TRIG_LEVEL0 0x50
+
+#define EXYNOS4210_TMU_TRIG_LEVEL_MASK 0x
+
+/* Exynos5250, Exynos4412, Exynos3250 specific registers */
+#define EXYNOS_TMU_TRIMINFO_CON2   0x14
+#define EXYNOS_THD_TEMP_RISE   0x50
+#define EXYNOS_THD_TEMP_FALL   0x54
+#define EXYNOS_EMUL_CON0x80
+
+#define EXYNOS_TRIMINFO_RELOAD_ENABLE  1
+#define EXYNOS_TRIMINFO_25_SHIFT   0
+#define EXYNOS_TRIMINFO_85_SHIFT   8
+#define EXYNOS_TMU_RISE_INT_MASK   0x111
+#define EXYNOS_TMU_RISE_INT_SHIFT  0
+#define EXYNOS_TMU_FALL_INT_MASK   0x111
+#define EXYNOS_TMU_CLEAR_FALL_INT_SHIFT12
+#define EXYNOS5420_TMU_CLEAR_FALL_INT_SHIFT16
+#define EXYNOS5440_TMU_CLEAR_FALL_INT_SHIFT4
+#define EXYNOS_TMU_TRIP_MODE_SHIFT 13
+#define EXYNOS_TMU_TRIP_MODE_MASK  0x7
+#define EXYNOS_TMU_THERM_TRIP_EN_SHIFT 12
+
+#define EXYNOS_TMU_INTEN_RISE0_SHIFT   0
+#define EXYNOS_TMU_INTEN_RISE1_SHIFT   4
+#define EXYNOS_TMU_INTEN_RISE2_SHIFT   8
+#define EXYNOS_TMU_INTEN_RISE3_SHIFT   12
+#define EXYNOS_TMU_INTEN_FALL0_SHIFT   16
+
+#define EXYNOS_EMUL_TIME   0x57F0
+#define EXYNOS_EMUL_TIME_MASK  0x
+#define EXYNOS_EMUL_TIME_SHIFT 16
+#define EXYNOS_EMUL_DATA_SHIFT 8
+#define EXYNOS_EMUL_DATA_MASK  0xFF
+#define EXYNOS_EMUL_ENABLE 0x1
+
+/* Exynos5260 specific */
+#define EXYNOS5260_TMU_REG_INTEN   0xC0
+#define EXYNOS5260_TMU_REG_INTSTAT 0xC4
+#define EXYNOS5260_TMU_REG_INTCLEAR0xC8
+#define EXYNOS5260_TMU_CLEAR_RISE_INT  0x
+#define EXYNOS5260_TMU_CLEAR_FALL_INT  (0x  16)
+#define EXYNOS5260_TMU_RISE_INT_MASK   0x
+#define EXYNOS5260_TMU_FALL_INT_MASK   0x
+#define EXYNOS5260_EMUL_CON0x100
+
+/* Exynos4412 specific */
+#define EXYNOS4412_MUX_ADDR_VALUE  6
+#define EXYNOS4412_MUX_ADDR_SHIFT  20
+
+/*exynos5440 specific registers*/
+#define EXYNOS5440_TMU_S0_7_TRIM   0x000
+#define EXYNOS5440_TMU_S0_7_CTRL   0x020
+#define EXYNOS5440_TMU_S0_7_DEBUG  0x040
+#define EXYNOS5440_TMU_S0_7_TEMP   0x0f0
+#define EXYNOS5440_TMU_S0_7_TH00x110
+#define EXYNOS5440_TMU_S0_7_TH10x130
+#define EXYNOS5440_TMU_S0_7_TH20x150
+#define EXYNOS5440_TMU_S0_7_IRQEN  0x210
+#define EXYNOS5440_TMU_S0_7_IRQ0x230
+/* exynos5440 common registers */
+#define EXYNOS5440_TMU_IRQ_STATUS  0x000
+#define EXYNOS5440_TMU_PMIN0x004
+
+#define EXYNOS5440_TMU_RISE_INT_MASK   0xf
+#define EXYNOS5440_TMU_RISE_INT_SHIFT  0
+#define EXYNOS5440_TMU_FALL_INT_MASK   0xf
+#define EXYNOS5440_TMU_INTEN_RISE0_SHIFT   0
+#define 

[PATCH 29/33] thermal: exynos: remove TMU_SUPPORT_MULTI_INST flag

2014-09-18 Thread Bartlomiej Zolnierkiewicz
Remove unused TMU_SUPPORT_MULTI_INST flag, no longer
needed TMU_SUPPORTS() macro and features field from
struct exynos_tmu_platform_data.

There should be no functional changes caused by this patch.

Cc: Naveen Krishna Chatradhi ch.nav...@samsung.com
Cc: Amit Daniel Kachhap amit.dan...@samsung.com
Cc: Lukasz Majewski l.majew...@samsung.com
Cc: Eduardo Valentin edubez...@gmail.com
Cc: Zhang Rui rui.zh...@intel.com
Signed-off-by: Bartlomiej Zolnierkiewicz b.zolnier...@samsung.com
Acked-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/thermal/samsung/exynos_tmu.h  | 13 -
 drivers/thermal/samsung/exynos_tmu_data.c |  3 +--
 2 files changed, 1 insertion(+), 15 deletions(-)

diff --git a/drivers/thermal/samsung/exynos_tmu.h 
b/drivers/thermal/samsung/exynos_tmu.h
index 54f018d..2eb4cb9 100644
--- a/drivers/thermal/samsung/exynos_tmu.h
+++ b/drivers/thermal/samsung/exynos_tmu.h
@@ -46,16 +46,6 @@ enum soc_type {
 };
 
 /**
- * EXYNOS TMU supported features.
- * TMU_SUPPORT_MULTI_INST - This features denotes that the soc
- * has many instances of TMU.
- * TMU_SUPPORT - macro to compare the above features with the supplied.
- */
-#define TMU_SUPPORT_MULTI_INST BIT(0)
-
-#define TMU_SUPPORTS(a, b) (a-features  TMU_SUPPORT_ ## b)
-
-/**
  * struct exynos_tmu_platform_data
  * @threshold: basic temperature for generating interrupt
  *25 = threshold = 125 [unit: degree Celsius]
@@ -104,8 +94,6 @@ enum soc_type {
  * @freq_clip_table: Table representing frequency reduction percentage.
  * @freq_tab_count: Count of the above table as frequency reduction may
  * applicable to only some of the trigger levels.
- * @features: a bitfield value indicating the features supported in SOC like
- * emulation, multi instance etc
  *
  * This structure is required for configuration of exynos_tmu driver.
  */
@@ -133,7 +121,6 @@ struct exynos_tmu_platform_data {
enum soc_type type;
struct freq_clip_table freq_tab[4];
unsigned int freq_tab_count;
-   unsigned int features;
 };
 
 /**
diff --git a/drivers/thermal/samsung/exynos_tmu_data.c 
b/drivers/thermal/samsung/exynos_tmu_data.c
index 13ac00b..d90b050 100644
--- a/drivers/thermal/samsung/exynos_tmu_data.c
+++ b/drivers/thermal/samsung/exynos_tmu_data.c
@@ -308,8 +308,7 @@ struct exynos_tmu_init_data const 
exynos5420_default_tmu_data = {
.first_point_trim = 25, \
.second_point_trim = 70, \
.default_temp_offset = 25, \
-   .type = SOC_ARCH_EXYNOS5440, \
-   .features = TMU_SUPPORT_MULTI_INST,
+   .type = SOC_ARCH_EXYNOS5440
 
 struct exynos_tmu_init_data const exynos5440_default_tmu_data = {
.tmu_data = {
-- 
1.8.2.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 30/33] thermal: exynos: remove test_mux pdata field

2014-09-18 Thread Bartlomiej Zolnierkiewicz
Replace pdata-test_mux check in get_con_reg() by explicitly
checking for SoC type.

Also since the used pdata-test_mux value is always identical
use it directly and remove pdata-test_mux completely.

There should be no functional changes caused by this patch.

Cc: Naveen Krishna Chatradhi ch.nav...@samsung.com
Cc: Amit Daniel Kachhap amit.dan...@samsung.com
Cc: Lukasz Majewski l.majew...@samsung.com
Cc: Eduardo Valentin edubez...@gmail.com
Cc: Zhang Rui rui.zh...@intel.com
Signed-off-by: Bartlomiej Zolnierkiewicz b.zolnier...@samsung.com
Acked-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/thermal/samsung/exynos_tmu.c  | 5 +++--
 drivers/thermal/samsung/exynos_tmu.h  | 2 --
 drivers/thermal/samsung/exynos_tmu_data.c | 2 --
 3 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/thermal/samsung/exynos_tmu.c 
b/drivers/thermal/samsung/exynos_tmu.c
index 367f4eb..80961e3 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -193,8 +193,9 @@ static u32 get_con_reg(struct exynos_tmu_data *data, u32 
con)
 {
struct exynos_tmu_platform_data *pdata = data-pdata;
 
-   if (pdata-test_mux)
-   con |= (pdata-test_mux  EXYNOS4412_MUX_ADDR_SHIFT);
+   if (data-soc == SOC_ARCH_EXYNOS4412 ||
+   data-soc == SOC_ARCH_EXYNOS3250)
+   con |= (EXYNOS4412_MUX_ADDR_VALUE  EXYNOS4412_MUX_ADDR_SHIFT);
 
con = ~(EXYNOS_TMU_REF_VOLTAGE_MASK  EXYNOS_TMU_REF_VOLTAGE_SHIFT);
con |= pdata-reference_voltage  EXYNOS_TMU_REF_VOLTAGE_SHIFT;
diff --git a/drivers/thermal/samsung/exynos_tmu.h 
b/drivers/thermal/samsung/exynos_tmu.h
index 2eb4cb9..8de0f82 100644
--- a/drivers/thermal/samsung/exynos_tmu.h
+++ b/drivers/thermal/samsung/exynos_tmu.h
@@ -89,7 +89,6 @@ enum soc_type {
  * @first_point_trim: temp value of the first point trimming
  * @second_point_trim: temp value of the second point trimming
  * @default_temp_offset: default temperature offset in case of no trimming
- * @test_mux; information if SoC supports test MUX
  * @cal_type: calibration type for temperature
  * @freq_clip_table: Table representing frequency reduction percentage.
  * @freq_tab_count: Count of the above table as frequency reduction may
@@ -115,7 +114,6 @@ struct exynos_tmu_platform_data {
u8 first_point_trim;
u8 second_point_trim;
u8 default_temp_offset;
-   u8 test_mux;
 
enum calibration_type cal_type;
enum soc_type type;
diff --git a/drivers/thermal/samsung/exynos_tmu_data.c 
b/drivers/thermal/samsung/exynos_tmu_data.c
index d90b050..708c3e1 100644
--- a/drivers/thermal/samsung/exynos_tmu_data.c
+++ b/drivers/thermal/samsung/exynos_tmu_data.c
@@ -109,7 +109,6 @@ struct exynos_tmu_init_data const 
exynos3250_default_tmu_data = {
{
EXYNOS3250_TMU_DATA,
.type = SOC_ARCH_EXYNOS3250,
-   .test_mux = EXYNOS4412_MUX_ADDR_VALUE,
},
},
.tmu_count = 1,
@@ -160,7 +159,6 @@ struct exynos_tmu_init_data const 
exynos4412_default_tmu_data = {
{
EXYNOS4412_TMU_DATA,
.type = SOC_ARCH_EXYNOS4412,
-   .test_mux = EXYNOS4412_MUX_ADDR_VALUE,
},
},
.tmu_count = 1,
-- 
1.8.2.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 26/33] thermal: exynos: remove TMU_SUPPORT_EMUL_TIME flag

2014-09-18 Thread Bartlomiej Zolnierkiewicz
Replace TMU_SUPPORT_EMUL_TIME flag check in get_emul_con_reg()
by an explicit check for a SoC type (all SoC types except
Exynos4210 and Exynos5440 have TMU_SUPPORT_EMUL_TIME flag set
in their struct exynos_tmu_init_data instances).

There should be no functional changes caused by this patch.

Cc: Naveen Krishna Chatradhi ch.nav...@samsung.com
Cc: Amit Daniel Kachhap amit.dan...@samsung.com
Cc: Lukasz Majewski l.majew...@samsung.com
Cc: Eduardo Valentin edubez...@gmail.com
Cc: Zhang Rui rui.zh...@intel.com
Signed-off-by: Bartlomiej Zolnierkiewicz b.zolnier...@samsung.com
Acked-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/thermal/samsung/exynos_tmu.c  |  4 +---
 drivers/thermal/samsung/exynos_tmu.h  |  5 +
 drivers/thermal/samsung/exynos_tmu_data.c | 11 +--
 3 files changed, 7 insertions(+), 13 deletions(-)

diff --git a/drivers/thermal/samsung/exynos_tmu.c 
b/drivers/thermal/samsung/exynos_tmu.c
index 121bc5d..890d4fe 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -442,12 +442,10 @@ static int exynos_tmu_read(struct exynos_tmu_data *data)
 static u32 get_emul_con_reg(struct exynos_tmu_data *data, unsigned int val,
unsigned long temp)
 {
-   struct exynos_tmu_platform_data *pdata = data-pdata;
-
if (temp) {
temp /= MCELSIUS;
 
-   if (TMU_SUPPORTS(pdata, EMUL_TIME)) {
+   if (data-soc != SOC_ARCH_EXYNOS5440) {
val = ~(EXYNOS_EMUL_TIME_MASK  
EXYNOS_EMUL_TIME_SHIFT);
val |= (EXYNOS_EMUL_TIME  EXYNOS_EMUL_TIME_SHIFT);
}
diff --git a/drivers/thermal/samsung/exynos_tmu.h 
b/drivers/thermal/samsung/exynos_tmu.h
index ed83d3d..d90852a 100644
--- a/drivers/thermal/samsung/exynos_tmu.h
+++ b/drivers/thermal/samsung/exynos_tmu.h
@@ -51,16 +51,13 @@ enum soc_type {
  * temperature to the TMU controller.
  * TMU_SUPPORT_MULTI_INST - This features denotes that the soc
  * has many instances of TMU.
- * TMU_SUPPORT_EMUL_TIME - This features allows to set next temp emulation
- * sample time.
  * TMU_SUPPORT_ADDRESS_MULTIPLE - This feature tells that the different TMU
  * sensors shares some common registers.
  * TMU_SUPPORT - macro to compare the above features with the supplied.
  */
 #define TMU_SUPPORT_EMULATION  BIT(0)
 #define TMU_SUPPORT_MULTI_INST BIT(1)
-#define TMU_SUPPORT_EMUL_TIME  BIT(2)
-#define TMU_SUPPORT_ADDRESS_MULTIPLE   BIT(3)
+#define TMU_SUPPORT_ADDRESS_MULTIPLE   BIT(2)
 
 #define TMU_SUPPORTS(a, b) (a-features  TMU_SUPPORT_ ## b)
 
diff --git a/drivers/thermal/samsung/exynos_tmu_data.c 
b/drivers/thermal/samsung/exynos_tmu_data.c
index 39b9651..82f1cba 100644
--- a/drivers/thermal/samsung/exynos_tmu_data.c
+++ b/drivers/thermal/samsung/exynos_tmu_data.c
@@ -101,7 +101,7 @@ struct exynos_tmu_init_data const 
exynos4210_default_tmu_data = {
.temp_level = 95, \
}, \
.freq_tab_count = 2, \
-   .features = (TMU_SUPPORT_EMULATION | TMU_SUPPORT_EMUL_TIME)
+   .features = TMU_SUPPORT_EMULATION
 #endif
 
 #if defined(CONFIG_SOC_EXYNOS3250)
@@ -153,7 +153,7 @@ struct exynos_tmu_init_data const 
exynos3250_default_tmu_data = {
.temp_level = 95, \
}, \
.freq_tab_count = 2, \
-   .features = (TMU_SUPPORT_EMULATION | TMU_SUPPORT_EMUL_TIME)
+   .features = TMU_SUPPORT_EMULATION
 #endif
 
 #if defined(CONFIG_SOC_EXYNOS4412)
@@ -221,7 +221,7 @@ struct exynos_tmu_init_data const 
exynos5250_default_tmu_data = {
 #define EXYNOS5260_TMU_DATA \
__EXYNOS5260_TMU_DATA \
.type = SOC_ARCH_EXYNOS5260, \
-   .features = (TMU_SUPPORT_EMULATION | TMU_SUPPORT_EMUL_TIME)
+   .features = TMU_SUPPORT_EMULATION
 
 struct exynos_tmu_init_data const exynos5260_default_tmu_data = {
.tmu_data = {
@@ -275,13 +275,12 @@ struct exynos_tmu_init_data const 
exynos5260_default_tmu_data = {
 #define EXYNOS5420_TMU_DATA \
__EXYNOS5420_TMU_DATA \
.type = SOC_ARCH_EXYNOS5420, \
-   .features = (TMU_SUPPORT_EMULATION | TMU_SUPPORT_EMUL_TIME)
+   .features = TMU_SUPPORT_EMULATION
 
 #define EXYNOS5420_TMU_DATA_SHARED \
__EXYNOS5420_TMU_DATA \
.type = SOC_ARCH_EXYNOS5420_TRIMINFO, \
-   .features = (TMU_SUPPORT_EMULATION | TMU_SUPPORT_EMUL_TIME | \
-   TMU_SUPPORT_ADDRESS_MULTIPLE)
+   .features = (TMU_SUPPORT_EMULATION | TMU_SUPPORT_ADDRESS_MULTIPLE)
 
 struct exynos_tmu_init_data const exynos5420_default_tmu_data = {
.tmu_data = {
-- 
1.8.2.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 28/33] thermal: exynos: remove TMU_SUPPORT_ADDRESS_MULTIPLE flag

2014-09-18 Thread Bartlomiej Zolnierkiewicz
Replace TMU_SUPPORT_ADDRESS_MULTIPLE flag check in exynos_map_dt_data()
by an explicit check for a SoC type (only Exynos5420 with TRIMINFO
quirk and Exynos5440 have TMU_SUPPORT_ADDRESS_MULTIPLE flag set in
their struct exynos_tmu_init_data instances).

Please note that this requires moving SoC type assignment and verification
from exynos_tmu_probe() to exynos_map_dt_data() so it happens earlier
(which is a good thing in itself).

There should be no functional changes caused by this patch.

Cc: Naveen Krishna Chatradhi ch.nav...@samsung.com
Cc: Amit Daniel Kachhap amit.dan...@samsung.com
Cc: Lukasz Majewski l.majew...@samsung.com
Cc: Eduardo Valentin edubez...@gmail.com
Cc: Zhang Rui rui.zh...@intel.com
Signed-off-by: Bartlomiej Zolnierkiewicz b.zolnier...@samsung.com
Acked-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/thermal/samsung/exynos_tmu.c  | 72 +++
 drivers/thermal/samsung/exynos_tmu.h  |  3 --
 drivers/thermal/samsung/exynos_tmu_data.c |  5 +--
 3 files changed, 38 insertions(+), 42 deletions(-)

diff --git a/drivers/thermal/samsung/exynos_tmu.c 
b/drivers/thermal/samsung/exynos_tmu.c
index d31e541..367f4eb 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -488,7 +488,6 @@ static void exynos5440_tmu_set_emulation(struct 
exynos_tmu_data *data,
 static int exynos_tmu_set_emulation(void *drv_data, unsigned long temp)
 {
struct exynos_tmu_data *data = drv_data;
-   struct exynos_tmu_platform_data *pdata = data-pdata;
int ret = -EINVAL;
 
if (data-soc == SOC_ARCH_EXYNOS4210)
@@ -702,12 +701,47 @@ static int exynos_map_dt_data(struct platform_device 
*pdev)
dev_err(pdev-dev, No platform init data supplied.\n);
return -ENODEV;
}
+
data-pdata = pdata;
+   data-soc = pdata-type;
+
+   switch (data-soc) {
+   case SOC_ARCH_EXYNOS4210:
+   data-tmu_initialize = exynos4210_tmu_initialize;
+   data-tmu_control = exynos4210_tmu_control;
+   data-tmu_read = exynos4210_tmu_read;
+   data-tmu_clear_irqs = exynos4210_tmu_clear_irqs;
+   break;
+   case SOC_ARCH_EXYNOS3250:
+   case SOC_ARCH_EXYNOS4412:
+   case SOC_ARCH_EXYNOS5250:
+   case SOC_ARCH_EXYNOS5260:
+   case SOC_ARCH_EXYNOS5420:
+   case SOC_ARCH_EXYNOS5420_TRIMINFO:
+   data-tmu_initialize = exynos4412_tmu_initialize;
+   data-tmu_control = exynos4210_tmu_control;
+   data-tmu_read = exynos4412_tmu_read;
+   data-tmu_set_emulation = exynos4412_tmu_set_emulation;
+   data-tmu_clear_irqs = exynos4210_tmu_clear_irqs;
+   break;
+   case SOC_ARCH_EXYNOS5440:
+   data-tmu_initialize = exynos5440_tmu_initialize;
+   data-tmu_control = exynos5440_tmu_control;
+   data-tmu_read = exynos5440_tmu_read;
+   data-tmu_set_emulation = exynos5440_tmu_set_emulation;
+   data-tmu_clear_irqs = exynos5440_tmu_clear_irqs;
+   break;
+   default:
+   dev_err(pdev-dev, Platform not supported\n);
+   return -EINVAL;
+   }
+
/*
 * Check if the TMU shares some registers and then try to map the
 * memory of common registers.
 */
-   if (!TMU_SUPPORTS(pdata, ADDRESS_MULTIPLE))
+   if (data-soc != SOC_ARCH_EXYNOS5420_TRIMINFO 
+   data-soc != SOC_ARCH_EXYNOS5440)
return 0;
 
if (of_address_to_resource(pdev-dev.of_node, 1, res)) {
@@ -774,40 +808,6 @@ static int exynos_tmu_probe(struct platform_device *pdev)
goto err_clk_sec;
}
 
-   data-soc = pdata-type;
-
-   switch (data-soc) {
-   case SOC_ARCH_EXYNOS4210:
-   data-tmu_initialize = exynos4210_tmu_initialize;
-   data-tmu_control = exynos4210_tmu_control;
-   data-tmu_read = exynos4210_tmu_read;
-   data-tmu_clear_irqs = exynos4210_tmu_clear_irqs;
-   break;
-   case SOC_ARCH_EXYNOS3250:
-   case SOC_ARCH_EXYNOS4412:
-   case SOC_ARCH_EXYNOS5250:
-   case SOC_ARCH_EXYNOS5260:
-   case SOC_ARCH_EXYNOS5420:
-   case SOC_ARCH_EXYNOS5420_TRIMINFO:
-   data-tmu_initialize = exynos4412_tmu_initialize;
-   data-tmu_control = exynos4210_tmu_control;
-   data-tmu_read = exynos4412_tmu_read;
-   data-tmu_set_emulation = exynos4412_tmu_set_emulation;
-   data-tmu_clear_irqs = exynos4210_tmu_clear_irqs;
-   break;
-   case SOC_ARCH_EXYNOS5440:
-   data-tmu_initialize = exynos5440_tmu_initialize;
-   data-tmu_control = exynos5440_tmu_control;
-   data-tmu_read = exynos5440_tmu_read;
-   data-tmu_set_emulation = exynos5440_tmu_set_emulation;
-   data-tmu_clear_irqs = 

[PATCH 27/33] thermal: exynos: remove TMU_SUPPORT_EMULATION flag

2014-09-18 Thread Bartlomiej Zolnierkiewicz
Replace TMU_SUPPORT_EMULATION flag check in exynos_tmu_set_emulation()
by an explicit check for a SoC type (all SoC types except Exynos4210
have TMU_SUPPORT_EMULATION flag set in their struct exynos_tmu_init_data
instances).

There should be no functional changes caused by this patch.

Cc: Naveen Krishna Chatradhi ch.nav...@samsung.com
Cc: Amit Daniel Kachhap amit.dan...@samsung.com
Cc: Lukasz Majewski l.majew...@samsung.com
Cc: Eduardo Valentin edubez...@gmail.com
Cc: Zhang Rui rui.zh...@intel.com
Signed-off-by: Bartlomiej Zolnierkiewicz b.zolnier...@samsung.com
Acked-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/thermal/samsung/exynos_tmu.c  |  2 +-
 drivers/thermal/samsung/exynos_tmu.h  |  7 ++-
 drivers/thermal/samsung/exynos_tmu_data.c | 17 ++---
 3 files changed, 9 insertions(+), 17 deletions(-)

diff --git a/drivers/thermal/samsung/exynos_tmu.c 
b/drivers/thermal/samsung/exynos_tmu.c
index 890d4fe..d31e541 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -491,7 +491,7 @@ static int exynos_tmu_set_emulation(void *drv_data, 
unsigned long temp)
struct exynos_tmu_platform_data *pdata = data-pdata;
int ret = -EINVAL;
 
-   if (!TMU_SUPPORTS(pdata, EMULATION))
+   if (data-soc == SOC_ARCH_EXYNOS4210)
goto out;
 
if (temp  temp  MCELSIUS)
diff --git a/drivers/thermal/samsung/exynos_tmu.h 
b/drivers/thermal/samsung/exynos_tmu.h
index d90852a..5ad3f3f 100644
--- a/drivers/thermal/samsung/exynos_tmu.h
+++ b/drivers/thermal/samsung/exynos_tmu.h
@@ -47,17 +47,14 @@ enum soc_type {
 
 /**
  * EXYNOS TMU supported features.
- * TMU_SUPPORT_EMULATION - This features is used to set user defined
- * temperature to the TMU controller.
  * TMU_SUPPORT_MULTI_INST - This features denotes that the soc
  * has many instances of TMU.
  * TMU_SUPPORT_ADDRESS_MULTIPLE - This feature tells that the different TMU
  * sensors shares some common registers.
  * TMU_SUPPORT - macro to compare the above features with the supplied.
  */
-#define TMU_SUPPORT_EMULATION  BIT(0)
-#define TMU_SUPPORT_MULTI_INST BIT(1)
-#define TMU_SUPPORT_ADDRESS_MULTIPLE   BIT(2)
+#define TMU_SUPPORT_MULTI_INST BIT(0)
+#define TMU_SUPPORT_ADDRESS_MULTIPLE   BIT(1)
 
 #define TMU_SUPPORTS(a, b) (a-features  TMU_SUPPORT_ ## b)
 
diff --git a/drivers/thermal/samsung/exynos_tmu_data.c 
b/drivers/thermal/samsung/exynos_tmu_data.c
index 82f1cba..4dd8d1c 100644
--- a/drivers/thermal/samsung/exynos_tmu_data.c
+++ b/drivers/thermal/samsung/exynos_tmu_data.c
@@ -100,8 +100,7 @@ struct exynos_tmu_init_data const 
exynos4210_default_tmu_data = {
.freq_clip_max = 400 * 1000, \
.temp_level = 95, \
}, \
-   .freq_tab_count = 2, \
-   .features = TMU_SUPPORT_EMULATION
+   .freq_tab_count = 2
 #endif
 
 #if defined(CONFIG_SOC_EXYNOS3250)
@@ -152,8 +151,7 @@ struct exynos_tmu_init_data const 
exynos3250_default_tmu_data = {
.freq_clip_max = 400 * 1000, \
.temp_level = 95, \
}, \
-   .freq_tab_count = 2, \
-   .features = TMU_SUPPORT_EMULATION
+   .freq_tab_count = 2
 #endif
 
 #if defined(CONFIG_SOC_EXYNOS4412)
@@ -220,8 +218,7 @@ struct exynos_tmu_init_data const 
exynos5250_default_tmu_data = {
 
 #define EXYNOS5260_TMU_DATA \
__EXYNOS5260_TMU_DATA \
-   .type = SOC_ARCH_EXYNOS5260, \
-   .features = TMU_SUPPORT_EMULATION
+   .type = SOC_ARCH_EXYNOS5260
 
 struct exynos_tmu_init_data const exynos5260_default_tmu_data = {
.tmu_data = {
@@ -274,13 +271,12 @@ struct exynos_tmu_init_data const 
exynos5260_default_tmu_data = {
 
 #define EXYNOS5420_TMU_DATA \
__EXYNOS5420_TMU_DATA \
-   .type = SOC_ARCH_EXYNOS5420, \
-   .features = TMU_SUPPORT_EMULATION
+   .type = SOC_ARCH_EXYNOS5420
 
 #define EXYNOS5420_TMU_DATA_SHARED \
__EXYNOS5420_TMU_DATA \
.type = SOC_ARCH_EXYNOS5420_TRIMINFO, \
-   .features = (TMU_SUPPORT_EMULATION | TMU_SUPPORT_ADDRESS_MULTIPLE)
+   .features = TMU_SUPPORT_ADDRESS_MULTIPLE
 
 struct exynos_tmu_init_data const exynos5420_default_tmu_data = {
.tmu_data = {
@@ -314,8 +310,7 @@ struct exynos_tmu_init_data const 
exynos5420_default_tmu_data = {
.second_point_trim = 70, \
.default_temp_offset = 25, \
.type = SOC_ARCH_EXYNOS5440, \
-   .features = (TMU_SUPPORT_EMULATION | TMU_SUPPORT_MULTI_INST | \
-   TMU_SUPPORT_ADDRESS_MULTIPLE),
+   .features = (TMU_SUPPORT_MULTI_INST | TMU_SUPPORT_ADDRESS_MULTIPLE),
 
 struct exynos_tmu_init_data const exynos5440_default_tmu_data = {
.tmu_data = {
-- 
1.8.2.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  

[PATCH 25/33] thermal: exynos: remove TMU_SUPPORT_FALLING_TRIP flag

2014-09-18 Thread Bartlomiej Zolnierkiewicz
Replace TMU_SUPPORT_FALLING_TRIP flag check in
exynos[4210,5440]_tmu_control() by an explicit check
for a SoC type (all SoC types except Exynos4210 have
TMU_SUPPORT_FALLING_TRIP flag set in their struct
exynos_tmu_init_data instances).

There should be no functional changes caused by this patch.

Cc: Naveen Krishna Chatradhi ch.nav...@samsung.com
Cc: Amit Daniel Kachhap amit.dan...@samsung.com
Cc: Lukasz Majewski l.majew...@samsung.com
Cc: Eduardo Valentin edubez...@gmail.com
Cc: Zhang Rui rui.zh...@intel.com
Signed-off-by: Bartlomiej Zolnierkiewicz b.zolnier...@samsung.com
Acked-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/thermal/samsung/exynos_tmu.c  |  6 ++
 drivers/thermal/samsung/exynos_tmu.h  |  7 ++-
 drivers/thermal/samsung/exynos_tmu_data.c | 20 
 3 files changed, 12 insertions(+), 21 deletions(-)

diff --git a/drivers/thermal/samsung/exynos_tmu.c 
b/drivers/thermal/samsung/exynos_tmu.c
index 30fd87a..121bc5d 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -388,7 +388,7 @@ static void exynos4210_tmu_control(struct platform_device 
*pdev, bool on)
pdata-trigger_enable[2]  
EXYNOS_TMU_INTEN_RISE2_SHIFT |
pdata-trigger_enable[1]  
EXYNOS_TMU_INTEN_RISE1_SHIFT |
pdata-trigger_enable[0]  
EXYNOS_TMU_INTEN_RISE0_SHIFT;
-   if (TMU_SUPPORTS(pdata, FALLING_TRIP))
+   if (data-soc != SOC_ARCH_EXYNOS4210)
interrupt_en |=
interrupt_en  EXYNOS_TMU_INTEN_FALL0_SHIFT;
} else {
@@ -414,9 +414,7 @@ static void exynos5440_tmu_control(struct platform_device 
*pdev, bool on)
pdata-trigger_enable[2]  
EXYNOS5440_TMU_INTEN_RISE2_SHIFT |
pdata-trigger_enable[1]  
EXYNOS5440_TMU_INTEN_RISE1_SHIFT |
pdata-trigger_enable[0]  
EXYNOS5440_TMU_INTEN_RISE0_SHIFT;
-   if (TMU_SUPPORTS(pdata, FALLING_TRIP))
-   interrupt_en |=
-   interrupt_en  
EXYNOS5440_TMU_INTEN_FALL0_SHIFT;
+   interrupt_en |= interrupt_en  
EXYNOS5440_TMU_INTEN_FALL0_SHIFT;
} else {
con = ~(1  EXYNOS_TMU_CORE_EN_SHIFT);
interrupt_en = 0; /* Disable all interrupts */
diff --git a/drivers/thermal/samsung/exynos_tmu.h 
b/drivers/thermal/samsung/exynos_tmu.h
index c4c0aa5..ed83d3d 100644
--- a/drivers/thermal/samsung/exynos_tmu.h
+++ b/drivers/thermal/samsung/exynos_tmu.h
@@ -51,8 +51,6 @@ enum soc_type {
  * temperature to the TMU controller.
  * TMU_SUPPORT_MULTI_INST - This features denotes that the soc
  * has many instances of TMU.
- * TMU_SUPPORT_FALLING_TRIP - This features shows that interrupt can
- * be registered for falling trips also.
  * TMU_SUPPORT_EMUL_TIME - This features allows to set next temp emulation
  * sample time.
  * TMU_SUPPORT_ADDRESS_MULTIPLE - This feature tells that the different TMU
@@ -61,9 +59,8 @@ enum soc_type {
  */
 #define TMU_SUPPORT_EMULATION  BIT(0)
 #define TMU_SUPPORT_MULTI_INST BIT(1)
-#define TMU_SUPPORT_FALLING_TRIP   BIT(2)
-#define TMU_SUPPORT_EMUL_TIME  BIT(3)
-#define TMU_SUPPORT_ADDRESS_MULTIPLE   BIT(4)
+#define TMU_SUPPORT_EMUL_TIME  BIT(2)
+#define TMU_SUPPORT_ADDRESS_MULTIPLE   BIT(3)
 
 #define TMU_SUPPORTS(a, b) (a-features  TMU_SUPPORT_ ## b)
 
diff --git a/drivers/thermal/samsung/exynos_tmu_data.c 
b/drivers/thermal/samsung/exynos_tmu_data.c
index d35ec15..39b9651 100644
--- a/drivers/thermal/samsung/exynos_tmu_data.c
+++ b/drivers/thermal/samsung/exynos_tmu_data.c
@@ -101,8 +101,7 @@ struct exynos_tmu_init_data const 
exynos4210_default_tmu_data = {
.temp_level = 95, \
}, \
.freq_tab_count = 2, \
-   .features = (TMU_SUPPORT_EMULATION | TMU_SUPPORT_FALLING_TRIP | \
-   TMU_SUPPORT_EMUL_TIME)
+   .features = (TMU_SUPPORT_EMULATION | TMU_SUPPORT_EMUL_TIME)
 #endif
 
 #if defined(CONFIG_SOC_EXYNOS3250)
@@ -154,8 +153,7 @@ struct exynos_tmu_init_data const 
exynos3250_default_tmu_data = {
.temp_level = 95, \
}, \
.freq_tab_count = 2, \
-   .features = (TMU_SUPPORT_EMULATION | TMU_SUPPORT_FALLING_TRIP | \
-   TMU_SUPPORT_EMUL_TIME)
+   .features = (TMU_SUPPORT_EMULATION | TMU_SUPPORT_EMUL_TIME)
 #endif
 
 #if defined(CONFIG_SOC_EXYNOS4412)
@@ -223,8 +221,7 @@ struct exynos_tmu_init_data const 
exynos5250_default_tmu_data = {
 #define EXYNOS5260_TMU_DATA \
__EXYNOS5260_TMU_DATA \
.type = SOC_ARCH_EXYNOS5260, \
-   .features = (TMU_SUPPORT_EMULATION | TMU_SUPPORT_FALLING_TRIP | \
-   TMU_SUPPORT_EMUL_TIME)
+   .features = 

[PATCH 31/33] thermal: exynos: remove SoC type ifdefs

2014-09-18 Thread Bartlomiej Zolnierkiewicz
Maximum theoretical size saving (i.e. with only Exynos5410
SoC support enabled in kernel config so all SoC dependend
Exynos thermal driver code was dropped) is 4096 bytes so
there is no much sense in keeping these ifdefs (especially
given that they are useless once the driver gets updated to
use device tree).

While at it remove needless 'void *' casts.

There should be no functional changes caused by this patch.

Cc: Naveen Krishna Chatradhi ch.nav...@samsung.com
Cc: Amit Daniel Kachhap amit.dan...@samsung.com
Cc: Lukasz Majewski l.majew...@samsung.com
Cc: Eduardo Valentin edubez...@gmail.com
Cc: Zhang Rui rui.zh...@intel.com
Signed-off-by: Bartlomiej Zolnierkiewicz b.zolnier...@samsung.com
Acked-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/thermal/samsung/exynos_tmu.c  | 16 ++--
 drivers/thermal/samsung/exynos_tmu_data.c | 18 --
 drivers/thermal/samsung/exynos_tmu_data.h | 41 ---
 3 files changed, 8 insertions(+), 67 deletions(-)

diff --git a/drivers/thermal/samsung/exynos_tmu.c 
b/drivers/thermal/samsung/exynos_tmu.c
index 80961e3..104fd7c 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -599,35 +599,35 @@ static irqreturn_t exynos_tmu_irq(int irq, void *id)
 static const struct of_device_id exynos_tmu_match[] = {
{
.compatible = samsung,exynos3250-tmu,
-   .data = (void *)EXYNOS3250_TMU_DRV_DATA,
+   .data = exynos3250_default_tmu_data,
},
{
.compatible = samsung,exynos4210-tmu,
-   .data = (void *)EXYNOS4210_TMU_DRV_DATA,
+   .data = exynos4210_default_tmu_data,
},
{
.compatible = samsung,exynos4412-tmu,
-   .data = (void *)EXYNOS4412_TMU_DRV_DATA,
+   .data = exynos4412_default_tmu_data,
},
{
.compatible = samsung,exynos5250-tmu,
-   .data = (void *)EXYNOS5250_TMU_DRV_DATA,
+   .data = exynos5250_default_tmu_data,
},
{
.compatible = samsung,exynos5260-tmu,
-   .data = (void *)EXYNOS5260_TMU_DRV_DATA,
+   .data = exynos5260_default_tmu_data,
},
{
.compatible = samsung,exynos5420-tmu,
-   .data = (void *)EXYNOS5420_TMU_DRV_DATA,
+   .data = exynos5420_default_tmu_data,
},
{
.compatible = samsung,exynos5420-tmu-ext-triminfo,
-   .data = (void *)EXYNOS5420_TMU_DRV_DATA,
+   .data = exynos5420_default_tmu_data,
},
{
.compatible = samsung,exynos5440-tmu,
-   .data = (void *)EXYNOS5440_TMU_DRV_DATA,
+   .data = exynos5440_default_tmu_data,
},
{},
 };
diff --git a/drivers/thermal/samsung/exynos_tmu_data.c 
b/drivers/thermal/samsung/exynos_tmu_data.c
index 708c3e1..02a1c34 100644
--- a/drivers/thermal/samsung/exynos_tmu_data.c
+++ b/drivers/thermal/samsung/exynos_tmu_data.c
@@ -24,7 +24,6 @@
 #include exynos_tmu.h
 #include exynos_tmu_data.h
 
-#if defined(CONFIG_CPU_EXYNOS4210)
 struct exynos_tmu_init_data const exynos4210_default_tmu_data = {
.tmu_data = {
{
@@ -63,9 +62,7 @@ struct exynos_tmu_init_data const exynos4210_default_tmu_data 
= {
},
.tmu_count = 1,
 };
-#endif
 
-#if defined(CONFIG_SOC_EXYNOS3250)
 #define EXYNOS3250_TMU_DATA \
.threshold_falling = 10, \
.trigger_levels[0] = 70, \
@@ -101,9 +98,7 @@ struct exynos_tmu_init_data const 
exynos4210_default_tmu_data = {
.temp_level = 95, \
}, \
.freq_tab_count = 2
-#endif
 
-#if defined(CONFIG_SOC_EXYNOS3250)
 struct exynos_tmu_init_data const exynos3250_default_tmu_data = {
.tmu_data = {
{
@@ -113,9 +108,7 @@ struct exynos_tmu_init_data const 
exynos3250_default_tmu_data = {
},
.tmu_count = 1,
 };
-#endif
 
-#if defined(CONFIG_SOC_EXYNOS4412) || defined(CONFIG_SOC_EXYNOS5250)
 #define EXYNOS4412_TMU_DATA \
.threshold_falling = 10, \
.trigger_levels[0] = 70, \
@@ -151,9 +144,7 @@ struct exynos_tmu_init_data const 
exynos3250_default_tmu_data = {
.temp_level = 95, \
}, \
.freq_tab_count = 2
-#endif
 
-#if defined(CONFIG_SOC_EXYNOS4412)
 struct exynos_tmu_init_data const exynos4412_default_tmu_data = {
.tmu_data = {
{
@@ -163,9 +154,7 @@ struct exynos_tmu_init_data const 
exynos4412_default_tmu_data = {
},
.tmu_count = 1,
 };
-#endif
 
-#if defined(CONFIG_SOC_EXYNOS5250)
 struct exynos_tmu_init_data const exynos5250_default_tmu_data = {
.tmu_data = {
{
@@ -175,9 +164,7 @@ struct exynos_tmu_init_data const 
exynos5250_default_tmu_data = {
},
.tmu_count = 1,
 };
-#endif
 
-#if defined(CONFIG_SOC_EXYNOS5260)
 #define __EXYNOS5260_TMU_DATA  \
 

[PATCH 24/33] thermal: exynos: add -tmu_clear_irqs method

2014-09-18 Thread Bartlomiej Zolnierkiewicz
Add -tmu_clear_irqs method to struct exynos_tmu_data and
use it in exynos_tmu_work().  Then add -tmu_clear_irqs
implementations for Exynos4210+ and Exynos5440.  Finally
remove no longer needed reg-tmu_int[stat,clear] abstractions
and struct exynos_tmu_registers instances.

There should be no functional changes caused by this patch.

Cc: Naveen Krishna Chatradhi ch.nav...@samsung.com
Cc: Amit Daniel Kachhap amit.dan...@samsung.com
Cc: Lukasz Majewski l.majew...@samsung.com
Cc: Eduardo Valentin edubez...@gmail.com
Cc: Zhang Rui rui.zh...@intel.com
Signed-off-by: Bartlomiej Zolnierkiewicz b.zolnier...@samsung.com
Acked-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/thermal/samsung/exynos_tmu.c  | 42 +--
 drivers/thermal/samsung/exynos_tmu.h  | 14 ---
 drivers/thermal/samsung/exynos_tmu_data.c | 36 --
 3 files changed, 34 insertions(+), 58 deletions(-)

diff --git a/drivers/thermal/samsung/exynos_tmu.c 
b/drivers/thermal/samsung/exynos_tmu.c
index 23d3163..30fd87a 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -56,6 +56,7 @@
  * @tmu_control: SoC specific TMU control method
  * @tmu_read: SoC specific TMU temperature read method
  * @tmu_set_emulation: SoC specific TMU emulation setting method
+ * @tmu_clear_irqs: SoC specific TMU interrupts clearing method
  */
 struct exynos_tmu_data {
int id;
@@ -75,6 +76,7 @@ struct exynos_tmu_data {
int (*tmu_read)(struct exynos_tmu_data *data);
void (*tmu_set_emulation)(struct exynos_tmu_data *data,
  unsigned long temp);
+   void (*tmu_clear_irqs)(struct exynos_tmu_data *data);
 };
 
 /*
@@ -537,9 +539,7 @@ static void exynos_tmu_work(struct work_struct *work)
 {
struct exynos_tmu_data *data = container_of(work,
struct exynos_tmu_data, irq_work);
-   struct exynos_tmu_platform_data *pdata = data-pdata;
-   const struct exynos_tmu_registers *reg = pdata-registers;
-   unsigned int val_irq, val_type;
+   unsigned int val_type;
 
if (!IS_ERR(data-clk_sec))
clk_enable(data-clk_sec);
@@ -555,18 +555,41 @@ static void exynos_tmu_work(struct work_struct *work)
exynos_report_trigger(data-reg_conf);
mutex_lock(data-lock);
clk_enable(data-clk);
-
/* TODO: take action based on particular interrupt */
-   val_irq = readl(data-base + reg-tmu_intstat);
-   /* clear the interrupts */
-   writel(val_irq, data-base + reg-tmu_intclear);
-
+   data-tmu_clear_irqs(data);
clk_disable(data-clk);
mutex_unlock(data-lock);
 out:
enable_irq(data-irq);
 }
 
+static void exynos4210_tmu_clear_irqs(struct exynos_tmu_data *data)
+{
+   unsigned int val_irq;
+   u32 tmu_intstat, tmu_intclear;
+
+   if (data-soc == SOC_ARCH_EXYNOS5260) {
+   tmu_intstat = EXYNOS5260_TMU_REG_INTSTAT;
+   tmu_intclear = EXYNOS5260_TMU_REG_INTCLEAR;
+   } else {
+   tmu_intstat = EXYNOS_TMU_REG_INTSTAT;
+   tmu_intclear = EXYNOS_TMU_REG_INTCLEAR;
+   }
+
+   val_irq = readl(data-base + tmu_intstat);
+   /* clear the interrupts */
+   writel(val_irq, data-base + tmu_intclear);
+}
+
+static void exynos5440_tmu_clear_irqs(struct exynos_tmu_data *data)
+{
+   unsigned int val_irq;
+
+   val_irq = readl(data-base + EXYNOS5440_TMU_S0_7_IRQ);
+   /* clear the interrupts */
+   writel(val_irq, data-base + EXYNOS5440_TMU_S0_7_IRQ);
+}
+
 static irqreturn_t exynos_tmu_irq(int irq, void *id)
 {
struct exynos_tmu_data *data = id;
@@ -762,6 +785,7 @@ static int exynos_tmu_probe(struct platform_device *pdev)
data-tmu_initialize = exynos4210_tmu_initialize;
data-tmu_control = exynos4210_tmu_control;
data-tmu_read = exynos4210_tmu_read;
+   data-tmu_clear_irqs = exynos4210_tmu_clear_irqs;
break;
case SOC_ARCH_EXYNOS3250:
case SOC_ARCH_EXYNOS4412:
@@ -773,12 +797,14 @@ static int exynos_tmu_probe(struct platform_device *pdev)
data-tmu_control = exynos4210_tmu_control;
data-tmu_read = exynos4412_tmu_read;
data-tmu_set_emulation = exynos4412_tmu_set_emulation;
+   data-tmu_clear_irqs = exynos4210_tmu_clear_irqs;
break;
case SOC_ARCH_EXYNOS5440:
data-tmu_initialize = exynos5440_tmu_initialize;
data-tmu_control = exynos5440_tmu_control;
data-tmu_read = exynos5440_tmu_read;
data-tmu_set_emulation = exynos5440_tmu_set_emulation;
+   data-tmu_clear_irqs = exynos5440_tmu_clear_irqs;
break;
default:
ret = -EINVAL;
diff --git a/drivers/thermal/samsung/exynos_tmu.h 
b/drivers/thermal/samsung/exynos_tmu.h
index 785eccf..c4c0aa5 100644

[PATCH 22/33] thermal: exynos: add get_emul_con_reg() helper

2014-09-18 Thread Bartlomiej Zolnierkiewicz
Factor out code for preparing EMUL_CON register value from
exynos_tmu_set_emulation() into get_emul_con_reg().

This is a preparation for introducing per-SoC type
tmu_set_emulation method.

There should be no functional changes caused by this patch.

Cc: Naveen Krishna Chatradhi ch.nav...@samsung.com
Cc: Amit Daniel Kachhap amit.dan...@samsung.com
Cc: Lukasz Majewski l.majew...@samsung.com
Cc: Eduardo Valentin edubez...@gmail.com
Cc: Zhang Rui rui.zh...@intel.com
Signed-off-by: Bartlomiej Zolnierkiewicz b.zolnier...@samsung.com
Acked-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/thermal/samsung/exynos_tmu.c | 38 ++--
 1 file changed, 23 insertions(+), 15 deletions(-)

diff --git a/drivers/thermal/samsung/exynos_tmu.c 
b/drivers/thermal/samsung/exynos_tmu.c
index a35f045..59708b6 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -436,6 +436,28 @@ static int exynos_tmu_read(struct exynos_tmu_data *data)
 }
 
 #ifdef CONFIG_THERMAL_EMULATION
+static u32 get_emul_con_reg(struct exynos_tmu_data *data, unsigned int val,
+   unsigned long temp)
+{
+   struct exynos_tmu_platform_data *pdata = data-pdata;
+
+   if (temp) {
+   temp /= MCELSIUS;
+
+   if (TMU_SUPPORTS(pdata, EMUL_TIME)) {
+   val = ~(EXYNOS_EMUL_TIME_MASK  
EXYNOS_EMUL_TIME_SHIFT);
+   val |= (EXYNOS_EMUL_TIME  EXYNOS_EMUL_TIME_SHIFT);
+   }
+   val = ~(EXYNOS_EMUL_DATA_MASK  EXYNOS_EMUL_DATA_SHIFT);
+   val |= (temp_to_code(data, temp)  EXYNOS_EMUL_DATA_SHIFT) |
+   EXYNOS_EMUL_ENABLE;
+   } else {
+   val = ~EXYNOS_EMUL_ENABLE;
+   }
+
+   return val;
+}
+
 static int exynos_tmu_set_emulation(void *drv_data, unsigned long temp)
 {
struct exynos_tmu_data *data = drv_data;
@@ -454,21 +476,7 @@ static int exynos_tmu_set_emulation(void *drv_data, 
unsigned long temp)
clk_enable(data-clk);
 
val = readl(data-base + reg-emul_con);
-
-   if (temp) {
-   temp /= MCELSIUS;
-
-   if (TMU_SUPPORTS(pdata, EMUL_TIME)) {
-   val = ~(EXYNOS_EMUL_TIME_MASK  
EXYNOS_EMUL_TIME_SHIFT);
-   val |= (EXYNOS_EMUL_TIME  EXYNOS_EMUL_TIME_SHIFT);
-   }
-   val = ~(EXYNOS_EMUL_DATA_MASK  EXYNOS_EMUL_DATA_SHIFT);
-   val |= (temp_to_code(data, temp)  EXYNOS_EMUL_DATA_SHIFT) |
-   EXYNOS_EMUL_ENABLE;
-   } else {
-   val = ~EXYNOS_EMUL_ENABLE;
-   }
-
+   val = get_emul_con_reg(data, val, temp);
writel(val, data-base + reg-emul_con);
 
clk_disable(data-clk);
-- 
1.8.2.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 23/33] thermal: exynos: add -tmu_set_emulation method

2014-09-18 Thread Bartlomiej Zolnierkiewicz
Add -tmu_set_emulation method to struct exynos_tmu_data and
use it in exynos_tmu_set_emulation().  Then add -tmu_set_emulation
implementations for Exynos4412+ and Exynos5440.  Finally remove
no longer needed reg-emul_con abstraction.

There should be no functional changes caused by this patch.

Cc: Naveen Krishna Chatradhi ch.nav...@samsung.com
Cc: Amit Daniel Kachhap amit.dan...@samsung.com
Cc: Lukasz Majewski l.majew...@samsung.com
Cc: Eduardo Valentin edubez...@gmail.com
Cc: Zhang Rui rui.zh...@intel.com
Signed-off-by: Bartlomiej Zolnierkiewicz b.zolnier...@samsung.com
Acked-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/thermal/samsung/exynos_tmu.c  | 41 +--
 drivers/thermal/samsung/exynos_tmu.h  |  2 --
 drivers/thermal/samsung/exynos_tmu_data.c |  5 
 3 files changed, 34 insertions(+), 14 deletions(-)

diff --git a/drivers/thermal/samsung/exynos_tmu.c 
b/drivers/thermal/samsung/exynos_tmu.c
index 59708b6..23d3163 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -55,6 +55,7 @@
  * @tmu_initialize: SoC specific TMU initialization method
  * @tmu_control: SoC specific TMU control method
  * @tmu_read: SoC specific TMU temperature read method
+ * @tmu_set_emulation: SoC specific TMU emulation setting method
  */
 struct exynos_tmu_data {
int id;
@@ -72,6 +73,8 @@ struct exynos_tmu_data {
int (*tmu_initialize)(struct platform_device *pdev);
void (*tmu_control)(struct platform_device *pdev, bool on);
int (*tmu_read)(struct exynos_tmu_data *data);
+   void (*tmu_set_emulation)(struct exynos_tmu_data *data,
+ unsigned long temp);
 };
 
 /*
@@ -458,12 +461,36 @@ static u32 get_emul_con_reg(struct exynos_tmu_data *data, 
unsigned int val,
return val;
 }
 
+static void exynos4412_tmu_set_emulation(struct exynos_tmu_data *data,
+unsigned long temp)
+{
+   unsigned int val;
+   u32 emul_con;
+
+   if (data-soc == SOC_ARCH_EXYNOS5260)
+   emul_con = EXYNOS5260_EMUL_CON;
+   else
+   emul_con = EXYNOS_EMUL_CON;
+
+   val = readl(data-base + emul_con);
+   val = get_emul_con_reg(data, val, temp);
+   writel(val, data-base + emul_con);
+}
+
+static void exynos5440_tmu_set_emulation(struct exynos_tmu_data *data,
+unsigned long temp)
+{
+   unsigned int val;
+
+   val = readl(data-base + EXYNOS5440_TMU_S0_7_DEBUG);
+   val = get_emul_con_reg(data, val, temp);
+   writel(val, data-base + EXYNOS5440_TMU_S0_7_DEBUG);
+}
+
 static int exynos_tmu_set_emulation(void *drv_data, unsigned long temp)
 {
struct exynos_tmu_data *data = drv_data;
struct exynos_tmu_platform_data *pdata = data-pdata;
-   const struct exynos_tmu_registers *reg = pdata-registers;
-   unsigned int val;
int ret = -EINVAL;
 
if (!TMU_SUPPORTS(pdata, EMULATION))
@@ -474,11 +501,7 @@ static int exynos_tmu_set_emulation(void *drv_data, 
unsigned long temp)
 
mutex_lock(data-lock);
clk_enable(data-clk);
-
-   val = readl(data-base + reg-emul_con);
-   val = get_emul_con_reg(data, val, temp);
-   writel(val, data-base + reg-emul_con);
-
+   data-tmu_set_emulation(data, temp);
clk_disable(data-clk);
mutex_unlock(data-lock);
return 0;
@@ -486,6 +509,8 @@ out:
return ret;
 }
 #else
+#define exynos4412_tmu_set_emulation NULL
+#define exynos5440_tmu_set_emulation NULL
 static int exynos_tmu_set_emulation(void *drv_data,unsigned long temp)
{ return -EINVAL; }
 #endif/*CONFIG_THERMAL_EMULATION*/
@@ -747,11 +772,13 @@ static int exynos_tmu_probe(struct platform_device *pdev)
data-tmu_initialize = exynos4412_tmu_initialize;
data-tmu_control = exynos4210_tmu_control;
data-tmu_read = exynos4412_tmu_read;
+   data-tmu_set_emulation = exynos4412_tmu_set_emulation;
break;
case SOC_ARCH_EXYNOS5440:
data-tmu_initialize = exynos5440_tmu_initialize;
data-tmu_control = exynos5440_tmu_control;
data-tmu_read = exynos5440_tmu_read;
+   data-tmu_set_emulation = exynos5440_tmu_set_emulation;
break;
default:
ret = -EINVAL;
diff --git a/drivers/thermal/samsung/exynos_tmu.h 
b/drivers/thermal/samsung/exynos_tmu.h
index 9460e6e..785eccf 100644
--- a/drivers/thermal/samsung/exynos_tmu.h
+++ b/drivers/thermal/samsung/exynos_tmu.h
@@ -72,12 +72,10 @@ enum soc_type {
  * The register validity may vary slightly across different exynos SOC's.
  * @tmu_intstat: Register containing the interrupt status values.
  * @tmu_intclear: Register for clearing the raised interrupt status.
- * @emul_con: TMU emulation controller register.
  */
 struct exynos_tmu_registers {
u32 

[PATCH 13/33] thermal: exynos: replace threshold_falling check by Exynos SoC type one

2014-09-18 Thread Bartlomiej Zolnierkiewicz
Replace pdata-threshold_falling check for non-zero value in
exynos_tmu_initialize() by an explicit check for a SoC type
(all SoC types except Exynos5440 have pdata-threshold_falling
assigned to non-zero value in their struct exynos_tmu_registers
instances).

This is a preparation for introducing per-SoC type tmu_initialize
method.

There should be no functional changes caused by this patch.

Cc: Naveen Krishna Chatradhi ch.nav...@samsung.com
Cc: Amit Daniel Kachhap amit.dan...@samsung.com
Cc: Lukasz Majewski l.majew...@samsung.com
Cc: Eduardo Valentin edubez...@gmail.com
Cc: Zhang Rui rui.zh...@intel.com
Signed-off-by: Bartlomiej Zolnierkiewicz b.zolnier...@samsung.com
Acked-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/thermal/samsung/exynos_tmu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/thermal/samsung/exynos_tmu.c 
b/drivers/thermal/samsung/exynos_tmu.c
index f02e65d..641a77a 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -214,7 +214,7 @@ static int exynos_tmu_initialize(struct platform_device 
*pdev)
pdata-trigger_levels[i]);
rising_threshold = ~(0xff  8 * i);
rising_threshold |= threshold_code  8 * i;
-   if (pdata-threshold_falling) {
+   if (data-soc != SOC_ARCH_EXYNOS5440) {
threshold_code = temp_to_code(data,
pdata-trigger_levels[i] -
pdata-threshold_falling);
-- 
1.8.2.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 14/33] thermal: exynos: remove TMU_SUPPORT_READY_STATUS flag

2014-09-18 Thread Bartlomiej Zolnierkiewicz
Replace TMU_SUPPORT_READY_STATUS flag check in
exynos_tmu_initialize() by an explicit check for a SoC type
(all SoC types except Exynos5440 have TMU_SUPPORT_READY_STATUS
flag set in their struct exynos_tmu_init_data instances).

This is a preparation for introducing per-SoC type tmu_initialize
method.

There should be no functional changes caused by this patch.

Cc: Naveen Krishna Chatradhi ch.nav...@samsung.com
Cc: Amit Daniel Kachhap amit.dan...@samsung.com
Cc: Lukasz Majewski l.majew...@samsung.com
Cc: Eduardo Valentin edubez...@gmail.com
Cc: Zhang Rui rui.zh...@intel.com
Signed-off-by: Bartlomiej Zolnierkiewicz b.zolnier...@samsung.com
Acked-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/thermal/samsung/exynos_tmu.c  |  2 +-
 drivers/thermal/samsung/exynos_tmu.h  |  7 ++-
 drivers/thermal/samsung/exynos_tmu_data.c | 14 +-
 3 files changed, 8 insertions(+), 15 deletions(-)

diff --git a/drivers/thermal/samsung/exynos_tmu.c 
b/drivers/thermal/samsung/exynos_tmu.c
index 641a77a..d9fa49a 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -136,7 +136,7 @@ static int exynos_tmu_initialize(struct platform_device 
*pdev)
if (!IS_ERR(data-clk_sec))
clk_enable(data-clk_sec);
 
-   if (TMU_SUPPORTS(pdata, READY_STATUS)) {
+   if (data-soc != SOC_ARCH_EXYNOS5440) {
status = readb(data-base + EXYNOS_TMU_REG_STATUS);
if (!status) {
ret = -EBUSY;
diff --git a/drivers/thermal/samsung/exynos_tmu.h 
b/drivers/thermal/samsung/exynos_tmu.h
index 3430852..400f10d 100644
--- a/drivers/thermal/samsung/exynos_tmu.h
+++ b/drivers/thermal/samsung/exynos_tmu.h
@@ -54,8 +54,6 @@ enum soc_type {
  * be reloaded.
  * TMU_SUPPORT_FALLING_TRIP - This features shows that interrupt can
  * be registered for falling trips also.
- * TMU_SUPPORT_READY_STATUS - This feature tells that the TMU current
- * state(active/idle) can be checked.
  * TMU_SUPPORT_EMUL_TIME - This features allows to set next temp emulation
  * sample time.
  * TMU_SUPPORT_ADDRESS_MULTIPLE - This feature tells that the different TMU
@@ -66,9 +64,8 @@ enum soc_type {
 #define TMU_SUPPORT_MULTI_INST BIT(1)
 #define TMU_SUPPORT_TRIM_RELOADBIT(2)
 #define TMU_SUPPORT_FALLING_TRIP   BIT(3)
-#define TMU_SUPPORT_READY_STATUS   BIT(4)
-#define TMU_SUPPORT_EMUL_TIME  BIT(5)
-#define TMU_SUPPORT_ADDRESS_MULTIPLE   BIT(6)
+#define TMU_SUPPORT_EMUL_TIME  BIT(4)
+#define TMU_SUPPORT_ADDRESS_MULTIPLE   BIT(5)
 
 #define TMU_SUPPORTS(a, b) (a-features  TMU_SUPPORT_ ## b)
 
diff --git a/drivers/thermal/samsung/exynos_tmu_data.c 
b/drivers/thermal/samsung/exynos_tmu_data.c
index a63d945..af886e3 100644
--- a/drivers/thermal/samsung/exynos_tmu_data.c
+++ b/drivers/thermal/samsung/exynos_tmu_data.c
@@ -74,7 +74,6 @@ struct exynos_tmu_init_data const exynos4210_default_tmu_data 
= {
.freq_tab_count = 2,
.type = SOC_ARCH_EXYNOS4210,
.registers = exynos4210_tmu_registers,
-   .features = TMU_SUPPORT_READY_STATUS,
},
},
.tmu_count = 1,
@@ -138,8 +137,7 @@ static const struct exynos_tmu_registers 
exynos3250_tmu_registers = {
.freq_tab_count = 2, \
.registers = exynos3250_tmu_registers, \
.features = (TMU_SUPPORT_EMULATION | TMU_SUPPORT_TRIM_RELOAD | \
-   TMU_SUPPORT_FALLING_TRIP | TMU_SUPPORT_READY_STATUS | \
-   TMU_SUPPORT_EMUL_TIME)
+   TMU_SUPPORT_FALLING_TRIP | TMU_SUPPORT_EMUL_TIME)
 #endif
 
 #if defined(CONFIG_SOC_EXYNOS3250)
@@ -213,8 +211,7 @@ static const struct exynos_tmu_registers 
exynos4412_tmu_registers = {
.freq_tab_count = 2, \
.registers = exynos4412_tmu_registers, \
.features = (TMU_SUPPORT_EMULATION | TMU_SUPPORT_TRIM_RELOAD | \
-   TMU_SUPPORT_FALLING_TRIP | TMU_SUPPORT_READY_STATUS | \
-   TMU_SUPPORT_EMUL_TIME)
+   TMU_SUPPORT_FALLING_TRIP | TMU_SUPPORT_EMUL_TIME)
 #endif
 
 #if defined(CONFIG_SOC_EXYNOS4412)
@@ -304,7 +301,7 @@ static const struct exynos_tmu_registers 
exynos5260_tmu_registers = {
__EXYNOS5260_TMU_DATA \
.type = SOC_ARCH_EXYNOS5260, \
.features = (TMU_SUPPORT_EMULATION | TMU_SUPPORT_FALLING_TRIP | \
-   TMU_SUPPORT_READY_STATUS | TMU_SUPPORT_EMUL_TIME)
+   TMU_SUPPORT_EMUL_TIME)
 
 struct exynos_tmu_init_data const exynos5260_default_tmu_data = {
.tmu_data = {
@@ -381,14 +378,13 @@ static const struct exynos_tmu_registers 
exynos5420_tmu_registers = {
__EXYNOS5420_TMU_DATA \
.type = SOC_ARCH_EXYNOS5250, \
.features = (TMU_SUPPORT_EMULATION | 

[PATCH 16/33] thermal: exynos: add sanitize_temp_error() helper

2014-09-18 Thread Bartlomiej Zolnierkiewicz
Factor out code for initializing data-temp_error[1,2] values
from exynos_tmu_initialize() into sanitize_temp_error().

This is a preparation for introducing per-SoC type tmu_initialize
method.

There should be no functional changes caused by this patch.

Cc: Naveen Krishna Chatradhi ch.nav...@samsung.com
Cc: Amit Daniel Kachhap amit.dan...@samsung.com
Cc: Lukasz Majewski l.majew...@samsung.com
Cc: Eduardo Valentin edubez...@gmail.com
Cc: Zhang Rui rui.zh...@intel.com
Signed-off-by: Bartlomiej Zolnierkiewicz b.zolnier...@samsung.com
Acked-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/thermal/samsung/exynos_tmu.c | 33 -
 1 file changed, 20 insertions(+), 13 deletions(-)

diff --git a/drivers/thermal/samsung/exynos_tmu.c 
b/drivers/thermal/samsung/exynos_tmu.c
index 4903a6e..a32ca04 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -122,6 +122,25 @@ static int code_to_temp(struct exynos_tmu_data *data, u8 
temp_code)
return temp;
 }
 
+static void sanitize_temp_error(struct exynos_tmu_data *data, u32 trim_info)
+{
+   struct exynos_tmu_platform_data *pdata = data-pdata;
+
+   data-temp_error1 = trim_info  EXYNOS_TMU_TEMP_MASK;
+   data-temp_error2 = ((trim_info  EXYNOS_TRIMINFO_85_SHIFT) 
+   EXYNOS_TMU_TEMP_MASK);
+
+   if (!data-temp_error1 ||
+   (pdata-min_efuse_value  data-temp_error1) ||
+   (data-temp_error1  pdata-max_efuse_value))
+   data-temp_error1 = pdata-efuse_value  EXYNOS_TMU_TEMP_MASK;
+
+   if (!data-temp_error2)
+   data-temp_error2 =
+   (pdata-efuse_value  EXYNOS_TRIMINFO_85_SHIFT) 
+   EXYNOS_TMU_TEMP_MASK;
+}
+
 static int exynos_tmu_initialize(struct platform_device *pdev)
 {
struct exynos_tmu_data *data = platform_get_drvdata(pdev);
@@ -183,19 +202,7 @@ static int exynos_tmu_initialize(struct platform_device 
*pdev)
else
trim_info = readl(data-base + EXYNOS_TMU_REG_TRIMINFO);
}
-   data-temp_error1 = trim_info  EXYNOS_TMU_TEMP_MASK;
-   data-temp_error2 = ((trim_info  EXYNOS_TRIMINFO_85_SHIFT) 
-   EXYNOS_TMU_TEMP_MASK);
-
-   if (!data-temp_error1 ||
-   (pdata-min_efuse_value  data-temp_error1) ||
-   (data-temp_error1  pdata-max_efuse_value))
-   data-temp_error1 = pdata-efuse_value  EXYNOS_TMU_TEMP_MASK;
-
-   if (!data-temp_error2)
-   data-temp_error2 =
-   (pdata-efuse_value  EXYNOS_TRIMINFO_85_SHIFT) 
-   EXYNOS_TMU_TEMP_MASK;
+   sanitize_temp_error(data, trim_info);
 
rising_threshold = readl(data-base + reg-threshold_th0);
 
-- 
1.8.2.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 15/33] thermal: exynos: remove TMU_SUPPORT_TRIM_RELOAD flag

2014-09-18 Thread Bartlomiej Zolnierkiewicz
Replace TMU_SUPPORT_TRIM_RELOAD flag check in exynos_tmu_initialize()
by an explicit check for a SoC type (only Exynos3250, Exynos4412 and
Exynos5250 have TMU_SUPPORT_READY_STATUS flag set in their struct
exynos_tmu_init_data instances).  Please note that this requires
adding separate SoC type for Exynos5420 so it doesn't get mistaken
with Exynos5250.

This is a preparation for introducing per-SoC type tmu_initialize
method.

There should be no functional changes caused by this patch.

Cc: Naveen Krishna Chatradhi ch.nav...@samsung.com
Cc: Amit Daniel Kachhap amit.dan...@samsung.com
Cc: Lukasz Majewski l.majew...@samsung.com
Cc: Eduardo Valentin edubez...@gmail.com
Cc: Zhang Rui rui.zh...@intel.com
Signed-off-by: Bartlomiej Zolnierkiewicz b.zolnier...@samsung.com
Acked-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/thermal/samsung/exynos_tmu.c  |  5 -
 drivers/thermal/samsung/exynos_tmu.h  | 10 --
 drivers/thermal/samsung/exynos_tmu_data.c | 10 +-
 3 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/drivers/thermal/samsung/exynos_tmu.c 
b/drivers/thermal/samsung/exynos_tmu.c
index d9fa49a..4903a6e 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -144,7 +144,9 @@ static int exynos_tmu_initialize(struct platform_device 
*pdev)
}
}
 
-   if (TMU_SUPPORTS(pdata, TRIM_RELOAD)) {
+   if (data-soc == SOC_ARCH_EXYNOS3250 ||
+   data-soc == SOC_ARCH_EXYNOS4412 ||
+   data-soc == SOC_ARCH_EXYNOS5250) {
if (data-soc == SOC_ARCH_EXYNOS3250) {
ctrl = readl(data-base + EXYNOS_TMU_TRIMINFO_CON1);
ctrl |= EXYNOS_TRIMINFO_RELOAD_ENABLE;
@@ -615,6 +617,7 @@ static int exynos_tmu_probe(struct platform_device *pdev)
pdata-type == SOC_ARCH_EXYNOS4412 ||
pdata-type == SOC_ARCH_EXYNOS5250 ||
pdata-type == SOC_ARCH_EXYNOS5260 ||
+   pdata-type == SOC_ARCH_EXYNOS5420 ||
pdata-type == SOC_ARCH_EXYNOS5420_TRIMINFO ||
pdata-type == SOC_ARCH_EXYNOS5440)
data-soc = pdata-type;
diff --git a/drivers/thermal/samsung/exynos_tmu.h 
b/drivers/thermal/samsung/exynos_tmu.h
index 400f10d..02ef3b0 100644
--- a/drivers/thermal/samsung/exynos_tmu.h
+++ b/drivers/thermal/samsung/exynos_tmu.h
@@ -40,6 +40,7 @@ enum soc_type {
SOC_ARCH_EXYNOS4412,
SOC_ARCH_EXYNOS5250,
SOC_ARCH_EXYNOS5260,
+   SOC_ARCH_EXYNOS5420,
SOC_ARCH_EXYNOS5420_TRIMINFO,
SOC_ARCH_EXYNOS5440,
 };
@@ -50,8 +51,6 @@ enum soc_type {
  * temperature to the TMU controller.
  * TMU_SUPPORT_MULTI_INST - This features denotes that the soc
  * has many instances of TMU.
- * TMU_SUPPORT_TRIM_RELOAD - This features shows that trimming can
- * be reloaded.
  * TMU_SUPPORT_FALLING_TRIP - This features shows that interrupt can
  * be registered for falling trips also.
  * TMU_SUPPORT_EMUL_TIME - This features allows to set next temp emulation
@@ -62,10 +61,9 @@ enum soc_type {
  */
 #define TMU_SUPPORT_EMULATION  BIT(0)
 #define TMU_SUPPORT_MULTI_INST BIT(1)
-#define TMU_SUPPORT_TRIM_RELOADBIT(2)
-#define TMU_SUPPORT_FALLING_TRIP   BIT(3)
-#define TMU_SUPPORT_EMUL_TIME  BIT(4)
-#define TMU_SUPPORT_ADDRESS_MULTIPLE   BIT(5)
+#define TMU_SUPPORT_FALLING_TRIP   BIT(2)
+#define TMU_SUPPORT_EMUL_TIME  BIT(3)
+#define TMU_SUPPORT_ADDRESS_MULTIPLE   BIT(4)
 
 #define TMU_SUPPORTS(a, b) (a-features  TMU_SUPPORT_ ## b)
 
diff --git a/drivers/thermal/samsung/exynos_tmu_data.c 
b/drivers/thermal/samsung/exynos_tmu_data.c
index af886e3..27782ac 100644
--- a/drivers/thermal/samsung/exynos_tmu_data.c
+++ b/drivers/thermal/samsung/exynos_tmu_data.c
@@ -136,8 +136,8 @@ static const struct exynos_tmu_registers 
exynos3250_tmu_registers = {
}, \
.freq_tab_count = 2, \
.registers = exynos3250_tmu_registers, \
-   .features = (TMU_SUPPORT_EMULATION | TMU_SUPPORT_TRIM_RELOAD | \
-   TMU_SUPPORT_FALLING_TRIP | TMU_SUPPORT_EMUL_TIME)
+   .features = (TMU_SUPPORT_EMULATION | TMU_SUPPORT_FALLING_TRIP | \
+   TMU_SUPPORT_EMUL_TIME)
 #endif
 
 #if defined(CONFIG_SOC_EXYNOS3250)
@@ -210,8 +210,8 @@ static const struct exynos_tmu_registers 
exynos4412_tmu_registers = {
}, \
.freq_tab_count = 2, \
.registers = exynos4412_tmu_registers, \
-   .features = (TMU_SUPPORT_EMULATION | TMU_SUPPORT_TRIM_RELOAD | \
-   TMU_SUPPORT_FALLING_TRIP | TMU_SUPPORT_EMUL_TIME)
+   .features = (TMU_SUPPORT_EMULATION | TMU_SUPPORT_FALLING_TRIP | \
+   TMU_SUPPORT_EMUL_TIME)
 #endif
 
 #if defined(CONFIG_SOC_EXYNOS4412)
@@ -376,7 +376,7 @@ static const struct 

[PATCH 17/33] thermal: exynos: add get_th_reg() helper

2014-09-18 Thread Bartlomiej Zolnierkiewicz
Factor out code for preparing threshold register value from
exynos_tmu_initialize() into get_th_reg().

This is a preparation for introducing per-SoC type tmu_initialize
method.

There should be no functional changes caused by this patch.

Cc: Naveen Krishna Chatradhi ch.nav...@samsung.com
Cc: Amit Daniel Kachhap amit.dan...@samsung.com
Cc: Lukasz Majewski l.majew...@samsung.com
Cc: Eduardo Valentin edubez...@gmail.com
Cc: Zhang Rui rui.zh...@intel.com
Signed-off-by: Bartlomiej Zolnierkiewicz b.zolnier...@samsung.com
Acked-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/thermal/samsung/exynos_tmu.c | 37 ++--
 1 file changed, 23 insertions(+), 14 deletions(-)

diff --git a/drivers/thermal/samsung/exynos_tmu.c 
b/drivers/thermal/samsung/exynos_tmu.c
index a32ca04..80b781d 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -141,6 +141,25 @@ static void sanitize_temp_error(struct exynos_tmu_data 
*data, u32 trim_info)
EXYNOS_TMU_TEMP_MASK;
 }
 
+static u32 get_th_reg(struct exynos_tmu_data *data, u32 threshold, bool 
falling)
+{
+   struct exynos_tmu_platform_data *pdata = data-pdata;
+   int i;
+
+   for (i = 0; i  pdata-non_hw_trigger_levels; i++) {
+   u8 temp = pdata-trigger_levels[i];
+
+   if (falling)
+   temp -= pdata-threshold_falling;
+   else
+   threshold = ~(0xff  8 * i);
+
+   threshold |= temp_to_code(data, temp)  8 * i;
+   }
+
+   return threshold;
+}
+
 static int exynos_tmu_initialize(struct platform_device *pdev)
 {
struct exynos_tmu_data *data = platform_get_drvdata(pdev);
@@ -204,8 +223,6 @@ static int exynos_tmu_initialize(struct platform_device 
*pdev)
}
sanitize_temp_error(data, trim_info);
 
-   rising_threshold = readl(data-base + reg-threshold_th0);
-
if (data-soc == SOC_ARCH_EXYNOS4210) {
/* Write temperature code for threshold */
threshold_code = temp_to_code(data, pdata-threshold);
@@ -218,18 +235,10 @@ static int exynos_tmu_initialize(struct platform_device 
*pdev)
writel(reg-intclr_rise_mask, data-base + reg-tmu_intclear);
} else {
/* Write temperature code for rising and falling threshold */
-   for (i = 0; i  pdata-non_hw_trigger_levels; i++) {
-   threshold_code = temp_to_code(data,
-   pdata-trigger_levels[i]);
-   rising_threshold = ~(0xff  8 * i);
-   rising_threshold |= threshold_code  8 * i;
-   if (data-soc != SOC_ARCH_EXYNOS5440) {
-   threshold_code = temp_to_code(data,
-   pdata-trigger_levels[i] -
-   pdata-threshold_falling);
-   falling_threshold |= threshold_code  8 * i;
-   }
-   }
+   rising_threshold = readl(data-base + reg-threshold_th0);
+   rising_threshold = get_th_reg(data, rising_threshold, false);
+   if (data-soc != SOC_ARCH_EXYNOS5440)
+   falling_threshold = get_th_reg(data, 0, true);
 
writel(rising_threshold,
data-base + reg-threshold_th0);
-- 
1.8.2.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 18/33] thermal: exynos: add -tmu_initialize method

2014-09-18 Thread Bartlomiej Zolnierkiewicz
Add -tmu_initialize method to struct exynos_tmu_data and
use it in exynos_tmu_initialize().  Then add -tmu_initialize
implementations for Exynos4210, Exynos4412+ and Exynos5440.
Finally remove no longer needed reg-threshold_th[0,1],
reg-intclr_[fall,rise]_shift and reg-intclr_[rise,fall]_mask
abstractions.

There are more improvements available in the future on top
of this patch like merging HW_TRIP level setting with setting
of other levels for Exynos4412+ or adding separate method
for clearing IRQs using INTCLEAR register (for Exynos5420,
Exynos5260 and Exynos4412+).

There should be no functional changes caused by this patch.

Cc: Naveen Krishna Chatradhi ch.nav...@samsung.com
Cc: Amit Daniel Kachhap amit.dan...@samsung.com
Cc: Lukasz Majewski l.majew...@samsung.com
Cc: Eduardo Valentin edubez...@gmail.com
Cc: Zhang Rui rui.zh...@intel.com
Signed-off-by: Bartlomiej Zolnierkiewicz b.zolnier...@samsung.com
Acked-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/thermal/samsung/exynos_tmu.c  | 293 ++
 drivers/thermal/samsung/exynos_tmu.h  |  13 --
 drivers/thermal/samsung/exynos_tmu_data.c |  32 
 3 files changed, 174 insertions(+), 164 deletions(-)

diff --git a/drivers/thermal/samsung/exynos_tmu.c 
b/drivers/thermal/samsung/exynos_tmu.c
index 80b781d..8dc5bf6 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -52,6 +52,7 @@
  * @temp_error2: fused value of the second point trim.
  * @regulator: pointer to the TMU regulator structure.
  * @reg_conf: pointer to structure to register with core thermal.
+ * @tmu_initialize: SoC specific TMU initialization method
  */
 struct exynos_tmu_data {
int id;
@@ -66,6 +67,7 @@ struct exynos_tmu_data {
u8 temp_error1, temp_error2;
struct regulator *regulator;
struct thermal_sensor_conf *reg_conf;
+   int (*tmu_initialize)(struct platform_device *pdev);
 };
 
 /*
@@ -163,120 +165,13 @@ static u32 get_th_reg(struct exynos_tmu_data *data, u32 
threshold, bool falling)
 static int exynos_tmu_initialize(struct platform_device *pdev)
 {
struct exynos_tmu_data *data = platform_get_drvdata(pdev);
-   struct exynos_tmu_platform_data *pdata = data-pdata;
-   const struct exynos_tmu_registers *reg = pdata-registers;
-   unsigned int status, trim_info = 0, con, ctrl;
-   unsigned int rising_threshold = 0, falling_threshold = 0;
-   int ret = 0, threshold_code, i;
+   int ret;
 
mutex_lock(data-lock);
clk_enable(data-clk);
if (!IS_ERR(data-clk_sec))
clk_enable(data-clk_sec);
-
-   if (data-soc != SOC_ARCH_EXYNOS5440) {
-   status = readb(data-base + EXYNOS_TMU_REG_STATUS);
-   if (!status) {
-   ret = -EBUSY;
-   goto out;
-   }
-   }
-
-   if (data-soc == SOC_ARCH_EXYNOS3250 ||
-   data-soc == SOC_ARCH_EXYNOS4412 ||
-   data-soc == SOC_ARCH_EXYNOS5250) {
-   if (data-soc == SOC_ARCH_EXYNOS3250) {
-   ctrl = readl(data-base + EXYNOS_TMU_TRIMINFO_CON1);
-   ctrl |= EXYNOS_TRIMINFO_RELOAD_ENABLE;
-   writel(ctrl, data-base + EXYNOS_TMU_TRIMINFO_CON1);
-   }
-   ctrl = readl(data-base + EXYNOS_TMU_TRIMINFO_CON2);
-   ctrl |= EXYNOS_TRIMINFO_RELOAD_ENABLE;
-   writel(ctrl, data-base + EXYNOS_TMU_TRIMINFO_CON2);
-   }
-
-   /* Save trimming info in order to perform calibration */
-   if (data-soc == SOC_ARCH_EXYNOS5440) {
-   /*
-* For exynos5440 soc triminfo value is swapped between TMU0 and
-* TMU2, so the below logic is needed.
-*/
-   switch (data-id) {
-   case 0:
-   trim_info = readl(data-base +
-   EXYNOS5440_EFUSE_SWAP_OFFSET + 
EXYNOS5440_TMU_S0_7_TRIM);
-   break;
-   case 1:
-   trim_info = readl(data-base + 
EXYNOS5440_TMU_S0_7_TRIM);
-   break;
-   case 2:
-   trim_info = readl(data-base -
-   EXYNOS5440_EFUSE_SWAP_OFFSET + 
EXYNOS5440_TMU_S0_7_TRIM);
-   }
-   } else {
-   /* On exynos5420 the triminfo register is in the shared space */
-   if (data-soc == SOC_ARCH_EXYNOS5420_TRIMINFO)
-   trim_info = readl(data-base_second +
-   EXYNOS_TMU_REG_TRIMINFO);
-   else
-   trim_info = readl(data-base + EXYNOS_TMU_REG_TRIMINFO);
-   }
-   sanitize_temp_error(data, trim_info);
-
-   if (data-soc == SOC_ARCH_EXYNOS4210) {
-   /* Write temperature code for threshold */
-   threshold_code = temp_to_code(data, pdata-threshold);
- 

[PATCH 07/33] thermal: exynos: remove needless therm_trip_en_shift abstraction

2014-09-18 Thread Bartlomiej Zolnierkiewicz
reg-therm_trip_en_shift is used only in exynos_tmu_initialize()
and not accessed on Exynos4210 (also reg-therm_trip_en_shift is
not even assigned in exynos4210_tmu_registers but it is assigned
to identical value for all other SoC types) so the register
abstraction is not needed and can be removed.

There should be no functional changes caused by this patch.

Cc: Naveen Krishna Chatradhi ch.nav...@samsung.com
Cc: Amit Daniel Kachhap amit.dan...@samsung.com
Cc: Lukasz Majewski l.majew...@samsung.com
Cc: Eduardo Valentin edubez...@gmail.com
Cc: Zhang Rui rui.zh...@intel.com
Signed-off-by: Bartlomiej Zolnierkiewicz b.zolnier...@samsung.com
Acked-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/thermal/samsung/exynos_tmu.c  | 2 +-
 drivers/thermal/samsung/exynos_tmu.h  | 2 --
 drivers/thermal/samsung/exynos_tmu_data.c | 5 -
 3 files changed, 1 insertion(+), 8 deletions(-)

diff --git a/drivers/thermal/samsung/exynos_tmu.c 
b/drivers/thermal/samsung/exynos_tmu.c
index 7c9793a..350a1f5 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -251,7 +251,7 @@ static int exynos_tmu_initialize(struct platform_device 
*pdev)
data-base + reg-threshold_th2);
}
con = readl(data-base + reg-tmu_ctrl);
-   con |= (1  reg-therm_trip_en_shift);
+   con |= (1  EXYNOS_TMU_THERM_TRIP_EN_SHIFT);
writel(con, data-base + reg-tmu_ctrl);
}
}
diff --git a/drivers/thermal/samsung/exynos_tmu.h 
b/drivers/thermal/samsung/exynos_tmu.h
index 6341d74..8f5ffcb 100644
--- a/drivers/thermal/samsung/exynos_tmu.h
+++ b/drivers/thermal/samsung/exynos_tmu.h
@@ -77,7 +77,6 @@ enum soc_type {
  * bitfields. The register validity, offsets and bitfield values may vary
  * slightly across different exynos SOC's.
  * @tmu_ctrl: TMU main controller register.
- * @therm_trip_en_shift: shift bits of tripping enable in tmu_ctrl register.
  * @tmu_cur_temp: register containing the current temperature of the TMU.
  * @threshold_th0: Register containing first set of rising levels.
  * @threshold_th1: Register containing second set of rising levels.
@@ -104,7 +103,6 @@ enum soc_type {
  */
 struct exynos_tmu_registers {
u32 tmu_ctrl;
-   u32 therm_trip_en_shift;
 
u32 tmu_cur_temp;
 
diff --git a/drivers/thermal/samsung/exynos_tmu_data.c 
b/drivers/thermal/samsung/exynos_tmu_data.c
index 22a0ade..a37f490 100644
--- a/drivers/thermal/samsung/exynos_tmu_data.c
+++ b/drivers/thermal/samsung/exynos_tmu_data.c
@@ -84,7 +84,6 @@ struct exynos_tmu_init_data const exynos4210_default_tmu_data 
= {
 #if defined(CONFIG_SOC_EXYNOS3250)
 static const struct exynos_tmu_registers exynos3250_tmu_registers = {
.tmu_ctrl = EXYNOS_TMU_REG_CONTROL,
-   .therm_trip_en_shift = EXYNOS_TMU_THERM_TRIP_EN_SHIFT,
.tmu_cur_temp = EXYNOS_TMU_REG_CURRENT_TEMP,
.threshold_th0 = EXYNOS_THD_TEMP_RISE,
.threshold_th1 = EXYNOS_THD_TEMP_FALL,
@@ -161,7 +160,6 @@ struct exynos_tmu_init_data const 
exynos3250_default_tmu_data = {
 #if defined(CONFIG_SOC_EXYNOS4412) || defined(CONFIG_SOC_EXYNOS5250)
 static const struct exynos_tmu_registers exynos4412_tmu_registers = {
.tmu_ctrl = EXYNOS_TMU_REG_CONTROL,
-   .therm_trip_en_shift = EXYNOS_TMU_THERM_TRIP_EN_SHIFT,
.tmu_cur_temp = EXYNOS_TMU_REG_CURRENT_TEMP,
.threshold_th0 = EXYNOS_THD_TEMP_RISE,
.threshold_th1 = EXYNOS_THD_TEMP_FALL,
@@ -251,7 +249,6 @@ struct exynos_tmu_init_data const 
exynos5250_default_tmu_data = {
 #if defined(CONFIG_SOC_EXYNOS5260)
 static const struct exynos_tmu_registers exynos5260_tmu_registers = {
.tmu_ctrl = EXYNOS_TMU_REG_CONTROL,
-   .therm_trip_en_shift = EXYNOS_TMU_THERM_TRIP_EN_SHIFT,
.tmu_cur_temp = EXYNOS_TMU_REG_CURRENT_TEMP,
.threshold_th0 = EXYNOS_THD_TEMP_RISE,
.threshold_th1 = EXYNOS_THD_TEMP_FALL,
@@ -330,7 +327,6 @@ struct exynos_tmu_init_data const 
exynos5260_default_tmu_data = {
 #if defined(CONFIG_SOC_EXYNOS5420)
 static const struct exynos_tmu_registers exynos5420_tmu_registers = {
.tmu_ctrl = EXYNOS_TMU_REG_CONTROL,
-   .therm_trip_en_shift = EXYNOS_TMU_THERM_TRIP_EN_SHIFT,
.tmu_cur_temp = EXYNOS_TMU_REG_CURRENT_TEMP,
.threshold_th0 = EXYNOS_THD_TEMP_RISE,
.threshold_th1 = EXYNOS_THD_TEMP_FALL,
@@ -417,7 +413,6 @@ struct exynos_tmu_init_data const 
exynos5420_default_tmu_data = {
 #if defined(CONFIG_SOC_EXYNOS5440)
 static const struct exynos_tmu_registers exynos5440_tmu_registers = {
.tmu_ctrl = EXYNOS5440_TMU_S0_7_CTRL,
-   .therm_trip_en_shift = EXYNOS_TMU_THERM_TRIP_EN_SHIFT,
.tmu_cur_temp = EXYNOS5440_TMU_S0_7_TEMP,
.threshold_th0 = EXYNOS5440_TMU_S0_7_TH0,
.threshold_th1 = EXYNOS5440_TMU_S0_7_TH1,
-- 
1.8.2.3

--
To unsubscribe from this list: send the line 

[PATCH 08/33] thermal: exynos: remove needless emul_temp_shift abstraction

2014-09-18 Thread Bartlomiej Zolnierkiewicz
reg-emul_temp_shift is used only in exynos_tmu_set_emulation()
and accessed only if TMU_SUPPORT_EMULATION flag is set.  This
flag is not set for Exynos4210 (reg-emul_temp_shift field is
not even assigned in exynos4210_tmu_registers and is assigned
to identical value for all other SoC types) so the abstraction
is not needed and can be removed.

There should be no functional changes caused by this patch.

Cc: Naveen Krishna Chatradhi ch.nav...@samsung.com
Cc: Amit Daniel Kachhap amit.dan...@samsung.com
Cc: Lukasz Majewski l.majew...@samsung.com
Cc: Eduardo Valentin edubez...@gmail.com
Cc: Zhang Rui rui.zh...@intel.com
Signed-off-by: Bartlomiej Zolnierkiewicz b.zolnier...@samsung.com
Acked-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/thermal/samsung/exynos_tmu.c  | 4 ++--
 drivers/thermal/samsung/exynos_tmu.h  | 2 --
 drivers/thermal/samsung/exynos_tmu_data.c | 5 -
 3 files changed, 2 insertions(+), 9 deletions(-)

diff --git a/drivers/thermal/samsung/exynos_tmu.c 
b/drivers/thermal/samsung/exynos_tmu.c
index 350a1f5..974c337 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -368,8 +368,8 @@ static int exynos_tmu_set_emulation(void *drv_data, 
unsigned long temp)
val = ~(EXYNOS_EMUL_TIME_MASK  reg-emul_time_shift);
val |= (EXYNOS_EMUL_TIME  reg-emul_time_shift);
}
-   val = ~(EXYNOS_EMUL_DATA_MASK  reg-emul_temp_shift);
-   val |= (temp_to_code(data, temp)  reg-emul_temp_shift) |
+   val = ~(EXYNOS_EMUL_DATA_MASK  EXYNOS_EMUL_DATA_SHIFT);
+   val |= (temp_to_code(data, temp)  EXYNOS_EMUL_DATA_SHIFT) |
EXYNOS_EMUL_ENABLE;
} else {
val = ~EXYNOS_EMUL_ENABLE;
diff --git a/drivers/thermal/samsung/exynos_tmu.h 
b/drivers/thermal/samsung/exynos_tmu.h
index 8f5ffcb..649a654 100644
--- a/drivers/thermal/samsung/exynos_tmu.h
+++ b/drivers/thermal/samsung/exynos_tmu.h
@@ -96,7 +96,6 @@ enum soc_type {
  * @intclr_rise_mask: mask bits of all rising interrupt bits.
  * @intclr_fall_mask: mask bits of all rising interrupt bits.
  * @emul_con: TMU emulation controller register.
- * @emul_temp_shift: shift bits of emulation temperature.
  * @emul_time_shift: shift bits of emulation time.
  * @tmu_irqstatus: register to find which TMU generated interrupts.
  * @tmu_pmin: register to get/set the Pmin value.
@@ -127,7 +126,6 @@ struct exynos_tmu_registers {
u32 intclr_rise_mask;
 
u32 emul_con;
-   u32 emul_temp_shift;
u32 emul_time_shift;
 
u32 tmu_irqstatus;
diff --git a/drivers/thermal/samsung/exynos_tmu_data.c 
b/drivers/thermal/samsung/exynos_tmu_data.c
index a37f490..3ae0376 100644
--- a/drivers/thermal/samsung/exynos_tmu_data.c
+++ b/drivers/thermal/samsung/exynos_tmu_data.c
@@ -99,7 +99,6 @@ static const struct exynos_tmu_registers 
exynos3250_tmu_registers = {
.intclr_rise_mask = EXYNOS_TMU_RISE_INT_MASK,
.intclr_fall_mask = EXYNOS_TMU_FALL_INT_MASK,
.emul_con = EXYNOS_EMUL_CON,
-   .emul_temp_shift = EXYNOS_EMUL_DATA_SHIFT,
.emul_time_shift = EXYNOS_EMUL_TIME_SHIFT,
 };
 
@@ -176,7 +175,6 @@ static const struct exynos_tmu_registers 
exynos4412_tmu_registers = {
.intclr_rise_mask = EXYNOS_TMU_RISE_INT_MASK,
.intclr_fall_mask = EXYNOS_TMU_FALL_INT_MASK,
.emul_con = EXYNOS_EMUL_CON,
-   .emul_temp_shift = EXYNOS_EMUL_DATA_SHIFT,
.emul_time_shift = EXYNOS_EMUL_TIME_SHIFT,
 };
 
@@ -265,7 +263,6 @@ static const struct exynos_tmu_registers 
exynos5260_tmu_registers = {
.intclr_rise_mask = EXYNOS5260_TMU_RISE_INT_MASK,
.intclr_fall_mask = EXYNOS5260_TMU_FALL_INT_MASK,
.emul_con = EXYNOS5260_EMUL_CON,
-   .emul_temp_shift = EXYNOS_EMUL_DATA_SHIFT,
.emul_time_shift = EXYNOS_EMUL_TIME_SHIFT,
 };
 
@@ -344,7 +341,6 @@ static const struct exynos_tmu_registers 
exynos5420_tmu_registers = {
.intclr_rise_mask = EXYNOS_TMU_RISE_INT_MASK,
.intclr_fall_mask = EXYNOS_TMU_FALL_INT_MASK,
.emul_con = EXYNOS_EMUL_CON,
-   .emul_temp_shift = EXYNOS_EMUL_DATA_SHIFT,
.emul_time_shift = EXYNOS_EMUL_TIME_SHIFT,
 };
 
@@ -432,7 +428,6 @@ static const struct exynos_tmu_registers 
exynos5440_tmu_registers = {
.intclr_fall_mask = EXYNOS5440_TMU_FALL_INT_MASK,
.tmu_irqstatus = EXYNOS5440_TMU_IRQ_STATUS,
.emul_con = EXYNOS5440_TMU_S0_7_DEBUG,
-   .emul_temp_shift = EXYNOS_EMUL_DATA_SHIFT,
.tmu_pmin = EXYNOS5440_TMU_PMIN,
 };
 
-- 
1.8.2.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 10/33] thermal: exynos: replace tmu_irqstatus check by Exynos5440 one

2014-09-18 Thread Bartlomiej Zolnierkiewicz
reg-tmu_irqstatus is set to non-zero value only for Exynos5440
so replace check for non-zero value of reg-tmu_irqstatus by
explicitly checking for Exynos5440 SoC type.  Then remove no
longer needed reg-tmu_irqstatus register abstraction.

There should be no functional changes caused by this patch.

Cc: Naveen Krishna Chatradhi ch.nav...@samsung.com
Cc: Amit Daniel Kachhap amit.dan...@samsung.com
Cc: Lukasz Majewski l.majew...@samsung.com
Cc: Eduardo Valentin edubez...@gmail.com
Cc: Zhang Rui rui.zh...@intel.com
Signed-off-by: Bartlomiej Zolnierkiewicz b.zolnier...@samsung.com
Acked-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/thermal/samsung/exynos_tmu.c  | 4 ++--
 drivers/thermal/samsung/exynos_tmu.h  | 2 --
 drivers/thermal/samsung/exynos_tmu_data.c | 1 -
 3 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/thermal/samsung/exynos_tmu.c 
b/drivers/thermal/samsung/exynos_tmu.c
index a4ed576..85e74e1 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -399,8 +399,8 @@ static void exynos_tmu_work(struct work_struct *work)
if (!IS_ERR(data-clk_sec))
clk_enable(data-clk_sec);
/* Find which sensor generated this interrupt */
-   if (reg-tmu_irqstatus) {
-   val_type = readl(data-base_second + reg-tmu_irqstatus);
+   if (data-soc == SOC_ARCH_EXYNOS5440) {
+   val_type = readl(data-base_second + EXYNOS5440_TMU_IRQ_STATUS);
if (!((val_type  data-id)  0x1))
goto out;
}
diff --git a/drivers/thermal/samsung/exynos_tmu.h 
b/drivers/thermal/samsung/exynos_tmu.h
index 6567293..5ab7482 100644
--- a/drivers/thermal/samsung/exynos_tmu.h
+++ b/drivers/thermal/samsung/exynos_tmu.h
@@ -96,7 +96,6 @@ enum soc_type {
  * @intclr_rise_mask: mask bits of all rising interrupt bits.
  * @intclr_fall_mask: mask bits of all rising interrupt bits.
  * @emul_con: TMU emulation controller register.
- * @tmu_irqstatus: register to find which TMU generated interrupts.
  * @tmu_pmin: register to get/set the Pmin value.
  */
 struct exynos_tmu_registers {
@@ -126,7 +125,6 @@ struct exynos_tmu_registers {
 
u32 emul_con;
 
-   u32 tmu_irqstatus;
u32 tmu_pmin;
 };
 
diff --git a/drivers/thermal/samsung/exynos_tmu_data.c 
b/drivers/thermal/samsung/exynos_tmu_data.c
index b9a3778..5811b99 100644
--- a/drivers/thermal/samsung/exynos_tmu_data.c
+++ b/drivers/thermal/samsung/exynos_tmu_data.c
@@ -422,7 +422,6 @@ static const struct exynos_tmu_registers 
exynos5440_tmu_registers = {
.intclr_rise_shift = EXYNOS5440_TMU_RISE_INT_SHIFT,
.intclr_rise_mask = EXYNOS5440_TMU_RISE_INT_MASK,
.intclr_fall_mask = EXYNOS5440_TMU_FALL_INT_MASK,
-   .tmu_irqstatus = EXYNOS5440_TMU_IRQ_STATUS,
.emul_con = EXYNOS5440_TMU_S0_7_DEBUG,
.tmu_pmin = EXYNOS5440_TMU_PMIN,
 };
-- 
1.8.2.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 05/33] thermal: exynos: remove needless test_mux_addr_shift abstraction

2014-09-18 Thread Bartlomiej Zolnierkiewicz
reg-test_mux_addr_shift is used only if pdata-test_mux is
non-zero.  pdata-test_mux is defined only on Exynos3250 and
Exynos4412 (other SoC types don't even have pdata-test_mux
entry assigned in their struct exynos_tmu_registers instances)
so the abstraction is not needed and can be removed.

There should be no functional changes caused by this patch.

Cc: Naveen Krishna Chatradhi ch.nav...@samsung.com
Cc: Amit Daniel Kachhap amit.dan...@samsung.com
Cc: Lukasz Majewski l.majew...@samsung.com
Cc: Eduardo Valentin edubez...@gmail.com
Cc: Zhang Rui rui.zh...@intel.com
Signed-off-by: Bartlomiej Zolnierkiewicz b.zolnier...@samsung.com
Acked-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/thermal/samsung/exynos_tmu.c  | 2 +-
 drivers/thermal/samsung/exynos_tmu.h  | 2 --
 drivers/thermal/samsung/exynos_tmu_data.c | 2 --
 3 files changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/thermal/samsung/exynos_tmu.c 
b/drivers/thermal/samsung/exynos_tmu.c
index 52bcc23..1527b25 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -280,7 +280,7 @@ static void exynos_tmu_control(struct platform_device 
*pdev, bool on)
con = readl(data-base + reg-tmu_ctrl);
 
if (pdata-test_mux)
-   con |= (pdata-test_mux  reg-test_mux_addr_shift);
+   con |= (pdata-test_mux  EXYNOS4412_MUX_ADDR_SHIFT);
 
con = ~(EXYNOS_TMU_REF_VOLTAGE_MASK  EXYNOS_TMU_REF_VOLTAGE_SHIFT);
con |= pdata-reference_voltage  EXYNOS_TMU_REF_VOLTAGE_SHIFT;
diff --git a/drivers/thermal/samsung/exynos_tmu.h 
b/drivers/thermal/samsung/exynos_tmu.h
index d12e242..5bcf7a8 100644
--- a/drivers/thermal/samsung/exynos_tmu.h
+++ b/drivers/thermal/samsung/exynos_tmu.h
@@ -77,7 +77,6 @@ enum soc_type {
  * bitfields. The register validity, offsets and bitfield values may vary
  * slightly across different exynos SOC's.
  * @tmu_ctrl: TMU main controller register.
- * @test_mux_addr_shift: shift bits of test mux address.
  * @therm_trip_mode_shift: shift bits of tripping mode in tmu_ctrl register.
  * @therm_trip_mode_mask: mask bits of tripping mode in tmu_ctrl register.
  * @therm_trip_en_shift: shift bits of tripping enable in tmu_ctrl register.
@@ -107,7 +106,6 @@ enum soc_type {
  */
 struct exynos_tmu_registers {
u32 tmu_ctrl;
-   u32 test_mux_addr_shift;
u32 therm_trip_mode_shift;
u32 therm_trip_mode_mask;
u32 therm_trip_en_shift;
diff --git a/drivers/thermal/samsung/exynos_tmu_data.c 
b/drivers/thermal/samsung/exynos_tmu_data.c
index 04f1d71..988e327 100644
--- a/drivers/thermal/samsung/exynos_tmu_data.c
+++ b/drivers/thermal/samsung/exynos_tmu_data.c
@@ -84,7 +84,6 @@ struct exynos_tmu_init_data const exynos4210_default_tmu_data 
= {
 #if defined(CONFIG_SOC_EXYNOS3250)
 static const struct exynos_tmu_registers exynos3250_tmu_registers = {
.tmu_ctrl = EXYNOS_TMU_REG_CONTROL,
-   .test_mux_addr_shift = EXYNOS4412_MUX_ADDR_SHIFT,
.therm_trip_mode_shift = EXYNOS_TMU_TRIP_MODE_SHIFT,
.therm_trip_mode_mask = EXYNOS_TMU_TRIP_MODE_MASK,
.therm_trip_en_shift = EXYNOS_TMU_THERM_TRIP_EN_SHIFT,
@@ -164,7 +163,6 @@ struct exynos_tmu_init_data const 
exynos3250_default_tmu_data = {
 #if defined(CONFIG_SOC_EXYNOS4412) || defined(CONFIG_SOC_EXYNOS5250)
 static const struct exynos_tmu_registers exynos4412_tmu_registers = {
.tmu_ctrl = EXYNOS_TMU_REG_CONTROL,
-   .test_mux_addr_shift = EXYNOS4412_MUX_ADDR_SHIFT,
.therm_trip_mode_shift = EXYNOS_TMU_TRIP_MODE_SHIFT,
.therm_trip_mode_mask = EXYNOS_TMU_TRIP_MODE_MASK,
.therm_trip_en_shift = EXYNOS_TMU_THERM_TRIP_EN_SHIFT,
-- 
1.8.2.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 06/33] thermal: exynos: remove needless therm_trip_[mode,mask]_shift abstractions

2014-09-18 Thread Bartlomiej Zolnierkiewicz
reg-therm_trip_mode_shift and reg-therm_trip_mode_mask are
used only in exynos_tmu_control() and accessed only if
pdata-noise_cancel_mode is non-zero.  pdata-noise_cancel
field is not defined on Exynos4210 (also therm_trip_mode_shift
and therm_trip_mode_mask entries are not even assigned in
exynos4210_tmu_registers but they are assigned to identical
values for all other SoC types) so the abstractions are not
needed and can be removed.

There should be no functional changes caused by this patch.

Cc: Naveen Krishna Chatradhi ch.nav...@samsung.com
Cc: Amit Daniel Kachhap amit.dan...@samsung.com
Cc: Lukasz Majewski l.majew...@samsung.com
Cc: Eduardo Valentin edubez...@gmail.com
Cc: Zhang Rui rui.zh...@intel.com
Signed-off-by: Bartlomiej Zolnierkiewicz b.zolnier...@samsung.com
Acked-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/thermal/samsung/exynos_tmu.c  |  5 ++---
 drivers/thermal/samsung/exynos_tmu.h  |  4 
 drivers/thermal/samsung/exynos_tmu_data.c | 10 --
 3 files changed, 2 insertions(+), 17 deletions(-)

diff --git a/drivers/thermal/samsung/exynos_tmu.c 
b/drivers/thermal/samsung/exynos_tmu.c
index 1527b25..7c9793a 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -289,9 +289,8 @@ static void exynos_tmu_control(struct platform_device 
*pdev, bool on)
con |= (pdata-gain  EXYNOS_TMU_BUF_SLOPE_SEL_SHIFT);
 
if (pdata-noise_cancel_mode) {
-   con = ~(reg-therm_trip_mode_mask 
-   reg-therm_trip_mode_shift);
-   con |= (pdata-noise_cancel_mode  reg-therm_trip_mode_shift);
+   con = ~(EXYNOS_TMU_TRIP_MODE_MASK  
EXYNOS_TMU_TRIP_MODE_SHIFT);
+   con |= (pdata-noise_cancel_mode  EXYNOS_TMU_TRIP_MODE_SHIFT);
}
 
if (on) {
diff --git a/drivers/thermal/samsung/exynos_tmu.h 
b/drivers/thermal/samsung/exynos_tmu.h
index 5bcf7a8..6341d74 100644
--- a/drivers/thermal/samsung/exynos_tmu.h
+++ b/drivers/thermal/samsung/exynos_tmu.h
@@ -77,8 +77,6 @@ enum soc_type {
  * bitfields. The register validity, offsets and bitfield values may vary
  * slightly across different exynos SOC's.
  * @tmu_ctrl: TMU main controller register.
- * @therm_trip_mode_shift: shift bits of tripping mode in tmu_ctrl register.
- * @therm_trip_mode_mask: mask bits of tripping mode in tmu_ctrl register.
  * @therm_trip_en_shift: shift bits of tripping enable in tmu_ctrl register.
  * @tmu_cur_temp: register containing the current temperature of the TMU.
  * @threshold_th0: Register containing first set of rising levels.
@@ -106,8 +104,6 @@ enum soc_type {
  */
 struct exynos_tmu_registers {
u32 tmu_ctrl;
-   u32 therm_trip_mode_shift;
-   u32 therm_trip_mode_mask;
u32 therm_trip_en_shift;
 
u32 tmu_cur_temp;
diff --git a/drivers/thermal/samsung/exynos_tmu_data.c 
b/drivers/thermal/samsung/exynos_tmu_data.c
index 988e327..22a0ade 100644
--- a/drivers/thermal/samsung/exynos_tmu_data.c
+++ b/drivers/thermal/samsung/exynos_tmu_data.c
@@ -84,8 +84,6 @@ struct exynos_tmu_init_data const exynos4210_default_tmu_data 
= {
 #if defined(CONFIG_SOC_EXYNOS3250)
 static const struct exynos_tmu_registers exynos3250_tmu_registers = {
.tmu_ctrl = EXYNOS_TMU_REG_CONTROL,
-   .therm_trip_mode_shift = EXYNOS_TMU_TRIP_MODE_SHIFT,
-   .therm_trip_mode_mask = EXYNOS_TMU_TRIP_MODE_MASK,
.therm_trip_en_shift = EXYNOS_TMU_THERM_TRIP_EN_SHIFT,
.tmu_cur_temp = EXYNOS_TMU_REG_CURRENT_TEMP,
.threshold_th0 = EXYNOS_THD_TEMP_RISE,
@@ -163,8 +161,6 @@ struct exynos_tmu_init_data const 
exynos3250_default_tmu_data = {
 #if defined(CONFIG_SOC_EXYNOS4412) || defined(CONFIG_SOC_EXYNOS5250)
 static const struct exynos_tmu_registers exynos4412_tmu_registers = {
.tmu_ctrl = EXYNOS_TMU_REG_CONTROL,
-   .therm_trip_mode_shift = EXYNOS_TMU_TRIP_MODE_SHIFT,
-   .therm_trip_mode_mask = EXYNOS_TMU_TRIP_MODE_MASK,
.therm_trip_en_shift = EXYNOS_TMU_THERM_TRIP_EN_SHIFT,
.tmu_cur_temp = EXYNOS_TMU_REG_CURRENT_TEMP,
.threshold_th0 = EXYNOS_THD_TEMP_RISE,
@@ -255,8 +251,6 @@ struct exynos_tmu_init_data const 
exynos5250_default_tmu_data = {
 #if defined(CONFIG_SOC_EXYNOS5260)
 static const struct exynos_tmu_registers exynos5260_tmu_registers = {
.tmu_ctrl = EXYNOS_TMU_REG_CONTROL,
-   .therm_trip_mode_shift = EXYNOS_TMU_TRIP_MODE_SHIFT,
-   .therm_trip_mode_mask = EXYNOS_TMU_TRIP_MODE_MASK,
.therm_trip_en_shift = EXYNOS_TMU_THERM_TRIP_EN_SHIFT,
.tmu_cur_temp = EXYNOS_TMU_REG_CURRENT_TEMP,
.threshold_th0 = EXYNOS_THD_TEMP_RISE,
@@ -336,8 +330,6 @@ struct exynos_tmu_init_data const 
exynos5260_default_tmu_data = {
 #if defined(CONFIG_SOC_EXYNOS5420)
 static const struct exynos_tmu_registers exynos5420_tmu_registers = {
.tmu_ctrl = EXYNOS_TMU_REG_CONTROL,
-   .therm_trip_mode_shift = EXYNOS_TMU_TRIP_MODE_SHIFT,
-   

[PATCH 12/33] thermal: exynos: simplify HW_TRIP level setting

2014-09-18 Thread Bartlomiej Zolnierkiewicz
Simplify HW_TRIP level setting in exynos_tmu_initialize() (don't
pretend that the current code is hardware and configuration
independent and just do SoC type check explicitly).  Then remove
no longer needed reg-threshold_[th2,th3_l0_shift] abstractions
(only assigned for Exynos5440 in exynos5440_tmu_registers) and
EXYNOS_MAX_TRIGGER_PER_REG define.

There should be no functional changes caused by this patch.

Cc: Naveen Krishna Chatradhi ch.nav...@samsung.com
Cc: Amit Daniel Kachhap amit.dan...@samsung.com
Cc: Lukasz Majewski l.majew...@samsung.com
Cc: Eduardo Valentin edubez...@gmail.com
Cc: Zhang Rui rui.zh...@intel.com
Signed-off-by: Bartlomiej Zolnierkiewicz b.zolnier...@samsung.com
Acked-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/thermal/samsung/exynos_tmu.c  | 10 +-
 drivers/thermal/samsung/exynos_tmu.h  |  4 
 drivers/thermal/samsung/exynos_tmu_data.c |  2 --
 drivers/thermal/samsung/exynos_tmu_data.h |  2 --
 4 files changed, 5 insertions(+), 13 deletions(-)

diff --git a/drivers/thermal/samsung/exynos_tmu.c 
b/drivers/thermal/samsung/exynos_tmu.c
index f009a04..f02e65d 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -237,18 +237,18 @@ static int exynos_tmu_initialize(struct platform_device 
*pdev)
(pdata-trigger_type[i] == HW_TRIP)) {
threshold_code = temp_to_code(data,
pdata-trigger_levels[i]);
-   if (i == EXYNOS_MAX_TRIGGER_PER_REG - 1) {
+   if (data-soc != SOC_ARCH_EXYNOS5440) {
/* 1-4 level to be assigned in th0 reg */
rising_threshold = ~(0xff  8 * i);
rising_threshold |= threshold_code  8 * i;
writel(rising_threshold,
-   data-base + reg-threshold_th0);
-   } else if (i == EXYNOS_MAX_TRIGGER_PER_REG) {
+   data-base + EXYNOS_THD_TEMP_RISE);
+   } else {
/* 5th level to be assigned in th2 reg */
rising_threshold =
-   threshold_code  reg-threshold_th3_l0_shift;
+   threshold_code  EXYNOS5440_TMU_TH_RISE4_SHIFT;
writel(rising_threshold,
-   data-base + reg-threshold_th2);
+   data-base + EXYNOS5440_TMU_S0_7_TH2);
}
con = readl(data-base + reg-tmu_ctrl);
con |= (1  EXYNOS_TMU_THERM_TRIP_EN_SHIFT);
diff --git a/drivers/thermal/samsung/exynos_tmu.h 
b/drivers/thermal/samsung/exynos_tmu.h
index 7098e37..3430852 100644
--- a/drivers/thermal/samsung/exynos_tmu.h
+++ b/drivers/thermal/samsung/exynos_tmu.h
@@ -80,8 +80,6 @@ enum soc_type {
  * @tmu_cur_temp: register containing the current temperature of the TMU.
  * @threshold_th0: Register containing first set of rising levels.
  * @threshold_th1: Register containing second set of rising levels.
- * @threshold_th2: Register containing third set of rising levels.
- * @threshold_th3_l0_shift: shift bits of level0 threshold temperature.
  * @tmu_inten: register containing the different threshold interrupt
enable bits.
  * @inten_rise0_shift: shift bits of rising 0 interrupt bits.
@@ -104,8 +102,6 @@ struct exynos_tmu_registers {
 
u32 threshold_th0;
u32 threshold_th1;
-   u32 threshold_th2;
-   u32 threshold_th3_l0_shift;
 
u32 tmu_inten;
u32 inten_rise0_shift;
diff --git a/drivers/thermal/samsung/exynos_tmu_data.c 
b/drivers/thermal/samsung/exynos_tmu_data.c
index 23beb70..a63d945 100644
--- a/drivers/thermal/samsung/exynos_tmu_data.c
+++ b/drivers/thermal/samsung/exynos_tmu_data.c
@@ -408,8 +408,6 @@ static const struct exynos_tmu_registers 
exynos5440_tmu_registers = {
.tmu_cur_temp = EXYNOS5440_TMU_S0_7_TEMP,
.threshold_th0 = EXYNOS5440_TMU_S0_7_TH0,
.threshold_th1 = EXYNOS5440_TMU_S0_7_TH1,
-   .threshold_th2 = EXYNOS5440_TMU_S0_7_TH2,
-   .threshold_th3_l0_shift = EXYNOS5440_TMU_TH_RISE4_SHIFT,
.tmu_inten = EXYNOS5440_TMU_S0_7_IRQEN,
.inten_rise0_shift = EXYNOS5440_TMU_INTEN_RISE0_SHIFT,
.inten_rise1_shift = EXYNOS5440_TMU_INTEN_RISE1_SHIFT,
diff --git a/drivers/thermal/samsung/exynos_tmu_data.h 
b/drivers/thermal/samsung/exynos_tmu_data.h
index 96cf369..3ae42cd 100644
--- a/drivers/thermal/samsung/exynos_tmu_data.h
+++ b/drivers/thermal/samsung/exynos_tmu_data.h
@@ -80,8 +80,6 @@
 #define EXYNOS_EMUL_DATA_MASK  0xFF
 #define EXYNOS_EMUL_ENABLE 0x1
 
-#define EXYNOS_MAX_TRIGGER_PER_REG 4
-
 /* Exynos5260 specific */
 #define EXYNOS5260_TMU_REG_INTEN   

[PATCH 11/33] thermal: exynos: replace tmu_pmin check by Exynos5440 one

2014-09-18 Thread Bartlomiej Zolnierkiewicz
reg-tmu_pmin is set to non-zero value only for Exynos5440
so replace check for non-zero value of reg-tmu_pmin by
explicitly checking for Exynos5440 SoC type.  Then remove no
longer needed reg-tmu_pmin register abstraction.

There should be no functional changes caused by this patch.

Cc: Naveen Krishna Chatradhi ch.nav...@samsung.com
Cc: Amit Daniel Kachhap amit.dan...@samsung.com
Cc: Lukasz Majewski l.majew...@samsung.com
Cc: Eduardo Valentin edubez...@gmail.com
Cc: Zhang Rui rui.zh...@intel.com
Signed-off-by: Bartlomiej Zolnierkiewicz b.zolnier...@samsung.com
Acked-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/thermal/samsung/exynos_tmu.c  | 4 ++--
 drivers/thermal/samsung/exynos_tmu.h  | 3 ---
 drivers/thermal/samsung/exynos_tmu_data.c | 1 -
 3 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/thermal/samsung/exynos_tmu.c 
b/drivers/thermal/samsung/exynos_tmu.c
index 85e74e1..f009a04 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -256,8 +256,8 @@ static int exynos_tmu_initialize(struct platform_device 
*pdev)
}
}
/*Clear the PMIN in the common TMU register*/
-   if (reg-tmu_pmin  !data-id)
-   writel(0, data-base_second + reg-tmu_pmin);
+   if (data-soc == SOC_ARCH_EXYNOS5440  !data-id)
+   writel(0, data-base_second + EXYNOS5440_TMU_PMIN);
 out:
clk_disable(data-clk);
mutex_unlock(data-lock);
diff --git a/drivers/thermal/samsung/exynos_tmu.h 
b/drivers/thermal/samsung/exynos_tmu.h
index 5ab7482..7098e37 100644
--- a/drivers/thermal/samsung/exynos_tmu.h
+++ b/drivers/thermal/samsung/exynos_tmu.h
@@ -96,7 +96,6 @@ enum soc_type {
  * @intclr_rise_mask: mask bits of all rising interrupt bits.
  * @intclr_fall_mask: mask bits of all rising interrupt bits.
  * @emul_con: TMU emulation controller register.
- * @tmu_pmin: register to get/set the Pmin value.
  */
 struct exynos_tmu_registers {
u32 tmu_ctrl;
@@ -124,8 +123,6 @@ struct exynos_tmu_registers {
u32 intclr_rise_mask;
 
u32 emul_con;
-
-   u32 tmu_pmin;
 };
 
 /**
diff --git a/drivers/thermal/samsung/exynos_tmu_data.c 
b/drivers/thermal/samsung/exynos_tmu_data.c
index 5811b99..23beb70 100644
--- a/drivers/thermal/samsung/exynos_tmu_data.c
+++ b/drivers/thermal/samsung/exynos_tmu_data.c
@@ -423,7 +423,6 @@ static const struct exynos_tmu_registers 
exynos5440_tmu_registers = {
.intclr_rise_mask = EXYNOS5440_TMU_RISE_INT_MASK,
.intclr_fall_mask = EXYNOS5440_TMU_FALL_INT_MASK,
.emul_con = EXYNOS5440_TMU_S0_7_DEBUG,
-   .tmu_pmin = EXYNOS5440_TMU_PMIN,
 };
 
 #define EXYNOS5440_TMU_DATA \
-- 
1.8.2.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 01/33] thermal: exynos: remove needless triminfo_data abstraction

2014-09-18 Thread Bartlomiej Zolnierkiewicz
reg-triminfo_data is used only in exynos_tmu_initialize() and
the code has already different paths for Exynos5440 and other
SoC types (on which TRIMINFO_DATA register offset is identical)
so the register abstraction is not needed and can be removed.

There should be no functional changes caused by this patch.

Cc: Naveen Krishna Chatradhi ch.nav...@samsung.com
Cc: Amit Daniel Kachhap amit.dan...@samsung.com
Cc: Lukasz Majewski l.majew...@samsung.com
Cc: Eduardo Valentin edubez...@gmail.com
Cc: Zhang Rui rui.zh...@intel.com
Signed-off-by: Bartlomiej Zolnierkiewicz b.zolnier...@samsung.com
Acked-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/thermal/samsung/exynos_tmu.c  | 10 +-
 drivers/thermal/samsung/exynos_tmu.h  |  3 ---
 drivers/thermal/samsung/exynos_tmu_data.c |  6 --
 3 files changed, 5 insertions(+), 14 deletions(-)

diff --git a/drivers/thermal/samsung/exynos_tmu.c 
b/drivers/thermal/samsung/exynos_tmu.c
index 092ab69..e0e1151 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -165,22 +165,22 @@ static int exynos_tmu_initialize(struct platform_device 
*pdev)
switch (data-id) {
case 0:
trim_info = readl(data-base +
-   EXYNOS5440_EFUSE_SWAP_OFFSET + reg-triminfo_data);
+   EXYNOS5440_EFUSE_SWAP_OFFSET + 
EXYNOS5440_TMU_S0_7_TRIM);
break;
case 1:
-   trim_info = readl(data-base + reg-triminfo_data);
+   trim_info = readl(data-base + 
EXYNOS5440_TMU_S0_7_TRIM);
break;
case 2:
trim_info = readl(data-base -
-   EXYNOS5440_EFUSE_SWAP_OFFSET + reg-triminfo_data);
+   EXYNOS5440_EFUSE_SWAP_OFFSET + 
EXYNOS5440_TMU_S0_7_TRIM);
}
} else {
/* On exynos5420 the triminfo register is in the shared space */
if (data-soc == SOC_ARCH_EXYNOS5420_TRIMINFO)
trim_info = readl(data-base_second +
-   reg-triminfo_data);
+   EXYNOS_TMU_REG_TRIMINFO);
else
-   trim_info = readl(data-base + reg-triminfo_data);
+   trim_info = readl(data-base + EXYNOS_TMU_REG_TRIMINFO);
}
data-temp_error1 = trim_info  EXYNOS_TMU_TEMP_MASK;
data-temp_error2 = ((trim_info  EXYNOS_TRIMINFO_85_SHIFT) 
diff --git a/drivers/thermal/samsung/exynos_tmu.h 
b/drivers/thermal/samsung/exynos_tmu.h
index f67203b..de20dcc 100644
--- a/drivers/thermal/samsung/exynos_tmu.h
+++ b/drivers/thermal/samsung/exynos_tmu.h
@@ -76,7 +76,6 @@ enum soc_type {
  * struct exynos_tmu_register - register descriptors to access registers and
  * bitfields. The register validity, offsets and bitfield values may vary
  * slightly across different exynos SOC's.
- * @triminfo_data: register containing 2 pont trimming data
  * @triminfo_ctrl: trim info controller register.
  * @triminfo_ctrl_count: the number of trim info controller register.
  * @tmu_ctrl: TMU main controller register.
@@ -111,8 +110,6 @@ enum soc_type {
  * @tmu_pmin: register to get/set the Pmin value.
  */
 struct exynos_tmu_registers {
-   u32 triminfo_data;
-
u32 triminfo_ctrl[MAX_TRIMINFO_CTRL_REG];
u32 triminfo_ctrl_count;
 
diff --git a/drivers/thermal/samsung/exynos_tmu_data.c 
b/drivers/thermal/samsung/exynos_tmu_data.c
index 54d30bc..0f1f1f1 100644
--- a/drivers/thermal/samsung/exynos_tmu_data.c
+++ b/drivers/thermal/samsung/exynos_tmu_data.c
@@ -26,7 +26,6 @@
 
 #if defined(CONFIG_CPU_EXYNOS4210)
 static const struct exynos_tmu_registers exynos4210_tmu_registers = {
-   .triminfo_data = EXYNOS_TMU_REG_TRIMINFO,
.tmu_ctrl = EXYNOS_TMU_REG_CONTROL,
.tmu_status = EXYNOS_TMU_REG_STATUS,
.tmu_cur_temp = EXYNOS_TMU_REG_CURRENT_TEMP,
@@ -86,7 +85,6 @@ struct exynos_tmu_init_data const exynos4210_default_tmu_data 
= {
 
 #if defined(CONFIG_SOC_EXYNOS3250)
 static const struct exynos_tmu_registers exynos3250_tmu_registers = {
-   .triminfo_data = EXYNOS_TMU_REG_TRIMINFO,
.triminfo_ctrl[0] = EXYNOS_TMU_TRIMINFO_CON1,
.triminfo_ctrl[1] = EXYNOS_TMU_TRIMINFO_CON2,
.triminfo_ctrl_count = 2,
@@ -173,7 +171,6 @@ struct exynos_tmu_init_data const 
exynos3250_default_tmu_data = {
 
 #if defined(CONFIG_SOC_EXYNOS4412) || defined(CONFIG_SOC_EXYNOS5250)
 static const struct exynos_tmu_registers exynos4412_tmu_registers = {
-   .triminfo_data = EXYNOS_TMU_REG_TRIMINFO,
.triminfo_ctrl[0] = EXYNOS_TMU_TRIMINFO_CON2,
.triminfo_ctrl_count = 1,
.tmu_ctrl = EXYNOS_TMU_REG_CONTROL,
@@ -271,7 +268,6 @@ struct exynos_tmu_init_data const 
exynos5250_default_tmu_data = {
 
 #if defined(CONFIG_SOC_EXYNOS5260)
 static 

[PATCH 02/33] thermal: exynos: remove needless tmu_status abstraction

2014-09-18 Thread Bartlomiej Zolnierkiewicz
reg-tmu_status is used only in exynos_tmu_initialize() and it
is accessed only if TMU_SUPPORT_READY_STATUS flag is set.  This
flag is not set for Exynos5440 and TMU_STATUS register offset
is identical for all other SoC types so the abstraction is not
needed and can be removed.

There should be no functional changes caused by this patch.

Cc: Naveen Krishna Chatradhi ch.nav...@samsung.com
Cc: Amit Daniel Kachhap amit.dan...@samsung.com
Cc: Lukasz Majewski l.majew...@samsung.com
Cc: Eduardo Valentin edubez...@gmail.com
Cc: Zhang Rui rui.zh...@intel.com
Signed-off-by: Bartlomiej Zolnierkiewicz b.zolnier...@samsung.com
Acked-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/thermal/samsung/exynos_tmu.c  | 2 +-
 drivers/thermal/samsung/exynos_tmu.h  | 3 ---
 drivers/thermal/samsung/exynos_tmu_data.c | 6 --
 drivers/thermal/samsung/exynos_tmu_data.h | 1 -
 4 files changed, 1 insertion(+), 11 deletions(-)

diff --git a/drivers/thermal/samsung/exynos_tmu.c 
b/drivers/thermal/samsung/exynos_tmu.c
index e0e1151..8bc475c 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -137,7 +137,7 @@ static int exynos_tmu_initialize(struct platform_device 
*pdev)
clk_enable(data-clk_sec);
 
if (TMU_SUPPORTS(pdata, READY_STATUS)) {
-   status = readb(data-base + reg-tmu_status);
+   status = readb(data-base + EXYNOS_TMU_REG_STATUS);
if (!status) {
ret = -EBUSY;
goto out;
diff --git a/drivers/thermal/samsung/exynos_tmu.h 
b/drivers/thermal/samsung/exynos_tmu.h
index de20dcc..30f5f41 100644
--- a/drivers/thermal/samsung/exynos_tmu.h
+++ b/drivers/thermal/samsung/exynos_tmu.h
@@ -83,7 +83,6 @@ enum soc_type {
  * @therm_trip_mode_shift: shift bits of tripping mode in tmu_ctrl register.
  * @therm_trip_mode_mask: mask bits of tripping mode in tmu_ctrl register.
  * @therm_trip_en_shift: shift bits of tripping enable in tmu_ctrl register.
- * @tmu_status: register drescribing the TMU status.
  * @tmu_cur_temp: register containing the current temperature of the TMU.
  * @threshold_temp: register containing the base threshold level.
  * @threshold_th0: Register containing first set of rising levels.
@@ -119,8 +118,6 @@ struct exynos_tmu_registers {
u32 therm_trip_mode_mask;
u32 therm_trip_en_shift;
 
-   u32 tmu_status;
-
u32 tmu_cur_temp;
 
u32 threshold_temp;
diff --git a/drivers/thermal/samsung/exynos_tmu_data.c 
b/drivers/thermal/samsung/exynos_tmu_data.c
index 0f1f1f1..4e95bbb 100644
--- a/drivers/thermal/samsung/exynos_tmu_data.c
+++ b/drivers/thermal/samsung/exynos_tmu_data.c
@@ -27,7 +27,6 @@
 #if defined(CONFIG_CPU_EXYNOS4210)
 static const struct exynos_tmu_registers exynos4210_tmu_registers = {
.tmu_ctrl = EXYNOS_TMU_REG_CONTROL,
-   .tmu_status = EXYNOS_TMU_REG_STATUS,
.tmu_cur_temp = EXYNOS_TMU_REG_CURRENT_TEMP,
.threshold_temp = EXYNOS4210_TMU_REG_THRESHOLD_TEMP,
.threshold_th0 = EXYNOS4210_TMU_REG_TRIG_LEVEL0,
@@ -93,7 +92,6 @@ static const struct exynos_tmu_registers 
exynos3250_tmu_registers = {
.therm_trip_mode_shift = EXYNOS_TMU_TRIP_MODE_SHIFT,
.therm_trip_mode_mask = EXYNOS_TMU_TRIP_MODE_MASK,
.therm_trip_en_shift = EXYNOS_TMU_THERM_TRIP_EN_SHIFT,
-   .tmu_status = EXYNOS_TMU_REG_STATUS,
.tmu_cur_temp = EXYNOS_TMU_REG_CURRENT_TEMP,
.threshold_th0 = EXYNOS_THD_TEMP_RISE,
.threshold_th1 = EXYNOS_THD_TEMP_FALL,
@@ -178,7 +176,6 @@ static const struct exynos_tmu_registers 
exynos4412_tmu_registers = {
.therm_trip_mode_shift = EXYNOS_TMU_TRIP_MODE_SHIFT,
.therm_trip_mode_mask = EXYNOS_TMU_TRIP_MODE_MASK,
.therm_trip_en_shift = EXYNOS_TMU_THERM_TRIP_EN_SHIFT,
-   .tmu_status = EXYNOS_TMU_REG_STATUS,
.tmu_cur_temp = EXYNOS_TMU_REG_CURRENT_TEMP,
.threshold_th0 = EXYNOS_THD_TEMP_RISE,
.threshold_th1 = EXYNOS_THD_TEMP_FALL,
@@ -272,7 +269,6 @@ static const struct exynos_tmu_registers 
exynos5260_tmu_registers = {
.therm_trip_mode_shift = EXYNOS_TMU_TRIP_MODE_SHIFT,
.therm_trip_mode_mask = EXYNOS_TMU_TRIP_MODE_MASK,
.therm_trip_en_shift = EXYNOS_TMU_THERM_TRIP_EN_SHIFT,
-   .tmu_status = EXYNOS_TMU_REG_STATUS,
.tmu_cur_temp = EXYNOS_TMU_REG_CURRENT_TEMP,
.threshold_th0 = EXYNOS_THD_TEMP_RISE,
.threshold_th1 = EXYNOS_THD_TEMP_FALL,
@@ -354,7 +350,6 @@ static const struct exynos_tmu_registers 
exynos5420_tmu_registers = {
.therm_trip_mode_shift = EXYNOS_TMU_TRIP_MODE_SHIFT,
.therm_trip_mode_mask = EXYNOS_TMU_TRIP_MODE_MASK,
.therm_trip_en_shift = EXYNOS_TMU_THERM_TRIP_EN_SHIFT,
-   .tmu_status = EXYNOS_TMU_REG_STATUS,
.tmu_cur_temp = EXYNOS_TMU_REG_CURRENT_TEMP,
.threshold_th0 = EXYNOS_THD_TEMP_RISE,
.threshold_th1 = EXYNOS_THD_TEMP_FALL,
@@ -444,7 +439,6 @@ 

[PATCH 04/33] thermal: exynos: remove needless triminfo_ctrl abstraction

2014-09-18 Thread Bartlomiej Zolnierkiewicz
reg-triminfo_ctrl[] is used in only exynos_tmu_initialize() and
accessed only if TMU_SUPPORT_TRIM_RELOAD flag is set.  This flag
is set only on Exynos3250, Exynos4412 and Exynos5250 (other SoC
types don't even have triminfo_ctrl[] entries assigned in their
struct exynos_tmu_registers instances) so the register abstraction
is not needed and can be removed.

There should be no functional changes caused by this patch.

Cc: Naveen Krishna Chatradhi ch.nav...@samsung.com
Cc: Amit Daniel Kachhap amit.dan...@samsung.com
Cc: Lukasz Majewski l.majew...@samsung.com
Cc: Eduardo Valentin edubez...@gmail.com
Cc: Zhang Rui rui.zh...@intel.com
Signed-off-by: Bartlomiej Zolnierkiewicz b.zolnier...@samsung.com
Acked-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/thermal/samsung/exynos_thermal_common.h |  1 -
 drivers/thermal/samsung/exynos_tmu.c| 15 +++
 drivers/thermal/samsung/exynos_tmu.h|  7 ---
 drivers/thermal/samsung/exynos_tmu_data.c   |  8 
 4 files changed, 7 insertions(+), 24 deletions(-)

diff --git a/drivers/thermal/samsung/exynos_thermal_common.h 
b/drivers/thermal/samsung/exynos_thermal_common.h
index 158f5aa..cd44719 100644
--- a/drivers/thermal/samsung/exynos_thermal_common.h
+++ b/drivers/thermal/samsung/exynos_thermal_common.h
@@ -27,7 +27,6 @@
 #define SENSOR_NAME_LEN16
 #define MAX_TRIP_COUNT 8
 #define MAX_COOLING_DEVICE 4
-#define MAX_TRIMINFO_CTRL_REG  2
 
 #define ACTIVE_INTERVAL 500
 #define IDLE_INTERVAL 1
diff --git a/drivers/thermal/samsung/exynos_tmu.c 
b/drivers/thermal/samsung/exynos_tmu.c
index 8a45b4b..52bcc23 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -145,15 +145,14 @@ static int exynos_tmu_initialize(struct platform_device 
*pdev)
}
 
if (TMU_SUPPORTS(pdata, TRIM_RELOAD)) {
-   for (i = 0; i  reg-triminfo_ctrl_count; i++) {
-   if (pdata-triminfo_reload[i]) {
-   ctrl = readl(data-base +
-   reg-triminfo_ctrl[i]);
-   ctrl |= pdata-triminfo_reload[i];
-   writel(ctrl, data-base +
-   reg-triminfo_ctrl[i]);
-   }
+   if (data-soc == SOC_ARCH_EXYNOS3250) {
+   ctrl = readl(data-base + EXYNOS_TMU_TRIMINFO_CON1);
+   ctrl |= EXYNOS_TRIMINFO_RELOAD_ENABLE;
+   writel(ctrl, data-base + EXYNOS_TMU_TRIMINFO_CON1);
}
+   ctrl = readl(data-base + EXYNOS_TMU_TRIMINFO_CON2);
+   ctrl |= EXYNOS_TRIMINFO_RELOAD_ENABLE;
+   writel(ctrl, data-base + EXYNOS_TMU_TRIMINFO_CON2);
}
 
/* Save trimming info in order to perform calibration */
diff --git a/drivers/thermal/samsung/exynos_tmu.h 
b/drivers/thermal/samsung/exynos_tmu.h
index 531c01c..d12e242 100644
--- a/drivers/thermal/samsung/exynos_tmu.h
+++ b/drivers/thermal/samsung/exynos_tmu.h
@@ -76,8 +76,6 @@ enum soc_type {
  * struct exynos_tmu_register - register descriptors to access registers and
  * bitfields. The register validity, offsets and bitfield values may vary
  * slightly across different exynos SOC's.
- * @triminfo_ctrl: trim info controller register.
- * @triminfo_ctrl_count: the number of trim info controller register.
  * @tmu_ctrl: TMU main controller register.
  * @test_mux_addr_shift: shift bits of test mux address.
  * @therm_trip_mode_shift: shift bits of tripping mode in tmu_ctrl register.
@@ -108,9 +106,6 @@ enum soc_type {
  * @tmu_pmin: register to get/set the Pmin value.
  */
 struct exynos_tmu_registers {
-   u32 triminfo_ctrl[MAX_TRIMINFO_CTRL_REG];
-   u32 triminfo_ctrl_count;
-
u32 tmu_ctrl;
u32 test_mux_addr_shift;
u32 therm_trip_mode_shift;
@@ -192,7 +187,6 @@ struct exynos_tmu_registers {
  * @second_point_trim: temp value of the second point trimming
  * @default_temp_offset: default temperature offset in case of no trimming
  * @test_mux; information if SoC supports test MUX
- * @triminfo_reload: reload value to read TRIMINFO register
  * @cal_type: calibration type for temperature
  * @freq_clip_table: Table representing frequency reduction percentage.
  * @freq_tab_count: Count of the above table as frequency reduction may
@@ -223,7 +217,6 @@ struct exynos_tmu_platform_data {
u8 second_point_trim;
u8 default_temp_offset;
u8 test_mux;
-   u8 triminfo_reload[MAX_TRIMINFO_CTRL_REG];
 
enum calibration_type cal_type;
enum soc_type type;
diff --git a/drivers/thermal/samsung/exynos_tmu_data.c 
b/drivers/thermal/samsung/exynos_tmu_data.c
index 89c072a..04f1d71 100644
--- a/drivers/thermal/samsung/exynos_tmu_data.c
+++ b/drivers/thermal/samsung/exynos_tmu_data.c
@@ -83,9 +83,6 @@ struct exynos_tmu_init_data const 

[PATCH 03/33] thermal: exynos: remove needless threshold_temp abstraction

2014-09-18 Thread Bartlomiej Zolnierkiewicz
reg-threshold_temp is used only in exynos_tmu_initialize() and
is accessed only on Exynos4210 (other SoC types don't even have
threshold_temp entry assigned in their struct exynos_tmu_registers
instances) so the register abstraction is not needed and can be
removed.

There should be no functional changes caused by this patch.

Cc: Naveen Krishna Chatradhi ch.nav...@samsung.com
Cc: Amit Daniel Kachhap amit.dan...@samsung.com
Cc: Lukasz Majewski l.majew...@samsung.com
Cc: Eduardo Valentin edubez...@gmail.com
Cc: Zhang Rui rui.zh...@intel.com
Signed-off-by: Bartlomiej Zolnierkiewicz b.zolnier...@samsung.com
Acked-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/thermal/samsung/exynos_tmu.c  | 2 +-
 drivers/thermal/samsung/exynos_tmu.h  | 3 ---
 drivers/thermal/samsung/exynos_tmu_data.c | 1 -
 3 files changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/thermal/samsung/exynos_tmu.c 
b/drivers/thermal/samsung/exynos_tmu.c
index 8bc475c..8a45b4b 100644
--- a/drivers/thermal/samsung/exynos_tmu.c
+++ b/drivers/thermal/samsung/exynos_tmu.c
@@ -202,7 +202,7 @@ static int exynos_tmu_initialize(struct platform_device 
*pdev)
/* Write temperature code for threshold */
threshold_code = temp_to_code(data, pdata-threshold);
writeb(threshold_code,
-   data-base + reg-threshold_temp);
+   data-base + EXYNOS4210_TMU_REG_THRESHOLD_TEMP);
for (i = 0; i  pdata-non_hw_trigger_levels; i++)
writeb(pdata-trigger_levels[i], data-base +
reg-threshold_th0 + i * sizeof(reg-threshold_th0));
diff --git a/drivers/thermal/samsung/exynos_tmu.h 
b/drivers/thermal/samsung/exynos_tmu.h
index 30f5f41..531c01c 100644
--- a/drivers/thermal/samsung/exynos_tmu.h
+++ b/drivers/thermal/samsung/exynos_tmu.h
@@ -84,7 +84,6 @@ enum soc_type {
  * @therm_trip_mode_mask: mask bits of tripping mode in tmu_ctrl register.
  * @therm_trip_en_shift: shift bits of tripping enable in tmu_ctrl register.
  * @tmu_cur_temp: register containing the current temperature of the TMU.
- * @threshold_temp: register containing the base threshold level.
  * @threshold_th0: Register containing first set of rising levels.
  * @threshold_th1: Register containing second set of rising levels.
  * @threshold_th2: Register containing third set of rising levels.
@@ -120,8 +119,6 @@ struct exynos_tmu_registers {
 
u32 tmu_cur_temp;
 
-   u32 threshold_temp;
-
u32 threshold_th0;
u32 threshold_th1;
u32 threshold_th2;
diff --git a/drivers/thermal/samsung/exynos_tmu_data.c 
b/drivers/thermal/samsung/exynos_tmu_data.c
index 4e95bbb..89c072a 100644
--- a/drivers/thermal/samsung/exynos_tmu_data.c
+++ b/drivers/thermal/samsung/exynos_tmu_data.c
@@ -28,7 +28,6 @@
 static const struct exynos_tmu_registers exynos4210_tmu_registers = {
.tmu_ctrl = EXYNOS_TMU_REG_CONTROL,
.tmu_cur_temp = EXYNOS_TMU_REG_CURRENT_TEMP,
-   .threshold_temp = EXYNOS4210_TMU_REG_THRESHOLD_TEMP,
.threshold_th0 = EXYNOS4210_TMU_REG_TRIG_LEVEL0,
.tmu_inten = EXYNOS_TMU_REG_INTEN,
.inten_rise0_shift = EXYNOS_TMU_INTEN_RISE0_SHIFT,
-- 
1.8.2.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 v4 6/8] arm64: exynos7: Enable ARMv8 based Exynos7 (SoC) support

2014-09-18 Thread Catalin Marinas
On Fri, Sep 12, 2014 at 04:26:30PM +0100, Naveen Krishna Chatradhi wrote:
 From: Alim Akhtar alim.akh...@samsung.com
 
 This patch adds the necessary Kconfig entries to enable
 support for the ARMv8 based Exynos7 SoC.
 
 Signed-off-by: Alim Akhtar alim.akh...@samsung.com
 Signed-off-by: Naveen Krishna Chatradhi ch.nav...@samsung.com
 Cc: Rob Herring r...@kernel.org
 Cc: Catalin Marinas catalin.mari...@arm.com
 ---
  arch/arm64/Kconfig |   12 

Please update the defconfig as well as we want the default image build
to contain all the available platforms.

-- 
Catalin
--
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: dts: Specify default clocks for Exynos4 FIMC devices

2014-09-18 Thread Daniel Drake
Hi Sylwester,

On Wed, Sep 10, 2014 at 10:37 AM, Sylwester Nawrocki
s.nawro...@samsung.com wrote:
 The default mux and divider clocks are specified in device tree
 so that the FIMC devices in Exynos4210 and Exynos4x12 SoCs are
 clocked from recommended clock source and with maximum supported
 frequency. If needed these settings could be overrode in board
 specific dts files, however they are in practice optimal in most
 cases.

Just curious about the Exynos4x12 situation here.
You set the FIMC clocks as 176MHz, child of MPLL, which works for
ODROID with a divider:

880MHz MPLL / 5 = 176MHz

However, talking of recommended frequencies... Is 880MHz really the
standard there?
Isn't 800MHz the more common one?

Also, if you happen to know, I would be curious about the equivalent
and recommended situation for the sclk_mfc clock. On the vendor kernel
it is clocked at 880/4 = 220MHz. When booting mainline on an odroid it
is 880/16 = 55MHz :/

Thanks
Daniel
--
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 18/19] ARM: SAMSUNG: Remove remaining legacy code

2014-09-18 Thread Paul Bolle
On Thu, 2014-09-04 at 12:16 +0200, Paul Bolle wrote:
 On Wed, 2014-07-16 at 14:58 +0200, Tomasz Figa wrote:
  I had two patches fixing those, but apparently this was lost in action.
  The correct solution is s/PLAT_S5P/ARCH_S5PV210/. I will include this in
  a follow-up series if nobody objects.
 
 No one objected, as far as I know.
 
 Exactly the same references are still to be found in v3.17-rc3 and
 next-20140903. Perhaps someone actually familiar with this matter (ie,
 not me) could submit one or more patches that implement Tomasz'
 proposal.

We're now at v3.17-rc5 and next-20140918 and nothing has changed. I
raised this issue the day it hit linux-next. After two months it's still
not fixed. Could anyone familiar with ARCH_S5PV210 please jump in?

Thanks,


Paul Bolle

--
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 18/19] ARM: SAMSUNG: Remove remaining legacy code

2014-09-18 Thread Tomasz Figa
On 18.09.2014 21:29, Paul Bolle wrote:
 On Thu, 2014-09-04 at 12:16 +0200, Paul Bolle wrote:
 On Wed, 2014-07-16 at 14:58 +0200, Tomasz Figa wrote:
 I had two patches fixing those, but apparently this was lost in action.
 The correct solution is s/PLAT_S5P/ARCH_S5PV210/. I will include this in
 a follow-up series if nobody objects.

 No one objected, as far as I know.

 Exactly the same references are still to be found in v3.17-rc3 and
 next-20140903. Perhaps someone actually familiar with this matter (ie,
 not me) could submit one or more patches that implement Tomasz'
 proposal.
 
 We're now at v3.17-rc5 and next-20140918 and nothing has changed. I
 raised this issue the day it hit linux-next. After two months it's still
 not fixed. Could anyone familiar with ARCH_S5PV210 please jump in?

Basically, it turned out that no respin was necessary and I didn't post
those two patches. Now, I don't work for Samsung anymore, but let me see
if I can find them in my private tree and then some time to send them.

Best regards,
Tomasz
--
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] ASoC: samsung: Remove goni or aquila with the WM8994

2014-09-18 Thread Mark Brown
On Thu, Sep 18, 2014 at 11:43:29AM +0200, Paul Bolle wrote:
 On Thu, 2014-09-04 at 18:02 +0200, Arnd Bergmann wrote:

  I think it would be nice if you could submit a patch to remove the
  drivers from ASoC, then we can see if anybody complains.

 Same thing for v3.17-rc5 and next-20140918. Let's see if we can remove
 the goni or aquila with wm8994 driver.
 
 Done on top of next-20140918. Untested.
 -8-
 From: Paul Bolle pebo...@tiscali.nl

Please follow the patch submission process in SubmittingPatches.


signature.asc
Description: Digital signature


Re: [PATCH] ASoC: samsung: Remove goni or aquila with the WM8994

2014-09-18 Thread Paul Bolle
Hi Mark,

Mark Brown schreef op do 18-09-2014 om 10:57 [-0700]:
 On Thu, Sep 18, 2014 at 11:43:29AM +0200, Paul Bolle wrote:
  On Thu, 2014-09-04 at 18:02 +0200, Arnd Bergmann wrote:
 
   I think it would be nice if you could submit a patch to remove the
   drivers from ASoC, then we can see if anybody complains.
 
  Same thing for v3.17-rc5 and next-20140918. Let's see if we can remove
  the goni or aquila with wm8994 driver.
  
  Done on top of next-20140918. Untested.
  -8-
  From: Paul Bolle pebo...@tiscali.nl
 
 Please follow the patch submission process in SubmittingPatches.

Could you please be more specific? What part of SubmittingPatches have I
skipped?

Is it the perhaps the use of scissors? Or the superfluous From: line?
git am -c appears to handle this message (and the very similar message
I also sent today) just fine.

Thanks,


Paul Bolle

--
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: dts: Specify default clocks for Exynos4 FIMC devices

2014-09-18 Thread Daniel Drake
On Wed, Sep 10, 2014 at 10:37 AM, Sylwester Nawrocki
s.nawro...@samsung.com wrote:
 The default mux and divider clocks are specified in device tree
 so that the FIMC devices in Exynos4210 and Exynos4x12 SoCs are
 clocked from recommended clock source and with maximum supported
 frequency. If needed these settings could be overrode in board
 specific dts files, however they are in practice optimal in most
 cases.

Another consideration for this patch.

fimc-core.c already has probe-time code that tries to set the clock
frequency, using a clock-frequency property in the DT, and falling
back to a hardcoded value in the driver. Maybe it is best to just set
the clock rate from one place.

Daniel
--
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] mfd: cros_ec: Instantiate sub-devices from device tree

2014-09-18 Thread Lee Jones
On Thu, 18 Sep 2014, Javier Martinez Canillas wrote:

 Hello Lee,
 
 On 09/17/2014 06:31 PM, Lee Jones wrote:
   
  -static const struct mfd_cell cros_devs[] = {
  -  {
  -  .name = cros-ec-keyb,
  -  .id = 1,
  -  .of_compatible = google,cros-ec-keyb,
  -  },
  -  {
  -  .name = cros-ec-i2c-tunnel,
  -  .id = 2,
  -  .of_compatible = google,cros-ec-i2c-tunnel,
  -  },
  -};
  -
   int cros_ec_register(struct cros_ec_device *ec_dev)
   {
 struct device *dev = ec_dev-dev;
  +  struct device_node *node = dev-of_node;
 int err = 0;
   
 if (ec_dev-din_size) {
  @@ -140,12 +129,12 @@ int cros_ec_register(struct cros_ec_device *ec_dev)
   
 mutex_init(ec_dev-lock);
   
  -  err = mfd_add_devices(dev, 0, cros_devs,
  -ARRAY_SIZE(cros_devs),
  -NULL, ec_dev-irq, NULL);
  -  if (err) {
  -  dev_err(dev, failed to add mfd devices\n);
  -  return err;
  
  So these devices will only ever probe with DT now ...
 
 
 Well, these are preparatory patches to reduce the delta between upstream and
 the downstream so the missing functionality could be added. One of the missing
 drivers is the cros_ec_dev.c [0] which allows user-space to access the
 ChromeOS Embedded Controller using a virtual character device (/dev/cros_ec).
 
 Since that is a virtual device, it does not fit on the DT which only describes
 hw and also is used on x86 machines so that subdevice is still probed using
 mfd_add_devices() and the mfd_cells array is not empty in the downstream
 cros_ec driver [1].
 
 That's why I didn't just made the cros_ec MFD to depend on OF, since I didn't
 want to diverge too much from the downstream driver because the idea of the
 series was to reduce the difference in order to add the missing bits on top.
 
  +  if (node) {
  
  So it would be wrong for dev-of_node not to be populated.
  
 
 As explained above, DT, non-DT and x86 platforms instantiate the cros-ec-dev
 cells but DT platforms can define other child nodes. But I can remove the
 conditional if you want and reintroduce it once cros-ec-dev support is added.

Yes, that makes sense.  I only care about doing what's right for
Mainline, so if it doesn't make sense here, then we shouldn't be doing
it.

  +  err = of_platform_populate(node, NULL, NULL, dev);
  +  if (err) {
  +  dev_err(dev, Failed to register subordinate devices);
  +  return err;
  +  }
 }
   
 dev_info(dev, Chrome EC device registered\n);
  
 
 Best regards,
 Javier
 
 [0]:
 https://chromium.googlesource.com/chromiumos/third_party/kernel/+/chromeos-3.8/drivers/mfd/cros_ec_dev.c
 [1]:
 https://chromium.googlesource.com/chromiumos/third_party/kernel/+/chromeos-3.8/drivers/mfd/cros_ec.c#93

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
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] drm/exynos: switch to universal plane API

2014-09-18 Thread Joonyoung Shim
Hi Andrzej,

On 09/18/2014 10:17 PM, Andrzej Hajda wrote:
 The patch replaces legacy functions
 drm_plane_init() / drm_crtc_init() with
 drm_universal_plane_init() and drm_crtc_init_with_planes().
 It allows to replace fake primary plane with the real one.
 
 Signed-off-by: Andrzej Hajda a.ha...@samsung.com
 ---
 Hi Inki,
 
 I have tested this patch with trats board, it looks OK.
 As a side effect it should solve fb refcounting issues
 reported by me and Daniel Drake.
 
 Regards
 Andrzej
 ---
  drivers/gpu/drm/exynos/exynos_drm_crtc.c  | 63 
 ---
  drivers/gpu/drm/exynos/exynos_drm_drv.c   |  5 ++-
  drivers/gpu/drm/exynos/exynos_drm_plane.c | 17 +
  drivers/gpu/drm/exynos/exynos_drm_plane.h |  3 +-
  4 files changed, 47 insertions(+), 41 deletions(-)
 
 diff --git a/drivers/gpu/drm/exynos/exynos_drm_crtc.c 
 b/drivers/gpu/drm/exynos/exynos_drm_crtc.c
 index b68e58f..d2f713e 100644
 --- a/drivers/gpu/drm/exynos/exynos_drm_crtc.c
 +++ b/drivers/gpu/drm/exynos/exynos_drm_crtc.c
 @@ -32,7 +32,6 @@ enum exynos_crtc_mode {
   * Exynos specific crtc structure.
   *
   * @drm_crtc: crtc object.
 - * @drm_plane: pointer of private plane object for this crtc
   * @manager: the manager associated with this crtc
   * @pipe: a crtc index created at load() with a new crtc object creation
   *   and the crtc object would be set to private-crtc array
 @@ -46,7 +45,6 @@ enum exynos_crtc_mode {
   */
  struct exynos_drm_crtc {
   struct drm_crtc drm_crtc;
 - struct drm_plane*plane;
   struct exynos_drm_manager   *manager;
   unsigned intpipe;
   unsigned intdpms;
 @@ -94,12 +92,12 @@ static void exynos_drm_crtc_commit(struct drm_crtc *crtc)
  
   exynos_drm_crtc_dpms(crtc, DRM_MODE_DPMS_ON);
  
 - exynos_plane_commit(exynos_crtc-plane);
 + exynos_plane_commit(crtc-primary);
  
   if (manager-ops-commit)
   manager-ops-commit(manager);
  
 - exynos_plane_dpms(exynos_crtc-plane, DRM_MODE_DPMS_ON);
 + exynos_plane_dpms(crtc-primary, DRM_MODE_DPMS_ON);
  }
  
  static bool
 @@ -123,10 +121,9 @@ exynos_drm_crtc_mode_set(struct drm_crtc *crtc, struct 
 drm_display_mode *mode,
  {
   struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc);
   struct exynos_drm_manager *manager = exynos_crtc-manager;
 - struct drm_plane *plane = exynos_crtc-plane;
 + struct drm_framebuffer *fb = crtc-primary-fb;
   unsigned int crtc_w;
   unsigned int crtc_h;
 - int ret;
  
   /*
* copy the mode data adjusted by mode_fixup() into crtc-mode
 @@ -134,29 +131,21 @@ exynos_drm_crtc_mode_set(struct drm_crtc *crtc, struct 
 drm_display_mode *mode,
*/
   memcpy(crtc-mode, adjusted_mode, sizeof(*adjusted_mode));
  
 - crtc_w = crtc-primary-fb-width - x;
 - crtc_h = crtc-primary-fb-height - y;
 + crtc_w = fb-width - x;
 + crtc_h = fb-height - y;
  
   if (manager-ops-mode_set)
   manager-ops-mode_set(manager, crtc-mode);
  
 - ret = exynos_plane_mode_set(plane, crtc, crtc-primary-fb, 0, 0, 
 crtc_w, crtc_h,
 - x, y, crtc_w, crtc_h);
 - if (ret)
 - return ret;
 -
 - plane-crtc = crtc;
 - plane-fb = crtc-primary-fb;
 - drm_framebuffer_reference(plane-fb);
 -
 - return 0;
 + return exynos_plane_mode_set(crtc-primary, crtc, fb, 0, 0,
 +  crtc_w, crtc_h, x, y, crtc_w, crtc_h);
  }
  
  static int exynos_drm_crtc_mode_set_commit(struct drm_crtc *crtc, int x, int 
 y,
 struct drm_framebuffer *old_fb)
  {
   struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc);
 - struct drm_plane *plane = exynos_crtc-plane;
 + struct drm_framebuffer *fb = crtc-primary-fb;
   unsigned int crtc_w;
   unsigned int crtc_h;
   int ret;
 @@ -167,11 +156,11 @@ static int exynos_drm_crtc_mode_set_commit(struct 
 drm_crtc *crtc, int x, int y,
   return -EPERM;
   }
  
 - crtc_w = crtc-primary-fb-width - x;
 - crtc_h = crtc-primary-fb-height - y;
 + crtc_w = fb-width - x;
 + crtc_h = fb-height - y;
  
 - ret = exynos_plane_mode_set(plane, crtc, crtc-primary-fb, 0, 0, 
 crtc_w, crtc_h,
 - x, y, crtc_w, crtc_h);
 + ret = exynos_plane_mode_set(crtc-primary, crtc, fb, 0, 0,
 + crtc_w, crtc_h, x, y, crtc_w, crtc_h);
   if (ret)
   return ret;
  
 @@ -279,6 +268,7 @@ static void exynos_drm_crtc_destroy(struct drm_crtc *crtc)
  
   private-crtc[exynos_crtc-pipe] = NULL;
  
 + crtc-primary-funcs-destroy(crtc-primary);

This is unnecessary.

   drm_crtc_cleanup(crtc);
   kfree(exynos_crtc);
  }
 @@ -304,8 +294,7 @@ static int exynos_drm_crtc_set_property(struct drm_crtc 
 *crtc,
   exynos_drm_crtc_commit(crtc);
 

RE: [PATCH v3] mfd: syscon: Decouple syscon interface from platform devices

2014-09-18 Thread li.xi...@freescale.com
  Thanks for testing. In that case I will post this change, as I feel this
  should be
  fixed irrespective of my syscon patch.
 
   But as Xiubo pointed in another mail, it may still cause other issues.
   Looking at regmap.c, there're still some other places using the device
  pointer, e.g.
   dev_xxx debug information and some tracepoints also take device pointer as
   parameter(not sure if it will break if dev is NULL).
   Another thing is that if dev is NULL, we may not be able to use regmap
  debugfs
   feature which seems also not as our expected.
  
 
  I would have preferred to check dev for NULL, as it's only at two places and
  we could
  still have debug prints for NULL dev, as normal pr_info instead of dev_info.
 
  But Xiubo also pointed out that his patch [1] which updates syscon binding
  information
  will be useless if we pass NULL dev in regmap_init_mmio, which he posted
  today,
  and it requires dev pointer in regmap_get_val_endian function to read DT
  property.
 
  [1]: [PATCH] mfd: syscon: binding: Add syscon endianness support
https://lkml.org/lkml/2014/9/18/67
 
  So instead of adding dummy device or creating device structure, I would
  prefer to get actual
  device pointer corresponding to np passed in of_syscon_register function
  as shown below:
 
 
 I wonder this may not work at early stage before the devices are populated
 from device tree.
 My initial understanding that one important thing for your patch is
 to address this issue, isn't it?
 Many people have asked for this feature before.
 

My boot log:

   ...
of_platform_bus_create() - skipping /chosen, no compatible prop
of_platform_bus_create() - skipping /aliases, no compatible prop
of_platform_bus_create() - skipping /memory, no compatible prop
of_platform_bus_create() - skipping /cpus, no compatible prop
   create child: /soc/smmu@120
   create child: /soc/smmu@128
   create child: /soc/smmu@130
   create child: /soc/smmu@138
   create child: /soc/interrupt-controller@140
   create child: /soc/tzasc@150
of_platform_bus_create() - skipping /soc/tzasc@150, no compatible prop
   create child: /soc/ifc@153
   create child: /soc/ifc@153/nor@0,0
   create child: /soc/ifc@153/board-control@2,0
   create child: /soc/dcfg@1ee
syscon 1ee.dcfg: regmap [mem 0x01ee-0x01ee] registered
   create child: /soc/quadspi@155
   create child: /soc/esdhc@156
   create child: /soc/scfg@157
   create child: /soc/crypto@170
   create child: /soc/sfp@1e8
of_platform_bus_create() - skipping /soc/sfp@1e8, no compatible prop
   create child: /soc/snvs@1e9
of_platform_bus_create() - skipping /soc/snvs@1e9, no compatible prop
   create child: /soc/serdes1@1ea
of_platform_bus_create() - skipping /soc/serdes1@1ea, no compatible prop
   create child: /soc/clocking@1ee1000
   create child: /soc/rcpm@1ee2000
   create child: /soc/dspi@210
   create child: /soc/dspi@211
   create child: /soc/i2c@218
   create child: /soc/i2c@219
   create child: /soc/i2c@21a
   create child: /soc/serial@21c0500
   create child: /soc/serial@21c0600
   create child: /soc/serial@21d0500
   create child: /soc/serial@21d0600
   create child: /soc/gpio@230
   create child: /soc/gpio@231
   create child: /soc/gpio@232
   create child: /soc/gpio@233
   create child: /soc/uqe@240
   create child: /soc/uqe@240/qeic@80
   create child: /soc/uqe@240/ucc@2000
irq: no irq domain found for /soc/uqe@240/qeic@80 !
   create child: /soc/uqe@240/ucc@2200
irq: no irq domain found for /soc/uqe@240/qeic@80 !
   create child: /soc/uqe@240/muram@1
   create child: /soc/uqe@240/si@700
   create child: /soc/uqe@240/siram@1000
   create child: /soc/serial@295
   create child: /soc/serial@296
   create child: /soc/serial@297
   create child: /soc/serial@298
   create child: /soc/serial@299
   create child: /soc/serial@29a
   create child: /soc/ftm0_1@29d
   create child: /soc/ftm@29f
of_platform_bus_create() - skipping /soc/ftm@29f, no compatible prop
   create child: /soc/ftm@2a0
   create child: /soc/ftm@2a1
of_platform_bus_create() - skipping /soc/ftm@2a1, no compatible prop
   create child: /soc/ftm@2a2
of_platform_bus_create() - skipping /soc/ftm@2a2, no compatible prop
   create child: /soc/ftm@2a3
   create child: /soc/ftm@2a4
   create child: /soc/wdog@2ad
   create child: /soc/sai@2b6
   create child: /soc/edma@2c0
   create child: /soc/dcu@2ce
   create child: /soc/mdio@2d24000
   create child: /soc/ptp_clock@2d10e00
   create child: /soc/ethernet@2d1
   create child: /soc/ethernet@2d5
   create child: /soc/ethernet@2d9
   create child: /soc/usb@860
   create child: /soc/usb3@310
   create child: /soc/can@2a7
   create child: /soc/can@2a8
   create child: /soc/can@2a9
   create child: /soc/can@2aa

Re: Re: [PATCH v4 6/8] arm64: exynos7: Enable ARMv8 based Exynos7 (SoC) support

2014-09-18 Thread ALIM AKHTAR
Hi Catalin,

 --- Original Message ---
 Sender : Catalin Marinascatalin.mari...@arm.com
 Date : Sep 19, 2014 01:18 (GMT+09:00)
 Title : Re: [PATCH v4 6/8] arm64: exynos7: Enable ARMv8 based Exynos7 (SoC) 
 support

 On Fri, Sep 12, 2014 at 04:26:30PM +0100, Naveen Krishna Chatradhi wrote:
 From: Alim Akhtar 
 
 This patch adds the necessary Kconfig entries to enable
 support for the ARMv8 based Exynos7 SoC.
 
 Signed-off-by: Alim Akhtar 
 Signed-off-by: Naveen Krishna Chatradhi 
 Cc: Rob Herring 
 Cc: Catalin Marinas 
 ---
  arch/arm64/Kconfig |   12 

 Please update the defconfig as well as we want the default image build
 to contain all the available platforms.
Ok, will send a patch to enable exynos7 in default config.
Thanks.
 -- 
 Catalin

Regards,
AlimN‹§²æìr¸›yúèšØb²X¬¶Ç§vØ^–)Þº{.nÇ+‰·¥Š{±±©¬ºx,¡È§¶›¡Ü¨}©ž²Æ 
zÚj:+v‰¨¾«‘êçzZ+€Ê+zf£¢·hšˆ§~†­†Ûiÿûàz¹®w¥¢¸?™¨è­Ú¢)ߢf

Re: [PATCH v3] mfd: syscon: Decouple syscon interface from platform devices

2014-09-18 Thread Dong Aisheng
On Fri, Sep 19, 2014 at 11:38:03AM +0800, Xiubo Li-B47053 wrote:
   Thanks for testing. In that case I will post this change, as I feel this
   should be
   fixed irrespective of my syscon patch.
  
But as Xiubo pointed in another mail, it may still cause other issues.
Looking at regmap.c, there're still some other places using the device
   pointer, e.g.
dev_xxx debug information and some tracepoints also take device pointer 
as
parameter(not sure if it will break if dev is NULL).
Another thing is that if dev is NULL, we may not be able to use regmap
   debugfs
feature which seems also not as our expected.
   
  
   I would have preferred to check dev for NULL, as it's only at two places 
   and
   we could
   still have debug prints for NULL dev, as normal pr_info instead of 
   dev_info.
  
   But Xiubo also pointed out that his patch [1] which updates syscon binding
   information
   will be useless if we pass NULL dev in regmap_init_mmio, which he posted
   today,
   and it requires dev pointer in regmap_get_val_endian function to read DT
   property.
  
   [1]: [PATCH] mfd: syscon: binding: Add syscon endianness support
 https://lkml.org/lkml/2014/9/18/67
  
   So instead of adding dummy device or creating device structure, I would
   prefer to get actual
   device pointer corresponding to np passed in of_syscon_register function
   as shown below:
  
  
  I wonder this may not work at early stage before the devices are populated
  from device tree.
  My initial understanding that one important thing for your patch is
  to address this issue, isn't it?
  Many people have asked for this feature before.
  
 
 My boot log:
 
...
 of_platform_bus_create() - skipping /chosen, no compatible prop
 of_platform_bus_create() - skipping /aliases, no compatible prop
 of_platform_bus_create() - skipping /memory, no compatible prop
 of_platform_bus_create() - skipping /cpus, no compatible prop
create child: /soc/smmu@120
create child: /soc/smmu@128
create child: /soc/smmu@130
create child: /soc/smmu@138
create child: /soc/interrupt-controller@140
create child: /soc/tzasc@150
 of_platform_bus_create() - skipping /soc/tzasc@150, no compatible prop
create child: /soc/ifc@153
create child: /soc/ifc@153/nor@0,0
create child: /soc/ifc@153/board-control@2,0
create child: /soc/dcfg@1ee
 syscon 1ee.dcfg: regmap [mem 0x01ee-0x01ee] registered
create child: /soc/quadspi@155
create child: /soc/esdhc@156
create child: /soc/scfg@157
create child: /soc/crypto@170
create child: /soc/sfp@1e8
 of_platform_bus_create() - skipping /soc/sfp@1e8, no compatible prop
create child: /soc/snvs@1e9
 of_platform_bus_create() - skipping /soc/snvs@1e9, no compatible prop
create child: /soc/serdes1@1ea
 of_platform_bus_create() - skipping /soc/serdes1@1ea, no compatible prop
create child: /soc/clocking@1ee1000
create child: /soc/rcpm@1ee2000
create child: /soc/dspi@210
create child: /soc/dspi@211
create child: /soc/i2c@218
create child: /soc/i2c@219
create child: /soc/i2c@21a
create child: /soc/serial@21c0500
create child: /soc/serial@21c0600
create child: /soc/serial@21d0500
create child: /soc/serial@21d0600
create child: /soc/gpio@230
create child: /soc/gpio@231
create child: /soc/gpio@232
create child: /soc/gpio@233
create child: /soc/uqe@240
create child: /soc/uqe@240/qeic@80
create child: /soc/uqe@240/ucc@2000
 irq: no irq domain found for /soc/uqe@240/qeic@80 !
create child: /soc/uqe@240/ucc@2200
 irq: no irq domain found for /soc/uqe@240/qeic@80 !
create child: /soc/uqe@240/muram@1
create child: /soc/uqe@240/si@700
create child: /soc/uqe@240/siram@1000
create child: /soc/serial@295
create child: /soc/serial@296
create child: /soc/serial@297
create child: /soc/serial@298
create child: /soc/serial@299
create child: /soc/serial@29a
create child: /soc/ftm0_1@29d
create child: /soc/ftm@29f
 of_platform_bus_create() - skipping /soc/ftm@29f, no compatible prop
create child: /soc/ftm@2a0
create child: /soc/ftm@2a1
 of_platform_bus_create() - skipping /soc/ftm@2a1, no compatible prop
create child: /soc/ftm@2a2
 of_platform_bus_create() - skipping /soc/ftm@2a2, no compatible prop
create child: /soc/ftm@2a3
create child: /soc/ftm@2a4
create child: /soc/wdog@2ad
create child: /soc/sai@2b6
create child: /soc/edma@2c0
create child: /soc/dcu@2ce
create child: /soc/mdio@2d24000
create child: /soc/ptp_clock@2d10e00
create child: /soc/ethernet@2d1
create child: /soc/ethernet@2d5
create child: /soc/ethernet@2d9

RE: [PATCH v3] mfd: syscon: Decouple syscon interface from platform devices

2014-09-18 Thread li.xi...@freescale.com
[...]
 create child: /dcsr@2000/dcsr-atbrepl@3a8000
 create child: /dcsr@2000/dcsr-tsgen-ctrl@3a9000
 create child: /dcsr@2000/dcsr-tsgen-read@3aa000
 create child: /regulators/regulator@0
 ...
 
  As default the Linux will create all the platform device for each DT node,
 which
  Can be found from drivers/of/platform.c.
 
  So we can get the pdev node using the specified DT node, and feel safe to
 use
  it as Pankaj's patch does.
 
 
 I mean before the devices are populated from device tree.
 For example, we usually call of_platform_populate in .init_machine.
 Before it, we may not be able to get it's device, isn't it?
 

Yes, right.

For this case, we'd better create the pdev or dev manually for the first time
We use it, right ?

Thanks,

BRs
Xiubo


 Regards
 Dong Aisheng
 
  And also we must make sure that the 'syscon' DT nodes has the compatible
 prop.
 
  Thanks,
 
  BRs
  Xiubo
 
 
   Regards
   Dong Aisheng
  

static struct syscon *of_syscon_register(struct device_node *np)
 {
+   struct platform_device *pdev;
struct syscon *syscon;
struct regmap *regmap;
void __iomem *base;
@@ -142,7 +144,11 @@ static struct syscon *of_syscon_register(struct
device_node *np)
if (!base)
return ERR_PTR(-ENOMEM);
   
-   regmap = regmap_init_mmio(NULL, base, syscon_regmap_config);
+   pdev = of_find_device_by_node(np);
+   if (!(pdev-dev))
+   return ERR_PTR(-ENODEV);
+
+   regmap = regmap_init_mmio(pdev-dev, base,
 syscon_regmap_config);
if (IS_ERR(regmap)) {
pr_err(regmap init failed\n);
return ERR_CAST(regmap);
---
   
I have tested this in linux-next and it works well. In this way there
 won't
be any issues of
dereferencing NULL pointer in regmap.c and at the same time, if DT has
{big,little}-endian
optional property in syscon device node, it will be taken care.
   
So I would wait for Arnd's opinion about above mentioned changes and
 then
post a new
change after addressing Arnd's minor comment along with this fix in next
revision.
   
   
Thanks,
Pankaj Dubey
 Maybe we could consider create device structure for each syscon
 compatible
device in
 syscon driver in of_syscon_register in first time which seems to be
reasonable.

 Regards
 Dong Aisheng

  
  Subject: [PATCH] regmap: fix NULL pointer dereference in
  regmap_get_val_endian
 
  Recent commits for getting reg endianess causing NULL pointer
  dereference if dev is passed NULL in regmap_init_mmio. This patch
  fixes this issue, and allows to parse reg endianess only if dev and
  dev-of_node exist.
 
  Signed-off-by: Pankaj Dubey pankaj.du...@samsung.com
  ---
   drivers/base/regmap/regmap.c |   23 ++-
   1 file changed, 14 insertions(+), 9 deletions(-)
 
  diff --git a/drivers/base/regmap/regmap.c
  b/drivers/base/regmap/regmap.c index f2281af..455a877 100644
  --- a/drivers/base/regmap/regmap.c
  +++ b/drivers/base/regmap/regmap.c
  @@ -477,7 +477,7 @@ static enum regmap_endian
  regmap_get_val_endian(struct device *dev,
  const struct regmap_bus *bus,
  const struct regmap_config 
  *config)
{
  -   struct device_node *np = dev-of_node;
  +   struct device_node *np;
  enum regmap_endian endian;
 
  /* Retrieve the endianness specification from the regmap config
   */
  @@ -487,15 +487,20 @@ static enum regmap_endian
  regmap_get_val_endian(struct device *dev,
  if (endian != REGMAP_ENDIAN_DEFAULT)
  return endian;
 
  -   /* Parse the device's DT node for an endianness specification */
  -   if (of_property_read_bool(np, big-endian))
  -   endian = REGMAP_ENDIAN_BIG;
  -   else if (of_property_read_bool(np, little-endian))
  -   endian = REGMAP_ENDIAN_LITTLE;
  +   /* If the dev and dev-of_node exist try to get endianness from
   DT
  */
  +   if (dev  dev-of_node) {
  +   np = dev-of_node;
 
  -   /* If the endianness was specified in DT, use that */
  -   if (endian != REGMAP_ENDIAN_DEFAULT)
  -   return endian;
  +   /* Parse the device's DT node for an endianness
  specification */
  +   if (of_property_read_bool(np, big-endian))
  +   endian = REGMAP_ENDIAN_BIG;
  +   else if (of_property_read_bool(np, little-endian))
  +   endian = REGMAP_ENDIAN_LITTLE;
  +
  +   /* If the endianness was specified in DT, use that */
  +   if (endian !=