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 <n...@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 _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot