All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 0/4] ARM: keystone: Add support for TI power processor
@ 2015-08-24 17:59 Nishanth Menon
  2015-08-24 17:59 ` [U-Boot] [PATCH 1/4] ARM: keystone: psc: redo doc in kernel-doc format Nishanth Menon
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Nishanth Menon @ 2015-08-24 17:59 UTC (permalink / raw)
  To: u-boot


The last patch in this series depends on
http://lists.denx.de/pipermail/u-boot/2015-August/225085.html Initial
set is a basic set of cleanups and a new function set to keep modules
in reset while we do some setup on the module - for example a
processor that is enabled, kept in reset while being loaded.

This eventually adds support for TI Power processor called pmmc with
the start of the next generation of TI processors based on keystone
architecture. These processor offloads power management functions to
an embedded microcontroller with a firmware - similar in nature to
what is currently available in AM335x/AM437x - except, the scope of
functionality provided by these power proessors are much more enhanced
from the purely "deep sleep support processor" that it used to be used
for.

Infact, these functionality is so detailed that main processors A15
and High Level Operating Systems(HLOS) such as Linux, running on those
processors are no longer expected to do low level register control for
SoC architecture specific nit-gritties anymore. instead they request
for services from this 'power processor'.

This series is primarily focussed on CM3 'power processor' on the
K2G Keystone SoCs - other processors and SoCs can be entitled in the
future as needed.

Nishanth Menon (4):
  ARM: keystone: psc: redo doc in kernel-doc format
  ARM: keystone: psc-defs: use adequate () for macros
  ARM: keystone: psc: introduce function to hold and release module in
    reset.
  remoteproc: Add support for TI power processor

 arch/arm/mach-keystone/include/mach/psc_defs.h     |  10 +-
 arch/arm/mach-keystone/psc.c                       | 200 ++++++++++++++++-----
 drivers/remoteproc/Kconfig                         |   9 +
 drivers/remoteproc/Makefile                        |   1 +
 drivers/remoteproc/ti_power_proc.c                 | 131 ++++++++++++++
 .../dm/platform_data/remoteproc_ti_power_proc.h    |  15 ++
 6 files changed, 319 insertions(+), 47 deletions(-)
 create mode 100644 drivers/remoteproc/ti_power_proc.c
 create mode 100644 include/dm/platform_data/remoteproc_ti_power_proc.h

-- 
2.1.4

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [U-Boot] [PATCH 1/4] ARM: keystone: psc: redo doc in kernel-doc format
  2015-08-24 17:59 [U-Boot] [PATCH 0/4] ARM: keystone: Add support for TI power processor Nishanth Menon
@ 2015-08-24 17:59 ` Nishanth Menon
  2015-08-24 17:59 ` [U-Boot] [PATCH 2/4] ARM: keystone: psc-defs: use adequate () for macros Nishanth Menon
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Nishanth Menon @ 2015-08-24 17:59 UTC (permalink / raw)
  To: u-boot

u-boot coding style guidance in
http://www.denx.de/wiki/U-Boot/CodingStyle clearly mentions that the
kernel doc style shall be followed for documentation in u-boot.

Current PSC documentation standard does not, so fix that.

Signed-off-by: Nishanth Menon <nm@ti.com>
---
 arch/arm/mach-keystone/psc.c | 96 ++++++++++++++++++++++++--------------------
 1 file changed, 52 insertions(+), 44 deletions(-)

diff --git a/arch/arm/mach-keystone/psc.c b/arch/arm/mach-keystone/psc.c
index 237e776e8790..8991e237735e 100644
--- a/arch/arm/mach-keystone/psc.c
+++ b/arch/arm/mach-keystone/psc.c
@@ -13,24 +13,27 @@
 #include <asm/processor.h>
 #include <asm/arch/psc_defs.h>
 
+/**
+ * psc_delay() - delay for psc
+ *
+ * Return: 10
+ */
 int psc_delay(void)
 {
 	udelay(10);
 	return 10;
 }
 
-/*
- * FUNCTION PURPOSE: Wait for end of transitional state
- *
- * DESCRIPTION: Polls pstat for the selected domain and waits for transitions
- *              to be complete.
+/**
+ * psc_wait() - Wait for end of transitional state
+ * @domain_num: GPSC domain number
  *
- *              Since this is boot loader code it is *ASSUMED* that interrupts
- *              are disabled and no other core is mucking around with the psc
- *              at the same time.
+ * Polls pstat for the selected domain and waits for transitions to be complete.
+ * Since this is boot loader code it is *ASSUMED* that interrupts are disabled
+ * and no other core is mucking around with the psc at the same time.
  *
- *              Returns 0 when the domain is free. Returns -1 if a timeout
- *              occurred waiting for the completion.
+ * Return: 0 when the domain is free. Returns -1 if a timeout occurred waiting
+ * for the completion.
  */
 int psc_wait(u32 domain_num)
 {
@@ -59,6 +62,10 @@ int psc_wait(u32 domain_num)
 	return 0;
 }
 
+/**
+ * psc_get_domain_num() - Get the domain number
+ * @mod_num:	LPSC module number
+ */
 u32 psc_get_domain_num(u32 mod_num)
 {
 	u32 domain_num;
@@ -70,20 +77,19 @@ u32 psc_get_domain_num(u32 mod_num)
 	return domain_num;
 }
 
-/*
- * FUNCTION PURPOSE: Power up/down a module
+/**
+ * psc_set_state() - powers up/down a module
+ * @mod_num:	LPSC module number
+ * @state:	1 to enable, 0 to disable.
  *
- * DESCRIPTION: Powers up/down the requested module and the associated power
- *		domain if required. No action is taken it the module is
- *		already powered up/down.
+ * Powers up/down the requested module and the associated power domain if
+ * required. No action is taken it the module is already powered up/down.
+ * This only controls modules. The domain in which the module resides will
+ * be left in the power on state. Multiple modules can exist in a power
+ * domain, so powering down the domain based on a single module is not done.
  *
- *              This only controls modules. The domain in which the module
- *              resides will be left in the power on state. Multiple modules
- *              can exist in a power domain, so powering down the domain based
- *              on a single module is not done.
- *
- *              Returns 0 on success, -1 if the module can't be powered up, or
- *              if there is a timeout waiting for the transition.
+ * Return: 0 on success, -1 if the module can't be powered up, or if there is a
+ * timeout waiting for the transition.
  */
 int psc_set_state(u32 mod_num, u32 state)
 {
@@ -136,15 +142,16 @@ int psc_set_state(u32 mod_num, u32 state)
 	return psc_wait(domain_num);
 }
 
-/*
- * FUNCTION PURPOSE: Power up a module
+/**
+ * psc_enable_module() - power up a module
+ * @mod_num:	LPSC module number
  *
- * DESCRIPTION: Powers up the requested module and the associated power domain
- *              if required. No action is taken it the module is already
- *              powered up.
+ * Powers up the requested module and the associated power domain
+ * if required. No action is taken it the module is already powered up.
+ *
+ * Return: 0 on success, -1 if the module can't be powered up, or
+ * if there is a timeout waiting for the transition.
  *
- *              Returns 0 on success, -1 if the module can't be powered up, or
- *              if there is a timeout waiting for the transition.
  */
 int psc_enable_module(u32 mod_num)
 {
@@ -158,12 +165,11 @@ int psc_enable_module(u32 mod_num)
 	return psc_set_state(mod_num, PSC_REG_VAL_MDCTL_NEXT_ON);
 }
 
-/*
- * FUNCTION PURPOSE: Power down a module
+/**
+ * psc_disable_module() - Power down a module
+ * @mod_num:	LPSC module number
  *
- * DESCRIPTION: Powers down the requested module.
- *
- *              Returns 0 on success, -1 on failure or timeout.
+ * Return: 0 on success, -1 on failure or timeout.
  */
 int psc_disable_module(u32 mod_num)
 {
@@ -179,13 +185,16 @@ int psc_disable_module(u32 mod_num)
 	return psc_set_state(mod_num, PSC_REG_VAL_MDCTL_NEXT_SWRSTDISABLE);
 }
 
-/*
- * FUNCTION PURPOSE: Set the reset isolation bit in mdctl
+/**
+ * psc_set_reset_iso() - Set the reset isolation bit in mdctl
+ * @mod_num:	LPSC module number
  *
- * DESCRIPTION: The reset isolation enable bit is set. The state of the module
- *              is not changed. Returns 0 if the module config showed that
- *              reset isolation is supported. Returns 1 otherwise. This is not
- *              an error, but setting the bit in mdctl has no effect.
+ * The reset isolation enable bit is set. The state of the module is not
+ * changed.
+ *
+ * Return: 0 if the module config showed that reset isolation is supported.
+ * Returns 1 otherwise. This is not an error, but setting the bit in mdctl
+ * has no effect.
  */
 int psc_set_reset_iso(u32 mod_num)
 {
@@ -204,10 +213,9 @@ int psc_set_reset_iso(u32 mod_num)
 	return 1;
 }
 
-/*
- * FUNCTION PURPOSE: Disable a power domain
- *
- * DESCRIPTION: The power domain is disabled
+/**
+ * psc_disable_domain() - Disable a power domain
+ * @domain_num: GPSC domain number
  */
 int psc_disable_domain(u32 domain_num)
 {
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [U-Boot] [PATCH 2/4] ARM: keystone: psc-defs: use adequate () for macros
  2015-08-24 17:59 [U-Boot] [PATCH 0/4] ARM: keystone: Add support for TI power processor Nishanth Menon
  2015-08-24 17:59 ` [U-Boot] [PATCH 1/4] ARM: keystone: psc: redo doc in kernel-doc format Nishanth Menon
