[PATCH] media: s5p_mfc: Release ctx-ctx if failed to allocate ctx-shm

2014-08-05 Thread Zhaowei Yuan
Signed-off-by: Zhaowei Yuan zhaowei.y...@samsung.com
---
 drivers/media/platform/s5p-mfc/s5p_mfc_opr_v5.c |1 +
 1 file changed, 1 insertion(+)
 mode change 100644 = 100755 drivers/media/platform/s5p-mfc/s5p_mfc_opr_v5.c

diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v5.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v5.c
old mode 100644
new mode 100755
index 58ec7bb..dc00aea
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v5.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v5.c
@@ -228,6 +228,7 @@ static int s5p_mfc_alloc_instance_buffer_v5(struct 
s5p_mfc_ctx *ctx)
ret = s5p_mfc_alloc_priv_buf(dev-mem_dev_l, ctx-shm);
if (ret) {
mfc_err(Failed to allocate shared memory buffer\n);
+   s5p_mfc_release_priv_buf(dev-mem_dev_l, ctx-ctx);
return ret;
}

--
1.7.9.5

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


[PATCH] usb: ehci/ohci-exynos: Fix PHY getting sequence

2014-08-05 Thread Vivek Gautam
Since we want to keep support for both older usb-phys as well as the
newer generic phys, lets first get the generic PHYs and fallback to
older USB-PHYs only when we fail to get the former.
This should fix the issue with ehci-exynos and ohci-exynos, wherein
in the absence of SAMSUNG_USB2PHY config symbol, we end up getting
the NOP_USB_XCEIV phy when the same is enabled. And thus the PHYs
are not configured properly.

Signed-off-by: Vivek Gautam gautam.vi...@samsung.com
Cc: Alan Stern st...@rowland.harvard.edu
Cc: Jingoo Han jg1@samsung.com
---
 drivers/usb/host/ehci-exynos.c |   40 +-
 drivers/usb/host/ohci-exynos.c |   47 +++-
 2 files changed, 42 insertions(+), 45 deletions(-)

