Re: [PATCH v4 00/11] ARM: OMAP2+: AM33XX: Add suspend-resume support

2014-07-14 Thread Andre Heider
On Fri, Jul 11, 2014 at 12:31:06PM -0500, Dave Gerlach wrote:
 On Thu, Jul 10, 2014 at 09:55:38PM -0500, Dave Gerlach wrote:
 Hello,
 
 This series adds suspend/resume support for am335x. Version 3 of this
 series can be found at [1]. I apologize for the large delay between this
 and the previous revision. This code has been heavily refined
 since the last version based on the various comments received for v3. The
 major change from previous version is moving all wkup_m3 code into a
 remoteproc based driver. The new driver handles all IPC and fw loading
 and exposes a small API to be used by PM code to achieve low power states.
 
 Firmware that can be used for testing this can be found at [2] on branch
 pm-remote-proc-v3, using am335x-pm-firmware.elf found in bin directory.
 Please note this has changed from all previous versions and is no longer
 the .bin file. Firmware can be built into kernel or placed in /lib/firmware
 in rootfs for automatic loading during boot.
 
 This series has several dependencies. The wkup_m3_rproc utilizes a mailbox
 to communicate with the cm3 and depends on Suman's series for omap mbox
 support [3], which has several dependencies of it's own, listed in the
 cover letter. Also, a few changes to remoteproc itself were needed and
 have been provided by Suman here [4]. The edma patch included in this
 series was previously submitted by Daniel Mack and after discussion with
 him we agreed to include an updated version with this series as resume
 has a direct dependency on it due to hangs in mmc without it.
 
 Because of the high number of dependencies I have pushed a branch for
 testing here [6] if anyone desires to try it out on branch pm-ds0-v3.16.
 
 As is this series will only suspend and resume one time and then
 fail to resume afterwards due to the removal of direct PM code control
 of hwmods that do not properly assert their MSTANDBY signal after a context
 loss, discussed here [7]. In particular it is due to the usb_otg_hs hwmod
 that currently has no driver controlling it in the kernel. The main
 cause of the issue is that the SYSCONFIG register present within
 the IP must be reprogrammed after every suspend cycle and this
 only happens at boot if no driver is present. Work is in progress to
 allow suspend to function with or without drivers for the troublesome
 hwmods (cpgmac, usb_otg_hs, and tptc1-3) and will be provided in a separate
 future patch. The previous suggestion of allowing omap_device to handle
 it proved to be too invasive into both omap_device and omap_hwmod and
 the approach of allowing the firmware to handle it is not possible due
 to the inability of the CM3 to access the IPs causing the issue. I'd
 be happy to discuss this at length if anybody is interested.

...

 It fails to compile with CONFIG_THUMB2_KERNEL though:
 arch/arm/mach-omap2/sleep33xx.S:61: Error: cannot use register index
 with PC-relative addressing -- `str r1,emif_addr_virt'
 
 Hmm, interestingly enough I can not reproduce this build error. Can you
 share your config and compiler version?

While I have a stripped down .config for just boneblack I can reproduce this 
with:
make multi_v7_defconfig
./scripts/config -e THUMB2_KERNEL

Which may not make much sense (exposes other thumb2 related issues), but with 
that
.config sleep33xx.S fails to assemble with binutils 2.24 and succeeds with 
2.23.2.

Which may be binutils' fault, I can't judge since I don't speak ARM asm ;)

Hope that helps,
Andre
--
To unsubscribe from this list: send the line unsubscribe linux-omap 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 00/11] ARM: OMAP2+: AM33XX: Add suspend-resume support

2014-07-11 Thread Andre Heider
Hi Dave,

On Thu, Jul 10, 2014 at 09:55:38PM -0500, Dave Gerlach wrote:
 Hello,
 
 This series adds suspend/resume support for am335x. Version 3 of this
 series can be found at [1]. I apologize for the large delay between this
 and the previous revision. This code has been heavily refined
 since the last version based on the various comments received for v3. The
 major change from previous version is moving all wkup_m3 code into a
 remoteproc based driver. The new driver handles all IPC and fw loading
 and exposes a small API to be used by PM code to achieve low power states.
 
 Firmware that can be used for testing this can be found at [2] on branch
 pm-remote-proc-v3, using am335x-pm-firmware.elf found in bin directory.
 Please note this has changed from all previous versions and is no longer
 the .bin file. Firmware can be built into kernel or placed in /lib/firmware
 in rootfs for automatic loading during boot.
 
 This series has several dependencies. The wkup_m3_rproc utilizes a mailbox
 to communicate with the cm3 and depends on Suman's series for omap mbox
 support [3], which has several dependencies of it's own, listed in the
 cover letter. Also, a few changes to remoteproc itself were needed and
 have been provided by Suman here [4]. The edma patch included in this
 series was previously submitted by Daniel Mack and after discussion with
 him we agreed to include an updated version with this series as resume
 has a direct dependency on it due to hangs in mmc without it.
 
 Because of the high number of dependencies I have pushed a branch for
 testing here [6] if anyone desires to try it out on branch pm-ds0-v3.16.
 
 As is this series will only suspend and resume one time and then
 fail to resume afterwards due to the removal of direct PM code control
 of hwmods that do not properly assert their MSTANDBY signal after a context
 loss, discussed here [7]. In particular it is due to the usb_otg_hs hwmod
 that currently has no driver controlling it in the kernel. The main
 cause of the issue is that the SYSCONFIG register present within
 the IP must be reprogrammed after every suspend cycle and this
 only happens at boot if no driver is present. Work is in progress to
 allow suspend to function with or without drivers for the troublesome
 hwmods (cpgmac, usb_otg_hs, and tptc1-3) and will be provided in a separate
 future patch. The previous suggestion of allowing omap_device to handle
 it proved to be too invasive into both omap_device and omap_hwmod and
 the approach of allowing the firmware to handle it is not possible due
 to the inability of the CM3 to access the IPs causing the issue. I'd
 be happy to discuss this at length if anybody is interested.

I gave this a quick spin on boneblack, and it works for me, thanks!

Tested with echo mem  /sys/power/state and uart0 input to resume.

Contradictionary to the limits you mention, multiple suspend/resume cycles
do work for me. Maybe because of the enabled drivers in my .config, or
maybe something was messed up, but at first glance it looked fine.

It fails to compile with CONFIG_THUMB2_KERNEL though:
arch/arm/mach-omap2/sleep33xx.S:61: Error: cannot use register index
with PC-relative addressing -- `str r1,emif_addr_virt'

Then I noticed freeze in /sys/power/state, when triggered then crashes
with a null pointer dereference in suspend_devices_and_enter(). That might
be expected or even stupid though ;)

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


Re: [PATCH 00/13] uio_pruss: add support for devicetree and am33xx

2014-07-09 Thread Andre Heider
On Mon, Jul 07, 2014 at 05:50:09PM +, Paul Walmsley wrote:
 On Mon, 7 Jul 2014, Andre Heider wrote:
 
  On Sun, Jun 29, 2014 at 06:21:34PM +0200, Andre Heider wrote:
   
   this series adds PRUv2 support to uio_pruss through devicetree, makes the
   device usable on am33xx and enables it on beaglebone black.
   Inspired by old patches from Matt Porter found in a downstream tree.
   
   To archieve that this series:
   * adds a flag to omap_hwmod.c to get PRUSS out of hardreset (patch 5 and 
   6)
 
 ...
 
   * is the hardreset thing I did there the right thing to do? I think the
 proper way would be a reset controller (which apparently doesn't yet 
   exist
 for this SoC?) and let the driver deassert/assert on probe/remove?
   * the platform device path has a clk_enable() / clk_put() calls. Are those
 now redundant with the introduced pm_runtime_enable() 
   pm_runtime_disable()
 calls?
 
 Probably you only need pm_runtime_{get,put}_*() calls, unless you're 
 changing clock parents or rates in your driver code.

No, the driver doesn't do that. So I can clean that up, nice.

 
  @OMAP guys: any comments? The series depends on patch 5 and 6; both touch
  common hwmod code.
 
 I'd suggest splitting the series into three independent pieces if 
 possible:
 
 1. UIO code, for the UIO maintainer(s)
 2. DT pieces for Tony
 3. hwmod pieces for me
 
 That way they can be cleanly merged by the respective maintainers.
 
 As far as the hwmod piece goes, I'd be willing to merge your code as a 
 temporary workaround for the issue, and marking it as such; but I'd be 
 concerned about power management-related interactions (i.e., does the 
 PRUSS need to be reset upon return from deep idle states, etc.)

Alright, thanks Paul.

About the deep idle states... I'm not sure, I couldn't find any explicit
wording about it in the am335x technical reference manual nor in in the
boneblack system reference manual.

According to the TRM the PRUSS lies in the PD_PER power domain, which is
powered down for the Deepsleep0 power mode. So I *guess* the PRUSS also
needs to be taken out of hard reset when waking up from such a state.

But there's no upstream support for these power modes on am33xx anyway,
and I'd assume that HWMOD_INIT_DEASSERT_HARD_RESET gets removed or
replaced once that lands. Which is probably what you meant by temporary.
FWIW, I'd be willing to look into that when the time comes and PRUSS gets
left behind.

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


Re: [PATCH 00/13] uio_pruss: add support for devicetree and am33xx

2014-07-07 Thread Andre Heider
On Sun, Jun 29, 2014 at 06:21:34PM +0200, Andre Heider wrote:
 Hi,
 
 this series adds PRUv2 support to uio_pruss through devicetree, makes the
 device usable on am33xx and enables it on beaglebone black.
 Inspired by old patches from Matt Porter found in a downstream tree.
 
 To archieve that this series:
 * adds a flag to omap_hwmod.c to get PRUSS out of hardreset (patch 5 and 6)
 * adds devicetree support to uio_pruss (patch 7 and 9)
 * adds the device to the am33xx dtsi and boneblack dts (patch 12 and 13)
 
 Bits and pieces:
 * some cleanup (patch 1-4)
 * take care of a fact that SRAM on am33xx is not exposed through UIO (patch 8)
 * add runtime pm support to enable clocks (patch 10)
 * allow the driver to be compiled on SOC_AM33XX (patch 11)
 
 This is only tested on beaglebone black (as that's the only hardware of the
 PRUSS enabled families I have) with some basic GPIO and IRQ tests.
 
 Notes:
 * I just got this hardware and I don't know if this UIO PRUSS business is
   desired. Looking at the userspace driver I'd guess not so much ;), but this
   interface is there for older generations anyway, and this small series lets
   me use the device.
 * is the hardreset thing I did there the right thing to do? I think the
   proper way would be a reset controller (which apparently doesn't yet exist
   for this SoC?) and let the driver deassert/assert on probe/remove?
 * the platform device path has a clk_enable() / clk_put() calls. Are those
   now redundant with the introduced pm_runtime_enable() pm_runtime_disable()
   calls?

@OMAP guys: any comments? The series depends on patch 5 and 6; both touch
common hwmod code.

I noticed that AM437x now comes with 4 PRUSS cores, maybe you had something
different in mind on how to expose these?

Thanks in advance,
Andre
--
To unsubscribe from this list: send the line unsubscribe linux-omap 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/13] Documentation: devicetree: add bindings for TI PRUSS

2014-06-30 Thread Andre Heider
On Mon, Jun 30, 2014 at 10:33:32AM +0100, Mark Rutland wrote:
 On Sun, Jun 29, 2014 at 05:21:41PM +0100, Andre Heider wrote:
  diff --git a/Documentation/devicetree/bindings/misc/ti,pruss.txt 
  b/Documentation/devicetree/bindings/misc/ti,pruss.txt
  new file mode 100644
  index 000..4eacc41
  --- /dev/null
  +++ b/Documentation/devicetree/bindings/misc/ti,pruss.txt
  @@ -0,0 +1,19 @@
  +TI Programmable Real-Time Unit Sub System (PRUSS)
  +
  +Required properties:
  +- compatible :
  +   - ti,pruss-v1 - for PRUv1 as found on the OMAPL138/DA850/AM18xx SoC 
  families
  +   - ti,pruss-v2 - for PRUv2 as found on the AM33xx SoC family
  +- ti,hwmods: Name of the hwmod associated to the PRUSS
  +- reg: Address range of rtc register set

Just noticed the rtc cp error, will fix that.

  +- interrupts: host event interrupts in order
 
 How many of these do we expect?

Exactly 8, which correspond to the /dev/uio* devices the driver creates.
I'll change that to make it clear.

Additionally, the driver currently expects those 8 to be sequential.
In fact, it just gets the first irq and increments from there on, I'll
add a patch to the series to improve that too.

  +- interrupt-parent: phandle for the interrupt controller
  +
  +Example:
  +pruss: pruss@4a30 {
  +   compatible = ti,pruss-v2;
  +   ti,hwmods = pruss;
  +   reg = 0x4a30 0x08;
  +   interrupts = 20 21 22 23 24 25 26 27;
 
 Assuming these represent more than one interrupt, could you please
 bracket them individually? e.g.
 
   interrupts = 20 21, 22 23, 24 25, 26 27;
 
 It makes it far clearer that it's a list of multi-cell elements rather
 than a giant binary blob, and usually makes it easier to read a dts.

This interrupt controller has one cell, so I assume you meant:

interrupts = 20, 21, 22, 23, 24, 25, 26, 27;

I can do that, but it would be out of line with the rest on the file. The
audio devices are the only ones using that format, but they also got
interrupt-names.

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


Re: [PATCH 09/13] uio: uio_pruss: add devicetree support

2014-06-30 Thread Andre Heider
On Mon, Jun 30, 2014 at 10:36:06AM +0100, Mark Rutland wrote:
 On Sun, Jun 29, 2014 at 05:21:43PM +0100, Andre Heider wrote:
  -   /* Power on PRU in case its not done as part of boot-loader */
  -   gdev-pruss_clk = clk_get(dev, pruss);
  -   if (IS_ERR(gdev-pruss_clk)) {
  -   dev_err(dev, Failed to get clock\n);
  -   return PTR_ERR(gdev-pruss_clk);
  +   if (dev-of_node) {
  +   match = of_match_device(pruss_of_match_table, dev);
  +   params = match-data;
  +   gdev-pintc_base = params-pintc_offset;
  } else {
  +   /* Power on PRU in case its not done as part of boot-loader */
  +   gdev-pruss_clk = clk_get(dev, pruss);
  +   if (IS_ERR(gdev-pruss_clk)) {
  +   dev_err(dev, Failed to get clock\n);
  +   return PTR_ERR(gdev-pruss_clk);
  +   }
 
 The pruss clock was not documented in the binding.
 
 Is the clock really called pruss, or is it given a specific name in
 the manual?

That hunk was moved, see above. It's not the devicetree path, it's for
non-DT TI DaVinci:

arch/arm/mach-davinci/da850.c:static struct clk pruss_clk = {
arch/arm/mach-davinci/da850.c:  .name   = pruss,

The DT path already has a clocks associated at the hwmod level.
From arch/arm/mach-omap2/omap_hwmod_33xx_43xx_ipblock_data.c:

struct omap_hwmod am33xx_pruss_hwmod = {
.name   = pruss,
.class  = 
am33xx_pruss_hwmod_class,
.clkdm_name = pruss_ocp_clkdm,
.flags  = 
HWMOD_INIT_DEASSERT_HARD_RESET,
.main_clk   = pruss_ocp_gclk,

and doesn't require any additional clock entries as far as the binding is
concerned.

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


Re: [PATCH 12/13] ARM: dts: am33xx: add the PRUSSv2 device

2014-06-30 Thread Andre Heider
On Mon, Jun 30, 2014 at 10:36:42AM +0100, Mark Rutland wrote:
 On Sun, Jun 29, 2014 at 05:21:46PM +0100, Andre Heider wrote:
  --- a/arch/arm/boot/dts/am33xx.dtsi
  +++ b/arch/arm/boot/dts/am33xx.dtsi
  @@ -409,6 +409,15 @@
  ti,hwmods = rtc;
  };
   
  +   pruss: pruss@4a30 {
  +   compatible = ti,pruss-v2;
  +   ti,hwmods = pruss;
  +   reg = 0x4a30 0x08;
  +   interrupts = 20 21 22 23 24 25 26 27;
 
 Could this please have entries individually bracketed?

I'll sync that to with what we end up with on path 7.

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


Re: [PATCH 02/13] uio: uio_pruss: use devm_kzalloc()

2014-06-30 Thread Andre Heider
On Mon, Jun 30, 2014 at 10:38:09AM +0100, Mark Rutland wrote:
 On Sun, Jun 29, 2014 at 05:21:36PM +0100, Andre Heider wrote:
  --- a/drivers/uio/uio_pruss.c
  +++ b/drivers/uio/uio_pruss.c
  @@ -109,9 +109,7 @@ static void pruss_cleanup(struct device *dev, struct 
  uio_pruss_dev *gdev)
  gen_pool_free(gdev-sram_pool,
gdev-sram_vaddr,
sram_pool_sz);
  -   kfree(gdev-info);
  clk_put(gdev-pruss_clk);
  -   kfree(gdev);
   }
   
   static int pruss_probe(struct platform_device *pdev)
  @@ -123,24 +121,19 @@ static int pruss_probe(struct platform_device *pdev)
  int ret = -ENODEV, cnt = 0, len;
  struct uio_pruss_pdata *pdata = dev_get_platdata(dev);
   
  -   gdev = kzalloc(sizeof(struct uio_pruss_dev), GFP_KERNEL);
  +   gdev = devm_kzalloc(dev, sizeof(struct uio_pruss_dev), GFP_KERNEL);
 
 If this is changing anyway, how about:
 
   gdev = devm_kzalloc(dev, sizeof(*gdev), GFP_KERNEL);
 

Sounds good, will do just that.

Thanks for having at look at the series, Mark!

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


[PATCH 02/13] uio: uio_pruss: use devm_kzalloc()

2014-06-29 Thread Andre Heider
Replace kzalloc() by devm_kzalloc() and remove the kfree() calls.

Signed-off-by: Andre Heider a.hei...@gmail.com
---
 drivers/uio/uio_pruss.c | 15 ---
 1 file changed, 4 insertions(+), 11 deletions(-)

diff --git a/drivers/uio/uio_pruss.c b/drivers/uio/uio_pruss.c
index c28d6e2..f07545b 100644
--- a/drivers/uio/uio_pruss.c
+++ b/drivers/uio/uio_pruss.c
@@ -109,9 +109,7 @@ static void pruss_cleanup(struct device *dev, struct 
uio_pruss_dev *gdev)
gen_pool_free(gdev-sram_pool,
  gdev-sram_vaddr,
  sram_pool_sz);
-   kfree(gdev-info);
clk_put(gdev-pruss_clk);
-   kfree(gdev);
 }
 
 static int pruss_probe(struct platform_device *pdev)
@@ -123,24 +121,19 @@ static int pruss_probe(struct platform_device *pdev)
int ret = -ENODEV, cnt = 0, len;
struct uio_pruss_pdata *pdata = dev_get_platdata(dev);
 
-   gdev = kzalloc(sizeof(struct uio_pruss_dev), GFP_KERNEL);
+   gdev = devm_kzalloc(dev, sizeof(struct uio_pruss_dev), GFP_KERNEL);
if (!gdev)
return -ENOMEM;
 
-   gdev-info = kzalloc(sizeof(*p) * MAX_PRUSS_EVT, GFP_KERNEL);
-   if (!gdev-info) {
-   kfree(gdev);
+   gdev-info = devm_kzalloc(dev, sizeof(*p) * MAX_PRUSS_EVT, GFP_KERNEL);
+   if (!gdev-info)
return -ENOMEM;
-   }
 
/* Power on PRU in case its not done as part of boot-loader */
gdev-pruss_clk = clk_get(dev, pruss);
if (IS_ERR(gdev-pruss_clk)) {
dev_err(dev, Failed to get clock\n);
-   ret = PTR_ERR(gdev-pruss_clk);
-   kfree(gdev-info);
-   kfree(gdev);
-   return ret;
+   return PTR_ERR(gdev-pruss_clk);
} else {
clk_enable(gdev-pruss_clk);
}
-- 
2.0.0

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


[PATCH 00/13] uio_pruss: add support for devicetree and am33xx

2014-06-29 Thread Andre Heider
Hi,

this series adds PRUv2 support to uio_pruss through devicetree, makes the
device usable on am33xx and enables it on beaglebone black.
Inspired by old patches from Matt Porter found in a downstream tree.

To archieve that this series:
* adds a flag to omap_hwmod.c to get PRUSS out of hardreset (patch 5 and 6)
* adds devicetree support to uio_pruss (patch 7 and 9)
* adds the device to the am33xx dtsi and boneblack dts (patch 12 and 13)

Bits and pieces:
* some cleanup (patch 1-4)
* take care of a fact that SRAM on am33xx is not exposed through UIO (patch 8)
* add runtime pm support to enable clocks (patch 10)
* allow the driver to be compiled on SOC_AM33XX (patch 11)

This is only tested on beaglebone black (as that's the only hardware of the
PRUSS enabled families I have) with some basic GPIO and IRQ tests.

Notes:
* I just got this hardware and I don't know if this UIO PRUSS business is
  desired. Looking at the userspace driver I'd guess not so much ;), but this
  interface is there for older generations anyway, and this small series lets
  me use the device.
* is the hardreset thing I did there the right thing to do? I think the
  proper way would be a reset controller (which apparently doesn't yet exist
  for this SoC?) and let the driver deassert/assert on probe/remove?
* the platform device path has a clk_enable() / clk_put() calls. Are those
  now redundant with the introduced pm_runtime_enable() pm_runtime_disable()
  calls?

Thanks,
Andre

Andre Heider (13):
  uio: uio_pruss: use struct device
  uio: uio_pruss: use devm_kzalloc()
  uio: uio_pruss: use devm_ioremap_resource()
  uio: uio_pruss: use dmam_alloc_coherent()
  ARM: OMAP2+: hwmod: Introduce a flag to deassert the HW reset line
  ARM: AM33XX: hwmod: deassert PRUSS' hardreset lines
  Documentation: devicetree: add bindings for TI PRUSS
  uio: uio_pruss: make the UIO SRAM memory region optional
  uio: uio_pruss: add devicetree support
  uio: uio_pruss: add runtime pm support
  uio: uio_pruss: enable the driver for am33xx SoCs
  ARM: dts: am33xx: add the PRUSSv2 device
  ARM: dts: am335x-boneblack: enable the PRUSSv2 device

 .../devicetree/bindings/misc/ti,pruss.txt  |  19 +++
 arch/arm/boot/dts/am335x-boneblack.dts |   4 +
 arch/arm/boot/dts/am33xx.dtsi  |   9 ++
 arch/arm/mach-omap2/omap_hwmod.c   |   2 +
 arch/arm/mach-omap2/omap_hwmod.h   |   2 +
 .../mach-omap2/omap_hwmod_33xx_43xx_ipblock_data.c |   1 +
 drivers/uio/Kconfig|   4 +-
 drivers/uio/uio_pruss.c| 144 -
 8 files changed, 123 insertions(+), 62 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/misc/ti,pruss.txt

-- 
2.0.0

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


[PATCH 13/13] ARM: dts: am335x-boneblack: enable the PRUSSv2 device

2014-06-29 Thread Andre Heider
Signed-off-by: Andre Heider a.hei...@gmail.com
---
 arch/arm/boot/dts/am335x-boneblack.dts | 4 
 1 file changed, 4 insertions(+)

diff --git a/arch/arm/boot/dts/am335x-boneblack.dts 
b/arch/arm/boot/dts/am335x-boneblack.dts
index 305975d..eeb5c2e 100644
--- a/arch/arm/boot/dts/am335x-boneblack.dts
+++ b/arch/arm/boot/dts/am335x-boneblack.dts
@@ -75,3 +75,7 @@
status = okay;
};
 };
+
+pruss {
+   status = okay;
+};
-- 
2.0.0

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


[PATCH 08/13] uio: uio_pruss: make the UIO SRAM memory region optional

2014-06-29 Thread Andre Heider
Skip creating the UIO SRAM memory region if no SRAM genalloc has been
passed along. This will be the case for am33xx SoCs.

The order of the memory regions is not changed for already supported
platforms. That is to keep the current behavior for existing userland
drivers.

For am33x this gives one memory region less. This behavior is in line
with downstream patches and userland driver support for this SoC family.

Signed-off-by: Andre Heider a.hei...@gmail.com
---
 drivers/uio/uio_pruss.c | 29 ++---
 1 file changed, 18 insertions(+), 11 deletions(-)

diff --git a/drivers/uio/uio_pruss.c b/drivers/uio/uio_pruss.c
index 50ff206..afaf726 100644
--- a/drivers/uio/uio_pruss.c
+++ b/drivers/uio/uio_pruss.c
@@ -111,7 +111,7 @@ static int pruss_probe(struct platform_device *pdev)
struct uio_pruss_dev *gdev;
struct resource *regs_prussio;
struct device *dev = pdev-dev;
-   int ret = -ENODEV, cnt = 0;
+   int ret = -ENODEV, cnt = 0, i;
struct uio_pruss_pdata *pdata = dev_get_platdata(dev);
dma_addr_t ddr_paddr;
 
@@ -160,17 +160,24 @@ static int pruss_probe(struct platform_device *pdev)
gdev-hostirq_start = platform_get_irq(pdev, 0);
 
for (cnt = 0, p = gdev-info; cnt  MAX_PRUSS_EVT; cnt++, p++) {
-   p-mem[0].addr = regs_prussio-start;
-   p-mem[0].size = resource_size(regs_prussio);
-   p-mem[0].memtype = UIO_MEM_PHYS;
-
-   p-mem[1].addr = gdev-sram_paddr;
-   p-mem[1].size = sram_pool_sz;
-   p-mem[1].memtype = UIO_MEM_PHYS;
+   i = 0;
+
+   p-mem[i].addr = regs_prussio-start;
+   p-mem[i].size = resource_size(regs_prussio);
+   p-mem[i].memtype = UIO_MEM_PHYS;
+   i++;
+
+   if (gdev-sram_vaddr) {
+   p-mem[i].addr = gdev-sram_paddr;
+   p-mem[i].size = sram_pool_sz;
+   p-mem[i].memtype = UIO_MEM_PHYS;
+   i++;
+   }
 
-   p-mem[2].addr = ddr_paddr;
-   p-mem[2].size = extram_pool_sz;
-   p-mem[2].memtype = UIO_MEM_PHYS;
+   p-mem[i].addr = ddr_paddr;
+   p-mem[i].size = extram_pool_sz;
+   p-mem[i].memtype = UIO_MEM_PHYS;
+   i++;
 
p-name = kasprintf(GFP_KERNEL, pruss_evt%d, cnt);
p-version = DRV_VERSION;
-- 
2.0.0

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


[PATCH 05/13] ARM: OMAP2+: hwmod: Introduce a flag to deassert the HW reset line

2014-06-29 Thread Andre Heider
hwmod's hardreset lines are not deasserted after a reset.
Add the HWMOD_INIT_DEASSERT_HARD_RESET flag to deassert those after a
successful reset.

This is required to get the PRU-ICSS in a usable state on am33xx SoCs.

Signed-off-by: Andre Heider a.hei...@gmail.com
---
 arch/arm/mach-omap2/omap_hwmod.c | 2 ++
 arch/arm/mach-omap2/omap_hwmod.h | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index f7bb435..1e56b65 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -2622,6 +2622,8 @@ static int __init _setup_reset(struct omap_hwmod *oh)
 
if (!(oh-flags  HWMOD_INIT_NO_RESET))
r = _reset(oh);
+   if (!r  oh-flags  HWMOD_INIT_DEASSERT_HARD_RESET)
+   r = _deassert_hardreset(oh, oh-name);
 
return r;
 }
diff --git a/arch/arm/mach-omap2/omap_hwmod.h b/arch/arm/mach-omap2/omap_hwmod.h
index 0f97d63..c41d44d 100644
--- a/arch/arm/mach-omap2/omap_hwmod.h
+++ b/arch/arm/mach-omap2/omap_hwmod.h
@@ -514,6 +514,7 @@ struct omap_hwmod_omap4_prcm {
  * HWMOD_SWSUP_SIDLE_ACT: omap_hwmod code should manually bring the module
  * out of idle, but rely on smart-idle to the put it back in idle,
  * so the wakeups are still functional (Only known case for now is UART)
+ * HWMOD_INIT_DEASSERT_HARD_RESET: deassert the HW reset line at boot
  */
 #define HWMOD_SWSUP_SIDLE  (1  0)
 #define HWMOD_SWSUP_MSTANDBY   (1  1)
@@ -528,6 +529,7 @@ struct omap_hwmod_omap4_prcm {
 #define HWMOD_BLOCK_WFI(1  10)
 #define HWMOD_FORCE_MSTANDBY   (1  11)
 #define HWMOD_SWSUP_SIDLE_ACT  (1  12)
+#define HWMOD_INIT_DEASSERT_HARD_RESET (1  13)
 
 /*
  * omap_hwmod._int_flags definitions
-- 
2.0.0

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


[PATCH 01/13] uio: uio_pruss: use struct device

2014-06-29 Thread Andre Heider
Get rid of the repeating dev-dev constructs and prevent introducing
new ones.

Signed-off-by: Andre Heider a.hei...@gmail.com
---
 drivers/uio/uio_pruss.c | 37 +++--
 1 file changed, 19 insertions(+), 18 deletions(-)

diff --git a/drivers/uio/uio_pruss.c b/drivers/uio/uio_pruss.c
index 96c4a19..c28d6e2 100644
--- a/drivers/uio/uio_pruss.c
+++ b/drivers/uio/uio_pruss.c
@@ -91,8 +91,7 @@ static irqreturn_t pruss_handler(int irq, struct uio_info 
*info)
return IRQ_HANDLED;
 }
 
-static void pruss_cleanup(struct platform_device *dev,
-   struct uio_pruss_dev *gdev)
+static void pruss_cleanup(struct device *dev, struct uio_pruss_dev *gdev)
 {
int cnt;
struct uio_info *p = gdev-info;
@@ -103,7 +102,7 @@ static void pruss_cleanup(struct platform_device *dev,
}
iounmap(gdev-prussio_vaddr);
if (gdev-ddr_vaddr) {
-   dma_free_coherent(dev-dev, extram_pool_sz, gdev-ddr_vaddr,
+   dma_free_coherent(dev, extram_pool_sz, gdev-ddr_vaddr,
gdev-ddr_paddr);
}
if (gdev-sram_vaddr)
@@ -115,13 +114,14 @@ static void pruss_cleanup(struct platform_device *dev,
kfree(gdev);
 }
 
-static int pruss_probe(struct platform_device *dev)
+static int pruss_probe(struct platform_device *pdev)
 {
struct uio_info *p;
struct uio_pruss_dev *gdev;
struct resource *regs_prussio;
+   struct device *dev = pdev-dev;
int ret = -ENODEV, cnt = 0, len;
-   struct uio_pruss_pdata *pdata = dev_get_platdata(dev-dev);
+   struct uio_pruss_pdata *pdata = dev_get_platdata(dev);
 
gdev = kzalloc(sizeof(struct uio_pruss_dev), GFP_KERNEL);
if (!gdev)
@@ -132,10 +132,11 @@ static int pruss_probe(struct platform_device *dev)
kfree(gdev);
return -ENOMEM;
}
+
/* Power on PRU in case its not done as part of boot-loader */
-   gdev-pruss_clk = clk_get(dev-dev, pruss);
+   gdev-pruss_clk = clk_get(dev, pruss);
if (IS_ERR(gdev-pruss_clk)) {
-   dev_err(dev-dev, Failed to get clock\n);
+   dev_err(dev, Failed to get clock\n);
ret = PTR_ERR(gdev-pruss_clk);
kfree(gdev-info);
kfree(gdev);
@@ -144,14 +145,14 @@ static int pruss_probe(struct platform_device *dev)
clk_enable(gdev-pruss_clk);
}
 
-   regs_prussio = platform_get_resource(dev, IORESOURCE_MEM, 0);
+   regs_prussio = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!regs_prussio) {
-   dev_err(dev-dev, No PRUSS I/O resource specified\n);
+   dev_err(dev, No PRUSS I/O resource specified\n);
goto out_free;
}
 
if (!regs_prussio-start) {
-   dev_err(dev-dev, Invalid memory resource\n);
+   dev_err(dev, Invalid memory resource\n);
goto out_free;
}
 
@@ -161,27 +162,27 @@ static int pruss_probe(struct platform_device *dev)
(unsigned long)gen_pool_dma_alloc(gdev-sram_pool,
sram_pool_sz, gdev-sram_paddr);
if (!gdev-sram_vaddr) {
-   dev_err(dev-dev, Could not allocate SRAM pool\n);
+   dev_err(dev, Could not allocate SRAM pool\n);
goto out_free;
}
}
 
-   gdev-ddr_vaddr = dma_alloc_coherent(dev-dev, extram_pool_sz,
+   gdev-ddr_vaddr = dma_alloc_coherent(dev, extram_pool_sz,
(gdev-ddr_paddr), GFP_KERNEL | GFP_DMA);
if (!gdev-ddr_vaddr) {
-   dev_err(dev-dev, Could not allocate external memory\n);
+   dev_err(dev, Could not allocate external memory\n);
goto out_free;
}
 
len = resource_size(regs_prussio);
gdev-prussio_vaddr = ioremap(regs_prussio-start, len);
if (!gdev-prussio_vaddr) {
-   dev_err(dev-dev, Can't remap PRUSS I/O  address range\n);
+   dev_err(dev, Can't remap PRUSS I/O  address range\n);
goto out_free;
}
 
gdev-pintc_base = pdata-pintc_base;
-   gdev-hostirq_start = platform_get_irq(dev, 0);
+   gdev-hostirq_start = platform_get_irq(pdev, 0);
 
for (cnt = 0, p = gdev-info; cnt  MAX_PRUSS_EVT; cnt++, p++) {
p-mem[0].addr = regs_prussio-start;
@@ -204,12 +205,12 @@ static int pruss_probe(struct platform_device *dev)
p-handler = pruss_handler;
p-priv = gdev;
 
-   ret = uio_register_device(dev-dev, p);
+   ret = uio_register_device(dev, p);
if (ret  0)
goto out_free;
}
 
-   platform_set_drvdata(dev, gdev);
+   platform_set_drvdata(pdev, gdev);
return 0;
 
 out_free:
@@ -221,7 +222,7 @@ static int pruss_remove

[PATCH 07/13] Documentation: devicetree: add bindings for TI PRUSS

2014-06-29 Thread Andre Heider
Signed-off-by: Andre Heider a.hei...@gmail.com
---
 Documentation/devicetree/bindings/misc/ti,pruss.txt | 19 +++
 1 file changed, 19 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/misc/ti,pruss.txt

diff --git a/Documentation/devicetree/bindings/misc/ti,pruss.txt 
b/Documentation/devicetree/bindings/misc/ti,pruss.txt
new file mode 100644
index 000..4eacc41
--- /dev/null
+++ b/Documentation/devicetree/bindings/misc/ti,pruss.txt
@@ -0,0 +1,19 @@
+TI Programmable Real-Time Unit Sub System (PRUSS)
+
+Required properties:
+- compatible :
+   - ti,pruss-v1 - for PRUv1 as found on the OMAPL138/DA850/AM18xx SoC 
families
+   - ti,pruss-v2 - for PRUv2 as found on the AM33xx SoC family
+- ti,hwmods: Name of the hwmod associated to the PRUSS
+- reg: Address range of rtc register set
+- interrupts: host event interrupts in order
+- interrupt-parent: phandle for the interrupt controller
+
+Example:
+pruss: pruss@4a30 {
+   compatible = ti,pruss-v2;
+   ti,hwmods = pruss;
+   reg = 0x4a30 0x08;
+   interrupts = 20 21 22 23 24 25 26 27;
+   interrupt-parent = intc;
+};
-- 
2.0.0

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


[PATCH 04/13] uio: uio_pruss: use dmam_alloc_coherent()

2014-06-29 Thread Andre Heider
Replace dma_alloc_coherent() with dmam_alloc_coherent() and remove the
dma_free_coherent() call.

This shaves off 2 vars in the driver data struct.

Signed-off-by: Andre Heider a.hei...@gmail.com
---
 drivers/uio/uio_pruss.c | 14 --
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/drivers/uio/uio_pruss.c b/drivers/uio/uio_pruss.c
index 310598a..50ff206 100644
--- a/drivers/uio/uio_pruss.c
+++ b/drivers/uio/uio_pruss.c
@@ -63,10 +63,8 @@ struct uio_pruss_dev {
struct uio_info *info;
struct clk *pruss_clk;
dma_addr_t sram_paddr;
-   dma_addr_t ddr_paddr;
void __iomem *prussio_vaddr;
unsigned long sram_vaddr;
-   void *ddr_vaddr;
unsigned int hostirq_start;
unsigned int pintc_base;
struct gen_pool *sram_pool;
@@ -100,10 +98,6 @@ static void pruss_cleanup(struct device *dev, struct 
uio_pruss_dev *gdev)
uio_unregister_device(p);
kfree(p-name);
}
-   if (gdev-ddr_vaddr) {
-   dma_free_coherent(dev, extram_pool_sz, gdev-ddr_vaddr,
-   gdev-ddr_paddr);
-   }
if (gdev-sram_vaddr)
gen_pool_free(gdev-sram_pool,
  gdev-sram_vaddr,
@@ -119,6 +113,7 @@ static int pruss_probe(struct platform_device *pdev)
struct device *dev = pdev-dev;
int ret = -ENODEV, cnt = 0;
struct uio_pruss_pdata *pdata = dev_get_platdata(dev);
+   dma_addr_t ddr_paddr;
 
gdev = devm_kzalloc(dev, sizeof(struct uio_pruss_dev), GFP_KERNEL);
if (!gdev)
@@ -155,9 +150,8 @@ static int pruss_probe(struct platform_device *pdev)
}
}
 
-   gdev-ddr_vaddr = dma_alloc_coherent(dev, extram_pool_sz,
-   (gdev-ddr_paddr), GFP_KERNEL | GFP_DMA);
-   if (!gdev-ddr_vaddr) {
+   if (!dmam_alloc_coherent(dev, extram_pool_sz, ddr_paddr,
+GFP_KERNEL | GFP_DMA)) {
dev_err(dev, Could not allocate external memory\n);
goto out_free;
}
@@ -174,7 +168,7 @@ static int pruss_probe(struct platform_device *pdev)
p-mem[1].size = sram_pool_sz;
p-mem[1].memtype = UIO_MEM_PHYS;
 
-   p-mem[2].addr = gdev-ddr_paddr;
+   p-mem[2].addr = ddr_paddr;
p-mem[2].size = extram_pool_sz;
p-mem[2].memtype = UIO_MEM_PHYS;
 
-- 
2.0.0

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


[PATCH 06/13] ARM: AM33XX: hwmod: deassert PRUSS' hardreset lines

2014-06-29 Thread Andre Heider
Set HWMOD_INIT_DEASSERT_HARD_RESET to get the PRUSS out of hardreset
upon boot.

Signed-off-by: Andre Heider a.hei...@gmail.com
---
 arch/arm/mach-omap2/omap_hwmod_33xx_43xx_ipblock_data.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/mach-omap2/omap_hwmod_33xx_43xx_ipblock_data.c 
b/arch/arm/mach-omap2/omap_hwmod_33xx_43xx_ipblock_data.c
index a579b89..f1c31f7 100644
--- a/arch/arm/mach-omap2/omap_hwmod_33xx_43xx_ipblock_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_33xx_43xx_ipblock_data.c
@@ -153,6 +153,7 @@ struct omap_hwmod am33xx_pruss_hwmod = {
.name   = pruss,
.class  = am33xx_pruss_hwmod_class,
.clkdm_name = pruss_ocp_clkdm,
+   .flags  = HWMOD_INIT_DEASSERT_HARD_RESET,
.main_clk   = pruss_ocp_gclk,
.prcm   = {
.omap4  = {
-- 
2.0.0

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


[PATCH 03/13] uio: uio_pruss: use devm_ioremap_resource()

2014-06-29 Thread Andre Heider
Replace resource_size() followed by ioremap() with
devm_ioremap_resource() and remove the iounmap() call.

Signed-off-by: Andre Heider a.hei...@gmail.com
---
 drivers/uio/uio_pruss.c | 20 
 1 file changed, 4 insertions(+), 16 deletions(-)

diff --git a/drivers/uio/uio_pruss.c b/drivers/uio/uio_pruss.c
index f07545b..310598a 100644
--- a/drivers/uio/uio_pruss.c
+++ b/drivers/uio/uio_pruss.c
@@ -100,7 +100,6 @@ static void pruss_cleanup(struct device *dev, struct 
uio_pruss_dev *gdev)
uio_unregister_device(p);
kfree(p-name);
}
-   iounmap(gdev-prussio_vaddr);
if (gdev-ddr_vaddr) {
dma_free_coherent(dev, extram_pool_sz, gdev-ddr_vaddr,
gdev-ddr_paddr);
@@ -118,7 +117,7 @@ static int pruss_probe(struct platform_device *pdev)
struct uio_pruss_dev *gdev;
struct resource *regs_prussio;
struct device *dev = pdev-dev;
-   int ret = -ENODEV, cnt = 0, len;
+   int ret = -ENODEV, cnt = 0;
struct uio_pruss_pdata *pdata = dev_get_platdata(dev);
 
gdev = devm_kzalloc(dev, sizeof(struct uio_pruss_dev), GFP_KERNEL);
@@ -139,13 +138,9 @@ static int pruss_probe(struct platform_device *pdev)
}
 
regs_prussio = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-   if (!regs_prussio) {
-   dev_err(dev, No PRUSS I/O resource specified\n);
-   goto out_free;
-   }
-
-   if (!regs_prussio-start) {
-   dev_err(dev, Invalid memory resource\n);
+   gdev-prussio_vaddr = devm_ioremap_resource(dev, regs_prussio);
+   if (IS_ERR(gdev-prussio_vaddr)) {
+   ret = PTR_ERR(gdev-prussio_vaddr);
goto out_free;
}
 
@@ -167,13 +162,6 @@ static int pruss_probe(struct platform_device *pdev)
goto out_free;
}
 
-   len = resource_size(regs_prussio);
-   gdev-prussio_vaddr = ioremap(regs_prussio-start, len);
-   if (!gdev-prussio_vaddr) {
-   dev_err(dev, Can't remap PRUSS I/O  address range\n);
-   goto out_free;
-   }
-
gdev-pintc_base = pdata-pintc_base;
gdev-hostirq_start = platform_get_irq(pdev, 0);
 
-- 
2.0.0

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


[PATCH 11/13] uio: uio_pruss: enable the driver for am33xx SoCs

2014-06-29 Thread Andre Heider
Signed-off-by: Andre Heider a.hei...@gmail.com
---
 drivers/uio/Kconfig | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/uio/Kconfig b/drivers/uio/Kconfig
index 5a90914..1678387 100644
--- a/drivers/uio/Kconfig
+++ b/drivers/uio/Kconfig
@@ -106,10 +106,10 @@ config UIO_NETX
 
 config UIO_PRUSS
tristate Texas Instruments PRUSS driver
-   depends on ARCH_DAVINCI_DA850
+   depends on ARCH_DAVINCI_DA850 || SOC_AM33XX
select GENERIC_ALLOCATOR
help
- PRUSS driver for OMAPL138/DA850/AM18XX devices
+ PRUSS driver for OMAPL138/DA850/AM18XX/AM33XX devices
  PRUSS driver requires user space components, examples and user space
  driver is available from below SVN repo - you may use anonymous login
 
-- 
2.0.0

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


[PATCH 12/13] ARM: dts: am33xx: add the PRUSSv2 device

2014-06-29 Thread Andre Heider
Signed-off-by: Andre Heider a.hei...@gmail.com
---
 arch/arm/boot/dts/am33xx.dtsi | 9 +
 1 file changed, 9 insertions(+)

diff --git a/arch/arm/boot/dts/am33xx.dtsi b/arch/arm/boot/dts/am33xx.dtsi
index 4a4e02d..28a7e5d 100644
--- a/arch/arm/boot/dts/am33xx.dtsi
+++ b/arch/arm/boot/dts/am33xx.dtsi
@@ -409,6 +409,15 @@
ti,hwmods = rtc;
};
 
+   pruss: pruss@4a30 {
+   compatible = ti,pruss-v2;
+   ti,hwmods = pruss;
+   reg = 0x4a30 0x08;
+   interrupts = 20 21 22 23 24 25 26 27;
+   interrupt-parent = intc;
+   status = disabled;
+   };
+
spi0: spi@4803 {
compatible = ti,omap4-mcspi;
#address-cells = 1;
-- 
2.0.0

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


[PATCH 09/13] uio: uio_pruss: add devicetree support

2014-06-29 Thread Andre Heider
Add support to probe via devicetree.

Signed-off-by: Andre Heider a.hei...@gmail.com
---
 drivers/uio/uio_pruss.c | 46 +++---
 1 file changed, 39 insertions(+), 7 deletions(-)

diff --git a/drivers/uio/uio_pruss.c b/drivers/uio/uio_pruss.c
index afaf726..2df54ab 100644
--- a/drivers/uio/uio_pruss.c
+++ b/drivers/uio/uio_pruss.c
@@ -26,6 +26,7 @@
 #include linux/dma-mapping.h
 #include linux/slab.h
 #include linux/genalloc.h
+#include linux/of_device.h
 
 #define DRV_NAME pruss_uio
 #define DRV_VERSION 1.0
@@ -70,6 +71,27 @@ struct uio_pruss_dev {
struct gen_pool *sram_pool;
 };
 
+#ifdef CONFIG_OF
+struct uio_pruss_params {
+   u32 pintc_offset;
+};
+
+static const struct uio_pruss_params uio_pruss_v1_params = {
+   .pintc_offset = 0x4000,
+};
+
+static const struct uio_pruss_params uio_pruss_v2_params = {
+   .pintc_offset = 0x2,
+};
+
+static const struct of_device_id pruss_of_match_table[] = {
+   { .compatible = ti,pruss-v1, .data = uio_pruss_v1_params, },
+   { .compatible = ti,pruss-v2, .data = uio_pruss_v2_params, },
+   {},
+};
+MODULE_DEVICE_TABLE(of, pruss_of_match_table);
+#endif
+
 static irqreturn_t pruss_handler(int irq, struct uio_info *info)
 {
struct uio_pruss_dev *gdev = info-priv;
@@ -111,6 +133,8 @@ static int pruss_probe(struct platform_device *pdev)
struct uio_pruss_dev *gdev;
struct resource *regs_prussio;
struct device *dev = pdev-dev;
+   const struct of_device_id *match;
+   const struct uio_pruss_params *params;
int ret = -ENODEV, cnt = 0, i;
struct uio_pruss_pdata *pdata = dev_get_platdata(dev);
dma_addr_t ddr_paddr;
@@ -123,13 +147,21 @@ static int pruss_probe(struct platform_device *pdev)
if (!gdev-info)
return -ENOMEM;
 
-   /* Power on PRU in case its not done as part of boot-loader */
-   gdev-pruss_clk = clk_get(dev, pruss);
-   if (IS_ERR(gdev-pruss_clk)) {
-   dev_err(dev, Failed to get clock\n);
-   return PTR_ERR(gdev-pruss_clk);
+   if (dev-of_node) {
+   match = of_match_device(pruss_of_match_table, dev);
+   params = match-data;
+   gdev-pintc_base = params-pintc_offset;
} else {
+   /* Power on PRU in case its not done as part of boot-loader */
+   gdev-pruss_clk = clk_get(dev, pruss);
+   if (IS_ERR(gdev-pruss_clk)) {
+   dev_err(dev, Failed to get clock\n);
+   return PTR_ERR(gdev-pruss_clk);
+   }
+
clk_enable(gdev-pruss_clk);
+
+   gdev-pintc_base = pdata-pintc_base;
}
 
regs_prussio = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -139,7 +171,7 @@ static int pruss_probe(struct platform_device *pdev)
goto out_free;
}
 
-   if (pdata-sram_pool) {
+   if (pdata  pdata-sram_pool) {
gdev-sram_pool = pdata-sram_pool;
gdev-sram_vaddr =
(unsigned long)gen_pool_dma_alloc(gdev-sram_pool,
@@ -156,7 +188,6 @@ static int pruss_probe(struct platform_device *pdev)
goto out_free;
}
 
-   gdev-pintc_base = pdata-pintc_base;
gdev-hostirq_start = platform_get_irq(pdev, 0);
 
for (cnt = 0, p = gdev-info; cnt  MAX_PRUSS_EVT; cnt++, p++) {
@@ -214,6 +245,7 @@ static struct platform_driver pruss_driver = {
.driver = {
   .name = DRV_NAME,
   .owner = THIS_MODULE,
+  .of_match_table = of_match_ptr(pruss_of_match_table),
   },
 };
 
-- 
2.0.0

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


[PATCH 10/13] uio: uio_pruss: add runtime pm support

2014-06-29 Thread Andre Heider
This enables the hwmod's associated clocks and gets the device in a
working state.

Signed-off-by: Andre Heider a.hei...@gmail.com
---
 drivers/uio/uio_pruss.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/drivers/uio/uio_pruss.c b/drivers/uio/uio_pruss.c
index 2df54ab..28a1c1f 100644
--- a/drivers/uio/uio_pruss.c
+++ b/drivers/uio/uio_pruss.c
@@ -27,6 +27,7 @@
 #include linux/slab.h
 #include linux/genalloc.h
 #include linux/of_device.h
+#include linux/pm_runtime.h
 
 #define DRV_NAME pruss_uio
 #define DRV_VERSION 1.0
@@ -125,6 +126,7 @@ static void pruss_cleanup(struct device *dev, struct 
uio_pruss_dev *gdev)
  gdev-sram_vaddr,
  sram_pool_sz);
clk_put(gdev-pruss_clk);
+   pm_runtime_disable(dev);
 }
 
 static int pruss_probe(struct platform_device *pdev)
@@ -164,6 +166,13 @@ static int pruss_probe(struct platform_device *pdev)
gdev-pintc_base = pdata-pintc_base;
}
 
+   pm_runtime_enable(dev);
+   ret = pm_runtime_get_sync(dev);
+   if (IS_ERR_VALUE(ret)) {
+   dev_err(dev, pm_runtime_get_sync() failed\n);
+   goto out_free;
+   }
+
regs_prussio = platform_get_resource(pdev, IORESOURCE_MEM, 0);
gdev-prussio_vaddr = devm_ioremap_resource(dev, regs_prussio);
if (IS_ERR(gdev-prussio_vaddr)) {
-- 
2.0.0

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