@ 2015-08-24 17:59 ` Nishanth Menon
  2015-08-24 18:00 ` [U-Boot] [PATCH 3/4] ARM: keystone: psc: introduce function to hold and release module in reset Nishanth Menon
  2015-08-24 18:00 ` [U-Boot] [PATCH 4/4] remoteproc: Add support for TI power processor Nishanth Menon
  3 siblings, 0 replies; 5+ messages in thread
From: Nishanth Menon @ 2015-08-24 17:59 UTC (permalink / raw)
  To: u-boot

'#define X a | b' is better defined as '#define X (a | b)' for obvious
reasons.

Signed-off-by: Nishanth Menon <nm@ti.com>
---
 arch/arm/mach-keystone/include/mach/psc_defs.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/arm/mach-keystone/include/mach/psc_defs.h b/arch/arm/mach-keystone/include/mach/psc_defs.h
index 70d22cf21787..2202946be5ea 100644
--- a/arch/arm/mach-keystone/include/mach/psc_defs.h
+++ b/arch/arm/mach-keystone/include/mach/psc_defs.h
@@ -30,9 +30,9 @@
 #define BOOTBITMASK(x, y)     ((((((u32)1 << (((u32)x) - ((u32)y) + (u32)1)) - \
 				  (u32)1)) << ((u32)y)))
 
-#define BOOT_READ_BITFIELD(z, x, y)    (((u32)z) & BOOTBITMASK(x, y)) >> (y)
-#define BOOT_SET_BITFIELD(z, f, x, y)  (((u32)z) & ~BOOTBITMASK(x, y)) | \
-					 ((((u32)f) << (y)) & BOOTBITMASK(x, y))
+#define BOOT_READ_BITFIELD(z, x, y)    ((((u32)z) & BOOTBITMASK(x, y)) >> (y))
+#define BOOT_SET_BITFIELD(z, f, x, y)  ((((u32)z) & ~BOOTBITMASK(x, y)) | \
+					((((u32)f) << (y)) & BOOTBITMASK(x, y)))
 
 /* PDCTL */
 #define PSC_REG_PDCTL_SET_NEXT(x, y)        BOOT_SET_BITFIELD((x), (y), 0, 0)
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [U-Boot] [PATCH 3/4] ARM: keystone: psc: introduce function to hold and release module in reset.
  2015-08-24 17:59 [U-Boot] [PATCH 0/4] ARM: keystone: Add support for TI power processor Nishanth Menon
  2015-08-24 17:59 ` [U-Boot] [PATCH 1/4] ARM: keystone: psc: redo doc in kernel-doc format Nishanth Menon
  2015-08-24 17:59 ` [U-Boot] [PATCH 2/4] ARM: keystone: psc-defs: use adequate () for macros Nishanth Menon
@ 2015-08-24 18:00 ` Nishanth Menon
  2015-08-24 18:00 ` [U-Boot] [PATCH 4/4] remoteproc: Add support for TI power processor Nishanth Menon
  3 siblings, 0 replies; 5+ messages in thread
From: Nishanth Menon @ 2015-08-24 18:00 UTC (permalink / raw)
  To: u-boot

These are useful for modules that need to be held in reset and are
enabled for data to be loaded on to them. Typically these are
microcontrollers or other processing entities in the system.

Signed-off-by: Nishanth Menon <nm@ti.com>
---
 arch/arm/mach-keystone/include/mach/psc_defs.h |   4 +
 arch/arm/mach-keystone/psc.c                   | 104 +++++++++++++++++++++++++
 2 files changed, 108 insertions(+)

diff --git a/arch/arm/mach-keystone/include/mach/psc_defs.h b/arch/arm/mach-keystone/include/mach/psc_defs.h
index 2202946be5ea..6e6e7fd433a1 100644
--- a/arch/arm/mach-keystone/include/mach/psc_defs.h
+++ b/arch/arm/mach-keystone/include/mach/psc_defs.h
@@ -56,6 +56,8 @@
 #define PSC_REG_MDSTAT_GET_STATUS(x)        BOOT_READ_BITFIELD((x), 5, 0)
 #define PSC_REG_MDSTAT_GET_LRSTZ(x)         BOOT_READ_BITFIELD((x), 8, 8)
 #define PSC_REG_MDSTAT_GET_LRSTDONE(x)      BOOT_READ_BITFIELD((x), 9, 9)
+#define PSC_REG_MDSTAT_GET_MRSTZ(x)         BOOT_READ_BITFIELD((x), 10, 10)
+#define PSC_REG_MDSTAT_GET_MRSTDONE(x)      BOOT_READ_BITFIELD((x), 11, 11)
 
 /* PDCTL states */
 #define PSC_REG_VAL_PDCTL_NEXT_ON           1
@@ -86,5 +88,7 @@ u32 psc_get_domain_num(u32 mod_num);
 int psc_enable_module(u32 mod_num);
 int psc_disable_module(u32 mod_num);
 int psc_disable_domain(u32 domain_num);
+int psc_module_keep_in_reset_enabled(u32 mod_num, bool gate_clocks);
+int psc_module_release_from_reset(u32 mod_num);
 
 #endif /* _PSC_DEFS_H_ */
diff --git a/arch/arm/mach-keystone/psc.c b/arch/arm/mach-keystone/psc.c
index 8991e237735e..ff042a6db2dd 100644
--- a/arch/arm/mach-keystone/psc.c
+++ b/arch/arm/mach-keystone/psc.c
@@ -233,3 +233,107 @@ int psc_disable_domain(u32 domain_num)
 
 	return psc_wait(domain_num);
 }
+
+/**
+ * psc_module_keep_in_reset_enabled() - Keep module in enabled,in-reset state
+ * @mod_num:	LPSC module number
+ * @gate_clocks: Can the clocks be gated on this module?
+ *
+ * Enable the module, but do not release the module from local reset. This is
+ * necessary for many processor systems on keystone SoCs to allow for system
+ * initialization from a master processor prior to releasing the processor
+ * from reset.
+ */
+int psc_module_keep_in_reset_enabled(u32 mod_num, bool gate_clocks)
+{
+	u32 mdctl, ptcmd, mdstat;
+	u32 next_state;
+	int domain_num = psc_get_domain_num(mod_num);
+	int timeout = 100000;
+
+	/* Wait for any previous transitions to complete */
+	psc_wait(domain_num);
+	mdctl = __raw_readl(KS2_PSC_BASE + PSC_REG_MDCTL(mod_num));
+	/* Should be set 0 to assert Local reset */
+	if ((mdctl & PSC_REG_MDCTL_SET_LRSTZ(mdctl, 1))) {
+		mdctl = PSC_REG_MDCTL_SET_LRSTZ(mdctl, 0);
+		__raw_writel(mdctl, KS2_PSC_BASE + PSC_REG_MDCTL(mod_num));
+		/* Wait for transition to take place */
+		psc_wait(domain_num);
+	}
+
+	/* Clear Module reset */
+	mdctl = __raw_readl(KS2_PSC_BASE + PSC_REG_MDCTL(mod_num));
+	next_state = gate_clocks ? PSC_REG_VAL_MDCTL_NEXT_OFF :
+			PSC_REG_VAL_MDCTL_NEXT_ON;
+	mdctl = PSC_REG_MDCTL_SET_NEXT(mdctl, next_state);
+	__raw_writel(mdctl, KS2_PSC_BASE + PSC_REG_MDCTL(mod_num));
+	/* Trigger PD transition */
+	ptcmd = __raw_readl(KS2_PSC_BASE + PSC_REG_PTCMD);
+	ptcmd |= (u32)(1 << domain_num);
+	__raw_writel(ptcmd, KS2_PSC_BASE + PSC_REG_PTCMD);
+	psc_wait(domain_num);
+
+	mdstat = __raw_readl(KS2_PSC_BASE + PSC_REG_MDSTAT(mod_num));
+	while (timeout) {
+		mdstat = __raw_readl(KS2_PSC_BASE + PSC_REG_MDSTAT(mod_num));
+
+		if (!(PSC_REG_MDSTAT_GET_STATUS(mdstat) & 0x30) &&
+		    PSC_REG_MDSTAT_GET_MRSTDONE(mdstat) &&
+		    PSC_REG_MDSTAT_GET_LRSTDONE(mdstat))
+			break;
+		timeout--;
+	}
+
+	if (!timeout) {
+		printf("%s: Timedout waiting for mdstat(0x%08x) to change\n",
+		       __func__, mdstat);
+		return -ETIMEDOUT;
+	}
+	return 0;
+}
+
+/**
+ * psc_module_release_from_reset() - Release the module from reset
+ * @mod_num:	LPSC module number
+ *
+ * This is the follow through for the command 'psc_module_keep_in_reset_enabled'
+ * Allowing the module to be released from reset once all required inits are
+ * complete for the module. Typically, this allows the processor module to start
+ * execution.
+ */
+int psc_module_release_from_reset(u32 mod_num)
+{
+	u32 mdctl, mdstat;
+	int domain_num = psc_get_domain_num(mod_num);
+	int timeout = 100000;
+
+	/* Wait for any previous transitions to complete */
+	psc_wait(domain_num);
+	mdctl = __raw_readl(KS2_PSC_BASE + PSC_REG_MDCTL(mod_num));
+	/* Should be set to 1 to de-assert Local reset */
+	if ((mdctl & PSC_REG_MDCTL_SET_LRSTZ(mdctl, 0))) {
+		mdctl = PSC_REG_MDCTL_SET_LRSTZ(mdctl, 1);
+		__raw_writel(mdctl, KS2_PSC_BASE + PSC_REG_MDCTL(mod_num));
+		/* Wait for transition to take place */
+		psc_wait(domain_num);
+	}
+	mdstat = __raw_readl(KS2_PSC_BASE + PSC_REG_MDSTAT(mod_num));
+	while (timeout) {
+		mdstat = __raw_readl(KS2_PSC_BASE + PSC_REG_MDSTAT(mod_num));
+
+		if (!(PSC_REG_MDSTAT_GET_STATUS(mdstat) & 0x30) &&
+		    PSC_REG_MDSTAT_GET_MRSTDONE(mdstat) &&
+		    PSC_REG_MDSTAT_GET_LRSTDONE(mdstat))
+			break;
+		timeout--;
+	}
+
+	if (!timeout) {
+		printf("%s: Timedout waiting for mdstat(0x%08x) to change\n",
+		       __func__, mdstat);
+		return -ETIMEDOUT;
+	}
+
+	return 0;
+}
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [U-Boot] [PATCH 4/4] remoteproc: Add support for TI power processor
  2015-08-24 17:59 [U-Boot] [PATCH 0/4] ARM: keystone: Add support for TI power processor Nishanth Menon
                   ` (2 preceding siblings ...)
  2015-08-24 18:00 ` [U-Boot] [PATCH 3/4] ARM: keystone: psc: introduce function to hold and release module in reset Nishanth Menon
@ 2015-08-24 18:00 ` Nishanth Menon
  3 siblings, 0 replies; 5+ messages in thread
From: Nishanth Menon @ 2015-08-24 18:00 UTC (permalink / raw)
  To: u-boot

Many TI System on Chip (SoC) solutions do have a dedicated
microcontroller for doing power management functionality. These include
the AM335x, AM437x, Keystone K2G SoCs. The functionality provided by
these microcontrollers and the communication mechanisms vary very
widely. However, we are able to consolidate some basic functionality to
be generic enough starting with K2G SoC family. Introduce a basic remote
proc driver to support these microcontrollers. In fact, on SoCs starting
with K2G, basic power management functions are primarily accessible for
the High Level Operating Systems(HLOS) via these microcontroller solutions.

Hence, having these started at a bootloader level is pretty much
mandatory.

NOTE: DT conversion is not done at this point in time.

Signed-off-by: Nishanth Menon <nm@ti.com>
---

Depends on http://lists.denx.de/pipermail/u-boot/2015-August/225085.html

 drivers/remoteproc/Kconfig                         |   9 ++
 drivers/remoteproc/Makefile                        |   1 +
 drivers/remoteproc/ti_power_proc.c                 | 131 +++++++++++++++++++++
 .../dm/platform_data/remoteproc_ti_power_proc.h    |  15 +++
 4 files changed, 156 insertions(+)
 create mode 100644 drivers/remoteproc/ti_power_proc.c
 create mode 100644 include/dm/platform_data/remoteproc_ti_power_proc.h