diff --git a/drivers/usb/host/ehci-exynos.c b/drivers/usb/host/ehci-exynos.c
index cda0a2f..2eed9a4 100644
--- a/drivers/usb/host/ehci-exynos.c
+++ b/drivers/usb/host/ehci-exynos.c
@@ -62,18 +62,6 @@ static int exynos_ehci_get_phy(struct device *dev,
int phy_number;
int ret = 0;
 
-   exynos_ehci-phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2);
-   if (IS_ERR(exynos_ehci-phy)) {
-   ret = PTR_ERR(exynos_ehci-phy);
-   if (ret != -ENXIO  ret != -ENODEV) {
-   dev_err(dev, no usb2 phy configured\n);
-   return ret;
-   }
-   dev_dbg(dev, Failed to get usb2 phy\n);
-   } else {
-   exynos_ehci-otg = exynos_ehci-phy-otg;
-   }
-
for_each_available_child_of_node(dev-of_node, child) {
ret = of_property_read_u32(child, reg, phy_number);
if (ret) {
@@ -90,15 +78,27 @@ static int exynos_ehci_get_phy(struct device *dev,
 
phy = devm_of_phy_get(dev, child, NULL);
of_node_put(child);
-   if (IS_ERR(phy)) {
-   ret = PTR_ERR(phy);
-   if (ret != -ENOSYS  ret != -ENODEV) {
-   dev_err(dev, no usb2 phy configured\n);
-   return ret;
-   }
-   dev_dbg(dev, Failed to get usb2 phy\n);
-   }
+   if (IS_ERR(phy))
+   /* Lets fallback to older USB-PHYs */
+   goto usb_phy_old;
exynos_ehci-phy_g[phy_number] = phy;
+   /* Make the older PHYs unavailable */
+   exynos_ehci-phy = ERR_PTR(-ENXIO);
+   }
+
+   return 0;
+
+usb_phy_old:
+   exynos_ehci-phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2);
+   if (IS_ERR(exynos_ehci-phy)) {
+   ret = PTR_ERR(exynos_ehci-phy);
+   if (ret != -ENXIO  ret != -ENODEV) {
+   dev_err(dev, no usb2 phy configured\n);
+   return ret;
+   }
+   dev_dbg(dev, Failed to get usb2 phy\n);
+   } else {
+   exynos_ehci-otg = exynos_ehci-phy-otg;
}
 
return ret;
diff --git a/drivers/usb/host/ohci-exynos.c b/drivers/usb/host/ohci-exynos.c
index a72ab8f..7c48e3f 100644
--- a/drivers/usb/host/ohci-exynos.c
+++ b/drivers/usb/host/ohci-exynos.c
@@ -51,27 +51,12 @@ static int exynos_ohci_get_phy(struct device *dev,
int phy_number;
int ret = 0;
 
-   exynos_ohci-phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2);
-   if (IS_ERR(exynos_ohci-phy)) {
-   ret = PTR_ERR(exynos_ohci-phy);
-   if (ret != -ENXIO  ret != -ENODEV) {
-   dev_err(dev, no usb2 phy configured\n);
-   return ret;
-   }
-   dev_dbg(dev, Failed to get usb2 phy\n);
-   } else {
-   exynos_ohci-otg = exynos_ohci-phy-otg;
-   }
-
/*
 * Getting generic phy:
 * We are keeping both types of phys as a part of transiting OHCI
 * to generic phy framework, so as to maintain backward compatibilty
-* with old DTB.
-* If there are existing devices using DTB files built from them,
-* to remove the support for old bindings in this driver,
-* we need to make sure that such devices have their DTBs
-* updated to ones built from new DTS.
+* with old DTB too.
+* We fallback to older USB-PHYs when we fail to get generic PHYs.
 */
for_each_available_child_of_node(dev-of_node, child) {
ret = of_property_read_u32(child, reg, phy_number);
@@ -89,15 +74,27 @@ static int exynos_ohci_get_phy(struct device *dev,
 
phy = devm_of_phy_get(dev, child, NULL);
of_node_put(child);
-   if (IS_ERR(phy)) {
-   ret = PTR_ERR(phy);
-   if (ret != -ENOSYS  ret != -ENODEV) {
-   dev_err(dev, no usb2 phy configured\n);
-   return ret;
-   }
-   

Re: [PATCH v2 1/2] drm/mipi-dsi: add (LPM) Low Power Mode transfer support

2014-08-05 Thread Andrzej Hajda
On 08/03/2014 09:16 AM, Inki Dae wrote:
 2014-08-03 16:03 GMT+09:00 Inki Dae inki@samsung.com:
 2014-07-29 19:23 GMT+09:00 Andrzej Hajda a.ha...@samsung.com:
 On 07/29/2014 02:57 AM, YoungJun Cho wrote:
 Hi Andrzej,

 On 07/29/2014 01:09 AM, Andrzej Hajda wrote:
 On 07/28/2014 04:00 AM, Inki Dae wrote:
 This patch adds below two flags for LPM transfer, and it attaches LPM 
 flags
 to a msg in accordance with master's mode_flags set by LCD Panel driver.

 MIPI_DSI_MODE_CMD_LPM
 - If this flag is set by Panel driver, MIPI-DSI controller will tranfer
 command data to Panel device in Low Power Mode.
 What do you mean by command data? It could be:
 - all transfer in command mode of operations,
 - transfer initialized by the driver by writing to DSIM registers.
 The 2nd one.

 MIPI_DSI_MODE_VIDEO_LPM
 - If this flag is set by Panel driver, MIPI-DSI controller will tranfer
 image data to Panel device in Low Power Mode.
 What is the meaning of this flag in case of command mode of operation?
 I'm also not sure that there is a case to transfer image data in Low
 Power Mode, but this flag is not related with 'command mode' only.
 Inki may consider generic condition.

 Maybe it would be better to create flags based on source of data/FIFOs:
 - commands send by SFR registers,
 - commands generated from data sent from Display Controller.


 And above two flags can be combined together to transfer command and 
 video
 data to Panel device.

 MIPI DSI spec says,
   the host processor controls the desired mode of clock operation.
Host protocol and applications control Clock Lane operating mode
(High Speed or Low Power mode). System designers are responsible
for understanding the clock requirements for peripherals attached
to DSI and controlling clock behavior in accordance with those
requirements.

 Some LCD Panel devices, nt35502a, would need LPM transfer support
 because they should receive some initial commands with LPM by default
 hardware setting.
 Is this requirement for initial commands, or for all commands.
 Btw what is the mode of operation of nt35502a? What flags do you need
 for it?

 The nt35502a panel is video(RGB) mode panel and it requires low power
 mode for initial commands, which means to initialize nt35502a panel, the
 initial commands are transferred by LP mode(Not HS mode).
 And after initialization, its other features like gamma control or etc
 could be controlled in HS mode.
 It sounds similar to my tc358764 bridge driver [1]. The difference is that
 it uses only MIPI_DSI_GENERIC_LONG_(WRITE|READ) in LPM.

 As I understand nt35502a requires also different driving of
 TxRequestHSClk signal
 and this seems to me unrelated to LPM. As LPM is not related at all with
 HS clock, AFAIK.

 + Tomi Valkeinen

 At private talks before, I think we reached the following consensus,

 1. D-PHY could disable HS clock of MIPI-DSI controller in case that
 D-PHY detectsTransition to Stop state (LP=11) and TxRequestHSClk bit
 of MIPI-DSI controller is set, which means that Panel driver set
 MIPI_DSI_CLOCK_NON_CONTINUOUS flag.

 2. Lower Power Mode means that the state of HS clock is low, Positive
 and Negative lane are all low,  LP-11 state.

 However, it seems some misunderstanding each other.

 I guess that non-contiguous clock mode - TxRequestHSCllk bit is set or
 maybe unset - would mean that HS clock is high while MIPI-DSI
 controller transmits data to Panel  until D-PHY detects LP-11 state.
 Or with non-contiguous clock mode, data may be transmistted to Panel
 in LPM (HS clock is low and LP-11) after D-PHY detects LP-11 state. To
 make sure this, I will try to test that Panel - requiring LPM transfer
 for initial commands as default hw setting - works well with
 non-contiguous clock mode. In this cae, it seems that we need to
 consider HW that supports non-continuous clock mode.

I think the situation is quite simple:
1. HS clock is provided via clock line and according to DSI specs it can
be used for two things:
  a) HS transfers,
  b) Application clock - to support active circuitry at the peripheral
[1]. Some peripherals does not need
  it so in such case DSI-Master can disable the HS clock between HS
transfer - it is called non-continuous clock behavior.
  All DSI-Masters shall support continuous clock behavior and can
optionally support non-continuous clock behavior.
  non-continuous clock behavior can be enabled in case peripheral have
such capability.
  In case of drm_mipi_dsi bus the capability is signaled by recently
introduced MIPI_DSI_CLOCK_NON_CONTINUOUS flag.

2. Low-Power Transmissions does not use/depend on clock line, so it has
nothing to do with HS clock. It uses so-caled
Spaced-One-Hot coding which roughly means the clock is embedded in data
signal. In case of drm_mipi_dsi if we want to transfer
data using LPM (or more precisely escape mode) we can use
MIPI_DSI_MSG_USE_LPM flag.

3. There is question if and how TxRequestHSClk bit in Exynos-DSI is

Re: [PATCH 01/15] drm/panel: add prepare and unprepare routines

2014-08-05 Thread Andrzej Hajda
Hi Ajay,

I am glad we have finally more fine-grained callbacks.
Just few nitpicks.

On 07/31/2014 07:42 PM, Ajay Kumar wrote:
 Most of the panels need an init sequence as mentioned below:
   -- poweron LCD unit/LCD_EN
   -- start video data
   -- poweron LED unit/BACKLIGHT_EN
 And, a de-init sequence as mentioned below:
   -- poweroff LED unit/BACKLIGHT_EN
   -- stop video data
   -- poweroff LCD unit/LCD_EN
 With existing callbacks for drm panel, we cannot accomodate such panels,
 since only two callbacks, i.e panel_enable and panel_disable are supported.
 
 This patch adds:
   -- prepare callback which can be called before
   the actual video data is on, and then call the enable
   callback after the video data is available.
 
   -- unprepare callback which can be called after
   the video data is off, and use disable callback
   to do something before switching off the video data.
 
 Now, we can easily map the above scenario as shown below:
   poweron LCD unit/LCD_EN = prepare callback
   poweron LED unit/BACKLIGHT_EN = enable callback
   poweroff LED unit/BACKLIGHT_EN = disable callback
   poweroff LCD unit/LCD_EN = unprepare callback
 
 Signed-off-by: Ajay Kumar ajaykumar...@samsung.com
 ---
  include/drm/drm_panel.h |   18 ++
  1 file changed, 18 insertions(+)
 
 diff --git a/include/drm/drm_panel.h b/include/drm/drm_panel.h
 index c2ab77a..9addc69 100644
 --- a/include/drm/drm_panel.h
 +++ b/include/drm/drm_panel.h
 @@ -31,7 +31,9 @@ struct drm_device;
  struct drm_panel;
  
  struct drm_panel_funcs {
 + int (*unprepare)(struct drm_panel *panel);
   int (*disable)(struct drm_panel *panel);
 + int (*prepare)(struct drm_panel *panel);
   int (*enable)(struct drm_panel *panel);
   int (*get_modes)(struct drm_panel *panel);
  };
 @@ -46,6 +48,14 @@ struct drm_panel {
   struct list_head list;
  };
  
 +static inline int drm_panel_unprepare(struct drm_panel *panel)
 +{
 + if (panel  panel-funcs  panel-funcs-unprepare)
 + return panel-funcs-unprepare(panel);
 +
 + return panel ? -ENOSYS : -EINVAL;
 +}

Wouldn't be better to return 0 in case there is no callback.
In such case we could avoid implementing ugly dummy callbacks in
each panel driver. This is true for all
prepare/unprepare/enable/disable callbacks.

Regards
Andrzej

 +
  static inline int drm_panel_disable(struct drm_panel *panel)
  {
   if (panel  panel-funcs  panel-funcs-disable)
 @@ -54,6 +64,14 @@ static inline int drm_panel_disable(struct drm_panel 
 *panel)
   return panel ? -ENOSYS : -EINVAL;
  }
  
 +static inline int drm_panel_prepare(struct drm_panel *panel)
 +{
 + if (panel  panel-funcs  panel-funcs-prepare)
 + return panel-funcs-prepare(panel);
 +
 + return panel ? -ENOSYS : -EINVAL;
 +}
 +
  static inline int drm_panel_enable(struct drm_panel *panel)
  {
   if (panel  panel-funcs  panel-funcs-enable)
 


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


RE: [PATCH] media: s5p_mfc: Release ctx-ctx if failed to allocate ctx-shm

2014-08-05 Thread Kamil Debski
Hi Zhaowei,

Please provide a short and informative commit description.

Best wishes,
-- 
Kamil Debski
Samsung RD Institute Poland


 -Original Message-
 From: Zhaowei Yuan [mailto:zhaowei.y...@samsung.com]
 Sent: Tuesday, August 05, 2014 9:13 AM
 To: linux-me...@vger.kernel.org; k.deb...@samsung.com;
 m.che...@samsung.com; kyungmin.p...@samsung.com; jtp.p...@samsung.com
 Cc: linux-samsung-soc@vger.kernel.org
 Subject: [PATCH] media: s5p_mfc: Release ctx-ctx if failed to allocate
 ctx-shm
 
 Signed-off-by: Zhaowei Yuan zhaowei.y...@samsung.com
 ---
  drivers/media/platform/s5p-mfc/s5p_mfc_opr_v5.c |1 +
  1 file changed, 1 insertion(+)
  mode change 100644 = 100755 drivers/media/platform/s5p-
 mfc/s5p_mfc_opr_v5.c
 
 diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v5.c
 b/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v5.c
 old mode 100644
 new mode 100755
 index 58ec7bb..dc00aea
 --- a/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v5.c
 +++ b/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v5.c
 @@ -228,6 +228,7 @@ static int s5p_mfc_alloc_instance_buffer_v5(struct
 s5p_mfc_ctx *ctx)
   ret = s5p_mfc_alloc_priv_buf(dev-mem_dev_l, ctx-shm);
   if (ret) {
   mfc_err(Failed to allocate shared memory buffer\n);
 + s5p_mfc_release_priv_buf(dev-mem_dev_l, ctx-ctx);
   return ret;
   }
 
 --
 1.7.9.5

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


Re: [PATCH 01/15] drm/panel: add prepare and unprepare routines

2014-08-05 Thread Andrzej Hajda
Hi Ajay,

[RESEND with reconstructed mail receivers, sorry for noise]

I am glad we have finally more fine-grained callbacks.
Just few nitpicks.

On 07/31/2014 07:42 PM, Ajay Kumar wrote:
 Most of the panels need an init sequence as mentioned below:
   -- poweron LCD unit/LCD_EN
   -- start video data
   -- poweron LED unit/BACKLIGHT_EN
 And, a de-init sequence as mentioned below:
   -- poweroff LED unit/BACKLIGHT_EN
   -- stop video data
   -- poweroff LCD unit/LCD_EN
 With existing callbacks for drm panel, we cannot accomodate such panels,
 since only two callbacks, i.e panel_enable and panel_disable are supported.
 
 This patch adds:
   -- prepare callback which can be called before
   the actual video data is on, and then call the enable
   callback after the video data is available.
 
   -- unprepare callback which can be called after
   the video data is off, and use disable callback
   to do something before switching off the video data.
 
 Now, we can easily map the above scenario as shown below:
   poweron LCD unit/LCD_EN = prepare callback
   poweron LED unit/BACKLIGHT_EN = enable callback
   poweroff LED unit/BACKLIGHT_EN = disable callback
   poweroff LCD unit/LCD_EN = unprepare callback
 
 Signed-off-by: Ajay Kumar 
 ajaykumar.rs-sze3o3uu22jbdgjk7y7...@public.gmane.org
 ---
  include/drm/drm_panel.h |   18 ++
  1 file changed, 18 insertions(+)
 
 diff --git a/include/drm/drm_panel.h b/include/drm/drm_panel.h
 index c2ab77a..9addc69 100644
 --- a/include/drm/drm_panel.h
 +++ b/include/drm/drm_panel.h
 @@ -31,7 +31,9 @@ struct drm_device;
  struct drm_panel;
  
  struct drm_panel_funcs {
 + int (*unprepare)(struct drm_panel *panel);
   int (*disable)(struct drm_panel *panel);
 + int (*prepare)(struct drm_panel *panel);
   int (*enable)(struct drm_panel *panel);
   int (*get_modes)(struct drm_panel *panel);
  };
 @@ -46,6 +48,14 @@ struct drm_panel {
   struct list_head list;
  };
  
 +static inline int drm_panel_unprepare(struct drm_panel *panel)
 +{
 + if (panel  panel-funcs  panel-funcs-unprepare)
 + return panel-funcs-unprepare(panel);
 +
 + return panel ? -ENOSYS : -EINVAL;
 +}

Wouldn't be better to return 0 in case there is no callback.
In such case we could avoid implementing ugly dummy callbacks in
each panel driver. This is true for all
prepare/unprepare/enable/disable callbacks.

Regards
Andrzej

 +
  static inline int drm_panel_disable(struct drm_panel *panel)
  {
   if (panel  panel-funcs  panel-funcs-disable)
 @@ -54,6 +64,14 @@ static inline int drm_panel_disable(struct drm_panel 
 *panel)
   return panel ? -ENOSYS : -EINVAL;
  }
  
 +static inline int drm_panel_prepare(struct drm_panel *panel)
 +{
 + if (panel  panel-funcs  panel-funcs-prepare)
 + return panel-funcs-prepare(panel);
 +
 + return panel ? -ENOSYS : -EINVAL;
 +}
 +
  static inline int drm_panel_enable(struct drm_panel *panel)
  {
   if (panel  panel-funcs  panel-funcs-enable)
 

--
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 07/15] drm/exynos: dsi: Add support for panel prepare and unprepare routines

2014-08-05 Thread Andrzej Hajda
Hi Ajay,


On 07/31/2014 07:42 PM, Ajay Kumar wrote:
 Modify exynos_dsi driver to support the new panel calls:
 prepare and unprepare.
 
 Signed-off-by: Ajay Kumar ajaykumar...@samsung.com
 ---
  drivers/gpu/drm/exynos/exynos_drm_dsi.c |   12 ++--
  1 file changed, 10 insertions(+), 2 deletions(-)
 
 diff --git a/drivers/gpu/drm/exynos/exynos_drm_dsi.c 
 b/drivers/gpu/drm/exynos/exynos_drm_dsi.c
 index dc7c80b..4834932 100644
 --- a/drivers/gpu/drm/exynos/exynos_drm_dsi.c
 +++ b/drivers/gpu/drm/exynos/exynos_drm_dsi.c
 @@ -1351,7 +1351,7 @@ static int exynos_dsi_enable(struct exynos_dsi *dsi)
   if (ret  0)
   return ret;
  
 - ret = drm_panel_enable(dsi-panel);
 + ret = drm_panel_prepare(dsi-panel);
   if (ret  0) {
   exynos_dsi_poweroff(dsi);
   return ret;
 @@ -1360,6 +1360,13 @@ static int exynos_dsi_enable(struct exynos_dsi *dsi)
   exynos_dsi_set_display_mode(dsi);
   exynos_dsi_set_display_enable(dsi, true);
  
 + ret = drm_panel_enable(dsi-panel);
 + if (ret  0) {
 + exynos_dsi_set_display_enable(dsi, false);

I guess drm_panel_unprepare(dsi-panel) should be here.

Regards
Andrzej

 + exynos_dsi_poweroff(dsi);
 + return ret;
 + }
 +
   dsi-state |= DSIM_STATE_ENABLED;
  
   return 0;
 @@ -1370,8 +1377,9 @@ static void exynos_dsi_disable(struct exynos_dsi *dsi)
   if (!(dsi-state  DSIM_STATE_ENABLED))
   return;
  
 - exynos_dsi_set_display_enable(dsi, false);
   drm_panel_disable(dsi-panel);
 + exynos_dsi_set_display_enable(dsi, false);
 + drm_panel_unprepare(dsi-panel);
   exynos_dsi_poweroff(dsi);
  
   dsi-state = ~DSIM_STATE_ENABLED;
 


--
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 RESEND] usb: ehci/ohci-exynos: Fix PHY getting sequence

2014-08-05 Thread Vivek Gautam
Since we want to keep support for both older usb-phys as well as the
newer generic phys, lets first get the generic PHYs and fallback to
older USB-PHYs only when we fail to get the former.
This should fix the issue with ehci-exynos and ohci-exynos, wherein
in the absence of SAMSUNG_USB2PHY config symbol, we end up getting
the NOP_USB_XCEIV phy when the same is enabled. And thus the PHYs
are not configured properly.

Reported-by: Sachin Kamat sachin.ka...@samsung.com
Signed-off-by: Vivek Gautam gautam.vi...@samsung.com
Cc: Alan Stern st...@rowland.harvard.edu
Cc: Jingoo Han jg1@samsung.com
---

Based on 'usb-next' branch.
Resending it after adding 'Reported-by' tag.

 drivers/usb/host/ehci-exynos.c |   40 +-
 drivers/usb/host/ohci-exynos.c |   47 +++-
 2 files changed, 42 insertions(+), 45 deletions(-)

diff --git a/drivers/usb/host/ehci-exynos.c b/drivers/usb/host/ehci-exynos.c
index cda0a2f..2eed9a4 100644
--- a/drivers/usb/host/ehci-exynos.c
+++ b/drivers/usb/host/ehci-exynos.c
@@ -62,18 +62,6 @@ static int exynos_ehci_get_phy(struct device *dev,
int phy_number;
int ret = 0;
 
-   exynos_ehci-phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2);
-   if (IS_ERR(exynos_ehci-phy)) {
-   ret = PTR_ERR(exynos_ehci-phy);
-   if (ret != -ENXIO  ret != -ENODEV) {
-   dev_err(dev, no usb2 phy configured\n);
-   return ret;
-   }
-   dev_dbg(dev, Failed to get usb2 phy\n);
-   } else {
-   exynos_ehci-otg = exynos_ehci-phy-otg;
-   }
-
for_each_available_child_of_node(dev-of_node, child) {
ret = of_property_read_u32(child, reg, phy_number);
if (ret) {
@@ -90,15 +78,27 @@ static int exynos_ehci_get_phy(struct device *dev,
 
phy = devm_of_phy_get(dev, child, NULL);
of_node_put(child);
-   if (IS_ERR(phy)) {
-   ret = PTR_ERR(phy);
-   if (ret != -ENOSYS  ret != -ENODEV) {
-   dev_err(dev, no usb2 phy configured\n);
-   return ret;
-   }
-   dev_dbg(dev, Failed to get usb2 phy\n);
-   }
+   if (IS_ERR(phy))
+   /* Lets fallback to older USB-PHYs */
+   goto usb_phy_old;
exynos_ehci-phy_g[phy_number] = phy;
+   /* Make the older PHYs unavailable */
+   exynos_ehci-phy = ERR_PTR(-ENXIO);
+   }
+
+   return 0;
+
+usb_phy_old:
+   exynos_ehci-phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2);
+   if (IS_ERR(exynos_ehci-phy)) {
+   ret = PTR_ERR(exynos_ehci-phy);
+   if (ret != -ENXIO  ret != -ENODEV) {
+   dev_err(dev, no usb2 phy configured\n);
+   return ret;
+   }
+   dev_dbg(dev, Failed to get usb2 phy\n);
+   } else {
+   exynos_ehci-otg = exynos_ehci-phy-otg;
}
 
return ret;
diff --git a/drivers/usb/host/ohci-exynos.c b/drivers/usb/host/ohci-exynos.c
index a72ab8f..7c48e3f 100644
--- a/drivers/usb/host/ohci-exynos.c
+++ b/drivers/usb/host/ohci-exynos.c
@@ -51,27 +51,12 @@ static int exynos_ohci_get_phy(struct device *dev,
int phy_number;
int ret = 0;
 
-   exynos_ohci-phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2);
-   if (IS_ERR(exynos_ohci-phy)) {
-   ret = PTR_ERR(exynos_ohci-phy);
-   if (ret != -ENXIO  ret != -ENODEV) {
-   dev_err(dev, no usb2 phy configured\n);
-   return ret;
-   }
-   dev_dbg(dev, Failed to get usb2 phy\n);
-   } else {
-   exynos_ohci-otg = exynos_ohci-phy-otg;
-   }
-
/*
 * Getting generic phy:
 * We are keeping both types of phys as a part of transiting OHCI
 * to generic phy framework, so as to maintain backward compatibilty
-* with old DTB.
-* If there are existing devices using DTB files built from them,
-* to remove the support for old bindings in this driver,
-* we need to make sure that such devices have their DTBs
-* updated to ones built from new DTS.
+* with old DTB too.
+* We fallback to older USB-PHYs when we fail to get generic PHYs.
 */
for_each_available_child_of_node(dev-of_node, child) {
ret = of_property_read_u32(child, reg, phy_number);
@@ -89,15 +74,27 @@ static int exynos_ohci_get_phy(struct device *dev,
 
phy = devm_of_phy_get(dev, child, NULL);
of_node_put(child);
-   if (IS_ERR(phy)) {
-   ret = PTR_ERR(phy);
-   if (ret != -ENOSYS  ret != -ENODEV) {
-   

[PATCH v5 1/3] ARM: EXYNOS: Move code from hotplug.c to platsmp.c

2014-08-05 Thread Krzysztof Kozlowski
Cleanup a little the SMP/hotplug code for Exynos by:
1. Moving completely all functions from hotplug.c into the platsmp.c;
2. Deleting the hotplug.c file.

After recent cleanups (e.g. 75ad2ab28f0f ARM: EXYNOS: use
v7_exit_coherency_flush macro for cache disabling) there was only CPU
power down related code in hotplug.c file. Keeping this file does not
give any benefits.

The commit only moves code around with one additional observable change:
the hotplug.c was compiled with custom CFLAGS (-march=armv7-a). These
CFLAGS are not necessary any more.

Signed-off-by: Krzysztof Kozlowski k.kozlow...@samsung.com
Reviewed-by: Tomasz Figa t.f...@samsung.com

---
Changes since v4:
1. Rebase on linux-next-20140804.
2. Add Reviewed-by Tomasz Figa.
---
 arch/arm/mach-exynos/Makefile  |  3 --
 arch/arm/mach-exynos/common.h  |  2 -
 arch/arm/mach-exynos/hotplug.c | 91 --
 arch/arm/mach-exynos/platsmp.c | 74 ++
 4 files changed, 74 insertions(+), 96 deletions(-)
 delete mode 100644 arch/arm/mach-exynos/hotplug.c

diff --git a/arch/arm/mach-exynos/Makefile b/arch/arm/mach-exynos/Makefile
index 788f26d21141..0095de99d703 100644
--- a/arch/arm/mach-exynos/Makefile
+++ b/arch/arm/mach-exynos/Makefile
@@ -21,9 +21,6 @@ obj-$(CONFIG_PM_GENERIC_DOMAINS) += pm_domains.o
 
 obj-$(CONFIG_SMP)  += platsmp.o headsmp.o
 
-obj-$(CONFIG_HOTPLUG_CPU)  += hotplug.o
-CFLAGS_hotplug.o   += -march=armv7-a
-
 plus_sec := $(call as-instr,.arch_extension sec,+sec)
 AFLAGS_exynos-smc.o:=-Wa,-march=armv7-a$(plus_sec)
 
diff --git a/arch/arm/mach-exynos/common.h b/arch/arm/mach-exynos/common.h
index 47b904b3b973..3d3e6af9d015 100644
--- a/arch/arm/mach-exynos/common.h
+++ b/arch/arm/mach-exynos/common.h
@@ -130,8 +130,6 @@ extern void exynos_cpu_resume(void);
 
 extern struct smp_operations exynos_smp_ops;
 
-extern void exynos_cpu_die(unsigned int cpu);
-
 /* PMU(Power Management Unit) support */
 
 #define PMU_TABLE_END  (-1U)
diff --git a/arch/arm/mach-exynos/hotplug.c b/arch/arm/mach-exynos/hotplug.c
deleted file mode 100644
index 4d86961a7957..
--- a/arch/arm/mach-exynos/hotplug.c
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- *  Cloned from linux/arch/arm/mach-realview/hotplug.c
- *
- *  Copyright (C) 2002 ARM Ltd.
- *  All Rights Reserved
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
-*/
-
-#include linux/kernel.h
-#include linux/errno.h
-#include linux/smp.h
-#include linux/io.h
-
-#include asm/cacheflush.h
-#include asm/cp15.h
-#include asm/smp_plat.h
-
-#include common.h
-#include regs-pmu.h
-
-static inline void cpu_leave_lowpower(void)
-{
-   unsigned int v;
-
-   asm volatile(
-   mrcp15, 0, %0, c1, c0, 0\n
-  orr %0, %0, %1\n
-  mcr p15, 0, %0, c1, c0, 0\n
-  mrc p15, 0, %0, c1, c0, 1\n
-  orr %0, %0, %2\n
-  mcr p15, 0, %0, c1, c0, 1\n
- : =r (v)
- : Ir (CR_C), Ir (0x40)
- : cc);
-}
-
-static inline void platform_do_lowpower(unsigned int cpu, int *spurious)
-{
-   u32 mpidr = cpu_logical_map(cpu);
-   u32 core_id = MPIDR_AFFINITY_LEVEL(mpidr, 0);
-
-   for (;;) {
-
-   /* Turn the CPU off on next WFI instruction. */
-   exynos_cpu_power_down(core_id);
-
-   wfi();
-
-   if (pen_release == core_id) {
-   /*
-* OK, proper wakeup, we're done
-*/
-   break;
-   }
-
-   /*
-* Getting here, means that we have come out of WFI without
-* having been woken up - this shouldn't happen
-*
-* Just note it happening - when we're woken, we can report
-* its occurrence.
-*/
-   (*spurious)++;
-   }
-}
-
-/*
- * platform-specific code to shutdown a CPU
- *
- * Called with IRQs disabled
- */
-void __ref exynos_cpu_die(unsigned int cpu)
-{
-   int spurious = 0;
-
-   v7_exit_coherency_flush(louis);
-
-   platform_do_lowpower(cpu, spurious);
-
-   /*
-* bring this CPU back into the world of cache
-* coherency, and then restore interrupts
-*/
-   cpu_leave_lowpower();
-
-   if (spurious)
-   pr_warn(CPU%u: %u spurious wakeup calls\n, cpu, spurious);
-}
diff --git a/arch/arm/mach-exynos/platsmp.c b/arch/arm/mach-exynos/platsmp.c
index a9f1cf759949..a809f76c8160 100644
--- a/arch/arm/mach-exynos/platsmp.c
+++ b/arch/arm/mach-exynos/platsmp.c
@@ -22,6 +22,7 @@
 #include linux/of_address.h
 
 #include asm/cacheflush.h
+#include asm/cp15.h
 #include asm/smp_plat.h
 #include asm/smp_scu.h
 #include asm/firmware.h
@@ -33,6 +34,54 @@
 
 extern void 

[PATCH v5 3/3] ARM: exynos4: hotplug: Fix CPU idle clock down after CPU off

2014-08-05 Thread Krzysztof Kozlowski
On Exynos4 USE_DELAYED_RESET_ASSERTION must be set in
ARM_COREx_OPTION register during CPU power down. This is the proper way
of powering down CPU on Exynos4.

Additionally on Exynos4212 without this the CPU clock down feature won't
work after powering down some CPU and the online CPUs will work at full
frequency chosen by CPUfreq governor.

Signed-off-by: Krzysztof Kozlowski k.kozlow...@samsung.com
Reviewed-by: Tomasz Figa t.f...@samsung.com

---
Changes since v4:
1. Rebase on linux-next-20140804.
2. Add Reviewed-by Tomasz Figa.

Changes since v3:
1. Add patches moving hotplug code to platsmp.c file (patches 1 and 2).
   Suggested by Tomasz Figa.
2. Remove declaration of exynos_clear_delayed_reset_assertion() in
   header because hotplug code is integrated into platsmp.c file.
   Suggested by Tomasz Figa.
3. Replace 'clear' helper with 'set' helper. Suggested by Tomasz Figa.

Changes since v2:
1. Add missing disable of the use delayed reset assertion feature
   when starting secondary CPU (suggested by Tomasz Figa).

Changes since v1:
1. Use delayed reset assertion on all Exynos4 family and all cores, not
   only on core 1 of Exynos4212.
2. Rebase on Tomasz Figa's patch:
   ARM: EXYNOS: Fix core ID used by platsmp and hotplug code
   http://www.spinics.net/lists/linux-samsung-soc/msg31604.html
   Tomasz's patch is currently applied to Kukjin's v3.16-samsung-fixes-4
---
 arch/arm/mach-exynos/platsmp.c  | 43 +++--
 arch/arm/mach-exynos/regs-pmu.h |  3 +++
 2 files changed, 44 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-exynos/platsmp.c b/arch/arm/mach-exynos/platsmp.c
index 83b20a38a598..99c151bf30ad 100644
--- a/arch/arm/mach-exynos/platsmp.c
+++ b/arch/arm/mach-exynos/platsmp.c
@@ -34,8 +34,32 @@
 
 extern void exynos4_secondary_startup(void);
 
+/*
+ * Set or clear the USE_DELAYED_RESET_ASSERTION option, set on Exynos4 SoCs
+ * during hot-(un)plugging CPUx.
+ *
+ * The feature can be cleared safely during first boot of secondary CPU.
+ *
+ * Exynos4 SoCs require setting USE_DELAYED_RESET_ASSERTION during powering
+ * down a CPU so the CPU idle clock down feature could properly detect global
+ * idle state when CPUx is off.
+ */
+static void exynos_set_delayed_reset_assertion(u32 core_id, bool enable)
+{
+   if (soc_is_exynos4()) {
+   unsigned int tmp;
+
+   tmp = pmu_raw_readl(EXYNOS_ARM_CORE_OPTION(core_id));
+   if (enable)
+   tmp |= S5P_USE_DELAYED_RESET_ASSERTION;
+   else
+   tmp = ~(S5P_USE_DELAYED_RESET_ASSERTION);
+   pmu_raw_writel(tmp, EXYNOS_ARM_CORE_OPTION(core_id));
+   }
+}
+
 #ifdef CONFIG_HOTPLUG_CPU
-static inline void cpu_leave_lowpower(void)
+static inline void cpu_leave_lowpower(u32 core_id)
 {
unsigned int v;
 
@@ -49,6 +73,8 @@ static inline void cpu_leave_lowpower(void)
  : =r (v)
  : Ir (CR_C), Ir (0x40)
  : cc);
+
+exynos_set_delayed_reset_assertion(core_id, false);
 }
 
 static inline void platform_do_lowpower(unsigned int cpu, int *spurious)
@@ -61,6 +87,14 @@ static inline void platform_do_lowpower(unsigned int cpu, 
int *spurious)
/* Turn the CPU off on next WFI instruction. */
exynos_cpu_power_down(core_id);
 
+   /*
+* Exynos4 SoCs require setting
+* USE_DELAYED_RESET_ASSERTION so the CPU idle
+* clock down feature could properly detect
+* global idle state when CPUx is off.
+*/
+   exynos_set_delayed_reset_assertion(core_id, true);
+
wfi();
 
if (pen_release == core_id) {
@@ -286,6 +320,9 @@ static int exynos_boot_secondary(unsigned int cpu, struct 
task_struct *idle)
udelay(10);
}
 
+   /* No harm if this is called during first boot of secondary CPU */
+   exynos_set_delayed_reset_assertion(core_id, false);
+
/*
 * now the secondary core is starting up let it run its
 * calibrations, then wait for it to finish
@@ -376,6 +413,8 @@ static void __init exynos_smp_prepare_cpus(unsigned int 
max_cpus)
 static void exynos_cpu_die(unsigned int cpu)
 {
int spurious = 0;
+   u32 mpidr = cpu_logical_map(cpu);
+   u32 core_id = MPIDR_AFFINITY_LEVEL(mpidr, 0);
 
v7_exit_coherency_flush(louis);
 
@@ -385,7 +424,7 @@ static void exynos_cpu_die(unsigned int cpu)
 * bring this CPU back into the world of cache
 * coherency, and then restore interrupts
 */
-   cpu_leave_lowpower();
+   cpu_leave_lowpower(core_id);
 
if (spurious)
pr_warn(CPU%u: %u spurious wakeup calls\n, cpu, spurious);
diff --git a/arch/arm/mach-exynos/regs-pmu.h b/arch/arm/mach-exynos/regs-pmu.h
index 96a1569262b5..4e9b4440e2bd 100644
--- a/arch/arm/mach-exynos/regs-pmu.h
+++ b/arch/arm/mach-exynos/regs-pmu.h
@@ -20,6 +20,7 

[PATCH 00/29] Exynos SYSMMU (IOMMU) integration with DT and DMA-mapping subsystem

2014-08-05 Thread Marek Szyprowski
Hello Everyone,

A lot of things has happened in the area of improving Exynos IOMMU
driver and discussion about generic IOMMU bindings, which finally
motivated me to get back to IOMMU related tasks. Just to remind, here
are those 2 important threads:

1. [PATCH v13 00/19] iommu/exynos: Fixes and Enhancements of System MMU
driver with DT: https://lkml.org/lkml/2014/5/12/34

2. [PATCH v4] devicetree: Add generic IOMMU device tree bindings:
https://lkml.org/lkml/2014/7/4/349

As a follow up of those discussions I've decided to finish our internal
code, which adapts Exynos SYSMMU driver to meet generic IOMMU bindings
requirements and implement all needed glue code to finally demonstare
seemless integration IOMMU controller with DMA-mapping subsystem for
the drivers available on Exynos SoCs.


1. Introduction - a few words for those who are not fully aware of the
Exynos SoC hardware

Exynos SoC consists of various devices integrated directly into SoCs.
Most of them are multimedia devices, which usually process large
buffers. Some of them (like i.e. MFC - a multimedia codec or FIMD - a
multi-window framebuffer device  lcd panel controller) are equipped
with more than one memory interface for higher processing performance.
There are also really complex subsystems (like ISP, the camera sensor
interface  processor), which consist of many sub-blocks, each having
its own memory interface/channel/bus (different names are used for the
same thing).

Each such memory controller might be equipped with SYSMMU device, which
acts as IOMMU controller for the parent device (called master device, a
device which that memory interface belongs to). Each SYSMMU controller
has its own register set and clock, belongs to the same power domain as
master device. There is also some non-direct relation from master's
device gate clock - SYSMMU registers can be accessed only when master's
gate clock is enabled.

Basically we have following dependencies between hardware and drivers:
- each multimedia device might have 1 or more SYSMMU controller
- each SYSMMU controller belongs only to 1 master device
- all SYSMMU controllers are independent of each other, there is no
  global hardware ID that must be assigned to enable given SYSMMU
  controller
- multimedia devices are modeled usually by a separate node in device
  tree with it's own compatible string and separate driver for them
- sub-blocks of complex devices right now are not modeled by a separate
  device tree nodes, but this might be changed in the future
- some multimedia devices have limited address space per each memory
  controller/channel (i.e. codec might access buffers only in a 256MiB
  window for each of it's memory channels)
- some drivers for independent device are used together to provide a
  more complex subsystem, i.e. FIMD, HDMI-mixer and others form together
  Exynos DRM subsystem; it is highly welcome to let them to operate in
  the same, shared DMA address space to simplify buffer sharing


2. Introduction part 2 - a few word of summary of the discussions about
generic IOMMU DT bindings

There have been a lot of discussions on the method of modeling IOMMU
controllers in device tree. The approach which has been selected as the
generic IOMMU binding candidate has been described in the '[PATCH v4]
devicetree: Add generic IOMMU device tree bindings' thread.

Those bindings describe how to link an IOMMU controller with its master
device. Basically an 'iommus' property placed in the master's device
node has been introduced. This property contains phandle to IOMMU
controller node. Optional properties of the particular binding can also
be specified after the phandle, assuming that IOMMU controller node
contains '#iommu-cells' property, which defines number of cells used for
those parameters. Those parameters are then interpreted by particular
IOMMU controller driver. Those parameters might be some hw channel id
required for correct hardware setup, base address and size pair for
limited IO address space window or others hardware dependant properties.


3. IOMMU integration to DMA-mapping subsystem

By default we assume that each master device, which has been equipped
with IOMMU controller gets its own DMA (IO) address space. This is
created automatically and transparently without any changes in the
device driver code. All DMA-mapping functions are replaced with the
IOMMU aware versions. This has to be done somewhere by the architecture
or SoC startup code, so when master's driver probe() function is called,
everything is in place.

However some device drivers might need (for various reasons) to manually
manage DMA (IO) address space. For this case a driver need to notify
kernel about that and do the management of DMA address space on its own.
This has been achieved by introducing DRIVER_HAS_OWN_IOMMU_MANAGER flag,
which can be set in struct device_driver. This way the startup code can
easily determine if creating the default per-device separate DMA
address space is required 

[PATCH 05/29] drivers: convert suppress_bind_attrs parameter into flags

2014-08-05 Thread Marek Szyprowski
This patch extends struct device_driver with a flags member and converts
existing suppress_bind_attrs bool field to a flag. This way new flags
can be easily added in the future without changing the structure itself.

Signed-off-by: Marek Szyprowski m.szyprow...@samsung.com
---
 arch/arm/mach-integrator/impd1.c | 2 +-
 drivers/base/bus.c   | 4 ++--
 drivers/base/platform.c  | 2 +-
 drivers/pci/host/pci-mvebu.c | 2 +-
 drivers/pci/host/pci-rcar-gen2.c | 2 +-
 drivers/pci/host/pci-tegra.c | 2 +-
 drivers/pci/host/pcie-rcar.c | 2 +-
 drivers/soc/tegra/pmc.c  | 2 +-
 include/linux/device.h   | 6 --
 9 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/arch/arm/mach-integrator/impd1.c b/arch/arm/mach-integrator/impd1.c
index 3ce8807..a7e7330 100644
--- a/arch/arm/mach-integrator/impd1.c
+++ b/arch/arm/mach-integrator/impd1.c
@@ -406,7 +406,7 @@ static struct lm_driver impd1_driver = {
 * As we're dropping the probe() function, suppress driver
 * binding from sysfs.
 */
-   .suppress_bind_attrs = true,
+   .flags = DRIVER_SUPPRESS_BIND_ATTRS,
},
.probe  = impd1_probe,
.remove = impd1_remove,
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index 83e910a..f223f26 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -707,7 +707,7 @@ int bus_add_driver(struct device_driver *drv)
__func__, drv-name);
}
 
-   if (!drv-suppress_bind_attrs) {
+   if (!(drv-flags  DRIVER_SUPPRESS_BIND_ATTRS)) {
error = add_bind_files(drv);
if (error) {
/* Ditto */
@@ -740,7 +740,7 @@ void bus_remove_driver(struct device_driver *drv)
if (!drv-bus)
return;
 
-   if (!drv-suppress_bind_attrs)
+   if (!(drv-flags  DRIVER_SUPPRESS_BIND_ATTRS))
remove_bind_files(drv);
driver_remove_groups(drv, drv-bus-drv_groups);
driver_remove_file(drv, driver_attr_uevent);
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 68a8b77..c696058 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -608,7 +608,7 @@ int __init_or_module platform_driver_probe(struct 
platform_driver *drv,
drv-prevent_deferred_probe = true;
 
/* make sure driver won't have bind/unbind attributes */
-   drv-driver.suppress_bind_attrs = true;
+   drv-driver.flags = DRIVER_SUPPRESS_BIND_ATTRS;
 
/* temporary section violation during probe() */
drv-probe = probe;
diff --git a/drivers/pci/host/pci-mvebu.c b/drivers/pci/host/pci-mvebu.c
index a8c6f1a..6815c50 100644
--- a/drivers/pci/host/pci-mvebu.c
+++ b/drivers/pci/host/pci-mvebu.c
@@ -1086,7 +1086,7 @@ static struct platform_driver mvebu_pcie_driver = {
.name = mvebu-pcie,
.of_match_table = mvebu_pcie_of_match_table,
/* driver unloading/unbinding currently not supported */
-   .suppress_bind_attrs = true,
+   .flags = DRIVER_SUPPRESS_BIND_ATTRS,
},
.probe = mvebu_pcie_probe,
 };
diff --git a/drivers/pci/host/pci-rcar-gen2.c b/drivers/pci/host/pci-rcar-gen2.c
index 3ef854f..6f1b890 100644
--- a/drivers/pci/host/pci-rcar-gen2.c
+++ b/drivers/pci/host/pci-rcar-gen2.c
@@ -413,7 +413,7 @@ static struct platform_driver rcar_pci_driver = {
.driver = {
.name = pci-rcar-gen2,
.owner = THIS_MODULE,
-   .suppress_bind_attrs = true,
+   .flags = DRIVER_SUPPRESS_BIND_ATTRS,
.of_match_table = rcar_pci_of_match,
},
.probe = rcar_pci_probe,
diff --git a/drivers/pci/host/pci-tegra.c b/drivers/pci/host/pci-tegra.c
index 0fb0fdb..2e1698d 100644
--- a/drivers/pci/host/pci-tegra.c
+++ b/drivers/pci/host/pci-tegra.c
@@ -1927,7 +1927,7 @@ static struct platform_driver tegra_pcie_driver = {
.name = tegra-pcie,
.owner = THIS_MODULE,
.of_match_table = tegra_pcie_of_match,
-   .suppress_bind_attrs = true,
+   .flags = DRIVER_SUPPRESS_BIND_ATTRS,
},
.probe = tegra_pcie_probe,
 };
diff --git a/drivers/pci/host/pcie-rcar.c b/drivers/pci/host/pcie-rcar.c
index 4884ee5..9a1936e 100644
--- a/drivers/pci/host/pcie-rcar.c
+++ b/drivers/pci/host/pcie-rcar.c
@@ -981,7 +981,7 @@ static struct platform_driver rcar_pcie_driver = {
.name = DRV_NAME,
.owner = THIS_MODULE,
.of_match_table = rcar_pcie_of_match,
-   .suppress_bind_attrs = true,
+   .flags = DRIVER_SUPPRESS_BIND_ATTRS,
},
.probe = rcar_pcie_probe,
 };
diff --git a/drivers/soc/tegra/pmc.c b/drivers/soc/tegra/pmc.c
index a2c0ceb..77c3eb3 100644
--- a/drivers/soc/tegra/pmc.c
+++ b/drivers/soc/tegra/pmc.c
@@ -892,7 +892,7 @@ static const struct 

[PATCH 14/29] devicetree: Update Exynos SYSMMU device tree bindings

2014-08-05 Thread Marek Szyprowski
This patch describes how generic iommu bindings are implemented by
Exynos SYSMMU driver.

Signed-off-by: Marek Szyprowski m.szyprow...@samsung.com
---
 .../devicetree/bindings/iommu/samsung,sysmmu.txt   | 93 +++---
 1 file changed, 84 insertions(+), 9 deletions(-)

diff --git a/Documentation/devicetree/bindings/iommu/samsung,sysmmu.txt 
b/Documentation/devicetree/bindings/iommu/samsung,sysmmu.txt
index 6fa4c73..999ba6d 100644
--- a/Documentation/devicetree/bindings/iommu/samsung,sysmmu.txt
+++ b/Documentation/devicetree/bindings/iommu/samsung,sysmmu.txt
@@ -23,16 +23,33 @@ MMUs.
   for window 1, 2 and 3.
 * M2M Scalers and G2D in Exynos5420 has one System MMU on the read channel and
   the other System MMU on the write channel.
-The drivers must consider how to handle those System MMUs. One of the idea is
-to implement child devices or sub-devices which are the client devices of the
-System MMU.
 
-Note:
-The current DT binding for the Exynos System MMU is incomplete.
-The following properties can be removed or changed, if found incompatible with
-the Generic IOMMU Binding support for attaching devices to the IOMMU.
+The drivers must consider how to handle those System MMUs. When device
+have more than one SYSMMU controller it is neccessary to add
+iommu-names property, which specifies which SYSMMU controller operates
+on which bus or memory channel.
 
-Required properties:
+It is up to the master device driver to decide how such case will be
+handled. It is possible to create separate IO address spaces for each
+SYSMMU or to bind them together to one common IO address space. It is
+also possible to bind more than one device to one IO address space. All
+this has to be handled by master device driver in its initialization
+procedure or flags and no changes to device tree nodes are needed.
+
+In Linux kernel, the general idea is that presence of the SYSMMU
+controllers is transparent to master drivers if they use standard DMA
+API. When driver wants to use IO separate address spaces for each bus or
+memory channel (each SYSMMU) or to bind more than one device to one IO
+address space, it has to specify this to SYSMMU driver by
+DRIVER_HAS_OWN_IOMMU_MANAGER flag. To get access to each SYSMMU bound to
+the given device, additional child devices with special names (matching
+parent:bus scheme) have to be registered. Once then, all standard
+IOMMU operations can be performed on such child devices, what will
+result in respective operations done on IO address space managed by
+SYSMMU of the given name. Other operating systems might implement those
+features differently.
+
+Required properties for SYSMMU controller node:
 - compatible: Should be samsung,exynos-sysmmu
 - reg: A tuple of base address and size of System MMU registers.
 - interrupt-parent: The phandle of the interrupt controller of System MMU
@@ -45,11 +62,27 @@ Required properties:
   Exynos4 SoCs, there needs no master clock.
   Exynos5 SoCs, some System MMUs must have master clocks.
 - clocks: Required if the System MMU is needed to gate its clock.
+- #iommu-cells: Specify number of cells describing IO address space parameters,
+   can be: 0 (zero), meaning all 32bit address space is available,
+   or 2, if address space is limited, first cell then stores
+   base IO address, second cell contains IO window size in bytes.
 - samsung,power-domain: Required if the System MMU is needed to gate its power.
  Please refer to the following document:
  Documentation/devicetree/bindings/arm/exynos/power_domain.txt
 
-Examples:
+Required properties for master device:
+- iommus: one or more phandles to the SYSMMU controller node, with optionally
+ specified IO address space (see #iommu-cells property above)
+- iommu-names: if more than one SYSMMU controller is specified, this property
+  must contain names for each of them. Those names are defined by
+  the bindings for a particular master device.
+
+For more information, please refer to generic iommu bindings defined in
+iommu.txt file.
+
+Example 1:
+GScaller device with one SYSMMU controller
+
gsc_0: gsc@13e0 {
compatible = samsung,exynos5-gsc;
reg = 0x13e0 0x1000;
@@ -57,6 +90,7 @@ Examples:
samsung,power-domain = pd_gsc;
clocks = clock CLK_GSCL0;
clock-names = gscl;
+   iommus = sysmmu_gsc0;
};
 
sysmmu_gsc0: sysmmu@13E8 {
@@ -67,4 +101,45 @@ Examples:
clock-names = sysmmu, master;
clocks = clock CLK_SMMU_GSCL0, clock CLK_GSCL0;
samsung,power-domain = pd_gsc;
+   #iommu-cells = 0;
+   };
+
+Example 2:
+MFC Codec with two SYSMMU controllers (on left and right bus), with address
+space limited to 256MiB each, left bus starts IO address space at 0x2000,
+while right bus at 0x3000
+
+  

[PATCH 26/29] iommu: exynos: rename variables to reflect their purpose

2014-08-05 Thread Marek Szyprowski
This patch renames some variables to make the code easier to understand.
'domain' is replaced by 'iommu_domain' (more generic entity) and really
meaning less 'priv' by 'domain' to reflect its purpose.

Signed-off-by: Marek Szyprowski m.szyprow...@samsung.com
---
 drivers/iommu/exynos-iommu.c | 191 ++-
 1 file changed, 97 insertions(+), 94 deletions(-)

diff --git a/drivers/iommu/exynos-iommu.c b/drivers/iommu/exynos-iommu.c
index 5cd91b11..7600861 100644
--- a/drivers/iommu/exynos-iommu.c
+++ b/drivers/iommu/exynos-iommu.c
@@ -440,8 +440,8 @@ static void __sysmmu_enable_nocount(struct sysmmu_drvdata 
*data)
clk_disable(data-clk_master);
 }
 
-static int __sysmmu_enable(struct sysmmu_drvdata *data,
-   phys_addr_t pgtable, struct iommu_domain *domain)
+static int __sysmmu_enable(struct sysmmu_drvdata *data, phys_addr_t pgtable,
+  struct iommu_domain *iommu_domain)
 {
int ret = 0;
unsigned long flags;
@@ -449,7 +449,7 @@ static int __sysmmu_enable(struct sysmmu_drvdata *data,
spin_lock_irqsave(data-lock, flags);
if (set_sysmmu_active(data)) {
data-pgtable = pgtable;
-   data-domain = domain;
+   data-domain = iommu_domain;
 
__sysmmu_enable_nocount(data);
 
@@ -664,92 +664,93 @@ static inline void pgtable_flush(void *vastart, void 
*vaend)
virt_to_phys(vaend));
 }
 
-static int exynos_iommu_domain_init(struct iommu_domain *domain)
+static int exynos_iommu_domain_init(struct iommu_domain *iommu_domain)
 {
-   struct exynos_iommu_domain *priv;
+   struct exynos_iommu_domain *domain;
int i;
 
-   priv = kzalloc(sizeof(*priv), GFP_KERNEL);
-   if (!priv)
+   domain = kzalloc(sizeof(*domain), GFP_KERNEL);
+   if (!domain)
return -ENOMEM;
 
-   priv-pgtable = (sysmmu_pte_t *)__get_free_pages(GFP_KERNEL, 2);
-   if (!priv-pgtable)
+   domain-pgtable = (sysmmu_pte_t *)__get_free_pages(GFP_KERNEL, 2);
+   if (!domain-pgtable)
goto err_pgtable;
 
-   priv-lv2entcnt = (short *)__get_free_pages(GFP_KERNEL | __GFP_ZERO, 1);
-   if (!priv-lv2entcnt)
+   domain-lv2entcnt = (short *)
+   __get_free_pages(GFP_KERNEL | __GFP_ZERO, 1);
+   if (!domain-lv2entcnt)
goto err_counter;
 
/* w/a of System MMU v3.3 to prevent caching 1MiB mapping */
for (i = 0; i  NUM_LV1ENTRIES; i += 8) {
-   priv-pgtable[i + 0] = ZERO_LV2LINK;
-   priv-pgtable[i + 1] = ZERO_LV2LINK;
-   priv-pgtable[i + 2] = ZERO_LV2LINK;
-   priv-pgtable[i + 3] = ZERO_LV2LINK;
-   priv-pgtable[i + 4] = ZERO_LV2LINK;
-   priv-pgtable[i + 5] = ZERO_LV2LINK;
-   priv-pgtable[i + 6] = ZERO_LV2LINK;
-   priv-pgtable[i + 7] = ZERO_LV2LINK;
+   domain-pgtable[i + 0] = ZERO_LV2LINK;
+   domain-pgtable[i + 1] = ZERO_LV2LINK;
+   domain-pgtable[i + 2] = ZERO_LV2LINK;
+   domain-pgtable[i + 3] = ZERO_LV2LINK;
+   domain-pgtable[i + 4] = ZERO_LV2LINK;
+   domain-pgtable[i + 5] = ZERO_LV2LINK;
+   domain-pgtable[i + 6] = ZERO_LV2LINK;
+   domain-pgtable[i + 7] = ZERO_LV2LINK;
}
 
-   pgtable_flush(priv-pgtable, priv-pgtable + NUM_LV1ENTRIES);
+   pgtable_flush(domain-pgtable, domain-pgtable + NUM_LV1ENTRIES);
 
-   spin_lock_init(priv-lock);
-   spin_lock_init(priv-pgtablelock);
-   INIT_LIST_HEAD(priv-clients);
+   spin_lock_init(domain-lock);
+   spin_lock_init(domain-pgtablelock);
+   INIT_LIST_HEAD(domain-clients);
 
-   domain-geometry.aperture_start = 0;
-   domain-geometry.aperture_end   = ~0UL;
-   domain-geometry.force_aperture = true;
+   iommu_domain-geometry.aperture_start = 0;
+   iommu_domain-geometry.aperture_end   = ~0UL;
+   iommu_domain-geometry.force_aperture = true;
 
-   domain-priv = priv;
+   iommu_domain-priv = domain;
return 0;
 
 err_counter:
-   free_pages((unsigned long)priv-pgtable, 2);
+   free_pages((unsigned long)domain-pgtable, 2);
 err_pgtable:
-   kfree(priv);
+   kfree(domain);
return -ENOMEM;
 }
 
-static void exynos_iommu_domain_destroy(struct iommu_domain *domain)
+static void exynos_iommu_domain_destroy(struct iommu_domain *iommu_domain)
 {
-   struct exynos_iommu_domain *priv = domain-priv;
+   struct exynos_iommu_domain *domain = iommu_domain-priv;
struct sysmmu_drvdata *data;
unsigned long flags;
int i;
 
-   WARN_ON(!list_empty(priv-clients));
+   WARN_ON(!list_empty(domain-clients));
 
-   spin_lock_irqsave(priv-lock, flags);
+   spin_lock_irqsave(domain-lock, flags);
 
-   list_for_each_entry(data, priv-clients, domain_node) 

[PATCH 29/29] temporary: media: s5p-mfc: add support for IOMMU

2014-08-05 Thread Marek Szyprowski
This patch is an example how to use more than one IOMMU controller in a
device driver for hardware blocks, which have more then one dma master
(memory interface with iommu controller).

This patch is temporary, do not merge it yet.

Signed-off-by: Marek Szyprowski m.szyprow...@samsung.com
---
 drivers/media/platform/s5p-mfc/s5p_mfc.c | 46 ++--
 1 file changed, 44 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc.c
index 77b99ae..c2e95ab 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c
@@ -22,7 +22,11 @@
 #include media/v4l2-event.h
 #include linux/workqueue.h
 #include linux/of.h
+#include linux/of_platform.h
 #include media/videobuf2-core.h
+
+#include asm/dma-iommu.h
+
 #include s5p_mfc_common.h
 #include s5p_mfc_ctrl.h
 #include s5p_mfc_debug.h
@@ -996,6 +1000,39 @@ static const struct v4l2_file_operations s5p_mfc_fops = {
.mmap = s5p_mfc_mmap,
 };
 
+static struct device *s5p_mfc_alloc_memdev(struct device *dev, const char 
*name)
+{
+   struct device *child;
+   int ret;
+
+   child = devm_kzalloc(dev, sizeof(struct device), GFP_KERNEL);
+   if (!child)
+   return NULL;
+
+   device_initialize(child);
+   dev_set_name(child, %s:%s, dev_name(dev), name);
+   child-parent = dev;
+   child-bus = dev-bus;
+   child-coherent_dma_mask = dev-coherent_dma_mask;
+   child-dma_mask = dev-dma_mask;
+
+   if (device_add(child) == 0) {
+   ret = arm_iommu_create_default_mapping(child, 0x2000,
+  SZ_256M);
+   if (ret == 0)
+   return child;
+   }
+
+   put_device(child);
+   return NULL;
+}
+
+void s5p_mfc_free_memdev(struct device *dev)
+{
+   arm_iommu_release_default_mapping(dev);
+   put_device(dev);
+}
+
 static void *mfc_get_drv_data(struct platform_device *pdev);
 
 /* MFC probe function */
@@ -1049,8 +1086,8 @@ static int s5p_mfc_probe(struct platform_device *pdev)
goto err_res;
}
 
-   dev-mem_dev_l = dev-plat_dev-dev;
-   dev-mem_dev_r = dev-plat_dev-dev;
+   dev-mem_dev_l = s5p_mfc_alloc_memdev(dev-plat_dev-dev, left);
+   dev-mem_dev_r = s5p_mfc_alloc_memdev(dev-plat_dev-dev, right);
 
dev-alloc_ctx[0] = vb2_dma_contig_init_ctx(dev-mem_dev_l);
if (IS_ERR(dev-alloc_ctx[0])) {
@@ -1181,6 +1218,10 @@ static int s5p_mfc_remove(struct platform_device *pdev)
s5p_mfc_release_firmware(dev);
vb2_dma_contig_cleanup_ctx(dev-alloc_ctx[0]);
vb2_dma_contig_cleanup_ctx(dev-alloc_ctx[1]);
+   if (dev-mem_dev_l)
+   s5p_mfc_free_memdev(dev-mem_dev_l);
+   if (dev-mem_dev_r)
+   s5p_mfc_free_memdev(dev-mem_dev_r);
 
s5p_mfc_final_pm(dev);
return 0;
@@ -1436,6 +1477,7 @@ static struct platform_driver s5p_mfc_driver = {
.owner  = THIS_MODULE,
.pm = s5p_mfc_pm_ops,
.of_match_table = exynos_mfc_match,
+   .flags  = DRIVER_HAS_OWN_IOMMU_MANAGER,
},
 };
 
-- 
1.9.2

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


[PATCH 27/29] iommu: exynos: document internal structures

2014-08-05 Thread Marek Szyprowski
Add a few words of comment to all internal structures used by the driver.

Signed-off-by: Marek Szyprowski m.szyprow...@samsung.com
---
 drivers/iommu/exynos-iommu.c | 59 
 1 file changed, 38 insertions(+), 21 deletions(-)

diff --git a/drivers/iommu/exynos-iommu.c b/drivers/iommu/exynos-iommu.c
index 7600861..78ce618 100644
--- a/drivers/iommu/exynos-iommu.c
+++ b/drivers/iommu/exynos-iommu.c
@@ -189,37 +189,54 @@ static char *sysmmu_fault_name[SYSMMU_FAULTS_NUM] = {
UNKNOWN FAULT
 };
 
-/* attached to dev.archdata.iommu of the master device */
+/*
+ * This structure is attached to dev.archdata.iommu of the master device
+ * on device add, contains a list of SYSMMU controllers defined by device tree,
+ * which are bound to given master device. It is usually referenced by 'owner'
+ * pointer.
+ */
 struct exynos_iommu_owner {
-   struct list_head clients;
+   struct list_head clients; /* list of sysmmu_drvdata.owner_node */
 };
 
+/*
+ * This structure is stored in -priv field of generic struct iommu_domain,
+ * contains list of SYSMMU controllers from all master devices, which has been
+ * attached to this domain and page tables of IO address space defined by this
+ * domain. It is usually referenced by 'domain' pointer.
+ */
 struct exynos_iommu_domain {
-   struct list_head clients; /* list of sysmmu_drvdata.node */
+   struct list_head clients; /* list of sysmmu_drvdata.domain_node */
sysmmu_pte_t *pgtable; /* lv1 page table, 16KB */
short *lv2entcnt; /* free lv2 entry counter for each section */
-   spinlock_t lock; /* lock for this structure */
+   spinlock_t lock; /* lock for modyfying list of clients */
spinlock_t pgtablelock; /* lock for modifying page table @ pgtable */
 };
 
+/*
+ * This structure hold all data of a single SYSMMU controller, this includes
+ * hw resources like registers and clocks, pointers and list nodes to connect
+ * it to all other structures, internal state and parameters read from device
+ * tree. It is usually referenced by 'data' pointer.
+ */
 struct sysmmu_drvdata {
-   struct device *sysmmu;  /* System MMU's device descriptor */
-   struct device *master;  /* Owner of system MMU */
-   void __iomem *sfrbase;
-   struct clk *clk;
-   struct clk *clk_master;
-   int activations;
-   int suspended;
-   spinlock_t lock;
-   struct iommu_domain *domain;
-   struct list_head domain_node;
-   struct list_head owner_node;
-   phys_addr_t pgtable;
-   int version;
-   const char *name;
-   dma_addr_t base;
-   size_t size;
-   struct notifier_block pm_notifier;
+   struct device *sysmmu; /* SYSMMU controller device */
+   struct device *master; /* master device (owner of given SYSMMU) */
+   void __iomem *sfrbase; /* our registers */
+   struct clk *clk; /* SYSMMU's clock */
+   struct clk *clk_master; /* master's device clock */
+   int activations; /* number of calls to sysmmu_enable */
+   int suspended; /* status of the controller (managed by runtime pm) */
+   spinlock_t lock; /* lock for modyfying enable/disable state */
+   struct iommu_domain *domain; /* domain we belong to */
+   struct list_head domain_node; /* node for domain clients list */
+   struct list_head owner_node; /* node for owner clients list */
+   phys_addr_t pgtable; /* assigned page table structure */
+   int version; /* our version */
+   const char *name; /* our name from device tree */
+   dma_addr_t base; /* base addres of IO address space define in DT */
+   size_t size; /* size of IO address space define in DT */
+   struct notifier_block pm_notifier; /* notifier for pm domain on/off */
 };
 
 static bool set_sysmmu_active(struct sysmmu_drvdata *data)
-- 
1.9.2

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


[PATCH 28/29] iommu: exynos: remove excessive includes and sort others alphabetically

2014-08-05 Thread Marek Szyprowski
Removed following unused includes: linux/mm.h, linux/errno.h,
linux/memblock.h and linux/export.h.

Signed-off-by: Marek Szyprowski m.szyprow...@samsung.com
---
 drivers/iommu/exynos-iommu.c | 18 +++---
 1 file changed, 7 insertions(+), 11 deletions(-)

diff --git a/drivers/iommu/exynos-iommu.c b/drivers/iommu/exynos-iommu.c
index 78ce618..1bbb100 100644
--- a/drivers/iommu/exynos-iommu.c
+++ b/drivers/iommu/exynos-iommu.c
@@ -12,23 +12,19 @@
 #define DEBUG
 #endif
 
+#include linux/clk.h
 #include linux/dma-mapping.h
+#include linux/err.h
 #include linux/io.h
+#include linux/iommu.h
 #include linux/interrupt.h
-#include linux/platform_device.h
-#include linux/slab.h
-#include linux/pm_runtime.h
-#include linux/clk.h
-#include linux/err.h
-#include linux/mm.h
+#include linux/list.h
 #include linux/of.h
 #include linux/of_platform.h
-#include linux/iommu.h
-#include linux/errno.h
-#include linux/list.h
-#include linux/memblock.h
-#include linux/export.h
+#include linux/platform_device.h
 #include linux/pm_domain.h
+#include linux/pm_runtime.h
+#include linux/slab.h
 
 #include asm/cacheflush.h
 #include asm/dma-iommu.h
-- 
1.9.2

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


[PATCH 25/29] iommu: exynos: add support for runtime_pm

2014-08-05 Thread Marek Szyprowski
This patch enables support for runtime pm for SYSMMU controllers. State
of each controller is saved before master's device power domain is
turned off and restored after it has been turned on.

exynos_iommu_attach_device() function might be called anytime, even when
power domain for master's device has been turned off, so to let SYSMMU
controllers to access its registers, a call to pm_runtime_get_sync() has
to be done, which turns on the power domain, which SYSMMU belongs to.
Later, once SYSMMU has been enabled, a call to pm_runtime_put() lets
runtime pm to turn off the power domain if there are no other devices
enabled. This way, the SYSMMU drivers get a genpd pm event and save its
state with sysmmu_save_state() function.

Signed-off-by: Marek Szyprowski m.szyprow...@samsung.com
---
 drivers/iommu/exynos-iommu.c | 54 +++-
 1 file changed, 53 insertions(+), 1 deletion(-)

diff --git a/drivers/iommu/exynos-iommu.c b/drivers/iommu/exynos-iommu.c
index 336b2f8..5cd91b11 100644
--- a/drivers/iommu/exynos-iommu.c
+++ b/drivers/iommu/exynos-iommu.c
@@ -28,6 +28,7 @@
 #include linux/list.h
 #include linux/memblock.h
 #include linux/export.h
+#include linux/pm_domain.h
 
 #include asm/cacheflush.h
 #include asm/dma-iommu.h
@@ -208,6 +209,7 @@ struct sysmmu_drvdata {
struct clk *clk;
struct clk *clk_master;
int activations;
+   int suspended;
spinlock_t lock;
struct iommu_domain *domain;
struct list_head domain_node;
@@ -217,6 +219,7 @@ struct sysmmu_drvdata {
const char *name;
dma_addr_t base;
size_t size;
+   struct notifier_block pm_notifier;
 };
 
 static bool set_sysmmu_active(struct sysmmu_drvdata *data)
@@ -235,7 +238,7 @@ static bool set_sysmmu_inactive(struct sysmmu_drvdata *data)
 
 static bool is_sysmmu_active(struct sysmmu_drvdata *data)
 {
-   return data-activations  0;
+   return (!data-suspended  data-activations  0);
 }
 
 static void sysmmu_unblock(void __iomem *sfrbase)
@@ -528,6 +531,51 @@ static void sysmmu_tlb_invalidate_entry(struct 
sysmmu_drvdata *data,
spin_unlock_irqrestore(data-lock, flags);
 }
 
+static void sysmmu_restore_state(struct sysmmu_drvdata *data)
+{
+   unsigned long flags;
+
+   spin_lock_irqsave(data-lock, flags);
+   if (data-activations  0) {
+   data-suspended = false;
+   __sysmmu_enable_nocount(data);
+   dev_dbg(data-sysmmu, restored state\n);
+   }
+   spin_unlock_irqrestore(data-lock, flags);
+}
+
+static void sysmmu_save_state(struct sysmmu_drvdata *data)
+{
+   unsigned long flags;
+
+   spin_lock_irqsave(data-lock, flags);
+   if (data-activations  0) {
+   __sysmmu_disable_nocount(data);
+   data-suspended = true;
+   dev_dbg(data-sysmmu, saved state\n);
+   }
+   spin_unlock_irqrestore(data-lock, flags);
+}
+
+static int sysmmu_runtime_genpd_event(struct notifier_block *this,
+   unsigned long event, void *ptr)
+{
+   struct sysmmu_drvdata *data;
+
+   data = container_of(this, struct sysmmu_drvdata, pm_notifier);
+
+   switch (event) {
+   case PM_GENPD_POST_POWER_ON:
+   sysmmu_restore_state(data);
+   break;
+   case PM_GENPD_POWER_OFF_PREPARE:
+   sysmmu_save_state(data);
+   break;
+   }
+
+   return NOTIFY_DONE;
+}
+
 static int __init exynos_sysmmu_probe(struct platform_device *pdev)
 {
int irq, ret;
@@ -580,6 +628,7 @@ static int __init exynos_sysmmu_probe(struct 
platform_device *pdev)
}
 
data-sysmmu = dev;
+   data-pm_notifier.notifier_call = sysmmu_runtime_genpd_event;
 
/* default io address space parameters */
data-base = SZ_1G;
@@ -708,6 +757,7 @@ static int exynos_iommu_attach_device(struct iommu_domain 
*domain,
return -ENODEV;
 
list_for_each_entry(data, owner-clients, owner_node) {
+   pm_runtime_get_sync(data-sysmmu);
ret = __sysmmu_enable(data, pagetable, domain);
if (ret = 0) {
data-master = dev;
@@ -716,6 +766,7 @@ static int exynos_iommu_attach_device(struct iommu_domain 
*domain,
list_add_tail(data-domain_node, priv-clients);
spin_unlock_irqrestore(priv-lock, flags);
}
+   pm_runtime_put(data-sysmmu);
}
 
if (ret  0) {
@@ -1156,6 +1207,7 @@ static int __init_master_sysmmu(struct device *dev)
}
 
list_add_tail(data-owner_node, owner-clients);
+   pm_genpd_register_notifier(dev, data-pm_notifier);
 
i++;
}
-- 
1.9.2

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

[PATCH 19/29] iommu: exynos: remove useless spinlock

2014-08-05 Thread Marek Szyprowski
This patch removes useless spinlocks and other unused members from
struct exynos_iommu_owner. There is no point is protecting this
structure by spinlock because content of this structure doesn't change
and other structures have their own spinlocks.

Signed-off-by: Marek Szyprowski m.szyprow...@samsung.com
---
 drivers/iommu/exynos-iommu.c | 11 ---
 1 file changed, 11 deletions(-)

diff --git a/drivers/iommu/exynos-iommu.c b/drivers/iommu/exynos-iommu.c
index ec3c882..ed8c518 100644
--- a/drivers/iommu/exynos-iommu.c
+++ b/drivers/iommu/exynos-iommu.c
@@ -190,9 +190,6 @@ struct exynos_iommu_owner {
struct list_head client; /* entry of exynos_iommu_domain.clients */
struct device *dev;
struct device *sysmmu;
-   struct iommu_domain *domain;
-   void *vmm_data; /* IO virtual memory manager's data */
-   spinlock_t lock;/* Lock to preserve consistency of System MMU */
 };
 
 struct exynos_iommu_domain {
@@ -478,16 +475,12 @@ static int __exynos_sysmmu_enable(struct device *dev, 
phys_addr_t pgtable,
 
BUG_ON(!has_sysmmu(dev));
 
-   spin_lock_irqsave(owner-lock, flags);
-
data = dev_get_drvdata(owner-sysmmu);
 
ret = __sysmmu_enable(data, pgtable, domain);
if (ret = 0)
data-master = dev;
 
-   spin_unlock_irqrestore(owner-lock, flags);
-
return ret;
 }
 
@@ -500,16 +493,12 @@ static bool exynos_sysmmu_disable(struct device *dev)
 
BUG_ON(!has_sysmmu(dev));
 
-   spin_lock_irqsave(owner-lock, flags);
-
data = dev_get_drvdata(owner-sysmmu);
 
disabled = __sysmmu_disable(data);
if (disabled)
data-master = NULL;
 
-   spin_unlock_irqrestore(owner-lock, flags);
-
return disabled;
 }
 
-- 
1.9.2

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


[PATCH 24/29] iommu: exynos: create default iommu-based dma-mapping for master devices

2014-08-05 Thread Marek Szyprowski
This patch adds code to create default per-device iommu-based
dma-mapping instance for all master devices, whose driver didn't set
DRIVER_HAS_OWN_IOMMU_MANAGER flag.

Signed-off-by: Marek Szyprowski m.szyprow...@samsung.com
---
 drivers/iommu/exynos-iommu.c | 49 +++-
 1 file changed, 48 insertions(+), 1 deletion(-)

diff --git a/drivers/iommu/exynos-iommu.c b/drivers/iommu/exynos-iommu.c
index 845f547..336b2f8 100644
--- a/drivers/iommu/exynos-iommu.c
+++ b/drivers/iommu/exynos-iommu.c
@@ -12,6 +12,7 @@
 #define DEBUG
 #endif
 
+#include linux/dma-mapping.h
 #include linux/io.h
 #include linux/interrupt.h
 #include linux/platform_device.h
@@ -29,6 +30,7 @@
 #include linux/export.h
 
 #include asm/cacheflush.h
+#include asm/dma-iommu.h
 #include asm/pgtable.h
 
 typedef u32 sysmmu_iova_t;
@@ -1064,6 +1066,43 @@ static phys_addr_t exynos_iommu_iova_to_phys(struct 
iommu_domain *domain,
return phys;
 }
 
+static int sysmmu_master_device_event(struct notifier_block *nb,
+ unsigned long val, void *p)
+{
+   struct device *dev = p;
+   struct exynos_iommu_owner *owner = dev-archdata.iommu;
+   struct sysmmu_drvdata *data;
+
+   if (!owner)
+   return 0;
+
+   data = list_first_entry(owner-clients, struct sysmmu_drvdata,
+   owner_node);
+   if (!data)
+   return 0;
+
+   switch (val) {
+
+   case IOMMU_GROUP_NOTIFY_BIND_DRIVER:
+   if (!(dev-driver-flags  DRIVER_HAS_OWN_IOMMU_MANAGER))
+   arm_iommu_create_default_mapping(dev, data-base,
+data-size);
+   break;
+
+   case IOMMU_GROUP_NOTIFY_UNBOUND_DRIVER:
+   case IOMMU_GROUP_NOTIFY_DRVBIND_FAILED:
+   if (!(dev-driver-flags  DRIVER_HAS_OWN_IOMMU_MANAGER))
+   arm_iommu_release_default_mapping(dev);
+   break;
+   }
+
+   return 0;
+}
+
+static struct notifier_block sysmmu_master_device_notifier = {
+   .notifier_call = sysmmu_master_device_event,
+};
+
 static void __free_owner_struct(struct exynos_iommu_owner *owner,
struct device *dev)
 {
@@ -1202,6 +1241,7 @@ static int exynos_iommu_add_device(struct device *dev)
if (ret != 0)
goto err;
 
+   iommu_group_register_notifier(group, sysmmu_master_device_notifier);
iommu_group_put(group);
 
return 0;
@@ -1213,8 +1253,15 @@ err:
 static void exynos_iommu_remove_device(struct device *dev)
 {
struct exynos_iommu_owner *owner = dev-archdata.iommu;
+   struct iommu_group *group = iommu_group_get(dev);
+
+   if (group) {
+   iommu_group_unregister_notifier(group,
+   sysmmu_master_device_notifier);
+   iommu_group_remove_device(dev);
+   iommu_group_put(group);
+   }
 
-   iommu_group_remove_device(dev);
if (owner)
__free_owner_struct(owner, dev);
 }
-- 
1.9.2

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


[PATCH 23/29] iommu: exynos: init iommu controllers from device tree

2014-08-05 Thread Marek Szyprowski
This patch adds code to initialize and assign SYSMMU controllers to
their master devices defined in device tree.

Signed-off-by: Marek Szyprowski m.szyprow...@samsung.com
---
 drivers/iommu/exynos-iommu.c | 152 +--
 1 file changed, 145 insertions(+), 7 deletions(-)

diff --git a/drivers/iommu/exynos-iommu.c b/drivers/iommu/exynos-iommu.c
index 46e0edc..845f547 100644
--- a/drivers/iommu/exynos-iommu.c
+++ b/drivers/iommu/exynos-iommu.c
@@ -21,6 +21,7 @@
 #include linux/err.h
 #include linux/mm.h
 #include linux/of.h
+#include linux/of_platform.h
 #include linux/iommu.h
 #include linux/errno.h
 #include linux/list.h
@@ -211,6 +212,9 @@ struct sysmmu_drvdata {
struct list_head owner_node;
phys_addr_t pgtable;
int version;
+   const char *name;
+   dma_addr_t base;
+   size_t size;
 };
 
 static bool set_sysmmu_active(struct sysmmu_drvdata *data)
@@ -574,6 +578,11 @@ static int __init exynos_sysmmu_probe(struct 
platform_device *pdev)
}
 
data-sysmmu = dev;
+
+   /* default io address space parameters */
+   data-base = SZ_1G;
+   data-size = SZ_2G;
+
spin_lock_init(data-lock);
 
platform_set_drvdata(pdev, data);
@@ -1055,30 +1064,159 @@ static phys_addr_t exynos_iommu_iova_to_phys(struct 
iommu_domain *domain,
return phys;
 }
 
+static void __free_owner_struct(struct exynos_iommu_owner *owner,
+   struct device *dev)
+{
+   while (!list_empty(owner-clients))
+   list_del_init(owner-clients.next);
+
+   kfree(owner);
+   dev-archdata.iommu = NULL;
+}
+
+static int __init_master_sysmmu(struct device *dev)
+{
+   struct of_phandle_args sysmmu_spec;
+   struct exynos_iommu_owner *owner;
+   int i = 0;
+   int ret;
+
+   owner = kzalloc(sizeof(*owner), GFP_KERNEL);
+   if (!owner)
+   return -ENOMEM;
+   INIT_LIST_HEAD(owner-clients);
+
+   while (!of_parse_phandle_with_args(dev-of_node, iommus,
+  #iommu-cells, i,
+  sysmmu_spec)) {
+   struct platform_device *sysmmu;
+   struct sysmmu_drvdata *data;
+
+   sysmmu = of_find_device_by_node(sysmmu_spec.np);
+   if (!sysmmu) {
+   dev_err(dev, sysmmu node not found\n);
+   ret = -ENODEV;
+   goto err;
+   }
+   data = platform_get_drvdata(sysmmu);
+   if (!data) {
+   ret = -ENODEV;
+   goto err;
+   }
+
+   of_property_read_string_index(dev-of_node, iommu-names, i,
+ data-name);
+
+   if (sysmmu_spec.args_count == 2) {
+   data-base = sysmmu_spec.args[0];
+   data-size = sysmmu_spec.args[1];
+   } else if (sysmmu_spec.args_count != 0) {
+   dev_err(dev, incorrect iommu property specified\n);
+   ret = -EINVAL;
+   goto err;
+   }
+
+   list_add_tail(data-owner_node, owner-clients);
+
+   i++;
+   }
+
+   if (i == 0) {
+   ret = -ENODEV;
+   goto err;
+   }
+
+   dev-archdata.iommu = owner;
+   dev_dbg(dev, registered %d sysmmu controllers\n, i);
+
+   return 0;
+err:
+   __free_owner_struct(owner, dev);
+   return ret;
+}
+
+static int __init_subdevice_sysmmu(struct device *dev)
+{
+   struct device *parent = dev-parent;
+   struct exynos_iommu_owner *owner;
+   struct sysmmu_drvdata *data;
+   char *name;
+
+   name = strrchr(dev_name(dev), ':');
+   if (!name)
+   return -ENODEV;
+   name++;
+
+   owner = parent-archdata.iommu;
+   if (!owner)
+   return -ENODEV;
+
+   list_for_each_entry(data, owner-clients, owner_node)
+   if (strcmp(name, data-name) == 0)
+   break;
+   if (!data)
+   return -ENODEV;
+
+   owner = kzalloc(sizeof(*owner), GFP_KERNEL);
+   if (!owner)
+   return -ENOMEM;
+   INIT_LIST_HEAD(owner-clients);
+
+   /* move sysmmu from parent to child device */
+   list_del(data-owner_node);
+   list_add_tail(data-owner_node, owner-clients);
+
+   dev-archdata.iommu = owner;
+   dev_dbg(dev-parent,
+   registered sysmmu controller for %s subdevice\n, data-name);
+
+   return 0;
+}
+
 static int exynos_iommu_add_device(struct device *dev)
 {
struct iommu_group *group;
int ret;
 
-   group = iommu_group_get(dev);
+   BUG_ON(dev-archdata.iommu != NULL);
 
-   if (!group) {
-   group = iommu_group_alloc();
-   if (IS_ERR(group)) {
-   dev_err(dev, Failed to 

[PATCH 22/29] iommu: exynos: add support for binding more than one sysmmu to master device

2014-08-05 Thread Marek Szyprowski
This patch adds support for assigning more than one SYSMMU controller to
the master device. This has been achieved simply by chaning the struct
device pointer in struct exynos_iommu_owner into the list of struct
sysmmu_drvdata of all controllers assigned to the given master device.

Signed-off-by: Marek Szyprowski m.szyprow...@samsung.com
---
 drivers/iommu/exynos-iommu.c | 11 +--
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/iommu/exynos-iommu.c b/drivers/iommu/exynos-iommu.c
index 674d1fb..46e0edc 100644
--- a/drivers/iommu/exynos-iommu.c
+++ b/drivers/iommu/exynos-iommu.c
@@ -187,7 +187,7 @@ static char *sysmmu_fault_name[SYSMMU_FAULTS_NUM] = {
 
 /* attached to dev.archdata.iommu of the master device */
 struct exynos_iommu_owner {
-   struct device *sysmmu;
+   struct list_head clients;
 };
 
 struct exynos_iommu_domain {
@@ -208,6 +208,7 @@ struct sysmmu_drvdata {
spinlock_t lock;
struct iommu_domain *domain;
struct list_head domain_node;
+   struct list_head owner_node;
phys_addr_t pgtable;
int version;
 };
@@ -695,8 +696,7 @@ static int exynos_iommu_attach_device(struct iommu_domain 
*domain,
if (!has_sysmmu(dev))
return -ENODEV;
 
-   data = dev_get_drvdata(owner-sysmmu);
-   if (data) {
+   list_for_each_entry(data, owner-clients, owner_node) {
ret = __sysmmu_enable(data, pagetable, domain);
if (ret = 0) {
data-master = dev;
@@ -724,7 +724,7 @@ static void exynos_iommu_detach_device(struct iommu_domain 
*domain,
 {
struct exynos_iommu_domain *priv = domain-priv;
phys_addr_t pagetable = virt_to_phys(priv-pgtable);
-   struct sysmmu_drvdata *data;
+   struct sysmmu_drvdata *data, *next;
unsigned long flags;
int found = 0;
 
@@ -732,14 +732,13 @@ static void exynos_iommu_detach_device(struct 
iommu_domain *domain,
return;
 
spin_lock_irqsave(priv-lock, flags);
-   list_for_each_entry(data, priv-clients, domain_node) {
+   list_for_each_entry_safe(data, next, priv-clients, domain_node) {
if (data-master == dev) {
if (__sysmmu_disable(data)) {
data-master = NULL;
list_del_init(data-domain_node);
}
found = true;
-   break;
}
}
spin_unlock_irqrestore(priv-lock, flags);
-- 
1.9.2

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


[PATCH 20/29] iommu: exynos: refactor function parameters to simplify code

2014-08-05 Thread Marek Szyprowski
This patch simplifies the code by:
- refactoring function parameters from struct device pointer to direct pointer
  to struct sysmmu drvdata
- moving list_head enteries from struct exynos_iommu_owner directly to struct
  sysmmu_drvdata

Signed-off-by: Marek Szyprowski m.szyprow...@samsung.com
---
 drivers/iommu/exynos-iommu.c | 93 ++--
 1 file changed, 46 insertions(+), 47 deletions(-)

diff --git a/drivers/iommu/exynos-iommu.c b/drivers/iommu/exynos-iommu.c
index ed8c518..018a615 100644
--- a/drivers/iommu/exynos-iommu.c
+++ b/drivers/iommu/exynos-iommu.c
@@ -187,8 +187,6 @@ static char *sysmmu_fault_name[SYSMMU_FAULTS_NUM] = {
 
 /* attached to dev.archdata.iommu of the master device */
 struct exynos_iommu_owner {
-   struct list_head client; /* entry of exynos_iommu_domain.clients */
-   struct device *dev;
struct device *sysmmu;
 };
 
@@ -209,6 +207,7 @@ struct sysmmu_drvdata {
int activations;
spinlock_t lock;
struct iommu_domain *domain;
+   struct list_head domain_node;
phys_addr_t pgtable;
int version;
 };
@@ -509,12 +508,10 @@ static void __sysmmu_tlb_invalidate_flpdcache(struct 
sysmmu_drvdata *data,
__raw_writel(iova | 0x1, data-sfrbase + REG_MMU_FLUSH_ENTRY);
 }
 
-static void sysmmu_tlb_invalidate_flpdcache(struct device *dev,
+static void sysmmu_tlb_invalidate_flpdcache(struct sysmmu_drvdata *data,
sysmmu_iova_t iova)
 {
unsigned long flags;
-   struct exynos_iommu_owner *owner = dev-archdata.iommu;
-   struct sysmmu_drvdata *data = dev_get_drvdata(owner-sysmmu);
 
if (!IS_ERR(data-clk_master))
clk_enable(data-clk_master);
@@ -528,14 +525,10 @@ static void sysmmu_tlb_invalidate_flpdcache(struct device 
*dev,
clk_disable(data-clk_master);
 }
 
-static void sysmmu_tlb_invalidate_entry(struct device *dev, sysmmu_iova_t iova,
-   size_t size)
+static void sysmmu_tlb_invalidate_entry(struct sysmmu_drvdata *data,
+   sysmmu_iova_t iova, size_t size)
 {
-   struct exynos_iommu_owner *owner = dev-archdata.iommu;
unsigned long flags;
-   struct sysmmu_drvdata *data;
-
-   data = dev_get_drvdata(owner-sysmmu);
 
spin_lock_irqsave(data-lock, flags);
if (is_sysmmu_active(data)) {
@@ -565,8 +558,8 @@ static void sysmmu_tlb_invalidate_entry(struct device *dev, 
sysmmu_iova_t iova,
if (!IS_ERR(data-clk_master))
clk_disable(data-clk_master);
} else {
-   dev_dbg(dev, disabled. Skipping TLB invalidation @ %#x\n,
-   iova);
+   dev_dbg(data-master,
+   disabled. Skipping TLB invalidation @ %#x\n, iova);
}
spin_unlock_irqrestore(data-lock, flags);
 }
@@ -705,7 +698,7 @@ err_pgtable:
 static void exynos_iommu_domain_destroy(struct iommu_domain *domain)
 {
struct exynos_iommu_domain *priv = domain-priv;
-   struct exynos_iommu_owner *owner;
+   struct sysmmu_drvdata *data;
unsigned long flags;
int i;
 
@@ -713,14 +706,12 @@ static void exynos_iommu_domain_destroy(struct 
iommu_domain *domain)
 
spin_lock_irqsave(priv-lock, flags);
 
-   list_for_each_entry(owner, priv-clients, client) {
-   while (!exynos_sysmmu_disable(owner-dev))
-   ; /* until System MMU is actually disabled */
+   list_for_each_entry(data, priv-clients, domain_node) {
+   if (__sysmmu_disable(data))
+   data-master = NULL;
+   list_del_init(data-domain_node);
}
 
-   while (!list_empty(priv-clients))
-   list_del_init(priv-clients.next);
-
spin_unlock_irqrestore(priv-lock, flags);
 
for (i = 0; i  NUM_LV1ENTRIES; i++)
@@ -739,20 +730,26 @@ static int exynos_iommu_attach_device(struct iommu_domain 
*domain,
 {
struct exynos_iommu_owner *owner = dev-archdata.iommu;
struct exynos_iommu_domain *priv = domain-priv;
+   struct sysmmu_drvdata *data;
phys_addr_t pagetable = virt_to_phys(priv-pgtable);
unsigned long flags;
-   int ret;
+   int ret = -ENODEV;
 
-   spin_lock_irqsave(priv-lock, flags);
+   if (!has_sysmmu(dev))
+   return -ENODEV;
 
-   ret = __exynos_sysmmu_enable(dev, pagetable, domain);
-   if (ret == 0) {
-   list_add_tail(owner-client, priv-clients);
-   owner-domain = domain;
+   data = dev_get_drvdata(owner-sysmmu);
+   if (data) {
+   ret = __sysmmu_enable(data, pagetable, domain);
+   if (ret = 0) {
+   data-master = dev;
+
+   spin_lock_irqsave(priv-lock, flags);
+   list_add_tail(data-domain_node, priv-clients);
+   

[PATCH 17/29] iommu: exynos: don't read version register on every tlb operation

2014-08-05 Thread Marek Szyprowski
This patch removes reading of REG_MMU_VERSION register on every tlb
operation and caches SYSMMU version in driver's internal data.

Signed-off-by: Marek Szyprowski m.szyprow...@samsung.com
---
 drivers/iommu/exynos-iommu.c | 13 +
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/drivers/iommu/exynos-iommu.c b/drivers/iommu/exynos-iommu.c
index 64b3bc8..8927923 100644
--- a/drivers/iommu/exynos-iommu.c
+++ b/drivers/iommu/exynos-iommu.c
@@ -213,6 +213,7 @@ struct sysmmu_drvdata {
spinlock_t lock;
struct iommu_domain *domain;
phys_addr_t pgtable;
+   int version;
 };
 
 static bool set_sysmmu_active(struct sysmmu_drvdata *data)
@@ -239,11 +240,6 @@ static void sysmmu_unblock(void __iomem *sfrbase)
__raw_writel(CTRL_ENABLE, sfrbase + REG_MMU_CTRL);
 }
 
-static unsigned int __raw_sysmmu_version(struct sysmmu_drvdata *data)
-{
-   return MMU_RAW_VER(__raw_readl(data-sfrbase + REG_MMU_VERSION));
-}
-
 static bool sysmmu_block(void __iomem *sfrbase)
 {
int i = 120;
@@ -403,7 +399,7 @@ static void __sysmmu_init_config(struct sysmmu_drvdata 
*data)
unsigned int cfg = CFG_LRU | CFG_QOS(15);
unsigned int ver;
 
-   ver = __raw_sysmmu_version(data);
+   ver = MMU_RAW_VER(__raw_readl(data-sfrbase + REG_MMU_VERSION));
if (MMU_MAJ_VER(ver) == 3) {
if (MMU_MIN_VER(ver) = 2) {
cfg |= CFG_FLPDCACHE;
@@ -417,6 +413,7 @@ static void __sysmmu_init_config(struct sysmmu_drvdata 
*data)
}
 
__raw_writel(cfg, data-sfrbase + REG_MMU_CFG);
+   data-version = ver;
 }
 
 static void __sysmmu_enable_nocount(struct sysmmu_drvdata *data)
@@ -526,7 +523,7 @@ static bool exynos_sysmmu_disable(struct device *dev)
 static void __sysmmu_tlb_invalidate_flpdcache(struct sysmmu_drvdata *data,
  sysmmu_iova_t iova)
 {
-   if (__raw_sysmmu_version(data) == MAKE_MMU_VER(3, 3))
+   if (data-version == MAKE_MMU_VER(3, 3))
__raw_writel(iova | 0x1, data-sfrbase + REG_MMU_FLUSH_ENTRY);
 }
 
@@ -575,7 +572,7 @@ static void sysmmu_tlb_invalidate_entry(struct device *dev, 
sysmmu_iova_t iova,
 * 1MB page can be cached in one of all sets.
 * 64KB page can be one of 16 consecutive sets.
 */
-   if (MMU_MAJ_VER(__raw_sysmmu_version(data)) == 2)
+   if (MMU_MAJ_VER(data-version) == 2)
num_inv = min_t(unsigned int, size / PAGE_SIZE, 64);
 
if (sysmmu_block(data-sfrbase)) {
-- 
1.9.2

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


[PATCH 21/29] iommu: exynos: remove unused functions, part 2

2014-08-05 Thread Marek Szyprowski
After refactoring functions to use pointer to struct sysmmu_drvdata
directly, some functions became useless and thus never used, so remove
them completely.

Signed-off-by: Marek Szyprowski m.szyprow...@samsung.com
---
 drivers/iommu/exynos-iommu.c | 43 ---
 1 file changed, 43 deletions(-)

diff --git a/drivers/iommu/exynos-iommu.c b/drivers/iommu/exynos-iommu.c
index 018a615..674d1fb 100644
--- a/drivers/iommu/exynos-iommu.c
+++ b/drivers/iommu/exynos-iommu.c
@@ -458,49 +458,6 @@ static int __sysmmu_enable(struct sysmmu_drvdata *data,
return ret;
 }
 
-/* __exynos_sysmmu_enable: Enables System MMU
- *
- * returns -error if an error occurred and System MMU is not enabled,
- * 0 if the System MMU has been just enabled and 1 if System MMU was already
- * enabled before.
- */
-static int __exynos_sysmmu_enable(struct device *dev, phys_addr_t pgtable,
- struct iommu_domain *domain)
-{
-   int ret = 0;
-   unsigned long flags;
-   struct exynos_iommu_owner *owner = dev-archdata.iommu;
-   struct sysmmu_drvdata *data;
-
-   BUG_ON(!has_sysmmu(dev));
-
-   data = dev_get_drvdata(owner-sysmmu);
-
-   ret = __sysmmu_enable(data, pgtable, domain);
-   if (ret = 0)
-   data-master = dev;
-
-   return ret;
-}
-
-static bool exynos_sysmmu_disable(struct device *dev)
-{
-   unsigned long flags;
-   bool disabled = true;
-   struct exynos_iommu_owner *owner = dev-archdata.iommu;
-   struct sysmmu_drvdata *data;
-
-   BUG_ON(!has_sysmmu(dev));
-
-   data = dev_get_drvdata(owner-sysmmu);
-
-   disabled = __sysmmu_disable(data);
-   if (disabled)
-   data-master = NULL;
-
-   return disabled;
-}
-
 static void __sysmmu_tlb_invalidate_flpdcache(struct sysmmu_drvdata *data,
  sysmmu_iova_t iova)
 {
-- 
1.9.2

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


[PATCH 18/29] iommu: exynos: remove unused functions

2014-08-05 Thread Marek Szyprowski
This patch removes two unneeded functions, which are not a part of
generic IOMMU API and were never used by any other driver.

Signed-off-by: Marek Szyprowski m.szyprow...@samsung.com
---
 drivers/iommu/exynos-iommu.c | 31 ---
 1 file changed, 31 deletions(-)

diff --git a/drivers/iommu/exynos-iommu.c b/drivers/iommu/exynos-iommu.c
index 8927923..ec3c882 100644
--- a/drivers/iommu/exynos-iommu.c
+++ b/drivers/iommu/exynos-iommu.c
@@ -491,13 +491,6 @@ static int __exynos_sysmmu_enable(struct device *dev, 
phys_addr_t pgtable,
return ret;
 }
 
-int exynos_sysmmu_enable(struct device *dev, phys_addr_t pgtable)
-{
-   BUG_ON(!memblock_is_memory(pgtable));
-
-   return __exynos_sysmmu_enable(dev, pgtable, NULL);
-}
-
 static bool exynos_sysmmu_disable(struct device *dev)
 {
unsigned long flags;
@@ -589,30 +582,6 @@ static void sysmmu_tlb_invalidate_entry(struct device 
*dev, sysmmu_iova_t iova,
spin_unlock_irqrestore(data-lock, flags);
 }
 
-void exynos_sysmmu_tlb_invalidate(struct device *dev)
-{
-   struct exynos_iommu_owner *owner = dev-archdata.iommu;
-   unsigned long flags;
-   struct sysmmu_drvdata *data;
-
-   data = dev_get_drvdata(owner-sysmmu);
-
-   spin_lock_irqsave(data-lock, flags);
-   if (is_sysmmu_active(data)) {
-   if (!IS_ERR(data-clk_master))
-   clk_enable(data-clk_master);
-   if (sysmmu_block(data-sfrbase)) {
-   __sysmmu_tlb_invalidate(data-sfrbase);
-   sysmmu_unblock(data-sfrbase);
-   }
-   if (!IS_ERR(data-clk_master))
-   clk_disable(data-clk_master);
-   } else {
-   dev_dbg(dev, disabled. Skipping TLB invalidation\n);
-   }
-   spin_unlock_irqrestore(data-lock, flags);
-}
-
 static int __init exynos_sysmmu_probe(struct platform_device *pdev)
 {
int irq, ret;
-- 
1.9.2

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


[PATCH 13/29] temporary: media: s5p-mfc: remove DT hacks initialization custom memory init code

2014-08-05 Thread Marek Szyprowski
This patch removes custom initialization of reserved memory regions from
s5p-mfc driver. Driver will use main device pointer for all memory allocations.

This patch is temporary, do not merge it yet.

Signed-off-by: Marek Szyprowski m.szyprow...@samsung.com
---
 drivers/media/platform/s5p-mfc/s5p_mfc.c | 73 +---
 1 file changed, 2 insertions(+), 71 deletions(-)

diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc.c
index d35b041..77b99ae 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c
@@ -996,55 +996,8 @@ static const struct v4l2_file_operations s5p_mfc_fops = {
.mmap = s5p_mfc_mmap,
 };
 
-static int match_child(struct device *dev, void *data)
-{
-   if (!dev_name(dev))
-   return 0;
-   return !strcmp(dev_name(dev), (char *)data);
-}
-
 static void *mfc_get_drv_data(struct platform_device *pdev);
 
-static int s5p_mfc_alloc_memdevs(struct s5p_mfc_dev *dev)
-{
-   unsigned int mem_info[2] = { };
-
-   dev-mem_dev_l = devm_kzalloc(dev-plat_dev-dev,
-   sizeof(struct device), GFP_KERNEL);
-   if (!dev-mem_dev_l) {
-   mfc_err(Not enough memory\n);
-   return -ENOMEM;
-   }
-   device_initialize(dev-mem_dev_l);
-   of_property_read_u32_array(dev-plat_dev-dev.of_node,
-   samsung,mfc-l, mem_info, 2);
-   if (dma_declare_coherent_memory(dev-mem_dev_l, mem_info[0],
-   mem_info[0], mem_info[1],
-   DMA_MEMORY_MAP | DMA_MEMORY_EXCLUSIVE) == 0) {
-   mfc_err(Failed to declare coherent memory for\n
-   MFC device\n);
-   return -ENOMEM;
-   }
-
-   dev-mem_dev_r = devm_kzalloc(dev-plat_dev-dev,
-   sizeof(struct device), GFP_KERNEL);
-   if (!dev-mem_dev_r) {
-   mfc_err(Not enough memory\n);
-   return -ENOMEM;
-   }
-   device_initialize(dev-mem_dev_r);
-   of_property_read_u32_array(dev-plat_dev-dev.of_node,
-   samsung,mfc-r, mem_info, 2);
-   if (dma_declare_coherent_memory(dev-mem_dev_r, mem_info[0],
-   mem_info[0], mem_info[1],
-   DMA_MEMORY_MAP | DMA_MEMORY_EXCLUSIVE) == 0) {
-   pr_err(Failed to declare coherent memory for\n
-   MFC device\n);
-   return -ENOMEM;
-   }
-   return 0;
-}
-
 /* MFC probe function */
 static int s5p_mfc_probe(struct platform_device *pdev)
 {
@@ -1096,26 +1049,8 @@ static int s5p_mfc_probe(struct platform_device *pdev)
goto err_res;
}
 
-   if (pdev-dev.of_node) {
-   ret = s5p_mfc_alloc_memdevs(dev);
-   if (ret  0)
-   goto err_res;
-   } else {
-   dev-mem_dev_l = device_find_child(dev-plat_dev-dev,
-   s5p-mfc-l, match_child);
-   if (!dev-mem_dev_l) {
-   mfc_err(Mem child (L) device get failed\n);
-   ret = -ENODEV;
-   goto err_res;
-   }
-   dev-mem_dev_r = device_find_child(dev-plat_dev-dev,
-   s5p-mfc-r, match_child);
-   if (!dev-mem_dev_r) {
-   mfc_err(Mem child (R) device get failed\n);
-   ret = -ENODEV;
-   goto err_res;
-   }
-   }
+   dev-mem_dev_l = dev-plat_dev-dev;
+   dev-mem_dev_r = dev-plat_dev-dev;
 
dev-alloc_ctx[0] = vb2_dma_contig_init_ctx(dev-mem_dev_l);
if (IS_ERR(dev-alloc_ctx[0])) {
@@ -1246,10 +1181,6 @@ static int s5p_mfc_remove(struct platform_device *pdev)
s5p_mfc_release_firmware(dev);
vb2_dma_contig_cleanup_ctx(dev-alloc_ctx[0]);
vb2_dma_contig_cleanup_ctx(dev-alloc_ctx[1]);
-   if (pdev-dev.of_node) {
-   put_device(dev-mem_dev_l);
-   put_device(dev-mem_dev_r);
-   }
 
s5p_mfc_final_pm(dev);
return 0;
-- 
1.9.2

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


[PATCH 16/29] iommu: exynos: make driver multiarch friendly

2014-08-05 Thread Marek Szyprowski
Initialize all structures and register to iommu subsystem only on Exynos
compatible platforms.

Signed-off-by: Marek Szyprowski m.szyprow...@samsung.com
---
 drivers/iommu/exynos-iommu.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/iommu/exynos-iommu.c b/drivers/iommu/exynos-iommu.c
index d037e87..64b3bc8 100644
--- a/drivers/iommu/exynos-iommu.c
+++ b/drivers/iommu/exynos-iommu.c
@@ -20,6 +20,7 @@
 #include linux/clk.h
 #include linux/err.h
 #include linux/mm.h
+#include linux/of.h
 #include linux/iommu.h
 #include linux/errno.h
 #include linux/list.h
@@ -1187,6 +1188,11 @@ static int __init exynos_iommu_init(void)
 {
int ret;
 
+   if (!of_machine_is_compatible(samsung,exynos3) 
+   !of_machine_is_compatible(samsung,exynos4) 
+   !of_machine_is_compatible(samsung,exynos5))
+   return -ENODEV;
+
lv2table_kmem_cache = kmem_cache_create(exynos-iommu-lv2table,
LV2TABLE_SIZE, LV2TABLE_SIZE, 0, NULL);
if (!lv2table_kmem_cache) {
-- 
1.9.2

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


[PATCH 08/29] ARM: dma-mapping: add helpers for managing default per-device dma mappings

2014-08-05 Thread Marek Szyprowski
This patch adds 2 helpers: arm_iommu_create_default_mapping and
arm_iommu_release_default_mapping for managing default iommu-based
dma-mapping address space, created for exlusive use only by the given
device. Those helpers are convenient for setting up iommu-based
dma-mapping for most typical devices in the system.

Signed-off-by: Marek Szyprowski m.szyprow...@samsung.com
---
 arch/arm/include/asm/dma-iommu.h |  5 +
 arch/arm/mm/dma-mapping.c| 31 +++
 2 files changed, 36 insertions(+)

diff --git a/arch/arm/include/asm/dma-iommu.h b/arch/arm/include/asm/dma-iommu.h
index 8e3fcb9..ae3dac0 100644
--- a/arch/arm/include/asm/dma-iommu.h
+++ b/arch/arm/include/asm/dma-iommu.h
@@ -33,5 +33,10 @@ int arm_iommu_attach_device(struct device *dev,
struct dma_iommu_mapping *mapping);
 void arm_iommu_detach_device(struct device *dev);
 
+int arm_iommu_create_default_mapping(struct device *dev, dma_addr_t base,
+size_t size);
+
+void arm_iommu_release_default_mapping(struct device *dev);
+
 #endif /* __KERNEL__ */
 #endif
diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
index 8161102..233a8cf 100644
--- a/arch/arm/mm/dma-mapping.c
+++ b/arch/arm/mm/dma-mapping.c
@@ -2106,4 +2106,35 @@ void arm_iommu_detach_device(struct device *dev)
 }
 EXPORT_SYMBOL_GPL(arm_iommu_detach_device);
 
+int arm_iommu_create_default_mapping(struct device *dev, dma_addr_t base,
+size_t size)
+{
+   struct dma_iommu_mapping *mapping;
+   int ret;
+
+   mapping = arm_iommu_create_mapping(dev-bus, base, size);
+   if (IS_ERR(mapping))
+   return PTR_ERR(mapping);
+
+   ret = arm_iommu_attach_device(dev, mapping);
+   if (ret) {
+   arm_iommu_release_mapping(mapping);
+   return ret;
+   }
+
+   return 0;
+}
+EXPORT_SYMBOL_GPL(arm_iommu_create_default_mapping);
+
+void arm_iommu_release_default_mapping(struct device *dev)
+{
+   struct dma_iommu_mapping *mapping = to_dma_iommu_mapping(dev);
+   if (!mapping)
+   return;
+
+   arm_iommu_detach_device(dev);
+   arm_iommu_release_mapping(mapping);
+}
+EXPORT_SYMBOL_GPL(arm_iommu_release_default_mapping);
+
 #endif
-- 
1.9.2

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


[PATCH 09/29] ARM: dma-mapping: provide stubs if no ARM_DMA_USE_IOMMU has been selected

2014-08-05 Thread Marek Szyprowski
This patch provides stubs returing errors for all iommu related arm
dma-mapping functions, which are used when CONFIG_ARM_DMA_USE_IOMMU is
not set. This let drivers to use common code for iommu and non-iommu
cases without additional ifdefs.

Signed-off-by: Marek Szyprowski m.szyprow...@samsung.com
---
 arch/arm/include/asm/dma-iommu.h | 31 +++
 1 file changed, 31 insertions(+)

diff --git a/arch/arm/include/asm/dma-iommu.h b/arch/arm/include/asm/dma-iommu.h
index ae3dac0..1e57569 100644
--- a/arch/arm/include/asm/dma-iommu.h
+++ b/arch/arm/include/asm/dma-iommu.h
@@ -9,6 +9,8 @@
 #include linux/kmemcheck.h
 #include linux/kref.h
 
+#ifdef CONFIG_ARM_DMA_USE_IOMMU
+
 struct dma_iommu_mapping {
/* iommu specific data */
struct iommu_domain *domain;
@@ -38,5 +40,34 @@ int arm_iommu_create_default_mapping(struct device *dev, 
dma_addr_t base,
 
 void arm_iommu_release_default_mapping(struct device *dev);
 
+#else
+
+static inline struct dma_iommu_mapping *
+arm_iommu_create_mapping(struct bus_type *bus, dma_addr_t base, size_t size)
+{
+   return ERR_PTR(-ENOSYS);
+}
+
+static inline void
+arm_iommu_release_mapping(struct dma_iommu_mapping *mapping) { }
+
+static inline int arm_iommu_attach_device(struct device *dev,
+   struct dma_iommu_mapping *mapping)
+{
+   return -ENOSYS;
+}
+
+static inline void arm_iommu_detach_device(struct device *dev) { }
+
+static inline int arm_iommu_create_default_mapping(struct device *dev,
+   dma_addr_t base, size_t size)
+{
+   return -ENOSYS;
+}
+
+static inline void arm_iommu_release_default_mapping(struct device *dev) { }
+
+#endif
+
 #endif /* __KERNEL__ */
 #endif
-- 
1.9.2

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


[PATCH 10/29] drivers: add DRIVER_HAS_OWN_IOMMU_MANAGER flag

2014-08-05 Thread Marek Szyprowski
This patch adds a new flags for device drivers. This flag instructs
kernel that the device driver does it own management of IOMMU assisted
IO address space translations, so no default dma-mapping structures
should be initialized.

Signed-off-by: Marek Szyprowski m.szyprow...@samsung.com
---
 include/linux/device.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/linux/device.h b/include/linux/device.h
index 5f4ff02..2e62371 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -253,6 +253,8 @@ struct device_driver {
 
 /* disables bind/unbind via sysfs */
 #define DRIVER_SUPPRESS_BIND_ATTRS (1  0)
+/* driver uses own methods to manage IO address space */
+#define DRIVER_HAS_OWN_IOMMU_MANAGER   (1  1)
 
 extern int __must_check driver_register(struct device_driver *drv);
 extern void driver_unregister(struct device_driver *drv);
-- 
1.9.2

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


[PATCH 01/29] pm: Add PM domain notifications

2014-08-05 Thread Marek Szyprowski
From: Sylwester Nawrocki s.nawro...@samsung.com

This patch adds notifiers to the runtime PM/genpd subsystem. It is now
possible to register a notifier, which will be called before and after
the generic power domain subsystem calls the power domain's power_on
and power_off callbacks.

Signed-off-by: Sylwester Nawrocki s.nawro...@samsung.com
---
 Documentation/power/notifiers.txt | 14 
 drivers/base/power/domain.c   | 70 ---
 include/linux/pm.h|  2 ++
 include/linux/pm_domain.h | 19 +++
 4 files changed, 101 insertions(+), 4 deletions(-)

diff --git a/Documentation/power/notifiers.txt 
b/Documentation/power/notifiers.txt
index a81fa25..62303f6 100644
--- a/Documentation/power/notifiers.txt
+++ b/Documentation/power/notifiers.txt
@@ -53,3 +53,17 @@ NULL).  To register and/or unregister a suspend notifier use 
the functions
 register_pm_notifier() and unregister_pm_notifier(), respectively, defined in
 include/linux/suspend.h .  If you don't need to unregister the notifier, you 
can
 also use the pm_notifier() macro defined in include/linux/suspend.h .
+
+Power Domain notifiers
+--
+
+The power domain notifiers allow subsystems or drivers to register for power
+domain on/off notifications, should they need to perform any actions right
+before or right after the power domain on/off.  The device must be already
+added to a power domain before its subsystem or driver registers the notifier.
+Following events are supported:
+
+PM_GENPD_POWER_ON_PREPARE  The power domain is about to turn on.
+PM_GENPD_POST_POWER_ON The power domain has just turned on.
+PM_GENPD_POWER_OFF_PREPARE The power domain is about to turn off.
+PM_GENPD_POST_POWER_OFFThe power domain has just turned off.
diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
index eee55c1..5fe0966 100644
--- a/drivers/base/power/domain.c
+++ b/drivers/base/power/domain.c
@@ -70,6 +70,45 @@ static struct generic_pm_domain *pm_genpd_lookup_name(const 
char *domain_name)
return genpd;
 }
 
+int pm_genpd_register_notifier(struct device *dev, struct notifier_block *nb)
+{
+   struct pm_domain_data *pdd;
+   int ret = -EINVAL;
+
+   spin_lock_irq(dev-power.lock);
+   if (dev-power.subsys_data) {
+   pdd = dev-power.subsys_data-domain_data;
+   ret = blocking_notifier_chain_register(pdd-notify_chain_head,
+  nb);
+   }
+   spin_unlock_irq(dev-power.lock);
+   return ret;
+}
+EXPORT_SYMBOL_GPL(pm_genpd_register_notifier);
+
+void pm_genpd_unregister_notifier(struct device *dev, struct notifier_block 
*nb)
+{
+   struct pm_domain_data *pdd;
+
+   spin_lock_irq(dev-power.lock);
+   if (dev-power.subsys_data) {
+   pdd = dev-power.subsys_data-domain_data;
+   blocking_notifier_chain_unregister(pdd-notify_chain_head, nb);
+   }
+   spin_unlock_irq(dev-power.lock);
+}
+EXPORT_SYMBOL_GPL(pm_genpd_unregister_notifier);
+
+static void pm_genpd_notifier_call(unsigned long event,
+  struct generic_pm_domain *genpd)
+{
+   struct pm_domain_data *pdd;
+
+   list_for_each_entry(pdd, genpd-dev_list, list_node)
+   blocking_notifier_call_chain(pdd-notify_chain_head,
+event, pdd-dev);
+}
+
 #ifdef CONFIG_PM
 
 struct generic_pm_domain *dev_to_genpd(struct device *dev)
@@ -231,10 +270,14 @@ static int __pm_genpd_poweron(struct generic_pm_domain 
*genpd)
ktime_t time_start = ktime_get();
s64 elapsed_ns;
 
+   pm_genpd_notifier_call(PM_GENPD_POWER_ON_PREPARE, genpd);
+
ret = genpd-power_on(genpd);
if (ret)
goto err;
 
+   pm_genpd_notifier_call(PM_GENPD_POST_POWER_ON, genpd);
+
elapsed_ns = ktime_to_ns(ktime_sub(ktime_get(), time_start));
if (elapsed_ns  genpd-power_on_latency_ns) {
genpd-power_on_latency_ns = elapsed_ns;
@@ -554,13 +597,17 @@ static int pm_genpd_poweroff(struct generic_pm_domain 
*genpd)
 * the pm_genpd_poweron() restore power for us (this shouldn't
 * happen very often).
 */
+   pm_genpd_notifier_call(PM_GENPD_POWER_OFF_PREPARE, genpd);
+
ret = genpd-power_off(genpd);
if (ret == -EBUSY) {
genpd_set_active(genpd);
goto out;
}
-
elapsed_ns = ktime_to_ns(ktime_sub(ktime_get(), time_start));
+
+   pm_genpd_notifier_call(PM_GENPD_POST_POWER_OFF, genpd);
+
if (elapsed_ns  genpd-power_off_latency_ns) {
genpd-power_off_latency_ns = elapsed_ns;
genpd-max_off_time_changed = 

[PATCH 04/29] drivers: base: add notifier for failed driver bind

2014-08-05 Thread Marek Szyprowski
This patch adds support for getting a notify for failed device driver
bind, so all the items done in BUS_NOTIFY_BIND_DRIVER event can be
cleaned if the driver fails to bind.

Signed-off-by: Marek Szyprowski m.szyprow...@samsung.com
---
 drivers/base/dd.c  | 10 +++---
 include/linux/device.h |  4 +++-
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/base/dd.c b/drivers/base/dd.c
index e4ffbcf..541a41f 100644
--- a/drivers/base/dd.c
+++ b/drivers/base/dd.c
@@ -237,10 +237,14 @@ static int driver_sysfs_add(struct device *dev)
return ret;
 }
 
-static void driver_sysfs_remove(struct device *dev)
+static void driver_sysfs_remove(struct device *dev, int failed)
 {
struct device_driver *drv = dev-driver;
 
+   if (failed  dev-bus)
+   blocking_notifier_call_chain(dev-bus-p-bus_notifier,
+BUS_NOTIFY_DRVBIND_FAILED, dev);
+
if (drv) {
sysfs_remove_link(drv-p-kobj, kobject_name(dev-kobj));
sysfs_remove_link(dev-kobj, driver);
@@ -316,7 +320,7 @@ static int really_probe(struct device *dev, struct 
device_driver *drv)
 
 probe_failed:
devres_release_all(dev);
-   driver_sysfs_remove(dev);
+   driver_sysfs_remove(dev, true);
dev-driver = NULL;
dev_set_drvdata(dev, NULL);
 
@@ -509,7 +513,7 @@ static void __device_release_driver(struct device *dev)
if (drv) {
pm_runtime_get_sync(dev);
 
-   driver_sysfs_remove(dev);
+   driver_sysfs_remove(dev, false);
 
if (dev-bus)
blocking_notifier_call_chain(dev-bus-p-bus_notifier,
diff --git a/include/linux/device.h b/include/linux/device.h
index b387710..92daded 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -176,7 +176,7 @@ extern int bus_register_notifier(struct bus_type *bus,
 extern int bus_unregister_notifier(struct bus_type *bus,
   struct notifier_block *nb);
 
-/* All 4 notifers below get called with the target struct device *
+/* All 7 notifers below get called with the target struct device *
  * as an argument. Note that those functions are likely to be called
  * with the device lock held in the core, so be careful.
  */
@@ -189,6 +189,8 @@ extern int bus_unregister_notifier(struct bus_type *bus,
  unbound */
 #define BUS_NOTIFY_UNBOUND_DRIVER  0x0006 /* driver is unbound
  from the device */
+#define BUS_NOTIFY_DRVBIND_FAILED  0x0007 /* driver failed to bind
+ to device */
 
 extern struct kset *bus_get_kset(struct bus_type *bus);
 extern struct klist *bus_get_device_klist(struct bus_type *bus);
-- 
1.9.2

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


[PATCH 06/29] drivers: iommu: add notify about failed bind

2014-08-05 Thread Marek Szyprowski
This patch adds support for forwarding recently introduced
BUS_NOTIFY_DRVBIND_FAILED event to iommu groups. This lets us getting a
notify for failed device driver bind, so all the items done in
IOMMU_GROUP_NOTIFY_BIND_DRIVER event can be cleaned if the driver fails
to bind.

Signed-off-by: Marek Szyprowski m.szyprow...@samsung.com
---
 drivers/iommu/iommu.c | 3 +++
 include/linux/iommu.h | 1 +
 2 files changed, 4 insertions(+)

diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index 1698360..516e93a 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -758,6 +758,9 @@ static int iommu_bus_notifier(struct notifier_block *nb,
case BUS_NOTIFY_UNBOUND_DRIVER:
group_action = IOMMU_GROUP_NOTIFY_UNBOUND_DRIVER;
break;
+   case BUS_NOTIFY_DRVBIND_FAILED:
+   group_action = IOMMU_GROUP_NOTIFY_DRVBIND_FAILED;
+   break;
}
 
if (group_action)
diff --git a/include/linux/iommu.h b/include/linux/iommu.h
index 20f9a52..f9fdae5 100644
--- a/include/linux/iommu.h
+++ b/include/linux/iommu.h
@@ -139,6 +139,7 @@ struct iommu_ops {
 #define IOMMU_GROUP_NOTIFY_BOUND_DRIVER4 /* Post Driver bind */
 #define IOMMU_GROUP_NOTIFY_UNBIND_DRIVER   5 /* Pre Driver unbind */
 #define IOMMU_GROUP_NOTIFY_UNBOUND_DRIVER  6 /* Post Driver unbind */
+#define IOMMU_GROUP_NOTIFY_DRVBIND_FAILED  7 /* Driver failed to bind */
 
 extern int bus_set_iommu(struct bus_type *bus, const struct iommu_ops *ops);
 extern bool iommu_present(struct bus_type *bus);
-- 
1.9.2

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


[PATCH 03/29] clk: exynos: add missing smmu_g2d clock and update comments

2014-08-05 Thread Marek Szyprowski
This patch adds missing smmu_g2d clock implementation and updates
comment about Exynos4 clocks from 278-282 range. Those clocks are
available on all Exynos4 SoC series, so the misleading comment has been
removed.

Signed-off-by: Marek Szyprowski m.szyprow...@samsung.com
---
 drivers/clk/samsung/clk-exynos4.c   |  1 +
 include/dt-bindings/clock/exynos4.h | 10 +-
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/clk/samsung/clk-exynos4.c 
b/drivers/clk/samsung/clk-exynos4.c
index ac163d7..12a7cc3 100644
--- a/drivers/clk/samsung/clk-exynos4.c
+++ b/drivers/clk/samsung/clk-exynos4.c
@@ -1183,6 +1183,7 @@ static struct samsung_gate_clock exynos4x12_gate_clks[] 
__initdata = {
GATE(CLK_SPI1_ISP, spi1_isp, aclk200, E4X12_GATE_ISP1, 13,
CLK_IGNORE_UNUSED | CLK_GET_RATE_NOCACHE, 0),
GATE(CLK_G2D, g2d, aclk200, GATE_IP_DMC, 23, 0, 0),
+   GATE(CLK_SMMU_G2D, smmu_g2d, aclk200, GATE_IP_DMC, 24, 0, 0),
GATE(CLK_TMU_APBIF, tmu_apbif, aclk100, E4X12_GATE_IP_PERIR, 17, 0,
0),
 };
diff --git a/include/dt-bindings/clock/exynos4.h 
b/include/dt-bindings/clock/exynos4.h
index 459bd2b..fb981635 100644
--- a/include/dt-bindings/clock/exynos4.h
+++ b/include/dt-bindings/clock/exynos4.h
@@ -115,11 +115,11 @@
 #define CLK_SMMU_MFCR  275
 #define CLK_G3D276
 #define CLK_G2D277
-#define CLK_ROTATOR278 /* Exynos4210 only */
-#define CLK_MDMA   279 /* Exynos4210 only */
-#define CLK_SMMU_G2D   280 /* Exynos4210 only */
-#define CLK_SMMU_ROTATOR   281 /* Exynos4210 only */
-#define CLK_SMMU_MDMA  282 /* Exynos4210 only */
+#define CLK_ROTATOR278
+#define CLK_MDMA   279
+#define CLK_SMMU_G2D   280
+#define CLK_SMMU_ROTATOR   281
+#define CLK_SMMU_MDMA  282
 #define CLK_FIMD0  283
 #define CLK_MIE0   284
 #define CLK_MDNIE0 285 /* Exynos4412 only */
-- 
1.9.2

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


Re: [PATCH RESEND] usb: ehci/ohci-exynos: Fix PHY getting sequence

2014-08-05 Thread Jingoo Han
On Tuesday, August 05, 2014 7:39 PM, Vivek Gautam wrote:
 
 Since we want to keep support for both older usb-phys as well as the
 newer generic phys, lets first get the generic PHYs and fallback to
 older USB-PHYs only when we fail to get the former.
 This should fix the issue with ehci-exynos and ohci-exynos, wherein
 in the absence of SAMSUNG_USB2PHY config symbol, we end up getting
 the NOP_USB_XCEIV phy when the same is enabled. And thus the PHYs
 are not configured properly.
 
 Reported-by: Sachin Kamat sachin.ka...@samsung.com
 Signed-off-by: Vivek Gautam gautam.vi...@samsung.com
 Cc: Alan Stern st...@rowland.harvard.edu
 Cc: Jingoo Han jg1@samsung.com

Acked-by: Jingoo Han jg1@samsung.com

Right, we would get the generic PHYs first, then get the older
usb-phys. Then, the older one will be removed from the kernel.
Thank you.

Best regards,
Jingoo Han

 ---
 
 Based on 'usb-next' branch.
 Resending it after adding 'Reported-by' tag.
 
  drivers/usb/host/ehci-exynos.c |   40 +-
  drivers/usb/host/ohci-exynos.c |   47 
 +++-
  2 files changed, 42 insertions(+), 45 deletions(-)
 
 diff --git a/drivers/usb/host/ehci-exynos.c b/drivers/usb/host/ehci-exynos.c
 index cda0a2f..2eed9a4 100644
 --- a/drivers/usb/host/ehci-exynos.c
 +++ b/drivers/usb/host/ehci-exynos.c
 @@ -62,18 +62,6 @@ static int exynos_ehci_get_phy(struct device *dev,
   int phy_number;
   int ret = 0;
 
 - exynos_ehci-phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2);
 - if (IS_ERR(exynos_ehci-phy)) {
 - ret = PTR_ERR(exynos_ehci-phy);
 - if (ret != -ENXIO  ret != -ENODEV) {
 - dev_err(dev, no usb2 phy configured\n);
 - return ret;
 - }
 - dev_dbg(dev, Failed to get usb2 phy\n);
 - } else {
 - exynos_ehci-otg = exynos_ehci-phy-otg;
 - }
 -
   for_each_available_child_of_node(dev-of_node, child) {
   ret = of_property_read_u32(child, reg, phy_number);
   if (ret) {
 @@ -90,15 +78,27 @@ static int exynos_ehci_get_phy(struct device *dev,
 
   phy = devm_of_phy_get(dev, child, NULL);
   of_node_put(child);
 - if (IS_ERR(phy)) {
 - ret = PTR_ERR(phy);
 - if (ret != -ENOSYS  ret != -ENODEV) {
 - dev_err(dev, no usb2 phy configured\n);
 - return ret;
 - }
 - dev_dbg(dev, Failed to get usb2 phy\n);
 - }
 + if (IS_ERR(phy))
 + /* Lets fallback to older USB-PHYs */
 + goto usb_phy_old;
   exynos_ehci-phy_g[phy_number] = phy;
 + /* Make the older PHYs unavailable */
 + exynos_ehci-phy = ERR_PTR(-ENXIO);
 + }
 +
 + return 0;
 +
 +usb_phy_old:
 + exynos_ehci-phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2);
 + if (IS_ERR(exynos_ehci-phy)) {
 + ret = PTR_ERR(exynos_ehci-phy);
 + if (ret != -ENXIO  ret != -ENODEV) {
 + dev_err(dev, no usb2 phy configured\n);
 + return ret;
 + }
 + dev_dbg(dev, Failed to get usb2 phy\n);
 + } else {
 + exynos_ehci-otg = exynos_ehci-phy-otg;
   }
 
   return ret;
 diff --git a/drivers/usb/host/ohci-exynos.c b/drivers/usb/host/ohci-exynos.c
 index a72ab8f..7c48e3f 100644
 --- a/drivers/usb/host/ohci-exynos.c
 +++ b/drivers/usb/host/ohci-exynos.c
 @@ -51,27 +51,12 @@ static int exynos_ohci_get_phy(struct device *dev,
   int phy_number;
   int ret = 0;
 
 - exynos_ohci-phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2);
 - if (IS_ERR(exynos_ohci-phy)) {
 - ret = PTR_ERR(exynos_ohci-phy);
 - if (ret != -ENXIO  ret != -ENODEV) {
 - dev_err(dev, no usb2 phy configured\n);
 - return ret;
 - }
 - dev_dbg(dev, Failed to get usb2 phy\n);
 - } else {
 - exynos_ohci-otg = exynos_ohci-phy-otg;
 - }
 -
   /*
* Getting generic phy:
* We are keeping both types of phys as a part of transiting OHCI
* to generic phy framework, so as to maintain backward compatibilty
 -  * with old DTB.
 -  * If there are existing devices using DTB files built from them,
 -  * to remove the support for old bindings in this driver,
 -  * we need to make sure that such devices have their DTBs
 -  * updated to ones built from new DTS.
 +  * with old DTB too.
 +  * We fallback to older USB-PHYs when we fail to get generic PHYs.
*/
   for_each_available_child_of_node(dev-of_node, child) {
   ret = of_property_read_u32(child, reg, phy_number);
 @@ -89,15 +74,27 @@ static int exynos_ohci_get_phy(struct device *dev,
 
   phy = devm_of_phy_get(dev, 

[PATCH 02/29] ARM: Exynos: bind power domains earlier, on device creation

2014-08-05 Thread Marek Szyprowski
This patches change initialization time of power domain driver from client
device driver bind to device creation. This lets other core drivers to
register power domain notifiers before client driver is bound.

Signed-off-by: Marek Szyprowski m.szyprow...@samsung.com
---
 arch/arm/mach-exynos/pm_domains.c | 12 ++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-exynos/pm_domains.c 
b/arch/arm/mach-exynos/pm_domains.c
index fd76e1b..1d368a2 100644
--- a/arch/arm/mach-exynos/pm_domains.c
+++ b/arch/arm/mach-exynos/pm_domains.c
@@ -159,13 +159,13 @@ static int exynos_pm_notifier_call(struct notifier_block 
*nb,
struct device *dev = data;
 
switch (event) {
-   case BUS_NOTIFY_BIND_DRIVER:
+   case BUS_NOTIFY_ADD_DEVICE:
if (dev-of_node)
exynos_read_domain_from_dt(dev);
 
break;
 
-   case BUS_NOTIFY_UNBOUND_DRIVER:
+   case BUS_NOTIFY_DEL_DEVICE:
exynos_remove_device_from_domain(dev);
 
break;
@@ -177,6 +177,13 @@ static struct notifier_block platform_nb = {
.notifier_call = exynos_pm_notifier_call,
 };
 
+static int exynos_pm_domain_add(struct device *dev, void *priv)
+{
+   if (dev-of_node)
+   exynos_read_domain_from_dt(dev);
+   return 0;
+}
+
 static __init int exynos4_pm_init_power_domain(void)
 {
struct platform_device *pdev;
@@ -236,6 +243,7 @@ no_clk:
}
 
bus_register_notifier(platform_bus_type, platform_nb);
+   bus_for_each_dev(platform_bus_type, NULL, NULL, exynos_pm_domain_add);
 
return 0;
 }
-- 
1.9.2

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


Re: [PATCH v2 1/2] drm/mipi-dsi: add (LPM) Low Power Mode transfer support

2014-08-05 Thread Thierry Reding
On Mon, Jul 28, 2014 at 06:09:58PM +0200, Andrzej Hajda wrote:
 On 07/28/2014 04:00 AM, Inki Dae wrote:
  This patch adds below two flags for LPM transfer, and it attaches LPM flags
  to a msg in accordance with master's mode_flags set by LCD Panel driver.
  
  MIPI_DSI_MODE_CMD_LPM
  - If this flag is set by Panel driver, MIPI-DSI controller will tranfer
  command data to Panel device in Low Power Mode.
 
 What do you mean by command data? It could be:
 - all transfer in command mode of operations,
 - transfer initialized by the driver by writing to DSIM registers.
 
  
  MIPI_DSI_MODE_VIDEO_LPM
  - If this flag is set by Panel driver, MIPI-DSI controller will tranfer
  image data to Panel device in Low Power Mode.
 
 What is the meaning of this flag in case of command mode of operation?
 
 Maybe it would be better to create flags based on source of data/FIFOs:
 - commands send by SFR registers,
 - commands generated from data sent from Display Controller.

I have no idea what SFR is. But it sounds like you're talking about two
ways to generate command packets here. We have something similar on
Tegra, where it's called host-driven command mode and DC-driven
command mode.

In host-driven command mode the driver needs to explicitly program some
of the DSI controller registers to send command packets. This is
essentially a FIFO register and a control register to trigger
transmission and poll for completion.

DC-driven command mode is typically used to update contents of a remote
framebuffer (what MIPI calls Type 1 Display Architecture). This is
done by programming a different set of registers that cause the DSI
controller to take data output by the display controller and wrap it
into DCS commands (e.g. write_memory_start and write_memory_continue).

I think that low power mode is more often used for command transmission
(in host-driven mode). I'm not sure how much sense it really makes to
transmit video data in low power mode. It also seems like low power mode
is what all peripherals need to support (if they can do command mode).
Hence I'd like to propose the attached patch that makes all command
messages use low power mode.

The .transfer() function was really designed with initialization
commands in mind, so it doesn't deal with mixing video data and commands
anyway and for initialization low-power mode should be fast enough. The
downside is that it may not be optimal for some peripherals, but it
gives us a good solution for the general case since it should support
all devices.

If we absolutely must have faster initialization, or if we come across a
device that can only initialize in high speed mode, then I think we
should introduce a new flag to allow DSI host controllers to optimize in
those cases.

Note that this is based on some of my local patches, so it won't apply
as-is. But if anybody wants to give this a go it should be easy to apply
manually as well.

Thierry
From f93dd508afc19262fd95c01520d5d6d7937be4e8 Mon Sep 17 00:00:00 2001
From: Thierry Reding tred...@nvidia.com
Date: Tue, 5 Aug 2014 11:30:14 +0200
Subject: [PATCH] drm/dsi: Always use low-power mode for DCS commands

Many peripherals require DCS commands to be sent in low power mode and
will fail to correctly process them in high speed mode. Section 5.2 of
the MIPI DSI specification also mandates that on bidirectional lanes,
data shall be transmitted in low power mode only. At worst this change
will make transmission of DCS commands slower than optimal on some DSI
peripherals, but it should enable DCS commands to be successfully
transmitted to any DSI peripheral.

If transmission in low power mode turns out to be too slow at some point
in the future, one possible solution would be to explicitly mark devices
that support high speed transmission of DCS commands.

Signed-off-by: Thierry Reding tred...@nvidia.com
---
 drivers/gpu/drm/drm_mipi_dsi.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/drm_mipi_dsi.c b/drivers/gpu/drm/drm_mipi_dsi.c
index b0a304ab6827..57588b9ff7c6 100644
--- a/drivers/gpu/drm/drm_mipi_dsi.c
+++ b/drivers/gpu/drm/drm_mipi_dsi.c
@@ -370,6 +370,7 @@ ssize_t mipi_dsi_dcs_write_buffer(struct mipi_dsi_device *dsi,
 {
 	struct mipi_dsi_msg msg = {
 		.channel = dsi-channel,
+		.flags = MIPI_DSI_MSG_USE_LPM,
 		.tx_buf = data,
 		.tx_len = len
 	};
@@ -457,6 +458,7 @@ ssize_t mipi_dsi_dcs_write(struct mipi_dsi_device *dsi, u8 cmd,
 	}
 
 	memset(msg, 0, sizeof(msg));
+	msg.flags = MIPI_DSI_MSG_USE_LPM;
 	msg.channel = dsi-channel;
 	msg.tx_len = size;
 	msg.tx_buf = tx;
@@ -501,6 +503,7 @@ ssize_t mipi_dsi_dcs_read(struct mipi_dsi_device *dsi, u8 cmd, void *data,
 	struct mipi_dsi_msg msg = {
 		.channel = dsi-channel,
 		.type = MIPI_DSI_DCS_READ,
+		.flags = MIPI_DSI_MSG_USE_LPM,
 		.tx_buf = cmd,
 		.tx_len = 1,
 		.rx_buf = data,
-- 
2.0.4



pgpx9L2xcAA18.pgp
Description: PGP signature


Re: [PATCH RESEND] usb: ehci/ohci-exynos: Fix PHY getting sequence

2014-08-05 Thread Sachin Kamat
Hi Vivek,

On Tue, Aug 5, 2014 at 4:09 PM, Vivek Gautam gautam.vi...@samsung.com wrote:
 Since we want to keep support for both older usb-phys as well as the
 newer generic phys, lets first get the generic PHYs and fallback to
 older USB-PHYs only when we fail to get the former.
 This should fix the issue with ehci-exynos and ohci-exynos, wherein
 in the absence of SAMSUNG_USB2PHY config symbol, we end up getting
 the NOP_USB_XCEIV phy when the same is enabled. And thus the PHYs
 are not configured properly.

 Reported-by: Sachin Kamat sachin.ka...@samsung.com
 Signed-off-by: Vivek Gautam gautam.vi...@samsung.com
 Cc: Alan Stern st...@rowland.harvard.edu
 Cc: Jingoo Han jg1@samsung.com

Tested this patch on Exynos5250 based Arndale and Snow boards.
Fixes the said issue. Thanks.

Tested-by: Sachin Kamat sachin.ka...@samsung.com

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


Re: [PATCH RESEND] usb: ehci/ohci-exynos: Fix PHY getting sequence

2014-08-05 Thread Vivek Gautam

Hi Jingoo,


On Tuesday, August 05, 2014 4:28 PM, Jingoo Han wrote:

On Tuesday, August 05, 2014 7:39 PM, Vivek Gautam wrote:


Since we want to keep support for both older usb-phys as well as the
newer generic phys, lets first get the generic PHYs and fallback to
older USB-PHYs only when we fail to get the former.
This should fix the issue with ehci-exynos and ohci-exynos, wherein
in the absence of SAMSUNG_USB2PHY config symbol, we end up getting
the NOP_USB_XCEIV phy when the same is enabled. And thus the PHYs
are not configured properly.

Reported-by: Sachin Kamat sachin.ka...@samsung.com
Signed-off-by: Vivek Gautam gautam.vi...@samsung.com
Cc: Alan Stern st...@rowland.harvard.edu
Cc: Jingoo Han jg1@samsung.com


Acked-by: Jingoo Han jg1@samsung.com

Right, we would get the generic PHYs first, then get the older
usb-phys. Then, the older one will be removed from the kernel.


Right, I have a set of patches to remove the older phy support for Exynos 
SoC series,

keeping the support for S3C64XX, which I shall send soon.

[snip]

Thanks
Vivek Gautam 


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


Re: [PATCH v3 0/4] ARM: EXYNOS: cpuidle: fix AFTR mode on boards with secure firmware enabled

2014-08-05 Thread Bartlomiej Zolnierkiewicz

Hi Daniel,

On Monday, July 28, 2014 09:43:02 AM Daniel Lezcano wrote:
 On 07/09/2014 07:17 PM, Bartlomiej Zolnierkiewicz wrote:
  Hi,
 
  This patch series adds support for AFTR idle mode on boards with
  secure firmware enabled and allows EXYNOS cpuidle driver usage on
  Exynos4x12 SoCs.
 
  It has been tested on Trats2 board (using Exynos4412 SoC with secure
  firmware enabled) on which AFTR mode reduces power consumption by ~12%
  when EXYNOS cpuidle driver is enabled (in both cases the default
  exynos_defconfig config is used and CPU1-3 are offlined).
 
 
 Hi Bartlomiej,
 
 what is the status of this patchset ? Is it supposed to land for 3.17 ?

I posted v4 yesterday:
http://www.mail-archive.com/linux-samsung-soc@vger.kernel.org/msg35197.html

When it comes to merging the patchset for 3.17 it is up to Kukjin.

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

 Thanks
 
-- Daniel
 
  v3:
  - rebased on top of next-20140708 +
 
  http://www.mail-archive.com/linux-samsung-soc@vger.kernel.org/msg32809.html
 (with rejects fixed)
 
  http://www.mail-archive.com/linux-samsung-soc@vger.kernel.org/msg32808.html
 
  http://www.mail-archive.com/linux-samsung-soc@vger.kernel.org/msg32991.html
 (with rejects fixed in patch #2)
  - addressed review comments from Tomasz Figa and Daniel Lezcano
 
  Best regards,
  --
  Bartlomiej Zolnierkiewicz
  Samsung RD Institute Poland
  Samsung Electronics
 
 
  Bartlomiej Zolnierkiewicz (4):
 ARM: EXYNOS: PM: replace EXYNOS_BOOT_VECTOR_* macros by static inlines
 ARM: EXYNOS: add AFTR mode support to firmware do_idle method
 ARM: EXYNOS: cpuidle: add secure firmware support to AFTR mode code
 ARM: EXYNOS: cpuidle: allow driver usage on Exynos4x12 SoCs
 
arch/arm/include/asm/firmware.h  |  2 +-
arch/arm/mach-exynos/common.h|  7 ++-
arch/arm/mach-exynos/exynos.c|  3 ++-
arch/arm/mach-exynos/firmware.c  | 36 ++--
arch/arm/mach-exynos/pm.c| 39 
  +--
drivers/cpuidle/cpuidle-exynos.c |  6 +++---
6 files changed, 67 insertions(+), 26 deletions(-)

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


Re: [PATCH v3 0/4] ARM: EXYNOS: cpuidle: fix AFTR mode on boards with secure firmware enabled

2014-08-05 Thread Daniel Lezcano

On 08/05/2014 02:04 PM, Bartlomiej Zolnierkiewicz wrote:


Hi Daniel,

On Monday, July 28, 2014 09:43:02 AM Daniel Lezcano wrote:

On 07/09/2014 07:17 PM, Bartlomiej Zolnierkiewicz wrote:

Hi,

This patch series adds support for AFTR idle mode on boards with
secure firmware enabled and allows EXYNOS cpuidle driver usage on
Exynos4x12 SoCs.

It has been tested on Trats2 board (using Exynos4412 SoC with secure
firmware enabled) on which AFTR mode reduces power consumption by ~12%
when EXYNOS cpuidle driver is enabled (in both cases the default
exynos_defconfig config is used and CPU1-3 are offlined).



Hi Bartlomiej,

what is the status of this patchset ? Is it supposed to land for 3.17 ?


I posted v4 yesterday:
http://www.mail-archive.com/linux-samsung-soc@vger.kernel.org/msg35197.html

When it comes to merging the patchset for 3.17 it is up to Kukjin.


Ok, thanks for the sync up.

  -- Daniel


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


Thanks

-- Daniel


v3:
- rebased on top of next-20140708 +
http://www.mail-archive.com/linux-samsung-soc@vger.kernel.org/msg32809.html
(with rejects fixed)
http://www.mail-archive.com/linux-samsung-soc@vger.kernel.org/msg32808.html
http://www.mail-archive.com/linux-samsung-soc@vger.kernel.org/msg32991.html
(with rejects fixed in patch #2)
- addressed review comments from Tomasz Figa and Daniel Lezcano

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


Bartlomiej Zolnierkiewicz (4):
ARM: EXYNOS: PM: replace EXYNOS_BOOT_VECTOR_* macros by static inlines
ARM: EXYNOS: add AFTR mode support to firmware do_idle method
ARM: EXYNOS: cpuidle: add secure firmware support to AFTR mode code
ARM: EXYNOS: cpuidle: allow driver usage on Exynos4x12 SoCs

   arch/arm/include/asm/firmware.h  |  2 +-
   arch/arm/mach-exynos/common.h|  7 ++-
   arch/arm/mach-exynos/exynos.c|  3 ++-
   arch/arm/mach-exynos/firmware.c  | 36 ++--
   arch/arm/mach-exynos/pm.c| 39 +--
   drivers/cpuidle/cpuidle-exynos.c |  6 +++---
   6 files changed, 67 insertions(+), 26 deletions(-)





--
 http://www.linaro.org/ Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  http://www.facebook.com/pages/Linaro Facebook |
http://twitter.com/#!/linaroorg Twitter |
http://www.linaro.org/linaro-blog/ 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 v5 05/10] ARM: dts: Move dp_hpd from exynos5250 into smdk5250 and snow

2014-08-05 Thread Jingoo Han
On Saturday, August 02, 2014 5:57 AM, Tomasz Figa wrote:
 On 01.08.2014 22:54, Andreas Färber wrote:
  Am 01.08.2014 22:33, schrieb Doug Anderson:
  On Thu, Jul 31, 2014 at 9:54 PM, Andreas Färber afaer...@suse.de wrote:
  Spring uses a different GPIO, so this is not a generic SoC piece.
 
  Suggested-by: Tomasz Figa t.f...@samsung.com
  Signed-off-by: Andreas Färber afaer...@suse.de
  ---
   v5: New (Tomasz Figa)
   Frees dp_hpd for Spring.
 
   arch/arm/boot/dts/exynos5250-pinctrl.dtsi | 7 ---
   arch/arm/boot/dts/exynos5250-smdk5250.dts | 9 +
   arch/arm/boot/dts/exynos5250-snow.dts | 7 +++
   3 files changed, 16 insertions(+), 7 deletions(-)
 
  diff --git a/arch/arm/boot/dts/exynos5250-pinctrl.dtsi 
  b/arch/arm/boot/dts/exynos5250-pinctrl.dtsi
  index 886cfca044ac..ed0e5230514b 100644
  --- a/arch/arm/boot/dts/exynos5250-pinctrl.dtsi
  +++ b/arch/arm/boot/dts/exynos5250-pinctrl.dtsi
  @@ -581,13 +581,6 @@
  samsung,pin-pud = 0;
  samsung,pin-drv = 0;
  };
  -
  -   dp_hpd: dp_hpd {
  -   samsung,pins = gpx0-7;
  -   samsung,pin-function = 3;
  -   samsung,pin-pud = 0;
  -   samsung,pin-drv = 0;
  -   };
  };
 
  pinctrl@1340 {
  diff --git a/arch/arm/boot/dts/exynos5250-smdk5250.dts 
  b/arch/arm/boot/dts/exynos5250-smdk5250.dts
  index aaa055ac0fe3..5d30fe1dcda4 100644
  --- a/arch/arm/boot/dts/exynos5250-smdk5250.dts
  +++ b/arch/arm/boot/dts/exynos5250-smdk5250.dts
  @@ -414,3 +414,12 @@
  };
  };
   };
  +
  +pinctrl_0 {
  +   dp_hpd: dp_hpd {
  +   samsung,pins = gpx0-7;
  +   samsung,pin-function = 3;
  +   samsung,pin-pud = 0;
  +   samsung,pin-drv = 0;
  +   };
  +};
  diff --git a/arch/arm/boot/dts/exynos5250-snow.dts 
  b/arch/arm/boot/dts/exynos5250-snow.dts
  index c4b0c73c736d..a9a2f2743794 100644
  --- a/arch/arm/boot/dts/exynos5250-snow.dts
  +++ b/arch/arm/boot/dts/exynos5250-snow.dts
  @@ -547,6 +547,13 @@
   };
 
   pinctrl_0 {
  +   dp_hpd: dp_hpd {
  +   samsung,pins = gpx0-7;
  +   samsung,pin-function = 3;
  +   samsung,pin-pud = 0;
  +   samsung,pin-drv = 0;
  +   };
  +
 
  NAK.  dp_hpd is a generic SoC piece.  Pin function 0 and 1 are GPIOs.
  Pin function 3 is special function.  This pin _is_ the hot plug detect
  pin for display port.  When it's set as special function 3 it goes
  straight into the hot plug logic of the display port controller.
 
  Spring may have had its reasons to detect hot plug events on a GPIO
  instead of using this pin, but that doesn't make this pin any less the
  hot plug pin.
 
  Please advise how to handle it then: Should there be two different
  pinctrl entries (if so, how should it be named?),
 
 IMHO this is the right way. Just name the GPIO variant dp_hpd_gpio.

Hi Andreas Färber,

I agree with Tomasz Figa and Doug Anderson.
Please refer to the following.

1. case: Standard HPD pin is used. (smdk5420)
arch/arm/boot/dts/exynos5420-pinctrl.dts
pinctrl@1340 {
dp_hpd: dp_hpd {
samsung,pins = gpx0-7;
samsung,pin-function = 3;
samsung,pin-pud = 0;
samsung,pin-drv = 0;
};
arch/arm/boot/dts/exynos5420-smdk5420.dts
dp-controller@145B {
pinctrl-names = default;
pinctrl-0 = dp_hpd;
...

2. case: non-standard HPD pin such as GPIO is used. (peach pit)
arch/arm/boot/dts/exynos5420-peach-pit.dts
pinctrl@1340 {
dp_hpd_gpio: dp_hpd_gpio {
samsung,pins = gpx2-6;
samsung,pin-function = 0;
samsung,pin-pud = 3;
samsung,pin-drv = 0;
};
dp-controller@145B {
pinctrl-names = default;
pinctrl-0 = dp_hpd_gpio;
...
samsung,hpd-gpio = gpx2 6 0;

So, you need to follow the second case.
dp_hpd_gpio can be used for Spring board.

Best regards,
Jingoo Han

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


Re: [PATCH v2] ARM: EXYNOS: Refactor the pm code to use DT based lookup

2014-08-05 Thread Thomas Abraham
Hi Vikas,

On Fri, Jul 25, 2014 at 5:19 PM, Vikas Sajjan vikas.saj...@samsung.com wrote:
 Refactoring the pm.c to avoid using soc_is_exynos checks,
 instead use the DT based lookup.

 While at it, consolidate the common code across SoCs
 and create a static helper functions.

 Signed-off-by: Vikas Sajjan vikas.saj...@samsung.com
 ---
 changes since v1:
 - Address Kukjin Kim comments to respin this patch separately from
 
 http://lists.infradead.org/pipermail/linux-arm-kernel/2014-July/272574.html
 - removed panic, returned if no PMU node found and added check in 
 exynos_wkup_irq.

 Rebased on Kukjin Kim's tree, for-next branch
 
 https://git.kernel.org/cgit/linux/kernel/git/kgene/linux-samsung.git/log/?h=for-next
 ---
  arch/arm/mach-exynos/pm.c   |  234 
 ---
  arch/arm/mach-exynos/regs-pmu.h |1 +
  2 files changed, 192 insertions(+), 43 deletions(-)

 diff --git a/arch/arm/mach-exynos/pm.c b/arch/arm/mach-exynos/pm.c
 index c4c6d98..1c875e5 100644
 --- a/arch/arm/mach-exynos/pm.c
 +++ b/arch/arm/mach-exynos/pm.c
 @@ -36,6 +36,8 @@
  #include regs-pmu.h
  #include regs-sys.h

 +#define REG_TABLE_END (-1U)
 +
  /**
   * struct exynos_wkup_irq - Exynos GIC to PMU IRQ mapping
   * @hwirq: Hardware IRQ signal of the GIC
 @@ -59,6 +61,19 @@ static struct sleep_save exynos_core_save[] = {
 SAVE_ITEM(S5P_SROM_BC3),
  };

 +struct exynos_pm_data {
 +   const struct exynos_wkup_irq *wkup_irq;
 +   unsigned int wake_disable_mask;
 +   unsigned int *release_ret_regs;
 +
 +   void (*pm_prepare)(void);
 +   void (*pm_resume)(void);
 +   int (*pm_suspend)(void);
 +   int (*cpu_suspend)(unsigned long);
 +};
 +
 +struct exynos_pm_data *pm_data;
 +
  /*
   * GIC wake-up support
   */
 @@ -77,14 +92,24 @@ static const struct exynos_wkup_irq exynos5250_wkup_irq[] 
 = {
 { /* sentinel */ },
  };

 +unsigned int exynos_release_ret_regs[] = {
 +   S5P_PAD_RET_MAUDIO_OPTION,
 +   S5P_PAD_RET_GPIO_OPTION,
 +   S5P_PAD_RET_UART_OPTION,
 +   S5P_PAD_RET_MMCA_OPTION,
 +   S5P_PAD_RET_MMCB_OPTION,
 +   S5P_PAD_RET_EBIA_OPTION,
 +   S5P_PAD_RET_EBIB_OPTION,
 +   REG_TABLE_END,
 +};
 +
  static int exynos_irq_set_wake(struct irq_data *data, unsigned int state)
  {
 const struct exynos_wkup_irq *wkup_irq;

 -   if (soc_is_exynos5250())
 -   wkup_irq = exynos5250_wkup_irq;
 -   else
 -   wkup_irq = exynos4_wkup_irq;
 +   if (!pm_data-wkup_irq)
 +   return -ENOENT;
 +   wkup_irq = pm_data-wkup_irq;

 while (wkup_irq-mask) {
 if (wkup_irq-hwirq == data-hwirq) {
 @@ -241,13 +266,13 @@ static void exynos_cpu_restore_register(void)

  static int exynos_cpu_suspend(unsigned long arg)
  {
 -#ifdef CONFIG_CACHE_L2X0
 -   outer_flush_all();
 -#endif
 -
 -   if (soc_is_exynos5250())
 -   flush_cache_all();
 +   if (pm_data-cpu_suspend)
 +   return pm_data-cpu_suspend(arg);
 +   return -1;
 +}

 +static int exynos_cpu_do_idle(void)
 +{
 /* issue the standby signal into the pm unit. */
 cpu_do_idle();

 @@ -257,32 +282,73 @@ static int exynos_cpu_suspend(unsigned long arg)

  static void exynos_pm_prepare(void)
  {
 -   unsigned int tmp;
 +   if (pm_data-pm_prepare)
 +   pm_data-pm_prepare();
 +}

 +static int exynos4_cpu_suspend(unsigned long arg)
 +{
 +#ifdef CONFIG_CACHE_L2X0
 +   outer_flush_all();
 +#endif
 +   return exynos_cpu_do_idle();
 +}
 +
 +static int exynos5250_cpu_suspend(unsigned long arg)
 +{
 +#ifdef CONFIG_CACHE_L2X0
 +   outer_flush_all();
 +#endif

Exynos5 SoCs do not use an additional outer cache controller. So the
above #ifdef block can be dropped.

 +   flush_cache_all();
 +   return exynos_cpu_do_idle();
 +}
 +
 +static void exynos_pm_set_wakeup_mask(void)
 +{
 /* Set wake-up mask registers */
 pmu_raw_writel(exynos_get_eint_wake_mask(), S5P_EINT_WAKEUP_MASK);
 pmu_raw_writel(exynos_irqwake_intmask  ~(1  31), S5P_WAKEUP_MASK);
 +}

 -   s3c_pm_do_save(exynos_core_save, ARRAY_SIZE(exynos_core_save));
 -
 -   if (soc_is_exynos5250()) {
 -   s3c_pm_do_save(exynos5_sys_save, 
 ARRAY_SIZE(exynos5_sys_save));
 -   /* Disable USE_RETENTION of JPEG_MEM_OPTION */
 -   tmp = pmu_raw_readl(EXYNOS5_JPEG_MEM_OPTION);
 -   tmp = ~EXYNOS5_OPTION_USE_RETENTION;
 -   pmu_raw_writel(tmp, EXYNOS5_JPEG_MEM_OPTION);
 -   }
 -
 +static void exynos_pm_enter_sleep_mode(void)
 +{
 /* Set value of power down register for sleep mode */
 -
 exynos_sys_powerdown_conf(SYS_SLEEP);
 pmu_raw_writel(S5P_CHECK_SLEEP, S5P_INFORM1);

 /* ensure at least INFORM0 has the resume address */
 -
 pmu_raw_writel(virt_to_phys(exynos_cpu_resume), S5P_INFORM0);
  }

 +static void 

[PATCH 4/5] rtc: s3c: Add support for RTC of Exynos3250 SoC

2014-08-05 Thread Chanwoo Choi
This patch add support for RTC of Exynos3250 SoC. The Exynos3250 needs source
clock(32.768KHz) for RTC block. If source clock of RTC is registerd on clock
list of common clk framework, Exynos RTC drvier have to control this clock.

Clock list for s3c-rtc device:
- rtc : CLK_RTC of CLK_GATE_IP_PERIR is gate clock for RTC.
- rtc_src : XrtcXTI is 32.768.kHz source clock for RTC.
 (XRTCXTI: Specifies a clock from 32.768 kHz crystal pad with XRTCXTI and
 XRTCXTO pins. RTC uses this clock as the source of a real-time clock.)

Signed-off-by: Chanwoo Choi cw00.c...@samsung.com
Acked-by: Kyungmin Park kyungmin.p...@samsung.com
---
 Documentation/devicetree/bindings/rtc/s3c-rtc.txt |  1 +
 drivers/rtc/rtc-s3c.c | 93 ++-
 2 files changed, 93 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/rtc/s3c-rtc.txt 
b/Documentation/devicetree/bindings/rtc/s3c-rtc.txt
index 06db446..ab757b84 100644
--- a/Documentation/devicetree/bindings/rtc/s3c-rtc.txt
+++ b/Documentation/devicetree/bindings/rtc/s3c-rtc.txt
@@ -6,6 +6,7 @@ Required properties:
 * samsung,s3c2416-rtc - for controllers compatible with s3c2416 rtc.
 * samsung,s3c2443-rtc - for controllers compatible with s3c2443 rtc.
 * samsung,s3c6410-rtc - for controllers compatible with s3c6410 rtc.
+* samsung,exynos3250-rtc - for controllers compatible with exynos3250 
rtc.
 - reg: physical base address of the controller and length of memory mapped
   region.
 - interrupts: Two interrupt numbers to the cpu should be specified. First
diff --git a/drivers/rtc/rtc-s3c.c b/drivers/rtc/rtc-s3c.c
index 43070f5..e0719a7 100644
--- a/drivers/rtc/rtc-s3c.c
+++ b/drivers/rtc/rtc-s3c.c
@@ -38,6 +38,7 @@ struct s3c_rtc {
 
void __iomem *base;
struct clk *rtc_clk;
+   struct clk *rtc_src_clk;
bool enabled;
 
struct s3c_rtc_data *data;
@@ -54,6 +55,7 @@ struct s3c_rtc {
 
 struct s3c_rtc_data {
int max_user_freq;
+   bool needs_src_clk;
 
void (*irq_handler) (struct s3c_rtc *info, int mask);
void (*set_freq) (struct s3c_rtc *info, int freq);
@@ -73,10 +75,14 @@ static void s3c_rtc_alarm_clk_enable(struct s3c_rtc *info, 
bool enable)
if (enable) {
if (!info-enabled) {
clk_enable(info-rtc_clk);
+   if (info-data-needs_src_clk)
+   clk_enable(info-rtc_src_clk);
info-enabled = true;
}
} else {
if (info-enabled) {
+   if (info-data-needs_src_clk)
+   clk_disable(info-rtc_src_clk);
clk_disable(info-rtc_clk);
info-enabled = false;
}
@@ -114,12 +120,16 @@ static int s3c_rtc_setaie(struct device *dev, unsigned 
int enabled)
dev_dbg(info-dev, %s: aie=%d\n, __func__, enabled);
 
clk_enable(info-rtc_clk);
+   if (info-data-needs_src_clk)
+   clk_enable(info-rtc_src_clk);
tmp = readb(info-base + S3C2410_RTCALM)  ~S3C2410_RTCALM_ALMEN;
 
if (enabled)
tmp |= S3C2410_RTCALM_ALMEN;
 
writeb(tmp, info-base + S3C2410_RTCALM);
+   if (info-data-needs_src_clk)
+   clk_disable(info-rtc_src_clk);
clk_disable(info-rtc_clk);
 
s3c_rtc_alarm_clk_enable(info, enabled);
@@ -134,12 +144,16 @@ static int s3c_rtc_setfreq(struct s3c_rtc *info, int freq)
return -EINVAL;
 
clk_enable(info-rtc_clk);
+   if (info-data-needs_src_clk)
+   clk_enable(info-rtc_src_clk);
spin_lock_irq(info-pie_lock);
 
if (info-data-set_freq)
info-data-set_freq(info, freq);
 
spin_unlock_irq(info-pie_lock);
+   if (info-data-needs_src_clk)
+   clk_disable(info-rtc_src_clk);
clk_disable(info-rtc_clk);
 
return 0;
@@ -152,6 +166,9 @@ static int s3c_rtc_gettime(struct device *dev, struct 
rtc_time *rtc_tm)
unsigned int have_retried = 0;
 
clk_enable(info-rtc_clk);
+   if (info-data-needs_src_clk)
+   clk_enable(info-rtc_src_clk);
+
  retry_get_time:
rtc_tm-tm_min  = readb(info-base + S3C2410_RTCMIN);
rtc_tm-tm_hour = readb(info-base + S3C2410_RTCHOUR);
@@ -185,6 +202,8 @@ static int s3c_rtc_gettime(struct device *dev, struct 
rtc_time *rtc_tm)
 
rtc_tm-tm_mon -= 1;
 
+   if (info-data-needs_src_clk)
+   clk_disable(info-rtc_src_clk);
clk_disable(info-rtc_clk);
 
return rtc_valid_tm(rtc_tm);
@@ -207,6 +226,8 @@ static int s3c_rtc_settime(struct device *dev, struct 
rtc_time *tm)
}
 
clk_enable(info-rtc_clk);
+   if (info-data-needs_src_clk)
+   clk_enable(info-rtc_src_clk);
 
writeb(bin2bcd(tm-tm_sec),  info-base + S3C2410_RTCSEC);
writeb(bin2bcd(tm-tm_min),  info-base + 

[PATCH 1/5] rtc: s3c: Define s3c_rtc structure to remove global variables.

2014-08-05 Thread Chanwoo Choi
This patch define s3c_rtc structure including necessary variables for S3C RTC
device instead of global variables. This patch improves the readability by
removing global variables.

Signed-off-by: Chanwoo Choi cw00.c...@samsung.com
Acked-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/rtc/rtc-s3c.c | 428 +-
 1 file changed, 216 insertions(+), 212 deletions(-)

diff --git a/drivers/rtc/rtc-s3c.c b/drivers/rtc/rtc-s3c.c
index 4958a36..b9062b5 100644
--- a/drivers/rtc/rtc-s3c.c
+++ b/drivers/rtc/rtc-s3c.c
@@ -43,125 +43,132 @@ struct s3c_rtc_drv_data {
int cpu_type;
 };
 
-/* I have yet to find an S3C implementation with more than one
- * of these rtc blocks in */
+struct s3c_rtc {
+   struct device *dev;
+   struct rtc_device *rtc;
+
+   void __iomem *base;
+   struct clk *rtc_clk;
+   bool enabled;
+
+   enum s3c_cpu_type cpu_type;
 
-static struct clk *rtc_clk;
-static void __iomem *s3c_rtc_base;
-static int s3c_rtc_alarmno;
-static int s3c_rtc_tickno;
-static enum s3c_cpu_type s3c_rtc_cpu_type;
+   int irq_alarm;
+   int irq_tick;
 
-static DEFINE_SPINLOCK(s3c_rtc_pie_lock);
+   spinlock_t pie_lock;
+   spinlock_t alarm_clk_lock;
+
+   int ticnt_save, ticnt_en_save;
+   bool wake_en;
+};
 
-static void s3c_rtc_alarm_clk_enable(bool enable)
+static void s3c_rtc_alarm_clk_enable(struct s3c_rtc *info, bool enable)
 {
-   static DEFINE_SPINLOCK(s3c_rtc_alarm_clk_lock);
-   static bool alarm_clk_enabled;
unsigned long irq_flags;
 
-   spin_lock_irqsave(s3c_rtc_alarm_clk_lock, irq_flags);
+   spin_lock_irqsave(info-alarm_clk_lock, irq_flags);
if (enable) {
-   if (!alarm_clk_enabled) {
-   clk_enable(rtc_clk);
-   alarm_clk_enabled = true;
+   if (!info-enabled) {
+   clk_enable(info-rtc_clk);
+   info-enabled = true;
}
} else {
-   if (alarm_clk_enabled) {
-   clk_disable(rtc_clk);
-   alarm_clk_enabled = false;
+   if (info-enabled) {
+   clk_disable(info-rtc_clk);
+   info-enabled = false;
}
}
-   spin_unlock_irqrestore(s3c_rtc_alarm_clk_lock, irq_flags);
+   spin_unlock_irqrestore(info-alarm_clk_lock, irq_flags);
 }
 
 /* IRQ Handlers */
-
 static irqreturn_t s3c_rtc_alarmirq(int irq, void *id)
 {
-   struct rtc_device *rdev = id;
+   struct s3c_rtc *info = (struct s3c_rtc *)id;
 
-   clk_enable(rtc_clk);
-   rtc_update_irq(rdev, 1, RTC_AF | RTC_IRQF);
+   clk_enable(info-rtc_clk);
+   rtc_update_irq(info-rtc, 1, RTC_AF | RTC_IRQF);
 
-   if (s3c_rtc_cpu_type == TYPE_S3C64XX)
-   writeb(S3C2410_INTP_ALM, s3c_rtc_base + S3C2410_INTP);
+   if (info-cpu_type == TYPE_S3C64XX)
+   writeb(S3C2410_INTP_ALM, info-base + S3C2410_INTP);
 
-   clk_disable(rtc_clk);
+   clk_disable(info-rtc_clk);
 
-   s3c_rtc_alarm_clk_enable(false);
+   s3c_rtc_alarm_clk_enable(info, false);
 
return IRQ_HANDLED;
 }
 
 static irqreturn_t s3c_rtc_tickirq(int irq, void *id)
 {
-   struct rtc_device *rdev = id;
+   struct s3c_rtc *info = (struct s3c_rtc *)id;
+
+   clk_enable(info-rtc_clk);
+   rtc_update_irq(info-rtc, 1, RTC_PF | RTC_IRQF);
 
-   clk_enable(rtc_clk);
-   rtc_update_irq(rdev, 1, RTC_PF | RTC_IRQF);
+   if (info-cpu_type == TYPE_S3C64XX)
+   writeb(S3C2410_INTP_TIC, info-base + S3C2410_INTP);
 
-   if (s3c_rtc_cpu_type == TYPE_S3C64XX)
-   writeb(S3C2410_INTP_TIC, s3c_rtc_base + S3C2410_INTP);
+   clk_disable(info-rtc_clk);
 
-   clk_disable(rtc_clk);
return IRQ_HANDLED;
 }
 
 /* Update control registers */
 static int s3c_rtc_setaie(struct device *dev, unsigned int enabled)
 {
+   struct s3c_rtc *info = dev_get_drvdata(dev);
unsigned int tmp;
 
-   dev_dbg(dev, %s: aie=%d\n, __func__, enabled);
+   dev_dbg(info-dev, %s: aie=%d\n, __func__, enabled);
 
-   clk_enable(rtc_clk);
-   tmp = readb(s3c_rtc_base + S3C2410_RTCALM)  ~S3C2410_RTCALM_ALMEN;
+   clk_enable(info-rtc_clk);
+   tmp = readb(info-base + S3C2410_RTCALM)  ~S3C2410_RTCALM_ALMEN;
 
if (enabled)
tmp |= S3C2410_RTCALM_ALMEN;
 
-   writeb(tmp, s3c_rtc_base + S3C2410_RTCALM);
-   clk_disable(rtc_clk);
+   writeb(tmp, info-base + S3C2410_RTCALM);
+   clk_disable(info-rtc_clk);
 
-   s3c_rtc_alarm_clk_enable(enabled);
+   s3c_rtc_alarm_clk_enable(info, enabled);
 
return 0;
 }
 
-static int s3c_rtc_setfreq(struct device *dev, int freq)
+static int s3c_rtc_setfreq(struct s3c_rtc *info, int freq)
 {
-   struct platform_device *pdev = to_platform_device(dev);
-   struct rtc_device *rtc_dev = platform_get_drvdata(pdev);

[PATCH 2/5] rtc: s3c: Remove warning message when checking coding style with checkpatch script

2014-08-05 Thread Chanwoo Choi
This patch remove warning message when checking codeing style with checkpatch
script and reduce un-necessary i2c read operation on s3c_rtc_enable.

WARNING: line over 80 characters
#406: FILE: drivers/rtc/rtc-s3c.c:406:
+   if ((readw(info-base + S3C2410_RTCCON)  
S3C2410_RTCCON_RTCEN) == 0) {

WARNING: line over 80 characters
#414: FILE: drivers/rtc/rtc-s3c.c:414:
+   if ((readw(info-base + S3C2410_RTCCON)  
S3C2410_RTCCON_CNTSEL)) {

WARNING: line over 80 characters
#422: FILE: drivers/rtc/rtc-s3c.c:422:
+   if ((readw(info-base + S3C2410_RTCCON)  
S3C2410_RTCCON_CLKRST)) {

WARNING: Missing a blank line after declarations
#451: FILE: drivers/rtc/rtc-s3c.c:451:
+   struct s3c_rtc_drv_data *data;
+   if (pdev-dev.of_node) {

WARNING: Missing a blank line after declarations
#453: FILE: drivers/rtc/rtc-s3c.c:453:
+   const struct of_device_id *match;
+   match = of_match_node(s3c_rtc_dt_match, 
pdev-dev.of_node);

WARNING: DT compatible string samsung,s3c2416-rtc appears 
un-documented -- check ./Documentation/devicetree/bindings/
#650: FILE: drivers/rtc/rtc-s3c.c:650:
+   .compatible = samsung,s3c2416-rtc,

WARNING: DT compatible string samsung,s3c2443-rtc appears 
un-documented -- check ./Documentation/devicetree/bindings/
#653: FILE: drivers/rtc/rtc-s3c.c:653:
+   .compatible = samsung,s3c2443-rtc,

Signed-off-by: Chanwoo Choi cw00.c...@samsung.com
Acked-by: Kyungmin Park kyungmin.p...@samsung.com
---
 Documentation/devicetree/bindings/rtc/s3c-rtc.txt |  2 ++
 drivers/rtc/rtc-s3c.c | 26 ---
 2 files changed, 16 insertions(+), 12 deletions(-)

diff --git a/Documentation/devicetree/bindings/rtc/s3c-rtc.txt 
b/Documentation/devicetree/bindings/rtc/s3c-rtc.txt
index 7ac7259..06db446 100644
--- a/Documentation/devicetree/bindings/rtc/s3c-rtc.txt
+++ b/Documentation/devicetree/bindings/rtc/s3c-rtc.txt
@@ -3,6 +3,8 @@
 Required properties:
 - compatible: should be one of the following.
 * samsung,s3c2410-rtc - for controllers compatible with s3c2410 rtc.
+* samsung,s3c2416-rtc - for controllers compatible with s3c2416 rtc.
+* samsung,s3c2443-rtc - for controllers compatible with s3c2443 rtc.
 * samsung,s3c6410-rtc - for controllers compatible with s3c6410 rtc.
 - reg: physical base address of the controller and length of memory mapped
   region.
diff --git a/drivers/rtc/rtc-s3c.c b/drivers/rtc/rtc-s3c.c
index b9062b5..814ee74 100644
--- a/drivers/rtc/rtc-s3c.c
+++ b/drivers/rtc/rtc-s3c.c
@@ -382,28 +382,28 @@ static const struct rtc_class_ops s3c_rtcops = {
 
 static void s3c_rtc_enable(struct s3c_rtc *info, int en)
 {
-   unsigned int tmp;
+   unsigned int con, tmp;
 
if (!info-base)
return;
 
clk_enable(info-rtc_clk);
+
+   con = readw(info-base + S3C2410_RTCCON);
if (!en) {
-   tmp = readw(info-base + S3C2410_RTCCON);
if (info-cpu_type == TYPE_S3C64XX)
-   tmp = ~S3C64XX_RTCCON_TICEN;
-   tmp = ~S3C2410_RTCCON_RTCEN;
-   writew(tmp, info-base + S3C2410_RTCCON);
+   con = ~S3C64XX_RTCCON_TICEN;
+   con = ~S3C2410_RTCCON_RTCEN;
+   writew(con, info-base + S3C2410_RTCCON);
 
if (info-cpu_type != TYPE_S3C64XX) {
-   tmp = readb(info-base + S3C2410_TICNT);
-   tmp = ~S3C2410_TICNT_ENABLE;
-   writeb(tmp, info-base + S3C2410_TICNT);
+   con = readb(info-base + S3C2410_TICNT);
+   con = ~S3C2410_TICNT_ENABLE;
+   writeb(con, info-base + S3C2410_TICNT);
}
} else {
/* re-enable the device, and check it is ok */
-
-   if ((readw(info-base + S3C2410_RTCCON)  S3C2410_RTCCON_RTCEN) 
== 0) {
+   if ((con  S3C2410_RTCCON_RTCEN) == 0) {
dev_info(info-dev, rtc disabled, re-enabling\n);
 
tmp = readw(info-base + S3C2410_RTCCON);
@@ -411,7 +411,7 @@ static void s3c_rtc_enable(struct s3c_rtc *info, int en)
info-base + S3C2410_RTCCON);
}
 
-   if ((readw(info-base + S3C2410_RTCCON)  
S3C2410_RTCCON_CNTSEL)) {
+   if (con  S3C2410_RTCCON_CNTSEL) {
dev_info(info-dev, removing RTCCON_CNTSEL\n);
 
tmp = readw(info-base + S3C2410_RTCCON);
@@ -419,7 +419,7 @@ static void s3c_rtc_enable(struct s3c_rtc *info, int en)
info-base + S3C2410_RTCCON);
}
 
-   if ((readw(info-base + S3C2410_RTCCON)  
S3C2410_RTCCON_CLKRST)) 

[PATCH 5/5] ARM: dts: Fix wrong compatible string of Exynos3250 RTC dt node

2014-08-05 Thread Chanwoo Choi
This patch fix wrong compatible string of Exynos3250 RTC (Real-Time Clock) dt
node. The RTC of Exynos3250 must need additional source clock (XrtcXTI).

Signed-off-by: Chanwoo Choi cw00.c...@samsung.com
---
 arch/arm/boot/dts/exynos3250.dtsi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/exynos3250.dtsi 
b/arch/arm/boot/dts/exynos3250.dtsi
index abd6eb3..a04540e 100644
--- a/arch/arm/boot/dts/exynos3250.dtsi
+++ b/arch/arm/boot/dts/exynos3250.dtsi
@@ -162,7 +162,7 @@
};
 
rtc: rtc@1007 {
-   compatible = samsung,s3c6410-rtc;
+   compatible = samsung,exynos3250-rtc;
reg = 0x1007 0x100;
interrupts = 0 73 0, 0 74 0;
status = disabled;
-- 
1.8.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 3/5] rtc: s3c: Add s3c_rtc_data structure to use variant data instead of s3c_cpu_type

2014-08-05 Thread Chanwoo Choi
This patch add s3c_rtc_data structure to variant data according to SoC type.
The s3c_rtc_data structure includes some functions to control RTC operation
and specific data dependent on SoC type.

Signed-off-by: Chanwoo Choi cw00.c...@samsung.com
Acked-by: Kyungmin Park kyungmin.p...@samsung.com
---
 drivers/rtc/rtc-s3c.c | 464 +++---
 1 file changed, 289 insertions(+), 175 deletions(-)

diff --git a/drivers/rtc/rtc-s3c.c b/drivers/rtc/rtc-s3c.c
index 814ee74..43070f5 100644
--- a/drivers/rtc/rtc-s3c.c
+++ b/drivers/rtc/rtc-s3c.c
@@ -32,17 +32,6 @@
 #include asm/irq.h
 #include rtc-s3c.h
 
-enum s3c_cpu_type {
-   TYPE_S3C2410,
-   TYPE_S3C2416,
-   TYPE_S3C2443,
-   TYPE_S3C64XX,
-};
-
-struct s3c_rtc_drv_data {
-   int cpu_type;
-};
-
 struct s3c_rtc {
struct device *dev;
struct rtc_device *rtc;
@@ -51,7 +40,7 @@ struct s3c_rtc {
struct clk *rtc_clk;
bool enabled;
 
-   enum s3c_cpu_type cpu_type;
+   struct s3c_rtc_data *data;
 
int irq_alarm;
int irq_tick;
@@ -63,6 +52,19 @@ struct s3c_rtc {
bool wake_en;
 };
 
+struct s3c_rtc_data {
+   int max_user_freq;
+
+   void (*irq_handler) (struct s3c_rtc *info, int mask);
+   void (*set_freq) (struct s3c_rtc *info, int freq);
+   void (*enable_tick) (struct s3c_rtc *info, struct seq_file *seq);
+   void (*select_tick_clk) (struct s3c_rtc *info);
+   void (*save_tick_cnt) (struct s3c_rtc *info);
+   void (*restore_tick_cnt) (struct s3c_rtc *info);
+   void (*enable) (struct s3c_rtc *info);
+   void (*disable) (struct s3c_rtc *info);
+};
+
 static void s3c_rtc_alarm_clk_enable(struct s3c_rtc *info, bool enable)
 {
unsigned long irq_flags;
@@ -83,34 +85,22 @@ static void s3c_rtc_alarm_clk_enable(struct s3c_rtc *info, 
bool enable)
 }
 
 /* IRQ Handlers */
-static irqreturn_t s3c_rtc_alarmirq(int irq, void *id)
+static irqreturn_t s3c_rtc_tickirq(int irq, void *id)
 {
struct s3c_rtc *info = (struct s3c_rtc *)id;
 
-   clk_enable(info-rtc_clk);
-   rtc_update_irq(info-rtc, 1, RTC_AF | RTC_IRQF);
-
-   if (info-cpu_type == TYPE_S3C64XX)
-   writeb(S3C2410_INTP_ALM, info-base + S3C2410_INTP);
-
-   clk_disable(info-rtc_clk);
-
-   s3c_rtc_alarm_clk_enable(info, false);
+   if (info-data-irq_handler)
+   info-data-irq_handler(info, S3C2410_INTP_TIC);
 
return IRQ_HANDLED;
 }
 
-static irqreturn_t s3c_rtc_tickirq(int irq, void *id)
+static irqreturn_t s3c_rtc_alarmirq(int irq, void *id)
 {
struct s3c_rtc *info = (struct s3c_rtc *)id;
 
-   clk_enable(info-rtc_clk);
-   rtc_update_irq(info-rtc, 1, RTC_PF | RTC_IRQF);
-
-   if (info-cpu_type == TYPE_S3C64XX)
-   writeb(S3C2410_INTP_TIC, info-base + S3C2410_INTP);
-
-   clk_disable(info-rtc_clk);
+   if (info-data-irq_handler)
+   info-data-irq_handler(info, S3C2410_INTP_ALM);
 
return IRQ_HANDLED;
 }
@@ -137,36 +127,18 @@ static int s3c_rtc_setaie(struct device *dev, unsigned 
int enabled)
return 0;
 }
 
+/* Set RTC frequency */
 static int s3c_rtc_setfreq(struct s3c_rtc *info, int freq)
 {
-   unsigned int tmp = 0;
-   int val;
-
if (!is_power_of_2(freq))
return -EINVAL;
 
clk_enable(info-rtc_clk);
spin_lock_irq(info-pie_lock);
 
-   if (info-cpu_type != TYPE_S3C64XX) {
-   tmp = readb(info-base + S3C2410_TICNT);
-   tmp = S3C2410_TICNT_ENABLE;
-   }
-
-   val = (info-rtc-max_user_freq / freq) - 1;
-
-   if (info-cpu_type == TYPE_S3C2416 || info-cpu_type == TYPE_S3C2443) {
-   tmp |= S3C2443_TICNT_PART(val);
-   writel(S3C2443_TICNT1_PART(val), info-base + S3C2443_TICNT1);
+   if (info-data-set_freq)
+   info-data-set_freq(info, freq);
 
-   if (info-cpu_type == TYPE_S3C2416)
-   writel(S3C2416_TICNT2_PART(val),
-   info-base + S3C2416_TICNT2);
-   } else {
-   tmp |= val;
-   }
-
-   writel(tmp, info-base + S3C2410_TICNT);
spin_unlock_irq(info-pie_lock);
clk_disable(info-rtc_clk);
 
@@ -174,7 +146,6 @@ static int s3c_rtc_setfreq(struct s3c_rtc *info, int freq)
 }
 
 /* Time read/write */
-
 static int s3c_rtc_gettime(struct device *dev, struct rtc_time *rtc_tm)
 {
struct s3c_rtc *info = dev_get_drvdata(dev);
@@ -355,19 +326,14 @@ static int s3c_rtc_setalarm(struct device *dev, struct 
rtc_wkalrm *alrm)
 static int s3c_rtc_proc(struct device *dev, struct seq_file *seq)
 {
struct s3c_rtc *info = dev_get_drvdata(dev);
-   unsigned int ticnt;
 
clk_enable(info-rtc_clk);
-   if (info-cpu_type == TYPE_S3C64XX) {
-   ticnt = readw(info-base + S3C2410_RTCCON);
-   ticnt = S3C64XX_RTCCON_TICEN;
-   } else {
-   ticnt = readb(info-base 

[PATCH 0/5] rtc: s3c: Refactoring s3c-rtc driver and support Exynos3250 RTC

2014-08-05 Thread Chanwoo Choi
This patchset clean up codes to improve readability as following and support
the RTC of Exynos3250 SoC.
- Remove global variables and then use new s3c_rtc structure
- Remove warn message with checking checkpatch script
- Use variant structure according to SoC type instead of legacy enum 
variable(s3c_cpu_type)

Chanwoo Choi (5):
  rtc: s3c: Define s3c_rtc structure to remove global variables.
  rtc: s3c: Remove warning message when checking coding style with checkpatch 
script
  rtc: s3c: Add s3c_rtc_data structure to use variant data instead of 
s3c_cpu_type
  rtc: s3c: Add support for RTC of Exynos3250 SoC
  ARM: dts: Fix wrong compatible string of Exynos3250 RTC dt node

 Documentation/devicetree/bindings/rtc/s3c-rtc.txt |   3 +
 arch/arm/boot/dts/exynos3250.dtsi |   2 +-
 drivers/rtc/rtc-s3c.c | 849 ++
 3 files changed, 534 insertions(+), 320 deletions(-)

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


Re: [PATCH v4][next-20140804] ARM: EXYNOS: Fix suspend/resume sequences

2014-08-05 Thread Bartlomiej Zolnierkiewicz

Hi,

I'm very sorry but this version also has a problem as it still uses
read_cpuid_part_number() instead of read_cpuid_part().  v5 (which really
should be the final one) to be posted in a minute.

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

On Monday, August 04, 2014 04:40:20 PM Bartlomiej Zolnierkiewicz wrote:
 From: Tomasz Figa t.f...@samsung.com
 
 Due to recent consolidation of Exynos suspend and cpuidle code, some
 parts of suspend and resume sequences are executed two times, once from
 exynos_pm_syscore_ops and then from exynos_cpu_pm_notifier() and thus it
 breaks suspend, at least on Exynos4-based boards. In addition, simple
 core power down from a cpuidle driver could, in case of CPU 0 could
 result in calling functions that are specific to suspend and deeper idle
 states.
 
 This patch fixes the issue by moving those operations outside the CPU PM
 notifier into suspend and AFTR code paths. This leads to a bit of code
 duplication, but allows additional code simplification, so in the end
 more code is removed than added.
 
 Fixes: 85f9f90808b4 (ARM: EXYNOS: Use the cpu_pm notifier for pm)
 Cc: Kukjin Kim kgene@samsung.com
 Cc: Arnd Bergmann a...@arndb.de
 Cc: Olof Johansson o...@lixom.net
 Cc: a...@kernel.org
 Signed-off-by: Tomasz Figa t.f...@samsung.com
 [b.zolnierkie: ported patch over current changes]
 [b.zolnierkie: fixed exynos_aftr_finisher() return value]
 Signed-off-by: Bartlomiej Zolnierkiewicz b.zolnier...@samsung.com
 ---
  arch/arm/mach-exynos/pm.c|  163 
 ++-
  drivers/cpuidle/cpuidle-exynos.c |   25 -
  2 files changed, 80 insertions(+), 108 deletions(-)
 
 v4:
 - fixed exynos_aftr_finisher() return value
 
 Index: b/arch/arm/mach-exynos/pm.c
 ===
 --- a/arch/arm/mach-exynos/pm.c   2014-08-04 16:36:18.927125851 +0200
 +++ b/arch/arm/mach-exynos/pm.c   2014-08-04 16:36:38.559126369 +0200
 @@ -114,26 +114,6 @@ static int exynos_irq_set_wake(struct ir
  #define S5P_CHECK_AFTR  0xFCBA0D10
  #define S5P_CHECK_SLEEP 0x0BAD
  
 -/* Ext-GIC nIRQ/nFIQ is the only wakeup source in AFTR */
 -static void exynos_set_wakeupmask(long mask)
 -{
 - pmu_raw_writel(mask, S5P_WAKEUP_MASK);
 -}
 -
 -static void exynos_cpu_set_boot_vector(long flags)
 -{
 - __raw_writel(virt_to_phys(exynos_cpu_resume), EXYNOS_BOOT_VECTOR_ADDR);
 - __raw_writel(flags, EXYNOS_BOOT_VECTOR_FLAG);
 -}
 -
 -void exynos_enter_aftr(void)
 -{
 - exynos_set_wakeupmask(0xff3e);
 - exynos_cpu_set_boot_vector(S5P_CHECK_AFTR);
 - /* Set value of power down register for aftr mode */
 - exynos_sys_powerdown_conf(SYS_AFTR);
 -}
 -
  /* For Cortex-A9 Diagnostic and Power control register */
  static unsigned int save_arm_register[2];
  
 @@ -173,6 +153,82 @@ static void exynos_cpu_restore_register(
 : cc);
  }
  
 +static void exynos_pm_central_suspend(void)
 +{
 + unsigned long tmp;
 +
 + /* Setting Central Sequence Register for power down mode */
 + tmp = pmu_raw_readl(S5P_CENTRAL_SEQ_CONFIGURATION);
 + tmp = ~S5P_CENTRAL_LOWPWR_CFG;
 + pmu_raw_writel(tmp, S5P_CENTRAL_SEQ_CONFIGURATION);
 +}
 +
 +static int exynos_pm_central_resume(void)
 +{
 + unsigned long tmp;
 +
 + /*
 +  * If PMU failed while entering sleep mode, WFI will be
 +  * ignored by PMU and then exiting cpu_do_idle().
 +  * S5P_CENTRAL_LOWPWR_CFG bit will not be set automatically
 +  * in this situation.
 +  */
 + tmp = pmu_raw_readl(S5P_CENTRAL_SEQ_CONFIGURATION);
 + if (!(tmp  S5P_CENTRAL_LOWPWR_CFG)) {
 + tmp |= S5P_CENTRAL_LOWPWR_CFG;
 + pmu_raw_writel(tmp, S5P_CENTRAL_SEQ_CONFIGURATION);
 + /* clear the wakeup state register */
 + pmu_raw_writel(0x0, S5P_WAKEUP_STAT);
 + /* No need to perform below restore code */
 + return -1;
 + }
 +
 + return 0;
 +}
 +
 +/* Ext-GIC nIRQ/nFIQ is the only wakeup source in AFTR */
 +static void exynos_set_wakeupmask(long mask)
 +{
 + pmu_raw_writel(mask, S5P_WAKEUP_MASK);
 +}
 +
 +static void exynos_cpu_set_boot_vector(long flags)
 +{
 + __raw_writel(virt_to_phys(exynos_cpu_resume), EXYNOS_BOOT_VECTOR_ADDR);
 + __raw_writel(flags, EXYNOS_BOOT_VECTOR_FLAG);
 +}
 +
 +static int exynos_aftr_finisher(unsigned long flags)
 +{
 + exynos_set_wakeupmask(0xff3e);
 + exynos_cpu_set_boot_vector(S5P_CHECK_AFTR);
 + /* Set value of power down register for aftr mode */
 + exynos_sys_powerdown_conf(SYS_AFTR);
 + cpu_do_idle();
 +
 + return 1;
 +}
 +
 +void exynos_enter_aftr(void)
 +{
 + cpu_pm_enter();
 +
 + exynos_pm_central_suspend();
 + if (read_cpuid_part_number() == ARM_CPU_PART_CORTEX_A9)
 + exynos_cpu_save_register();
 +
 + cpu_suspend(0, exynos_aftr_finisher);
 +
 + if (read_cpuid_part_number() == 

[PATCH v5][next-20140804] ARM: EXYNOS: Fix suspend/resume sequences

2014-08-05 Thread Bartlomiej Zolnierkiewicz
From: Tomasz Figa t.f...@samsung.com

Due to recent consolidation of Exynos suspend and cpuidle code, some
parts of suspend and resume sequences are executed two times, once from
exynos_pm_syscore_ops and then from exynos_cpu_pm_notifier() and thus it
breaks suspend, at least on Exynos4-based boards. In addition, simple
core power down from a cpuidle driver could, in case of CPU 0 could
result in calling functions that are specific to suspend and deeper idle
states.

This patch fixes the issue by moving those operations outside the CPU PM
notifier into suspend and AFTR code paths. This leads to a bit of code
duplication, but allows additional code simplification, so in the end
more code is removed than added.

Fixes: 85f9f90808b4 (ARM: EXYNOS: Use the cpu_pm notifier for pm)
Cc: Kukjin Kim kgene@samsung.com
Cc: Arnd Bergmann a...@arndb.de
Cc: Olof Johansson o...@lixom.net
Cc: a...@kernel.org
Signed-off-by: Tomasz Figa t.f...@samsung.com
[b.zolnierkie: ported patch over current changes]
[b.zolnierkie: fixed exynos_aftr_finisher() return value]
Signed-off-by: Bartlomiej Zolnierkiewicz b.zolnier...@samsung.com
---
 arch/arm/mach-exynos/pm.c|  163 ++-
 drivers/cpuidle/cpuidle-exynos.c |   25 -
 2 files changed, 80 insertions(+), 108 deletions(-)

v5:
- use read_cpuid_part() instead of the deprecated read_cpuid_part_number()

Index: b/arch/arm/mach-exynos/pm.c
===
--- a/arch/arm/mach-exynos/pm.c 2014-08-05 14:14:29.605182233 +0200
+++ b/arch/arm/mach-exynos/pm.c 2014-08-05 14:30:41.713207901 +0200
@@ -114,26 +114,6 @@ static int exynos_irq_set_wake(struct ir
 #define S5P_CHECK_AFTR  0xFCBA0D10
 #define S5P_CHECK_SLEEP 0x0BAD
 
-/* Ext-GIC nIRQ/nFIQ is the only wakeup source in AFTR */
-static void exynos_set_wakeupmask(long mask)
-{
-   pmu_raw_writel(mask, S5P_WAKEUP_MASK);
-}
-
-static void exynos_cpu_set_boot_vector(long flags)
-{
-   __raw_writel(virt_to_phys(exynos_cpu_resume), EXYNOS_BOOT_VECTOR_ADDR);
-   __raw_writel(flags, EXYNOS_BOOT_VECTOR_FLAG);
-}
-
-void exynos_enter_aftr(void)
-{
-   exynos_set_wakeupmask(0xff3e);
-   exynos_cpu_set_boot_vector(S5P_CHECK_AFTR);
-   /* Set value of power down register for aftr mode */
-   exynos_sys_powerdown_conf(SYS_AFTR);
-}
-
 /* For Cortex-A9 Diagnostic and Power control register */
 static unsigned int save_arm_register[2];
 
@@ -173,6 +153,82 @@ static void exynos_cpu_restore_register(
  : cc);
 }
 
+static void exynos_pm_central_suspend(void)
+{
+   unsigned long tmp;
+
+   /* Setting Central Sequence Register for power down mode */
+   tmp = pmu_raw_readl(S5P_CENTRAL_SEQ_CONFIGURATION);
+   tmp = ~S5P_CENTRAL_LOWPWR_CFG;
+   pmu_raw_writel(tmp, S5P_CENTRAL_SEQ_CONFIGURATION);
+}
+
+static int exynos_pm_central_resume(void)
+{
+   unsigned long tmp;
+
+   /*
+* If PMU failed while entering sleep mode, WFI will be
+* ignored by PMU and then exiting cpu_do_idle().
+* S5P_CENTRAL_LOWPWR_CFG bit will not be set automatically
+* in this situation.
+*/
+   tmp = pmu_raw_readl(S5P_CENTRAL_SEQ_CONFIGURATION);
+   if (!(tmp  S5P_CENTRAL_LOWPWR_CFG)) {
+   tmp |= S5P_CENTRAL_LOWPWR_CFG;
+   pmu_raw_writel(tmp, S5P_CENTRAL_SEQ_CONFIGURATION);
+   /* clear the wakeup state register */
+   pmu_raw_writel(0x0, S5P_WAKEUP_STAT);
+   /* No need to perform below restore code */
+   return -1;
+   }
+
+   return 0;
+}
+
+/* Ext-GIC nIRQ/nFIQ is the only wakeup source in AFTR */
+static void exynos_set_wakeupmask(long mask)
+{
+   pmu_raw_writel(mask, S5P_WAKEUP_MASK);
+}
+
+static void exynos_cpu_set_boot_vector(long flags)
+{
+   __raw_writel(virt_to_phys(exynos_cpu_resume), EXYNOS_BOOT_VECTOR_ADDR);
+   __raw_writel(flags, EXYNOS_BOOT_VECTOR_FLAG);
+}
+
+static int exynos_aftr_finisher(unsigned long flags)
+{
+   exynos_set_wakeupmask(0xff3e);
+   exynos_cpu_set_boot_vector(S5P_CHECK_AFTR);
+   /* Set value of power down register for aftr mode */
+   exynos_sys_powerdown_conf(SYS_AFTR);
+   cpu_do_idle();
+
+   return 1;
+}
+
+void exynos_enter_aftr(void)
+{
+   cpu_pm_enter();
+
+   exynos_pm_central_suspend();
+   if (read_cpuid_part() == ARM_CPU_PART_CORTEX_A9)
+   exynos_cpu_save_register();
+
+   cpu_suspend(0, exynos_aftr_finisher);
+
+   if (read_cpuid_part() == ARM_CPU_PART_CORTEX_A9) {
+   scu_enable(S5P_VA_SCU);
+   exynos_cpu_restore_register();
+   }
+
+   exynos_pm_central_resume();
+
+   cpu_pm_exit();
+}
+
 static int exynos_cpu_suspend(unsigned long arg)
 {
 #ifdef CONFIG_CACHE_L2X0
@@ -217,16 +273,6 @@ static void exynos_pm_prepare(void)
pmu_raw_writel(virt_to_phys(exynos_cpu_resume), S5P_INFORM0);
 }
 
-static void 

[PATCH v5 5/5] ARM: EXYNOS: cpuidle: allow driver usage on Exynos4x12 SoCs

2014-08-05 Thread Bartlomiej Zolnierkiewicz
Register cpuidle platform device on Exynos4x12 SoCs allowing EXYNOS
cpuidle driver usage on these SoCs.

AFTR mode reduces power consumption on Trats2 board (Exynos4412 SoC
with secure firmware enabled) by ~12% when EXYNOS cpuidle driver is
enabled (in both cases the default exynos_defconfig config is used
and CPU1-3 are offlined).

Signed-off-by: Bartlomiej Zolnierkiewicz b.zolnier...@samsung.com
Acked-by: Kyungmin Park kyungmin.p...@samsung.com
---
 arch/arm/mach-exynos/exynos.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-exynos/exynos.c b/arch/arm/mach-exynos/exynos.c
index 6a24e11..15cf86d 100644
--- a/arch/arm/mach-exynos/exynos.c
+++ b/arch/arm/mach-exynos/exynos.c
@@ -317,7 +317,9 @@ static void __init exynos_dt_machine_init(void)
exynos_sysram_init();
 
if (of_machine_is_compatible(samsung,exynos4210) ||
-   of_machine_is_compatible(samsung,exynos5250))
+   of_machine_is_compatible(samsung,exynos4212) ||
+   of_machine_is_compatible(samsung,exynos4412) ||
+   of_machine_is_compatible(samsung,exynos5250))
platform_device_register(exynos_cpuidle);
 
platform_device_register_simple(exynos-cpufreq, -1, NULL, 0);
-- 
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 v5 4/5] ARM: EXYNOS: PM: fix register setup for AFTR mode code

2014-08-05 Thread Bartlomiej Zolnierkiewicz
Add S5P_CENTRAL_SEQ_OPTION register setup to cpuidle AFTR mode code
by moving the relevant code from exynos_pm_suspend() (used only by
suspend) to exynos_pm_central_suspend() (used by both suspend and
AFTR).  Without this setup AFTR mode doesn't show any benefit over
WFI one (at least on Exynos4412 SoC).  When this setup is applied
AFTR mode reduces power consumption by ~12% (as measured on Trats2
board).

This change is a preparation for adding secure firmware support to
EXYNOS cpuidle driver.

Signed-off-by: Bartlomiej Zolnierkiewicz b.zolnier...@samsung.com
Acked-by: Kyungmin Park kyungmin.p...@samsung.com
---
 arch/arm/mach-exynos/pm.c | 11 ---
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/arch/arm/mach-exynos/pm.c b/arch/arm/mach-exynos/pm.c
index e0b6885..3cee123 100644
--- a/arch/arm/mach-exynos/pm.c
+++ b/arch/arm/mach-exynos/pm.c
@@ -169,6 +169,10 @@ static void exynos_pm_central_suspend(void)
tmp = pmu_raw_readl(S5P_CENTRAL_SEQ_CONFIGURATION);
tmp = ~S5P_CENTRAL_LOWPWR_CFG;
pmu_raw_writel(tmp, S5P_CENTRAL_SEQ_CONFIGURATION);
+
+   /* Setting SEQ_OPTION register */
+   pmu_raw_writel(S5P_USE_STANDBY_WFI0 | S5P_USE_STANDBY_WFE0,
+  S5P_CENTRAL_SEQ_OPTION);
 }
 
 static int exynos_pm_central_resume(void)
@@ -291,15 +295,8 @@ static void exynos_pm_prepare(void)
 
 static int exynos_pm_suspend(void)
 {
-   unsigned long tmp;
-
exynos_pm_central_suspend();
 
-   /* Setting SEQ_OPTION register */
-
-   tmp = (S5P_USE_STANDBY_WFI0 | S5P_USE_STANDBY_WFE0);
-   pmu_raw_writel(tmp, S5P_CENTRAL_SEQ_OPTION);
-
if (read_cpuid_part() == ARM_CPU_PART_CORTEX_A9)
exynos_cpu_save_register();
 
-- 
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 v5 3/5] ARM: EXYNOS: cpuidle: add secure firmware support to AFTR mode code

2014-08-05 Thread Bartlomiej Zolnierkiewicz
* Move cp15 registers saving to exynos_save_cp15() helper and add
  additional helper usage to do_idle firmware method.

* Use resume firmware method instead of exynos_cpu_restore_register()
  and skip exynos_cpu_save_register() on boards with secure firmware
  enabled.

* Use sysram_ns_base_addr + 0x24/0x20 addresses instead of the default
  ones used by exynos_cpu_set_boot_vector() on boards with secure
  firmware enabled.

* Use do_idle firmware method instead of cpu_do_idle() on boards with
  secure firmware enabled.

Signed-off-by: Bartlomiej Zolnierkiewicz b.zolnier...@samsung.com
Acked-by: Kyungmin Park kyungmin.p...@samsung.com
---
 arch/arm/mach-exynos/firmware.c | 24 +---
 arch/arm/mach-exynos/pm.c   | 17 -
 2 files changed, 29 insertions(+), 12 deletions(-)

diff --git a/arch/arm/mach-exynos/firmware.c b/arch/arm/mach-exynos/firmware.c
index e57b7c3..2c5bc6b 100644
--- a/arch/arm/mach-exynos/firmware.c
+++ b/arch/arm/mach-exynos/firmware.c
@@ -25,13 +25,28 @@
 #include smc.h
 
 #define EXYNOS_SLEEP_MAGIC 0x0bad
+#define EXYNOS_AFTR_MAGIC  0xfcba0d10
 #define EXYNOS_BOOT_ADDR   0x8
 #define EXYNOS_BOOT_FLAG   0xc
 
+static void exynos_save_cp15(void)
+{
+   /* Save Power control and Diagnostic registers */
+   asm (mrc p15, 0, %0, c15, c0, 0\n
+mrc p15, 0, %1, c15, c0, 1\n
+: =r (cp15_save_power), =r (cp15_save_diag)
+: : cc);
+}
+
 static int exynos_do_idle(unsigned long mode)
 {
switch (mode) {
case FW_DO_IDLE_AFTR:
+   if (read_cpuid_part() == ARM_CPU_PART_CORTEX_A9)
+   exynos_save_cp15();
+   __raw_writel(virt_to_phys(exynos_cpu_resume_ns),
+sysram_ns_base_addr + 0x24);
+   __raw_writel(EXYNOS_AFTR_MAGIC, sysram_ns_base_addr + 0x20);
exynos_smc(SMC_CMD_CPU0AFTR, 0, 0, 0);
break;
case FW_DO_IDLE_SLEEP:
@@ -96,13 +111,8 @@ static int exynos_cpu_suspend(unsigned long arg)
 
 static int exynos_suspend(void)
 {
-   if (read_cpuid_part() == ARM_CPU_PART_CORTEX_A9) {
-   /* Save Power control and Diagnostic registers */
-   asm (mrc p15, 0, %0, c15, c0, 0\n
-   mrc p15, 0, %1, c15, c0, 1\n
-   : =r (cp15_save_power), =r (cp15_save_diag)
-   : : cc);
-   }
+   if (read_cpuid_part() == ARM_CPU_PART_CORTEX_A9)
+   exynos_save_cp15();
 
writel(EXYNOS_SLEEP_MAGIC, sysram_ns_base_addr + EXYNOS_BOOT_FLAG);
writel(virt_to_phys(exynos_cpu_resume_ns),
diff --git a/arch/arm/mach-exynos/pm.c b/arch/arm/mach-exynos/pm.c
index 78e50ed..e0b6885 100644
--- a/arch/arm/mach-exynos/pm.c
+++ b/arch/arm/mach-exynos/pm.c
@@ -209,11 +209,19 @@ static void exynos_cpu_set_boot_vector(long flags)
 
 static int exynos_aftr_finisher(unsigned long flags)
 {
+   int ret;
+
exynos_set_wakeupmask(0xff3e);
-   exynos_cpu_set_boot_vector(S5P_CHECK_AFTR);
/* Set value of power down register for aftr mode */
exynos_sys_powerdown_conf(SYS_AFTR);
-   cpu_do_idle();
+
+   ret = call_firmware_op(do_idle, FW_DO_IDLE_AFTR);
+   if (ret == -ENOSYS) {
+   if (read_cpuid_part() == ARM_CPU_PART_CORTEX_A9)
+   exynos_cpu_save_register();
+   exynos_cpu_set_boot_vector(S5P_CHECK_AFTR);
+   cpu_do_idle();
+   }
 
return 1;
 }
@@ -223,14 +231,13 @@ void exynos_enter_aftr(void)
cpu_pm_enter();
 
exynos_pm_central_suspend();
-   if (read_cpuid_part() == ARM_CPU_PART_CORTEX_A9)
-   exynos_cpu_save_register();
 
cpu_suspend(0, exynos_aftr_finisher);
 
if (read_cpuid_part() == ARM_CPU_PART_CORTEX_A9) {
scu_enable(S5P_VA_SCU);
-   exynos_cpu_restore_register();
+   if (call_firmware_op(resume) == -ENOSYS)
+   exynos_cpu_restore_register();
}
 
exynos_pm_central_resume();
-- 
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 v5 2/5] ARM: EXYNOS: add AFTR mode support to firmware do_idle method

2014-08-05 Thread Bartlomiej Zolnierkiewicz
On some platforms (i.e. EXYNOS ones) more than one idle mode is
available and we need to distinguish them in firmware do_idle method.

Add mode parameter to do_idle firmware method and AFTR mode support
to EXYNOS do_idle implementation.

This change is a preparation for adding secure firmware support to
EXYNOS cpuidle driver.

This patch shouldn't cause any functionality changes (please note
that do_idle firmware method is unused currently).

Signed-off-by: Bartlomiej Zolnierkiewicz b.zolnier...@samsung.com
Acked-by: Kyungmin Park kyungmin.p...@samsung.com
---
 arch/arm/include/asm/firmware.h |  2 +-
 arch/arm/mach-exynos/common.h   |  5 +
 arch/arm/mach-exynos/firmware.c | 10 --
 3 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/arch/arm/include/asm/firmware.h b/arch/arm/include/asm/firmware.h
index 5904f59..89aefe1 100644
--- a/arch/arm/include/asm/firmware.h
+++ b/arch/arm/include/asm/firmware.h
@@ -28,7 +28,7 @@ struct firmware_ops {
/*
 * Enters CPU idle mode
 */
-   int (*do_idle)(void);
+   int (*do_idle)(unsigned long mode);
/*
 * Sets boot address of specified physical CPU
 */
diff --git a/arch/arm/mach-exynos/common.h b/arch/arm/mach-exynos/common.h
index c218200..2d830df 100644
--- a/arch/arm/mach-exynos/common.h
+++ b/arch/arm/mach-exynos/common.h
@@ -119,6 +119,11 @@ extern void __iomem *sysram_base_addr;
 extern void __iomem *pmu_base_addr;
 void exynos_sysram_init(void);
 
+enum {
+   FW_DO_IDLE_SLEEP,
+   FW_DO_IDLE_AFTR,
+};
+
 void exynos_firmware_init(void);
 
 extern u32 exynos_get_eint_wake_mask(void);
diff --git a/arch/arm/mach-exynos/firmware.c b/arch/arm/mach-exynos/firmware.c
index f5e626d..e57b7c3 100644
--- a/arch/arm/mach-exynos/firmware.c
+++ b/arch/arm/mach-exynos/firmware.c
@@ -28,9 +28,15 @@
 #define EXYNOS_BOOT_ADDR   0x8
 #define EXYNOS_BOOT_FLAG   0xc
 
-static int exynos_do_idle(void)
+static int exynos_do_idle(unsigned long mode)
 {
-   exynos_smc(SMC_CMD_SLEEP, 0, 0, 0);
+   switch (mode) {
+   case FW_DO_IDLE_AFTR:
+   exynos_smc(SMC_CMD_CPU0AFTR, 0, 0, 0);
+   break;
+   case FW_DO_IDLE_SLEEP:
+   exynos_smc(SMC_CMD_SLEEP, 0, 0, 0);
+   }
return 0;
 }
 
-- 
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 v5 1/5] ARM: EXYNOS: PM: replace EXYNOS_BOOT_VECTOR_* macros by static inlines

2014-08-05 Thread Bartlomiej Zolnierkiewicz
Replace EXYNOS_BOOT_VECTOR_ADDR and EXYNOS_BOOT_VECTOR_FLAG macros
by exynos_boot_vector_addr() and exynos_boot_vector_flag() static
inlines.

This patch shouldn't cause any functionality changes.

Signed-off-by: Bartlomiej Zolnierkiewicz b.zolnier...@samsung.com
Acked-by: Kyungmin Park kyungmin.p...@samsung.com
Acked-by: Daniel Lezcano daniel.lezc...@linaro.org
---
 arch/arm/mach-exynos/pm.c | 32 
 1 file changed, 20 insertions(+), 12 deletions(-)

diff --git a/arch/arm/mach-exynos/pm.c b/arch/arm/mach-exynos/pm.c
index 454c1cc..78e50ed 100644
--- a/arch/arm/mach-exynos/pm.c
+++ b/arch/arm/mach-exynos/pm.c
@@ -101,16 +101,23 @@ static int exynos_irq_set_wake(struct irq_data *data, 
unsigned int state)
return -ENOENT;
 }
 
-#define EXYNOS_BOOT_VECTOR_ADDR(samsung_rev() == EXYNOS4210_REV_1_1 ? \
-   pmu_base_addr + S5P_INFORM7 : \
-   (samsung_rev() == EXYNOS4210_REV_1_0 ? \
-   (sysram_base_addr + 0x24) : \
-   pmu_base_addr + S5P_INFORM0))
-#define EXYNOS_BOOT_VECTOR_FLAG(samsung_rev() == EXYNOS4210_REV_1_1 ? \
-   pmu_base_addr + S5P_INFORM6 : \
-   (samsung_rev() == EXYNOS4210_REV_1_0 ? \
-   (sysram_base_addr + 0x20) : \
-   pmu_base_addr + S5P_INFORM1))
+static inline void __iomem *exynos_boot_vector_addr(void)
+{
+   if (samsung_rev() == EXYNOS4210_REV_1_1)
+   return pmu_base_addr + S5P_INFORM7;
+   else if (samsung_rev() == EXYNOS4210_REV_1_0)
+   return sysram_base_addr + 0x24;
+   return pmu_base_addr + S5P_INFORM0;
+}
+
+static inline void __iomem *exynos_boot_vector_flag(void)
+{
+   if (samsung_rev() == EXYNOS4210_REV_1_1)
+   return pmu_base_addr + S5P_INFORM6;
+   else if (samsung_rev() == EXYNOS4210_REV_1_0)
+   return sysram_base_addr + 0x20;
+   return pmu_base_addr + S5P_INFORM1;
+}
 
 #define S5P_CHECK_AFTR  0xFCBA0D10
 #define S5P_CHECK_SLEEP 0x0BAD
@@ -195,8 +202,9 @@ static void exynos_set_wakeupmask(long mask)
 
 static void exynos_cpu_set_boot_vector(long flags)
 {
-   __raw_writel(virt_to_phys(exynos_cpu_resume), EXYNOS_BOOT_VECTOR_ADDR);
-   __raw_writel(flags, EXYNOS_BOOT_VECTOR_FLAG);
+   __raw_writel(virt_to_phys(exynos_cpu_resume),
+exynos_boot_vector_addr());
+   __raw_writel(flags, exynos_boot_vector_flag());
 }
 
 static int exynos_aftr_finisher(unsigned long flags)
-- 
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 v5 0/5] ARM: EXYNOS: cpuidle: fix AFTR mode on boards with secure firmware enabled

2014-08-05 Thread Bartlomiej Zolnierkiewicz
Hi,

This patch series adds support for AFTR idle mode on boards with
secure firmware enabled and allows EXYNOS cpuidle driver usage on
Exynos4x12 SoCs.

It has been tested on Trats2 board (using Exynos4412 SoC with secure
firmware enabled) on which AFTR mode reduces power consumption by ~12%
when EXYNOS cpuidle driver is enabled (in both cases the default
exynos_defconfig config is used and CPU1-3 are offlined).

Depends on:
- next-20140804 branch of linux-next kernel tree
- [PATCH v5][next-20140804] ARM: EXYNOS: Fix suspend/resume sequences
  (http://www.mail-archive.com/linux-samsung-soc@vger.kernel.org/msg35262.html)
- [PATCH v2 0/2] Firmware-assisted suspend/resume of Exynos SoCs
  (http://www.mail-archive.com/linux-samsung-soc@vger.kernel.org/msg34282.html)

Changes since v4:
- rebased on top of next-20140804 +
  [PATCH v5][next-20140804] ARM: EXYNOS: Fix suspend/resume sequences
  (http://www.mail-archive.com/linux-samsung-soc@vger.kernel.org/msg35262.html)
  [PATCH v2 0/2] Firmware-assisted suspend/resume of Exynos SoCs
  (http://www.mail-archive.com/linux-samsung-soc@vger.kernel.org/msg34282.html)
- call exynos_save_cp15() only on A9 type core (this is needed for the future
  Exynos3250 SoC support)

Changes since v3:
- rebased on top of next-20140804 +
  [PATCH v4][next-20140804] ARM: EXYNOS: Fix suspend/resume sequences
  (http://www.mail-archive.com/linux-samsung-soc@vger.kernel.org/msg35192.html)
  [PATCH v2 0/2] Firmware-assisted suspend/resume of Exynos SoCs
  (http://www.mail-archive.com/linux-samsung-soc@vger.kernel.org/msg34282.html)
- (re-)added patch fixing S5P_CENTRAL_SEQ_OPTION register setup

Changes since v2:
- rebased on top of next-20140708 +
  [PATCH 5/6] ARM: EXYNOS: Fix suspend/resume sequencies
  (http://www.mail-archive.com/linux-samsung-soc@vger.kernel.org/msg32809.html)
  [with rejects fixed]
  [PATCH 6/6] ARM: EXYNOS: Register cpuidle device only on Exynos4210 and 5250
  (http://www.mail-archive.com/linux-samsung-soc@vger.kernel.org/msg32808.html)
  [PATCH 0/2] Firmware-assisted suspend/resume of Exynos SoCs
  (http://www.mail-archive.com/linux-samsung-soc@vger.kernel.org/msg32991.html)
  [with rejects fixed in patch #2]
- addressed review comments from Tomasz Figa and Daniel Lezcano

Changes since v1:
- synced against next-20140602
- added missing Acked-by-s

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


Bartlomiej Zolnierkiewicz (5):
  ARM: EXYNOS: PM: replace EXYNOS_BOOT_VECTOR_* macros by static inlines
  ARM: EXYNOS: add AFTR mode support to firmware do_idle method
  ARM: EXYNOS: cpuidle: add secure firmware support to AFTR mode code
  ARM: EXYNOS: PM: fix register setup for AFTR mode code
  ARM: EXYNOS: cpuidle: allow driver usage on Exynos4x12 SoCs

 arch/arm/include/asm/firmware.h |  2 +-
 arch/arm/mach-exynos/common.h   |  5 
 arch/arm/mach-exynos/exynos.c   |  4 ++-
 arch/arm/mach-exynos/firmware.c | 34 ---
 arch/arm/mach-exynos/pm.c   | 60 -
 5 files changed, 70 insertions(+), 35 deletions(-)

-- 
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 v5 0/5] ARM: EXYNOS: cpuidle: fix AFTR mode on boards with secure firmware enabled

2014-08-05 Thread Daniel Lezcano

On 08/05/2014 03:34 PM, Bartlomiej Zolnierkiewicz wrote:

Hi,

This patch series adds support for AFTR idle mode on boards with
secure firmware enabled and allows EXYNOS cpuidle driver usage on
Exynos4x12 SoCs.

It has been tested on Trats2 board (using Exynos4412 SoC with secure
firmware enabled) on which AFTR mode reduces power consumption by ~12%
when EXYNOS cpuidle driver is enabled (in both cases the default
exynos_defconfig config is used and CPU1-3 are offlined).


Hi Bartlomiej,

I tested your patchset on an odroid-u2. When the cpuidle driver is 
enabled and the cpu1-3 are offlined, the kernel hangs.


If I disable the AFTR state on cpuidle, and offline the 1-3, it works as 
expected. So there is something wrong with the AFTR on the odroid board.



Depends on:
- next-20140804 branch of linux-next kernel tree
- [PATCH v5][next-20140804] ARM: EXYNOS: Fix suspend/resume sequences
   (http://www.mail-archive.com/linux-samsung-soc@vger.kernel.org/msg35262.html)
- [PATCH v2 0/2] Firmware-assisted suspend/resume of Exynos SoCs
   (http://www.mail-archive.com/linux-samsung-soc@vger.kernel.org/msg34282.html)

Changes since v4:
- rebased on top of next-20140804 +
   [PATCH v5][next-20140804] ARM: EXYNOS: Fix suspend/resume sequences
   (http://www.mail-archive.com/linux-samsung-soc@vger.kernel.org/msg35262.html)
   [PATCH v2 0/2] Firmware-assisted suspend/resume of Exynos SoCs
   (http://www.mail-archive.com/linux-samsung-soc@vger.kernel.org/msg34282.html)
- call exynos_save_cp15() only on A9 type core (this is needed for the future
   Exynos3250 SoC support)

Changes since v3:
- rebased on top of next-20140804 +
   [PATCH v4][next-20140804] ARM: EXYNOS: Fix suspend/resume sequences
   (http://www.mail-archive.com/linux-samsung-soc@vger.kernel.org/msg35192.html)
   [PATCH v2 0/2] Firmware-assisted suspend/resume of Exynos SoCs
   (http://www.mail-archive.com/linux-samsung-soc@vger.kernel.org/msg34282.html)
- (re-)added patch fixing S5P_CENTRAL_SEQ_OPTION register setup

Changes since v2:
- rebased on top of next-20140708 +
   [PATCH 5/6] ARM: EXYNOS: Fix suspend/resume sequencies
   (http://www.mail-archive.com/linux-samsung-soc@vger.kernel.org/msg32809.html)
   [with rejects fixed]
   [PATCH 6/6] ARM: EXYNOS: Register cpuidle device only on Exynos4210 and 5250
   (http://www.mail-archive.com/linux-samsung-soc@vger.kernel.org/msg32808.html)
   [PATCH 0/2] Firmware-assisted suspend/resume of Exynos SoCs
   (http://www.mail-archive.com/linux-samsung-soc@vger.kernel.org/msg32991.html)
   [with rejects fixed in patch #2]
- addressed review comments from Tomasz Figa and Daniel Lezcano

Changes since v1:
- synced against next-20140602
- added missing Acked-by-s

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


Bartlomiej Zolnierkiewicz (5):
   ARM: EXYNOS: PM: replace EXYNOS_BOOT_VECTOR_* macros by static inlines
   ARM: EXYNOS: add AFTR mode support to firmware do_idle method
   ARM: EXYNOS: cpuidle: add secure firmware support to AFTR mode code
   ARM: EXYNOS: PM: fix register setup for AFTR mode code
   ARM: EXYNOS: cpuidle: allow driver usage on Exynos4x12 SoCs

  arch/arm/include/asm/firmware.h |  2 +-
  arch/arm/mach-exynos/common.h   |  5 
  arch/arm/mach-exynos/exynos.c   |  4 ++-
  arch/arm/mach-exynos/firmware.c | 34 ---
  arch/arm/mach-exynos/pm.c   | 60 -
  5 files changed, 70 insertions(+), 35 deletions(-)




--
 http://www.linaro.org/ Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  http://www.facebook.com/pages/Linaro Facebook |
http://twitter.com/#!/linaroorg Twitter |
http://www.linaro.org/linaro-blog/ 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 v5 0/5] ARM: EXYNOS: cpuidle: fix AFTR mode on boards with secure firmware enabled

2014-08-05 Thread Daniel Lezcano

On 08/05/2014 03:34 PM, Bartlomiej Zolnierkiewicz wrote:

Hi,

This patch series adds support for AFTR idle mode on boards with
secure firmware enabled and allows EXYNOS cpuidle driver usage on
Exynos4x12 SoCs.

It has been tested on Trats2 board (using Exynos4412 SoC with secure
firmware enabled) on which AFTR mode reduces power consumption by ~12%
when EXYNOS cpuidle driver is enabled (in both cases the default
exynos_defconfig config is used and CPU1-3 are offlined).


As a sidenote:

On my odroid-U2:
 * 4 cpus online - 130 mA
 * 3 cpus online - 164 mA
 * 2 cpus online - 160 mA
 * 1 cpu online  - 157 mA

So were are consuming more when there are unplugged cpu ... any ideas ?

Thanks !

  -- Daniel


Depends on:
- next-20140804 branch of linux-next kernel tree
- [PATCH v5][next-20140804] ARM: EXYNOS: Fix suspend/resume sequences
   (http://www.mail-archive.com/linux-samsung-soc@vger.kernel.org/msg35262.html)
- [PATCH v2 0/2] Firmware-assisted suspend/resume of Exynos SoCs
   (http://www.mail-archive.com/linux-samsung-soc@vger.kernel.org/msg34282.html)

Changes since v4:
- rebased on top of next-20140804 +
   [PATCH v5][next-20140804] ARM: EXYNOS: Fix suspend/resume sequences
   (http://www.mail-archive.com/linux-samsung-soc@vger.kernel.org/msg35262.html)
   [PATCH v2 0/2] Firmware-assisted suspend/resume of Exynos SoCs
   (http://www.mail-archive.com/linux-samsung-soc@vger.kernel.org/msg34282.html)
- call exynos_save_cp15() only on A9 type core (this is needed for the future
   Exynos3250 SoC support)

Changes since v3:
- rebased on top of next-20140804 +
   [PATCH v4][next-20140804] ARM: EXYNOS: Fix suspend/resume sequences
   (http://www.mail-archive.com/linux-samsung-soc@vger.kernel.org/msg35192.html)
   [PATCH v2 0/2] Firmware-assisted suspend/resume of Exynos SoCs
   (http://www.mail-archive.com/linux-samsung-soc@vger.kernel.org/msg34282.html)
- (re-)added patch fixing S5P_CENTRAL_SEQ_OPTION register setup

Changes since v2:
- rebased on top of next-20140708 +
   [PATCH 5/6] ARM: EXYNOS: Fix suspend/resume sequencies
   (http://www.mail-archive.com/linux-samsung-soc@vger.kernel.org/msg32809.html)
   [with rejects fixed]
   [PATCH 6/6] ARM: EXYNOS: Register cpuidle device only on Exynos4210 and 5250
   (http://www.mail-archive.com/linux-samsung-soc@vger.kernel.org/msg32808.html)
   [PATCH 0/2] Firmware-assisted suspend/resume of Exynos SoCs
   (http://www.mail-archive.com/linux-samsung-soc@vger.kernel.org/msg32991.html)
   [with rejects fixed in patch #2]
- addressed review comments from Tomasz Figa and Daniel Lezcano

Changes since v1:
- synced against next-20140602
- added missing Acked-by-s

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


Bartlomiej Zolnierkiewicz (5):
   ARM: EXYNOS: PM: replace EXYNOS_BOOT_VECTOR_* macros by static inlines
   ARM: EXYNOS: add AFTR mode support to firmware do_idle method
   ARM: EXYNOS: cpuidle: add secure firmware support to AFTR mode code
   ARM: EXYNOS: PM: fix register setup for AFTR mode code
   ARM: EXYNOS: cpuidle: allow driver usage on Exynos4x12 SoCs

  arch/arm/include/asm/firmware.h |  2 +-
  arch/arm/mach-exynos/common.h   |  5 
  arch/arm/mach-exynos/exynos.c   |  4 ++-
  arch/arm/mach-exynos/firmware.c | 34 ---
  arch/arm/mach-exynos/pm.c   | 60 -
  5 files changed, 70 insertions(+), 35 deletions(-)




--
 http://www.linaro.org/ Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  http://www.facebook.com/pages/Linaro Facebook |
http://twitter.com/#!/linaroorg Twitter |
http://www.linaro.org/linaro-blog/ 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 RESEND] usb: ehci/ohci-exynos: Fix PHY getting sequence

2014-08-05 Thread Alan Stern
On Tue, 5 Aug 2014, Vivek Gautam wrote:

 Since we want to keep support for both older usb-phys as well as the
 newer generic phys, lets first get the generic PHYs and fallback to
 older USB-PHYs only when we fail to get the former.
 This should fix the issue with ehci-exynos and ohci-exynos, wherein
 in the absence of SAMSUNG_USB2PHY config symbol, we end up getting
 the NOP_USB_XCEIV phy when the same is enabled. And thus the PHYs
 are not configured properly.
 
 Reported-by: Sachin Kamat sachin.ka...@samsung.com
 Signed-off-by: Vivek Gautam gautam.vi...@samsung.com
 Cc: Alan Stern st...@rowland.harvard.edu
 Cc: Jingoo Han jg1@samsung.com
 ---
 
 Based on 'usb-next' branch.
 Resending it after adding 'Reported-by' tag.
 
  drivers/usb/host/ehci-exynos.c |   40 +-
  drivers/usb/host/ohci-exynos.c |   47 
 +++-
  2 files changed, 42 insertions(+), 45 deletions(-)
 
 diff --git a/drivers/usb/host/ehci-exynos.c b/drivers/usb/host/ehci-exynos.c
 index cda0a2f..2eed9a4 100644
 --- a/drivers/usb/host/ehci-exynos.c
 +++ b/drivers/usb/host/ehci-exynos.c
 @@ -62,18 +62,6 @@ static int exynos_ehci_get_phy(struct device *dev,
   int phy_number;
   int ret = 0;
  
 - exynos_ehci-phy = devm_usb_get_phy(dev, USB_PHY_TYPE_USB2);
 - if (IS_ERR(exynos_ehci-phy)) {
 - ret = PTR_ERR(exynos_ehci-phy);
 - if (ret != -ENXIO  ret != -ENODEV) {
 - dev_err(dev, no usb2 phy configured\n);
 - return ret;
 - }
 - dev_dbg(dev, Failed to get usb2 phy\n);
 - } else {
 - exynos_ehci-otg = exynos_ehci-phy-otg;
 - }
 -
   for_each_available_child_of_node(dev-of_node, child) {
   ret = of_property_read_u32(child, reg, phy_number);
   if (ret) {
 @@ -90,15 +78,27 @@ static int exynos_ehci_get_phy(struct device *dev,

What about the code that you skipped here?  Suppose the 
of_property_read_32() call returns an error.  Do you then want to abort 
the whole thing, or should you go on to try the old usb_phy?

Alan Stern

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


Re: [PATCH v5 0/5] ARM: EXYNOS: cpuidle: fix AFTR mode on boards with secure firmware enabled

2014-08-05 Thread Krzysztof Kozlowski

On 05.08.2014 16:03, Daniel Lezcano wrote:

On 08/05/2014 03:34 PM, Bartlomiej Zolnierkiewicz wrote:

Hi,

This patch series adds support for AFTR idle mode on boards with
secure firmware enabled and allows EXYNOS cpuidle driver usage on
Exynos4x12 SoCs.

It has been tested on Trats2 board (using Exynos4412 SoC with secure
firmware enabled) on which AFTR mode reduces power consumption by ~12%
when EXYNOS cpuidle driver is enabled (in both cases the default
exynos_defconfig config is used and CPU1-3 are offlined).


As a sidenote:

On my odroid-U2:
  * 4 cpus online - 130 mA
  * 3 cpus online - 164 mA
  * 2 cpus online - 160 mA
  * 1 cpu online  - 157 mA

So were are consuming more when there are unplugged cpu ... any ideas ?


On which tree are you testing? Current next has ARMCLK down feature 
enabled. ARMCLK down may stop working after hotunplugging CPU:

http://www.spinics.net/lists/arm-kernel/msg352890.html

That was observed especially on Exynos4212 where ARMCLK down stops 
working permanently. On Trats2 (Exynos4412) the clock down stopped only 
a for short period after disabling CPU.


Best regards,
Krzysztof



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


Re: [PATCH v5 1/3] ARM: EXYNOS: Move code from hotplug.c to platsmp.c

2014-08-05 Thread Daniel Lezcano

On 08/05/2014 12:43 PM, Krzysztof Kozlowski wrote:

Cleanup a little the SMP/hotplug code for Exynos by:
1. Moving completely all functions from hotplug.c into the platsmp.c;
2. Deleting the hotplug.c file.

After recent cleanups (e.g. 75ad2ab28f0f ARM: EXYNOS: use
v7_exit_coherency_flush macro for cache disabling) there was only CPU
power down related code in hotplug.c file. Keeping this file does not
give any benefits.

The commit only moves code around with one additional observable change:
the hotplug.c was compiled with custom CFLAGS (-march=armv7-a). These
CFLAGS are not necessary any more.


What is the benefit of moving this code around ?

Usually the cpu hotplug code is located in hotplug.c for most of the 
platforms, so why moving pm code inside platsmp ?



Signed-off-by: Krzysztof Kozlowski k.kozlow...@samsung.com
Reviewed-by: Tomasz Figa t.f...@samsung.com

---
Changes since v4:
1. Rebase on linux-next-20140804.
2. Add Reviewed-by Tomasz Figa.
---
  arch/arm/mach-exynos/Makefile  |  3 --
  arch/arm/mach-exynos/common.h  |  2 -
  arch/arm/mach-exynos/hotplug.c | 91 --
  arch/arm/mach-exynos/platsmp.c | 74 ++
  4 files changed, 74 insertions(+), 96 deletions(-)
  delete mode 100644 arch/arm/mach-exynos/hotplug.c

diff --git a/arch/arm/mach-exynos/Makefile b/arch/arm/mach-exynos/Makefile
index 788f26d21141..0095de99d703 100644
--- a/arch/arm/mach-exynos/Makefile
+++ b/arch/arm/mach-exynos/Makefile
@@ -21,9 +21,6 @@ obj-$(CONFIG_PM_GENERIC_DOMAINS) += pm_domains.o

  obj-$(CONFIG_SMP) += platsmp.o headsmp.o

-obj-$(CONFIG_HOTPLUG_CPU)  += hotplug.o
-CFLAGS_hotplug.o   += -march=armv7-a
-
  plus_sec := $(call as-instr,.arch_extension sec,+sec)
  AFLAGS_exynos-smc.o   :=-Wa,-march=armv7-a$(plus_sec)

diff --git a/arch/arm/mach-exynos/common.h b/arch/arm/mach-exynos/common.h
index 47b904b3b973..3d3e6af9d015 100644
--- a/arch/arm/mach-exynos/common.h
+++ b/arch/arm/mach-exynos/common.h
@@ -130,8 +130,6 @@ extern void exynos_cpu_resume(void);

  extern struct smp_operations exynos_smp_ops;

-extern void exynos_cpu_die(unsigned int cpu);
-
  /* PMU(Power Management Unit) support */

  #define PMU_TABLE_END (-1U)
diff --git a/arch/arm/mach-exynos/hotplug.c b/arch/arm/mach-exynos/hotplug.c
deleted file mode 100644
index 4d86961a7957..
--- a/arch/arm/mach-exynos/hotplug.c
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- *  Cloned from linux/arch/arm/mach-realview/hotplug.c
- *
- *  Copyright (C) 2002 ARM Ltd.
- *  All Rights Reserved
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
-*/
-
-#include linux/kernel.h
-#include linux/errno.h
-#include linux/smp.h
-#include linux/io.h
-
-#include asm/cacheflush.h
-#include asm/cp15.h
-#include asm/smp_plat.h
-
-#include common.h
-#include regs-pmu.h
-
-static inline void cpu_leave_lowpower(void)
-{
-   unsigned int v;
-
-   asm volatile(
-   mrc   p15, 0, %0, c1, c0, 0\n
- orr %0, %0, %1\n
- mcr p15, 0, %0, c1, c0, 0\n
- mrc p15, 0, %0, c1, c0, 1\n
- orr %0, %0, %2\n
- mcr p15, 0, %0, c1, c0, 1\n
- : =r (v)
- : Ir (CR_C), Ir (0x40)
- : cc);
-}
-
-static inline void platform_do_lowpower(unsigned int cpu, int *spurious)
-{
-   u32 mpidr = cpu_logical_map(cpu);
-   u32 core_id = MPIDR_AFFINITY_LEVEL(mpidr, 0);
-
-   for (;;) {
-
-   /* Turn the CPU off on next WFI instruction. */
-   exynos_cpu_power_down(core_id);
-
-   wfi();
-
-   if (pen_release == core_id) {
-   /*
-* OK, proper wakeup, we're done
-*/
-   break;
-   }
-
-   /*
-* Getting here, means that we have come out of WFI without
-* having been woken up - this shouldn't happen
-*
-* Just note it happening - when we're woken, we can report
-* its occurrence.
-*/
-   (*spurious)++;
-   }
-}
-
-/*
- * platform-specific code to shutdown a CPU
- *
- * Called with IRQs disabled
- */
-void __ref exynos_cpu_die(unsigned int cpu)
-{
-   int spurious = 0;
-
-   v7_exit_coherency_flush(louis);
-
-   platform_do_lowpower(cpu, spurious);
-
-   /*
-* bring this CPU back into the world of cache
-* coherency, and then restore interrupts
-*/
-   cpu_leave_lowpower();
-
-   if (spurious)
-   pr_warn(CPU%u: %u spurious wakeup calls\n, cpu, spurious);
-}
diff --git a/arch/arm/mach-exynos/platsmp.c b/arch/arm/mach-exynos/platsmp.c
index a9f1cf759949..a809f76c8160 100644
--- a/arch/arm/mach-exynos/platsmp.c
+++ 

Re: [PATCH v5 1/3] ARM: EXYNOS: Move code from hotplug.c to platsmp.c

2014-08-05 Thread Krzysztof Kozlowski
On wto, 2014-08-05 at 16:46 +0200, Daniel Lezcano wrote:
 On 08/05/2014 12:43 PM, Krzysztof Kozlowski wrote:
  Cleanup a little the SMP/hotplug code for Exynos by:
  1. Moving completely all functions from hotplug.c into the platsmp.c;
  2. Deleting the hotplug.c file.
 
  After recent cleanups (e.g. 75ad2ab28f0f ARM: EXYNOS: use
  v7_exit_coherency_flush macro for cache disabling) there was only CPU
  power down related code in hotplug.c file. Keeping this file does not
  give any benefits.
 
  The commit only moves code around with one additional observable change:
  the hotplug.c was compiled with custom CFLAGS (-march=armv7-a). These
  CFLAGS are not necessary any more.
 
 What is the benefit of moving this code around ?
 
 Usually the cpu hotplug code is located in hotplug.c for most of the 
 platforms, so why moving pm code inside platsmp ?

The benefits are:

1. Less dependencies, cleaner code because platsmp.c is the only user of
code located in hotplug.c. So the exynos_cpu_die() had to be declared in
common.h.

2. Less dependencies between modules after adding patch 3/3 [1] which
introduces exynos_set_delayed_reset_assertion() function. The
exynos_set_delayed_reset_assertion() is called by:
 - cpu_leave_power (hotplug.c)
 - platform_do_lowpower (hotplug.c)
 - exynos_boot_secondary (platsmp.c)

so merging everything into one file seemed simpler and cleaner.

However I do not insist on such solution. I'm merely interested in
getting the third patch into the kernel :) .

[1] http://www.spinics.net/lists/arm-kernel/msg352890.html

Best regards,
Krzysztof

 
  Signed-off-by: Krzysztof Kozlowski k.kozlow...@samsung.com
  Reviewed-by: Tomasz Figa t.f...@samsung.com
 
  ---
  Changes since v4:
  1. Rebase on linux-next-20140804.
  2. Add Reviewed-by Tomasz Figa.
  ---
arch/arm/mach-exynos/Makefile  |  3 --
arch/arm/mach-exynos/common.h  |  2 -
arch/arm/mach-exynos/hotplug.c | 91 
  --
arch/arm/mach-exynos/platsmp.c | 74 ++
4 files changed, 74 insertions(+), 96 deletions(-)
delete mode 100644 arch/arm/mach-exynos/hotplug.c
 
  diff --git a/arch/arm/mach-exynos/Makefile b/arch/arm/mach-exynos/Makefile
  index 788f26d21141..0095de99d703 100644
  --- a/arch/arm/mach-exynos/Makefile
  +++ b/arch/arm/mach-exynos/Makefile
  @@ -21,9 +21,6 @@ obj-$(CONFIG_PM_GENERIC_DOMAINS) += pm_domains.o
 
obj-$(CONFIG_SMP) += platsmp.o headsmp.o
 
  -obj-$(CONFIG_HOTPLUG_CPU)  += hotplug.o
  -CFLAGS_hotplug.o   += -march=armv7-a
  -
plus_sec := $(call as-instr,.arch_extension sec,+sec)
AFLAGS_exynos-smc.o   :=-Wa,-march=armv7-a$(plus_sec)
 
  diff --git a/arch/arm/mach-exynos/common.h b/arch/arm/mach-exynos/common.h
  index 47b904b3b973..3d3e6af9d015 100644
  --- a/arch/arm/mach-exynos/common.h
  +++ b/arch/arm/mach-exynos/common.h
  @@ -130,8 +130,6 @@ extern void exynos_cpu_resume(void);
 
extern struct smp_operations exynos_smp_ops;
 
  -extern void exynos_cpu_die(unsigned int cpu);
  -
/* PMU(Power Management Unit) support */
 
#define PMU_TABLE_END (-1U)
  diff --git a/arch/arm/mach-exynos/hotplug.c b/arch/arm/mach-exynos/hotplug.c
  deleted file mode 100644
  index 4d86961a7957..
  --- a/arch/arm/mach-exynos/hotplug.c
  +++ /dev/null
  @@ -1,91 +0,0 @@
  -/*
  - *  Cloned from linux/arch/arm/mach-realview/hotplug.c
  - *
  - *  Copyright (C) 2002 ARM Ltd.
  - *  All Rights Reserved
  - *
  - * This program is free software; you can redistribute it and/or modify
  - * it under the terms of the GNU General Public License version 2 as
  - * published by the Free Software Foundation.
  -*/
  -
  -#include linux/kernel.h
  -#include linux/errno.h
  -#include linux/smp.h
  -#include linux/io.h
  -
  -#include asm/cacheflush.h
  -#include asm/cp15.h
  -#include asm/smp_plat.h
  -
  -#include common.h
  -#include regs-pmu.h
  -
  -static inline void cpu_leave_lowpower(void)
  -{
  -   unsigned int v;
  -
  -   asm volatile(
  -   mrcp15, 0, %0, c1, c0, 0\n
  -  orr %0, %0, %1\n
  -  mcr p15, 0, %0, c1, c0, 0\n
  -  mrc p15, 0, %0, c1, c0, 1\n
  -  orr %0, %0, %2\n
  -  mcr p15, 0, %0, c1, c0, 1\n
  - : =r (v)
  - : Ir (CR_C), Ir (0x40)
  - : cc);
  -}
  -
  -static inline void platform_do_lowpower(unsigned int cpu, int *spurious)
  -{
  -   u32 mpidr = cpu_logical_map(cpu);
  -   u32 core_id = MPIDR_AFFINITY_LEVEL(mpidr, 0);
  -
  -   for (;;) {
  -
  -   /* Turn the CPU off on next WFI instruction. */
  -   exynos_cpu_power_down(core_id);
  -
  -   wfi();
  -
  -   if (pen_release == core_id) {
  -   /*
  -* OK, proper wakeup, we're done
  -*/
  -   break;
  -   }
  -
  -   /*
  -* Getting here, means that we have come out of WFI without
  -* having 

Re: [PATCH v5 0/5] ARM: EXYNOS: cpuidle: fix AFTR mode on boards with secure firmware enabled

2014-08-05 Thread Daniel Lezcano

On 08/05/2014 04:26 PM, Krzysztof Kozlowski wrote:

On 05.08.2014 16:03, Daniel Lezcano wrote:

On 08/05/2014 03:34 PM, Bartlomiej Zolnierkiewicz wrote:

Hi,

This patch series adds support for AFTR idle mode on boards with
secure firmware enabled and allows EXYNOS cpuidle driver usage on
Exynos4x12 SoCs.

It has been tested on Trats2 board (using Exynos4412 SoC with secure
firmware enabled) on which AFTR mode reduces power consumption by ~12%
when EXYNOS cpuidle driver is enabled (in both cases the default
exynos_defconfig config is used and CPU1-3 are offlined).


As a sidenote:

On my odroid-U2:
  * 4 cpus online - 130 mA
  * 3 cpus online - 164 mA
  * 2 cpus online - 160 mA
  * 1 cpu online  - 157 mA

So were are consuming more when there are unplugged cpu ... any ideas ?


On which tree are you testing? Current next has ARMCLK down feature
enabled. ARMCLK down may stop working after hotunplugging CPU:
http://www.spinics.net/lists/arm-kernel/msg352890.html

That was observed especially on Exynos4212 where ARMCLK down stops
working permanently. On Trats2 (Exynos4412) the clock down stopped only
a for short period after disabling CPU.


Hi Krzysztof,

I tested the patches you mentioned above on top of this patchset.

You are right this is directly related to the ARMCLK but the behavior 
may be not as you expect I think.


When I boot:

4 cpus online = 131 mA

Then I unplug one by one the cpus:

3 cpus online = 127 mA
2 cpus online = 123 mA
1 cpu online  = 120 mA

This is consistent.

But now, I online the cpus:

2 cpus online = 162 mA
3 cpus online = 165 mA
4 cpus online = 131 mA


-- side note --

Please note, I did not disable the cpuidle neither the AFTR state and 
the kernel did not hang but I don't see the noticeable power saving we 
should be observing when there is one cpu remaining entering the AFTR 
state (cpuidle stats show we enter AFTR). So there is definitively 
something wrong with this state.



--
 http://www.linaro.org/ Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  http://www.facebook.com/pages/Linaro Facebook |
http://twitter.com/#!/linaroorg Twitter |
http://www.linaro.org/linaro-blog/ 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 07/15] drm/exynos: dsi: Add support for panel prepare and unprepare routines

2014-08-05 Thread Ajay kumar
Hi Andreas,


On Tue, Aug 5, 2014 at 3:33 PM, Andrzej Hajda a.ha...@samsung.com wrote:
 Hi Ajay,


 On 07/31/2014 07:42 PM, Ajay Kumar wrote:
 Modify exynos_dsi driver to support the new panel calls:
 prepare and unprepare.

 Signed-off-by: Ajay Kumar ajaykumar...@samsung.com
 ---
  drivers/gpu/drm/exynos/exynos_drm_dsi.c |   12 ++--
  1 file changed, 10 insertions(+), 2 deletions(-)

 diff --git a/drivers/gpu/drm/exynos/exynos_drm_dsi.c 
 b/drivers/gpu/drm/exynos/exynos_drm_dsi.c
 index dc7c80b..4834932 100644
 --- a/drivers/gpu/drm/exynos/exynos_drm_dsi.c
 +++ b/drivers/gpu/drm/exynos/exynos_drm_dsi.c
 @@ -1351,7 +1351,7 @@ static int exynos_dsi_enable(struct exynos_dsi *dsi)
   if (ret  0)
   return ret;

 - ret = drm_panel_enable(dsi-panel);
 + ret = drm_panel_prepare(dsi-panel);
   if (ret  0) {
   exynos_dsi_poweroff(dsi);
   return ret;
 @@ -1360,6 +1360,13 @@ static int exynos_dsi_enable(struct exynos_dsi *dsi)
   exynos_dsi_set_display_mode(dsi);
   exynos_dsi_set_display_enable(dsi, true);

 + ret = drm_panel_enable(dsi-panel);
 + if (ret  0) {
 + exynos_dsi_set_display_enable(dsi, false);

 I guess drm_panel_unprepare(dsi-panel) should be here.
Thanks for pointing it out. I am not sure if Thierry has already
picked this up since Inki has given Acked by.
In that case, you can send it as a fix separately :)

Ajay
 + exynos_dsi_poweroff(dsi);
 + return ret;
 + }
 +
   dsi-state |= DSIM_STATE_ENABLED;

   return 0;
 @@ -1370,8 +1377,9 @@ static void exynos_dsi_disable(struct exynos_dsi *dsi)
   if (!(dsi-state  DSIM_STATE_ENABLED))
   return;

 - exynos_dsi_set_display_enable(dsi, false);
   drm_panel_disable(dsi-panel);
 + exynos_dsi_set_display_enable(dsi, false);
 + drm_panel_unprepare(dsi-panel);
   exynos_dsi_poweroff(dsi);

   dsi-state = ~DSIM_STATE_ENABLED;



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


Re: [PATCH v2] ARM: EXYNOS: Refactor the pm code to use DT based lookup

2014-08-05 Thread Tomasz Figa
Hi Vikas,

Please see my comments inline.

On 25.07.2014 13:49, Vikas Sajjan wrote:
 Refactoring the pm.c to avoid using soc_is_exynos checks,
 instead use the DT based lookup.
 
 While at it, consolidate the common code across SoCs
 and create a static helper functions.

[snip]

 @@ -241,13 +266,13 @@ static void exynos_cpu_restore_register(void)
  
  static int exynos_cpu_suspend(unsigned long arg)
  {
 -#ifdef CONFIG_CACHE_L2X0
 - outer_flush_all();
 -#endif
 -
 - if (soc_is_exynos5250())
 - flush_cache_all();
 + if (pm_data-cpu_suspend)
 + return pm_data-cpu_suspend(arg);
 + return -1;
 +}

I believe you could just pass pm_data-cpu_suspend to cpu_suspend(),
without this three-liner.

  
 +static int exynos_cpu_do_idle(void)
 +{
   /* issue the standby signal into the pm unit. */
   cpu_do_idle();
  
 @@ -257,32 +282,73 @@ static int exynos_cpu_suspend(unsigned long arg)
  
  static void exynos_pm_prepare(void)
  {
 - unsigned int tmp;
 + if (pm_data-pm_prepare)
 + pm_data-pm_prepare();

You could just directly insert this code into exynos_suspend_enter()
instead of adding this two-liner.

 +}
  
 +static int exynos4_cpu_suspend(unsigned long arg)
 +{
 +#ifdef CONFIG_CACHE_L2X0
 + outer_flush_all();
 +#endif
 + return exynos_cpu_do_idle();
 +}
 +
 +static int exynos5250_cpu_suspend(unsigned long arg)
 +{
 +#ifdef CONFIG_CACHE_L2X0
 + outer_flush_all();
 +#endif
 + flush_cache_all();
 + return exynos_cpu_do_idle();
 +}

I believe both can be merged safely into the same single function. A
call to flush_cache_all() will not hurt on Exynos4, but it should be
moved before outer_flush_all().

Moreover, the #ifdef CONFIG_CACHE_L2X0 is superfluous, because the
existence of outer_flush_all() symbol doesn't depend on this Kconfig
symbol (it depends on CONFIG_OUTER_CACHE_SYNC, but a stub is provided if
it is disabled).

 +
 +static void exynos_pm_set_wakeup_mask(void)
 +{
   /* Set wake-up mask registers */
   pmu_raw_writel(exynos_get_eint_wake_mask(), S5P_EINT_WAKEUP_MASK);
   pmu_raw_writel(exynos_irqwake_intmask  ~(1  31), S5P_WAKEUP_MASK);
 +}
  
 - s3c_pm_do_save(exynos_core_save, ARRAY_SIZE(exynos_core_save));
 -
 - if (soc_is_exynos5250()) {
 - s3c_pm_do_save(exynos5_sys_save, ARRAY_SIZE(exynos5_sys_save));
 - /* Disable USE_RETENTION of JPEG_MEM_OPTION */
 - tmp = pmu_raw_readl(EXYNOS5_JPEG_MEM_OPTION);
 - tmp = ~EXYNOS5_OPTION_USE_RETENTION;
 - pmu_raw_writel(tmp, EXYNOS5_JPEG_MEM_OPTION);
 - }
 -
 +static void exynos_pm_enter_sleep_mode(void)
 +{
   /* Set value of power down register for sleep mode */
 -
   exynos_sys_powerdown_conf(SYS_SLEEP);
   pmu_raw_writel(S5P_CHECK_SLEEP, S5P_INFORM1);
  
   /* ensure at least INFORM0 has the resume address */
 -
   pmu_raw_writel(virt_to_phys(exynos_cpu_resume), S5P_INFORM0);
  }
  
 +static void exynos5250_pm_prepare(void)
 +{
 + unsigned int tmp;
 +
 + /* Set wake-up mask registers */
 + exynos_pm_set_wakeup_mask();
 +
 + s3c_pm_do_save(exynos_core_save, ARRAY_SIZE(exynos_core_save));
 +
 + s3c_pm_do_save(exynos5_sys_save, ARRAY_SIZE(exynos5_sys_save));

You could store a pointer to this array in new .extra_save field of the
variant struct and handle this with generic code, like below:

if (pm_data-extra_save)
s3c_pm_do_save(pm_data-extra_save,
pm_data-num_extra_save);

 +
 + /* Disable USE_RETENTION of JPEG_MEM_OPTION */
 + tmp = pmu_raw_readl(EXYNOS5_JPEG_MEM_OPTION);
 + tmp = ~EXYNOS5_OPTION_USE_RETENTION;
 + pmu_raw_writel(tmp, EXYNOS5_JPEG_MEM_OPTION);

This looks completely like a copy paste from a vendor tree needed to
workaround some issues in early revisions of the SoC. Are you sure this
is still needed in production versions of the silicon used on boards
supported in mainline?

Even if yes, Exynos4 handles such registers in PMU register array in
pmu.c, so I wonder whether it shouldn't be moved there and allow
handling of all Exynos SoCs uniformly in this file.

 +
 + exynos_pm_enter_sleep_mode();
 +}
 +
 +static void exynos4_pm_prepare(void)
 +{
 + /* Set wake-up mask registers */
 + exynos_pm_set_wakeup_mask();
 +
 + s3c_pm_do_save(exynos_core_save, ARRAY_SIZE(exynos_core_save));
 +
 + exynos_pm_enter_sleep_mode();
 +}

In fact, exynos4_pm_prepare() is a direct subset of
exynos5250_pm_prepare(). This just confirms that it might be a good idea
to just merge both functions into a single generic one.

 +
  static void exynos_pm_central_suspend(void)
  {
   unsigned long tmp;
 @@ -295,6 +361,13 @@ static void exynos_pm_central_suspend(void)
  
  static int exynos_pm_suspend(void)
  {
 + if (pm_data-pm_suspend)
 + return pm_data-pm_suspend();
 + return -1;
 +}

Do you need this three-liner? I believe you could just assign

Re: [PATCH v5 1/3] ARM: EXYNOS: Move code from hotplug.c to platsmp.c

2014-08-05 Thread Tomasz Figa
On 05.08.2014 17:03, Krzysztof Kozlowski wrote:
 On wto, 2014-08-05 at 16:46 +0200, Daniel Lezcano wrote:
 On 08/05/2014 12:43 PM, Krzysztof Kozlowski wrote:
 Cleanup a little the SMP/hotplug code for Exynos by:
 1. Moving completely all functions from hotplug.c into the platsmp.c;
 2. Deleting the hotplug.c file.

 After recent cleanups (e.g. 75ad2ab28f0f ARM: EXYNOS: use
 v7_exit_coherency_flush macro for cache disabling) there was only CPU
 power down related code in hotplug.c file. Keeping this file does not
 give any benefits.

 The commit only moves code around with one additional observable change:
 the hotplug.c was compiled with custom CFLAGS (-march=armv7-a). These
 CFLAGS are not necessary any more.

 What is the benefit of moving this code around ?

 Usually the cpu hotplug code is located in hotplug.c for most of the 
 platforms, so why moving pm code inside platsmp ?
 
 The benefits are:
 
 1. Less dependencies, cleaner code because platsmp.c is the only user of
 code located in hotplug.c. So the exynos_cpu_die() had to be declared in
 common.h.
 
 2. Less dependencies between modules after adding patch 3/3 [1] which
 introduces exynos_set_delayed_reset_assertion() function. The
 exynos_set_delayed_reset_assertion() is called by:
  - cpu_leave_power (hotplug.c)
  - platform_do_lowpower (hotplug.c)
  - exynos_boot_secondary (platsmp.c)
 
 so merging everything into one file seemed simpler and cleaner.

mach-exynos/hotplug.c does not have too much code right now and as
Krzysztof noticed the only user of functions from it is platsmp.c
anyway. We don't need to follow other machs in something that makes no
sense, so

Acked-by: Tomasz Figa t.f...@samsung.com

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: PWM on Hardkernel ODROID-XU board

2014-08-05 Thread Tomasz Figa
Hi Daniel,

On 05.08.2014 22:48, Gachet Daniel wrote:
 Hi Thomasz,
 
 I’m currently trying to use the Hardkernel ODROID-XU board under Linux 
 version 3.14 (hard kernel sources “odroid-3.14.y-linaro”.
 I’m almost happy with that version, but I still have a problem by migrating 
 the “odroidxu_fan.c” module from the 3.4 version.
 I can register to the samsung pwm module (pam_request).
 
 Could you tell me what are the right entry for the flattened device tree for 
 this board ?

Unfortunately I don't know too much about this board or hardkernel
sources. I mostly work with mainline kernel.

In general, you probably need a node for the PWM block of the SoC and a
node for the PWM fan, but I don't have any details for you at the moment.

I'd say you should have posted this to linux-samsung-soc mailing list
for bigger chance of getting more information. For your convenience, I'm
adding them and several people that might be able to give some input on
this.

By the way, you might be interested in pwm-fan driver recently merged
for Linux 3.17: https://lkml.org/lkml/2014/7/16/426 .

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 V2] media: s5p_mfc: Release ctx-ctx if failed to allocate ctx-shm

2014-08-05 Thread Joonyoung Shim
Hi,

On 08/05/2014 06:31 PM, Zhaowei Yuan wrote:
 ctx-ctx should be released if the following allocation for ctx-shm
 gets failed.
 
 Signed-off-by: Zhaowei Yuan zhaowei.y...@samsung.com
 ---
  drivers/media/platform/s5p-mfc/s5p_mfc_opr_v5.c |1 +
  1 file changed, 1 insertion(+)
  mode change 100644 = 100755 drivers/media/platform/s5p-mfc/s5p_mfc_opr_v5.c

It's wrong to change file permission, please don't make a same mistake.
--
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 0/2] sbs-battery: Add missing power class sysfs files

2014-08-05 Thread Sebastian Reichel
On Mon, Aug 04, 2014 at 01:47:44PM +0200, Javier Martinez Canillas wrote:
 This series add the model_name, manufacturer and voltage_min_design
 files from the power supply monitor class sysfs interface that were
 missing for the sbs-battery driver. The commits were taken from the
 Chrome OS 3.8 downstream kernel and patches were squashed when they
 just fixed bugs introduced on previous commits that do the export.
 
 The patch-set was tested on a Exynos5420 based Peach Pit machine by
 confirming that the sysfs files existed and provide the right data:
 
 # cat 
 /sys/class/power_supply/sbs-20-000b/{voltage_min_design,manufacturer,model_name}
 750
 SANYO
 4302A40
 
 Simon Que (1):
   sbs-battery: add min design voltage to sbs-battery
 
 cychiang (1):
   sbs-battery: export manufacturer and model name to sysfs
 
  drivers/power/sbs-battery.c | 125 
 +++-
  1 file changed, 123 insertions(+), 2 deletions(-)
 
 Best regards,
 Javier

Both applied to battery.git's next-next branch. I modified the
author from the first commit (cychiang cychi...@chromium.org),
so that it's equal to the signed-off line (Cheng-Yi Chiang
cychi...@chromium.org).

-- Sebastian


signature.asc
Description: Digital signature


[PATCH V3] media: s5p_mfc: Release ctx-ctx if failed to allocate ctx-shm

2014-08-05 Thread Zhaowei Yuan
ctx-ctx should be released if the following allocation for ctx-shm
gets failed.

Signed-off-by: Zhaowei Yuan zhaowei.y...@samsung.com
---
 drivers/media/platform/s5p-mfc/s5p_mfc_opr_v5.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v5.c 
b/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v5.c
index 58ec7bb..dc00aea 100644
--- a/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v5.c
+++ b/drivers/media/platform/s5p-mfc/s5p_mfc_opr_v5.c
@@ -228,6 +228,7 @@ static int s5p_mfc_alloc_instance_buffer_v5(struct 
s5p_mfc_ctx *ctx)
ret = s5p_mfc_alloc_priv_buf(dev-mem_dev_l, ctx-shm);
if (ret) {
mfc_err(Failed to allocate shared memory buffer\n);
+   s5p_mfc_release_priv_buf(dev-mem_dev_l, ctx-ctx);
return ret;
}

--
1.7.9.5

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