diff --git a/drivers/remoteproc/Kconfig b/drivers/remoteproc/Kconfig
index 61cc506d6baa..75fb9340f47d 100644
--- a/drivers/remoteproc/Kconfig
+++ b/drivers/remoteproc/Kconfig
@@ -21,4 +21,13 @@ config DM_TESTPROC_SANDBOX
 	help
 	  Say 'y' here to add support for test processor which does dummy
 	  operations for sandbox platform.
+
+config DM_POWER_PROC_TI
+	bool "Support for TI Power processor"
+	select DM_REMOTEPROC
+	depends on DM
+	depends on ARCH_KEYSTONE
+	help
+	  Say 'y' here to add support for TI power processors such as those
+	  found on certain TI keystone and OMAP generation SoCs
 endmenu
diff --git a/drivers/remoteproc/Makefile b/drivers/remoteproc/Makefile
index 57c04d0e024a..ea79f193cb02 100644
--- a/drivers/remoteproc/Makefile
+++ b/drivers/remoteproc/Makefile
@@ -8,3 +8,4 @@ obj-$(CONFIG_DM_REMOTEPROC) += rproc-uclass.o
 
 # Remote proc drivers - Please keep this list alphabetically sorted.
 obj-$(CONFIG_DM_TESTPROC_SANDBOX) += sandbox_testproc.o
+obj-$(CONFIG_DM_POWER_PROC_TI) += ti_power_proc.o
diff --git a/drivers/remoteproc/ti_power_proc.c b/drivers/remoteproc/ti_power_proc.c
new file mode 100644
index 000000000000..76b13093c0d8
--- /dev/null
+++ b/drivers/remoteproc/ti_power_proc.c
@@ -0,0 +1,131 @@
+/*
+ * (C) Copyright 2015
+ * Texas Instruments Incorporated - http://www.ti.com/
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+#define DEBUG 1
+#define pr_fmt(fmt) "%s: " fmt, __func__
+#include <common.h>
+#include <dm.h>
+#include <errno.h>
+#include <remoteproc.h>
+#include <mach/psc_defs.h>
+#include <dm/platform_data/remoteproc_ti_power_proc.h>
+
+static int ti_powerproc_probe(struct udevice *dev)
+{
+	struct dm_rproc_uclass_pdata *uc_pdata;
+	struct ti_powerproc_platdata *pdata;
+
+	uc_pdata = dev_get_uclass_platdata(dev);
+	if (!uc_pdata) {
+		printf("%s: no uc pdata!\n", dev->name);
+		return -EINVAL;
+	}
+
+	pdata = uc_pdata->driver_plat_data;
+	if (!pdata) {
+		printf("%s unable to find driver platform data\n",
+		       uc_pdata->name);
+		return -EINVAL;
+	}
+
+	printf("%s probed with slave_addr=0x%08lX module=%d\n",
+	       uc_pdata->name, pdata->slave_base, pdata->module);
+	return 0;
+}
+
+static int ti_powerproc_load(struct udevice *dev, ulong addr, ulong size)
+{
+	struct dm_rproc_uclass_pdata *uc_pdata;
+	struct ti_powerproc_platdata *pdata;
+	int ret;
+
+	uc_pdata = dev_get_uclass_platdata(dev);
+	if (!uc_pdata) {
+		printf("%s: no uc pdata!\n", dev->name);
+		return -EINVAL;
+	}
+
+	pdata = uc_pdata->driver_plat_data;
+	if (!pdata) {
+		printf("%s unable to find driver platform data\n",
+		       uc_pdata->name);
+		return -EINVAL;
+	}
+	ret = psc_module_keep_in_reset_enabled(pdata->module, false);
+	if (ret) {
+		printf("%s Unable to disable module '%d'(ret=%d)\n",
+		       uc_pdata->name, pdata->module, ret);
+		return ret;
+	}
+
+	printf("%s: Loading binary from 0x%08lX, size 0x%08lX to 0x%08lX\n",
+	       uc_pdata->name, addr, size, pdata->slave_base);
+
+	memcpy((void *)pdata->slave_base, (void *)addr, size);
+
+	printf("%s: Complete!\n", uc_pdata->name);
+	return 0;
+}
+
+static int ti_powerproc_start(struct udevice *dev)
+{
+	struct dm_rproc_uclass_pdata *uc_pdata;
+	struct ti_powerproc_platdata *pdata;
+	int ret;
+
+	uc_pdata = dev_get_uclass_platdata(dev);
+	if (!uc_pdata) {
+		printf("%s: no uc pdata!\n", dev->name);
+		return -EINVAL;
+	}
+
+	pdata = uc_pdata->driver_plat_data;
+	if (!pdata) {
+		printf("%s unable to find driver platform data\n",
+		       uc_pdata->name);
+		return -EINVAL;
+	}
+	ret = psc_disable_module(pdata->module);
+	if (ret) {
+		printf("%s Unable to disable module '%d'(ret=%d)\n",
+		       uc_pdata->name, pdata->module, ret);
+		return ret;
+	}
+
+	ret = psc_module_release_from_reset(pdata->module);
+	if (ret) {
+		printf("%s Failed to wait for module '%d'(ret=%d)\n",
+		       uc_pdata->name, pdata->module, ret);
+		return ret;
+	}
+	ret = psc_enable_module(pdata->module);
+	if (ret) {
+		printf("%s Unable to disable module '%d'(ret=%d)\n",
+		       uc_pdata->name, pdata->module, ret);
+		return ret;
+	}
+
+	return 0;
+}
+
+static const struct dm_rproc_ops ti_powerproc_ops = {
+	.load = ti_powerproc_load,
+	.start = ti_powerproc_start,
+};
+
+static const struct udevice_id ti_powerproc_ids[] = {
+	{.compatible = "sandbox,test-processor"},
+	{}
+};
+
+U_BOOT_DRIVER(ti_powerproc) = {
+	/* *INDENT-OFF* */
+	.name = "ti_power_proc",
+	.of_match = ti_powerproc_ids,
+	.id = UCLASS_RPROC,
+	.ops = &ti_powerproc_ops,
+	.probe = ti_powerproc_probe,
+	/* *INDENT-ON* */
+};
diff --git a/include/dm/platform_data/remoteproc_ti_power_proc.h b/include/dm/platform_data/remoteproc_ti_power_proc.h
new file mode 100644
index 000000000000..c09243b4b713
--- /dev/null
+++ b/include/dm/platform_data/remoteproc_ti_power_proc.h
@@ -0,0 +1,15 @@
+/*
+ * (C) Copyright 2015
+ * Texas Instruments Incorporated - http://www.ti.com/
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#ifndef __REMOTEPROC_POWER_PROC_TI_H__
+#define __REMOTEPROC_POWER_PROC_TI_H__
+
+struct ti_powerproc_platdata {
+	ulong slave_base;
+	u32 module;
+};
+
+#endif /* __REMOTEPROC_POWER_PROC_TI_H__ */
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-08-24 18:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-24 17:59 [U-Boot] [PATCH 0/4] ARM: keystone: Add support for TI power processor Nishanth Menon
2015-08-24 17:59 ` [U-Boot] [PATCH 1/4] ARM: keystone: psc: redo doc in kernel-doc format Nishanth Menon
2015-08-24 17:59 ` [U-Boot] [PATCH 2/4] ARM: keystone: psc-defs: use adequate () for macros Nishanth Menon
2015-08-24 18:00 ` [U-Boot] [PATCH 3/4] ARM: keystone: psc: introduce function to hold and release module in reset Nishanth Menon
2015-08-24 18:00 ` [U-Boot] [PATCH 4/4] remoteproc: Add support for TI power processor Nishanth Menon

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.