Driver changes for ti-sysc for v4.17
This series of changes enables the use device tree based sysconfig data for ti-sysc driver. As we already have SmartReflex data configured, we use that as the first driver to enable. To do that in a way where SmartReflex is not probed twice, we need to prepare the SmartReflex driver before flipping dts data on for it in the last patch of the series. To avoid regressions, we are checking the passed dts data against existing platform data since we still have it available. Then after the dts files are converted, we can simply drop the related platform data at some point in the future. -----BEGIN PGP SIGNATURE----- iQJFBAABCAAvFiEEkgNvrZJU/QSQYIcQG9Q+yVyrpXMFAlqdehERHHRvbnlAYXRv bWlkZS5jb20ACgkQG9Q+yVyrpXMRihAA2jlmAf4dePwe0K5V1VlQINbAU/FV+tXN 1oasvGwNBxaJMqJeZAdBd/veuXgrsprIbmlMmF+zP/wQDYiMccr0+ZvzMsUKJ9aA mgzpW/pkpZEbi0ncci4UhQVOuZLja1xxtQ+ZGx82Vo7MXyU2jU9/Wzk67B4BZLws 1MGTsy5VZZh+wicq46eW9AspvFhKCMIw6Ylor3lfmm08H3V/cq9A8dHQeWX2jjsC hSw9RzglGMi58FQ8cqNkxbD38r1VZh74OOqzOOlcJ5CwLWzIJwanWfwDesVb4ZTL bdrn/Aps5b223LTAFN97vwUmyux/ja17YyCC5fU6C6wskgN+9jhPSslzFbFbU0kT 4chc5OYcdq5Lhm+vLCe2H5rB14KQxy6Ugb6aT+XAUOq0hw6tRSG17kqlXk/KtwrG cDzPJzPjG/PDb8hW0Bd7JcjLqadmh7w1180KtT+9IayQM50XxcwwAOPT0XdUEUeP aKIp5cRfOm/75KUIiNomhmoAd1pxX1G6y2qo49p3fbY0nJx09MgtQvWlbDrbhL8+ ACp2adGAlLqsW26E44cqNwMPPhyVcQXlVD9bc2D04nVhXapvRHtlrW4cRkkbQzfw dAiQHDaBn4geSBUqGayQaIvX1WWqeZ6nzpI0JlyHPMiQdkdDvtyUqhJuK2uaY39n vyRPw2H09ZM= =/hJY -----END PGP SIGNATURE----- Merge tag 'omap-for-v4.17/ti-sysc-signed' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/tmlind/linux-omap into next/soc Pull "Driver changes for ti-sysc for v4.17" from Tony Lindgren: This series of changes enables the use device tree based sysconfig data for ti-sysc driver. As we already have SmartReflex data configured, we use that as the first driver to enable. To do that in a way where SmartReflex is not probed twice, we need to prepare the SmartReflex driver before flipping dts data on for it in the last patch of the series. To avoid regressions, we are checking the passed dts data against existing platform data since we still have it available. Then after the dts files are converted, we can simply drop the related platform data at some point in the future. * tag 'omap-for-v4.17/ti-sysc-signed' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/tmlind/linux-omap: ARM: OMAP2+: Enable ti-sysc to use device tree data for smartreflex PM / AVS: SmartReflex: Prepare to use device tree based probing ARM: OMAP2+: Try to parse earlycon from parent too ARM: OMAP2+: Add checks for device tree based sysconfig data ARM: OMAP2+: Add functions to allocate module data from device tree bus: ti-sysc: Handle some devices in omap_device compatible way bus: ti-sysc: Add support for platform data callbacks bus: ti-sysc: Remove unnecessary debugging statements bus: ti-sysc: Improve handling for no-reset-on-init and no-idle-on-init bus: ti-sysc: Handle stdout-path for debug console bus: ti-sysc: Add suspend and resume handling bus: ti-sysc: Add fck clock alias for children with notifier_block ARM: OMAP2+: Prepare to pass auxdata for smartreflex
This commit is contained in:
Коммит
3bf5c70d06
|
@ -566,11 +566,11 @@ static int n8x0_menelaus_late_init(struct device *dev)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct menelaus_platform_data n8x0_menelaus_platform_data __initdata = {
|
struct menelaus_platform_data n8x0_menelaus_platform_data = {
|
||||||
.late_init = n8x0_menelaus_late_init,
|
.late_init = n8x0_menelaus_late_init,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct aic3x_pdata n810_aic33_data __initdata = {
|
struct aic3x_pdata n810_aic33_data = {
|
||||||
.gpio_reset = 118,
|
.gpio_reset = 118,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -140,6 +140,7 @@ static int omap_device_build_from_dt(struct platform_device *pdev)
|
||||||
struct omap_device *od;
|
struct omap_device *od;
|
||||||
struct omap_hwmod *oh;
|
struct omap_hwmod *oh;
|
||||||
struct device_node *node = pdev->dev.of_node;
|
struct device_node *node = pdev->dev.of_node;
|
||||||
|
struct resource res;
|
||||||
const char *oh_name;
|
const char *oh_name;
|
||||||
int oh_cnt, i, ret = 0;
|
int oh_cnt, i, ret = 0;
|
||||||
bool device_active = false;
|
bool device_active = false;
|
||||||
|
@ -150,6 +151,10 @@ static int omap_device_build_from_dt(struct platform_device *pdev)
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Use ti-sysc driver instead of omap_device? */
|
||||||
|
if (!omap_hwmod_parse_module_range(NULL, node, &res))
|
||||||
|
return -ENODEV;
|
||||||
|
|
||||||
hwmods = kzalloc(sizeof(struct omap_hwmod *) * oh_cnt, GFP_KERNEL);
|
hwmods = kzalloc(sizeof(struct omap_hwmod *) * oh_cnt, GFP_KERNEL);
|
||||||
if (!hwmods) {
|
if (!hwmods) {
|
||||||
ret = -ENOMEM;
|
ret = -ENOMEM;
|
||||||
|
|
|
@ -145,6 +145,8 @@
|
||||||
|
|
||||||
#include <linux/platform_data/ti-sysc.h>
|
#include <linux/platform_data/ti-sysc.h>
|
||||||
|
|
||||||
|
#include <dt-bindings/bus/ti-sysc.h>
|
||||||
|
|
||||||
#include <asm/system_misc.h>
|
#include <asm/system_misc.h>
|
||||||
|
|
||||||
#include "clock.h"
|
#include "clock.h"
|
||||||
|
@ -2498,7 +2500,7 @@ static void __init _setup_postsetup(struct omap_hwmod *oh)
|
||||||
* affects the IP block hardware, or system integration hardware
|
* affects the IP block hardware, or system integration hardware
|
||||||
* associated with the IP block. Returns 0.
|
* associated with the IP block. Returns 0.
|
||||||
*/
|
*/
|
||||||
static int __init _setup(struct omap_hwmod *oh, void *data)
|
static int _setup(struct omap_hwmod *oh, void *data)
|
||||||
{
|
{
|
||||||
if (oh->_state != _HWMOD_STATE_INITIALIZED)
|
if (oh->_state != _HWMOD_STATE_INITIALIZED)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -3060,6 +3062,414 @@ int __init omap_hwmod_setup_one(const char *oh_name)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void omap_hwmod_check_one(struct device *dev,
|
||||||
|
const char *name, s8 v1, u8 v2)
|
||||||
|
{
|
||||||
|
if (v1 < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (v1 != v2)
|
||||||
|
dev_warn(dev, "%s %d != %d\n", name, v1, v2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* omap_hwmod_check_sysc - check sysc against platform sysc
|
||||||
|
* @dev: struct device
|
||||||
|
* @data: module data
|
||||||
|
* @sysc_fields: new sysc configuration
|
||||||
|
*/
|
||||||
|
static int omap_hwmod_check_sysc(struct device *dev,
|
||||||
|
const struct ti_sysc_module_data *data,
|
||||||
|
struct sysc_regbits *sysc_fields)
|
||||||
|
{
|
||||||
|
const struct sysc_regbits *regbits = data->cap->regbits;
|
||||||
|
|
||||||
|
omap_hwmod_check_one(dev, "dmadisable_shift",
|
||||||
|
regbits->dmadisable_shift,
|
||||||
|
sysc_fields->dmadisable_shift);
|
||||||
|
omap_hwmod_check_one(dev, "midle_shift",
|
||||||
|
regbits->midle_shift,
|
||||||
|
sysc_fields->midle_shift);
|
||||||
|
omap_hwmod_check_one(dev, "sidle_shift",
|
||||||
|
regbits->sidle_shift,
|
||||||
|
sysc_fields->sidle_shift);
|
||||||
|
omap_hwmod_check_one(dev, "clkact_shift",
|
||||||
|
regbits->clkact_shift,
|
||||||
|
sysc_fields->clkact_shift);
|
||||||
|
omap_hwmod_check_one(dev, "enwkup_shift",
|
||||||
|
regbits->enwkup_shift,
|
||||||
|
sysc_fields->enwkup_shift);
|
||||||
|
omap_hwmod_check_one(dev, "srst_shift",
|
||||||
|
regbits->srst_shift,
|
||||||
|
sysc_fields->srst_shift);
|
||||||
|
omap_hwmod_check_one(dev, "autoidle_shift",
|
||||||
|
regbits->autoidle_shift,
|
||||||
|
sysc_fields->autoidle_shift);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* omap_hwmod_init_regbits - init sysconfig specific register bits
|
||||||
|
* @dev: struct device
|
||||||
|
* @data: module data
|
||||||
|
* @sysc_fields: new sysc configuration
|
||||||
|
*/
|
||||||
|
static int omap_hwmod_init_regbits(struct device *dev,
|
||||||
|
const struct ti_sysc_module_data *data,
|
||||||
|
struct sysc_regbits **sysc_fields)
|
||||||
|
{
|
||||||
|
*sysc_fields = NULL;
|
||||||
|
|
||||||
|
switch (data->cap->type) {
|
||||||
|
case TI_SYSC_OMAP2:
|
||||||
|
case TI_SYSC_OMAP2_TIMER:
|
||||||
|
*sysc_fields = &omap_hwmod_sysc_type1;
|
||||||
|
break;
|
||||||
|
case TI_SYSC_OMAP3_SHAM:
|
||||||
|
*sysc_fields = &omap3_sham_sysc_fields;
|
||||||
|
break;
|
||||||
|
case TI_SYSC_OMAP3_AES:
|
||||||
|
*sysc_fields = &omap3xxx_aes_sysc_fields;
|
||||||
|
break;
|
||||||
|
case TI_SYSC_OMAP4:
|
||||||
|
case TI_SYSC_OMAP4_TIMER:
|
||||||
|
*sysc_fields = &omap_hwmod_sysc_type2;
|
||||||
|
break;
|
||||||
|
case TI_SYSC_OMAP4_SIMPLE:
|
||||||
|
*sysc_fields = &omap_hwmod_sysc_type3;
|
||||||
|
break;
|
||||||
|
case TI_SYSC_OMAP34XX_SR:
|
||||||
|
*sysc_fields = &omap34xx_sr_sysc_fields;
|
||||||
|
break;
|
||||||
|
case TI_SYSC_OMAP36XX_SR:
|
||||||
|
*sysc_fields = &omap36xx_sr_sysc_fields;
|
||||||
|
break;
|
||||||
|
case TI_SYSC_OMAP4_SR:
|
||||||
|
*sysc_fields = &omap36xx_sr_sysc_fields;
|
||||||
|
break;
|
||||||
|
case TI_SYSC_OMAP4_MCASP:
|
||||||
|
*sysc_fields = &omap_hwmod_sysc_type_mcasp;
|
||||||
|
break;
|
||||||
|
case TI_SYSC_OMAP4_USB_HOST_FS:
|
||||||
|
*sysc_fields = &omap_hwmod_sysc_type_usb_host_fs;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return omap_hwmod_check_sysc(dev, data, *sysc_fields);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* omap_hwmod_init_reg_offs - initialize sysconfig register offsets
|
||||||
|
* @dev: struct device
|
||||||
|
* @data: module data
|
||||||
|
* @rev_offs: revision register offset
|
||||||
|
* @sysc_offs: sysc register offset
|
||||||
|
* @syss_offs: syss register offset
|
||||||
|
*/
|
||||||
|
int omap_hwmod_init_reg_offs(struct device *dev,
|
||||||
|
const struct ti_sysc_module_data *data,
|
||||||
|
u32 *rev_offs, u32 *sysc_offs, u32 *syss_offs)
|
||||||
|
{
|
||||||
|
*rev_offs = 0;
|
||||||
|
*sysc_offs = 0;
|
||||||
|
*syss_offs = 0;
|
||||||
|
|
||||||
|
if (data->offsets[SYSC_REVISION] > 0)
|
||||||
|
*rev_offs = data->offsets[SYSC_REVISION];
|
||||||
|
|
||||||
|
if (data->offsets[SYSC_SYSCONFIG] > 0)
|
||||||
|
*sysc_offs = data->offsets[SYSC_SYSCONFIG];
|
||||||
|
|
||||||
|
if (data->offsets[SYSC_SYSSTATUS] > 0)
|
||||||
|
*syss_offs = data->offsets[SYSC_SYSSTATUS];
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* omap_hwmod_init_sysc_flags - initialize sysconfig features
|
||||||
|
* @dev: struct device
|
||||||
|
* @data: module data
|
||||||
|
* @sysc_flags: module configuration
|
||||||
|
*/
|
||||||
|
int omap_hwmod_init_sysc_flags(struct device *dev,
|
||||||
|
const struct ti_sysc_module_data *data,
|
||||||
|
u32 *sysc_flags)
|
||||||
|
{
|
||||||
|
*sysc_flags = 0;
|
||||||
|
|
||||||
|
switch (data->cap->type) {
|
||||||
|
case TI_SYSC_OMAP2:
|
||||||
|
case TI_SYSC_OMAP2_TIMER:
|
||||||
|
/* See SYSC_OMAP2_* in include/dt-bindings/bus/ti-sysc.h */
|
||||||
|
if (data->cfg->sysc_val & SYSC_OMAP2_CLOCKACTIVITY)
|
||||||
|
*sysc_flags |= SYSC_HAS_CLOCKACTIVITY;
|
||||||
|
if (data->cfg->sysc_val & SYSC_OMAP2_EMUFREE)
|
||||||
|
*sysc_flags |= SYSC_HAS_EMUFREE;
|
||||||
|
if (data->cfg->sysc_val & SYSC_OMAP2_ENAWAKEUP)
|
||||||
|
*sysc_flags |= SYSC_HAS_ENAWAKEUP;
|
||||||
|
if (data->cfg->sysc_val & SYSC_OMAP2_SOFTRESET)
|
||||||
|
*sysc_flags |= SYSC_HAS_SOFTRESET;
|
||||||
|
if (data->cfg->sysc_val & SYSC_OMAP2_AUTOIDLE)
|
||||||
|
*sysc_flags |= SYSC_HAS_AUTOIDLE;
|
||||||
|
break;
|
||||||
|
case TI_SYSC_OMAP4:
|
||||||
|
case TI_SYSC_OMAP4_TIMER:
|
||||||
|
/* See SYSC_OMAP4_* in include/dt-bindings/bus/ti-sysc.h */
|
||||||
|
if (data->cfg->sysc_val & SYSC_OMAP4_DMADISABLE)
|
||||||
|
*sysc_flags |= SYSC_HAS_DMADISABLE;
|
||||||
|
if (data->cfg->sysc_val & SYSC_OMAP4_FREEEMU)
|
||||||
|
*sysc_flags |= SYSC_HAS_EMUFREE;
|
||||||
|
if (data->cfg->sysc_val & SYSC_OMAP4_SOFTRESET)
|
||||||
|
*sysc_flags |= SYSC_HAS_SOFTRESET;
|
||||||
|
break;
|
||||||
|
case TI_SYSC_OMAP34XX_SR:
|
||||||
|
case TI_SYSC_OMAP36XX_SR:
|
||||||
|
/* See SYSC_OMAP3_SR_* in include/dt-bindings/bus/ti-sysc.h */
|
||||||
|
if (data->cfg->sysc_val & SYSC_OMAP3_SR_ENAWAKEUP)
|
||||||
|
*sysc_flags |= SYSC_HAS_ENAWAKEUP;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
if (data->cap->regbits->emufree_shift >= 0)
|
||||||
|
*sysc_flags |= SYSC_HAS_EMUFREE;
|
||||||
|
if (data->cap->regbits->enwkup_shift >= 0)
|
||||||
|
*sysc_flags |= SYSC_HAS_ENAWAKEUP;
|
||||||
|
if (data->cap->regbits->srst_shift >= 0)
|
||||||
|
*sysc_flags |= SYSC_HAS_SOFTRESET;
|
||||||
|
if (data->cap->regbits->autoidle_shift >= 0)
|
||||||
|
*sysc_flags |= SYSC_HAS_AUTOIDLE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data->cap->regbits->midle_shift >= 0 &&
|
||||||
|
data->cfg->midlemodes)
|
||||||
|
*sysc_flags |= SYSC_HAS_MIDLEMODE;
|
||||||
|
|
||||||
|
if (data->cap->regbits->sidle_shift >= 0 &&
|
||||||
|
data->cfg->sidlemodes)
|
||||||
|
*sysc_flags |= SYSC_HAS_SIDLEMODE;
|
||||||
|
|
||||||
|
if (data->cfg->quirks & SYSC_QUIRK_UNCACHED)
|
||||||
|
*sysc_flags |= SYSC_NO_CACHE;
|
||||||
|
if (data->cfg->quirks & SYSC_QUIRK_RESET_STATUS)
|
||||||
|
*sysc_flags |= SYSC_HAS_RESET_STATUS;
|
||||||
|
|
||||||
|
if (data->cfg->syss_mask & 1)
|
||||||
|
*sysc_flags |= SYSS_HAS_RESET_STATUS;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* omap_hwmod_init_idlemodes - initialize module idle modes
|
||||||
|
* @dev: struct device
|
||||||
|
* @data: module data
|
||||||
|
* @idlemodes: module supported idle modes
|
||||||
|
*/
|
||||||
|
int omap_hwmod_init_idlemodes(struct device *dev,
|
||||||
|
const struct ti_sysc_module_data *data,
|
||||||
|
u32 *idlemodes)
|
||||||
|
{
|
||||||
|
*idlemodes = 0;
|
||||||
|
|
||||||
|
if (data->cfg->midlemodes & BIT(SYSC_IDLE_FORCE))
|
||||||
|
*idlemodes |= MSTANDBY_FORCE;
|
||||||
|
if (data->cfg->midlemodes & BIT(SYSC_IDLE_NO))
|
||||||
|
*idlemodes |= MSTANDBY_NO;
|
||||||
|
if (data->cfg->midlemodes & BIT(SYSC_IDLE_SMART))
|
||||||
|
*idlemodes |= MSTANDBY_SMART;
|
||||||
|
if (data->cfg->midlemodes & BIT(SYSC_IDLE_SMART_WKUP))
|
||||||
|
*idlemodes |= MSTANDBY_SMART_WKUP;
|
||||||
|
|
||||||
|
if (data->cfg->sidlemodes & BIT(SYSC_IDLE_FORCE))
|
||||||
|
*idlemodes |= SIDLE_FORCE;
|
||||||
|
if (data->cfg->sidlemodes & BIT(SYSC_IDLE_NO))
|
||||||
|
*idlemodes |= SIDLE_NO;
|
||||||
|
if (data->cfg->sidlemodes & BIT(SYSC_IDLE_SMART))
|
||||||
|
*idlemodes |= SIDLE_SMART;
|
||||||
|
if (data->cfg->sidlemodes & BIT(SYSC_IDLE_SMART_WKUP))
|
||||||
|
*idlemodes |= SIDLE_SMART_WKUP;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* omap_hwmod_check_module - check new module against platform data
|
||||||
|
* @dev: struct device
|
||||||
|
* @oh: module
|
||||||
|
* @data: new module data
|
||||||
|
* @sysc_fields: sysc register bits
|
||||||
|
* @rev_offs: revision register offset
|
||||||
|
* @sysc_offs: sysconfig register offset
|
||||||
|
* @syss_offs: sysstatus register offset
|
||||||
|
* @sysc_flags: sysc specific flags
|
||||||
|
* @idlemodes: sysc supported idlemodes
|
||||||
|
*/
|
||||||
|
static int omap_hwmod_check_module(struct device *dev,
|
||||||
|
struct omap_hwmod *oh,
|
||||||
|
const struct ti_sysc_module_data *data,
|
||||||
|
struct sysc_regbits *sysc_fields,
|
||||||
|
u32 rev_offs, u32 sysc_offs,
|
||||||
|
u32 syss_offs, u32 sysc_flags,
|
||||||
|
u32 idlemodes)
|
||||||
|
{
|
||||||
|
if (!oh->class->sysc)
|
||||||
|
return -ENODEV;
|
||||||
|
|
||||||
|
if (sysc_fields != oh->class->sysc->sysc_fields)
|
||||||
|
dev_warn(dev, "sysc_fields %p != %p\n", sysc_fields,
|
||||||
|
oh->class->sysc->sysc_fields);
|
||||||
|
|
||||||
|
if (rev_offs != oh->class->sysc->rev_offs)
|
||||||
|
dev_warn(dev, "rev_offs %08x != %08x\n", rev_offs,
|
||||||
|
oh->class->sysc->rev_offs);
|
||||||
|
if (sysc_offs != oh->class->sysc->sysc_offs)
|
||||||
|
dev_warn(dev, "sysc_offs %08x != %08x\n", sysc_offs,
|
||||||
|
oh->class->sysc->sysc_offs);
|
||||||
|
if (syss_offs != oh->class->sysc->syss_offs)
|
||||||
|
dev_warn(dev, "syss_offs %08x != %08x\n", syss_offs,
|
||||||
|
oh->class->sysc->syss_offs);
|
||||||
|
|
||||||
|
if (sysc_flags != oh->class->sysc->sysc_flags)
|
||||||
|
dev_warn(dev, "sysc_flags %08x != %08x\n", sysc_flags,
|
||||||
|
oh->class->sysc->sysc_flags);
|
||||||
|
|
||||||
|
if (idlemodes != oh->class->sysc->idlemodes)
|
||||||
|
dev_warn(dev, "idlemodes %08x != %08x\n", idlemodes,
|
||||||
|
oh->class->sysc->idlemodes);
|
||||||
|
|
||||||
|
if (data->cfg->srst_udelay != oh->class->sysc->srst_udelay)
|
||||||
|
dev_warn(dev, "srst_udelay %i != %i\n",
|
||||||
|
data->cfg->srst_udelay,
|
||||||
|
oh->class->sysc->srst_udelay);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* omap_hwmod_allocate_module - allocate new module
|
||||||
|
* @dev: struct device
|
||||||
|
* @oh: module
|
||||||
|
* @sysc_fields: sysc register bits
|
||||||
|
* @rev_offs: revision register offset
|
||||||
|
* @sysc_offs: sysconfig register offset
|
||||||
|
* @syss_offs: sysstatus register offset
|
||||||
|
* @sysc_flags: sysc specific flags
|
||||||
|
* @idlemodes: sysc supported idlemodes
|
||||||
|
*
|
||||||
|
* Note that the allocations here cannot use devm as ti-sysc can rebind.
|
||||||
|
*/
|
||||||
|
int omap_hwmod_allocate_module(struct device *dev, struct omap_hwmod *oh,
|
||||||
|
const struct ti_sysc_module_data *data,
|
||||||
|
struct sysc_regbits *sysc_fields,
|
||||||
|
u32 rev_offs, u32 sysc_offs, u32 syss_offs,
|
||||||
|
u32 sysc_flags, u32 idlemodes)
|
||||||
|
{
|
||||||
|
struct omap_hwmod_class_sysconfig *sysc;
|
||||||
|
struct omap_hwmod_class *class;
|
||||||
|
void __iomem *regs = NULL;
|
||||||
|
unsigned long flags;
|
||||||
|
|
||||||
|
sysc = kzalloc(sizeof(*sysc), GFP_KERNEL);
|
||||||
|
if (!sysc)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
|
sysc->sysc_fields = sysc_fields;
|
||||||
|
sysc->rev_offs = rev_offs;
|
||||||
|
sysc->sysc_offs = sysc_offs;
|
||||||
|
sysc->syss_offs = syss_offs;
|
||||||
|
sysc->sysc_flags = sysc_flags;
|
||||||
|
sysc->idlemodes = idlemodes;
|
||||||
|
sysc->srst_udelay = data->cfg->srst_udelay;
|
||||||
|
|
||||||
|
if (!oh->_mpu_rt_va) {
|
||||||
|
regs = ioremap(data->module_pa,
|
||||||
|
data->module_size);
|
||||||
|
if (!regs)
|
||||||
|
return -ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We need new oh->class as the other devices in the same class
|
||||||
|
* may not yet have ioremapped their registers.
|
||||||
|
*/
|
||||||
|
class = kmemdup(oh->class, sizeof(*oh->class), GFP_KERNEL);
|
||||||
|
if (!class)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
|
class->sysc = sysc;
|
||||||
|
|
||||||
|
spin_lock_irqsave(&oh->_lock, flags);
|
||||||
|
if (regs)
|
||||||
|
oh->_mpu_rt_va = regs;
|
||||||
|
oh->class = class;
|
||||||
|
oh->_state = _HWMOD_STATE_INITIALIZED;
|
||||||
|
_setup(oh, NULL);
|
||||||
|
spin_unlock_irqrestore(&oh->_lock, flags);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* omap_hwmod_init_module - initialize new module
|
||||||
|
* @dev: struct device
|
||||||
|
* @data: module data
|
||||||
|
* @cookie: cookie for the caller to use for later calls
|
||||||
|
*/
|
||||||
|
int omap_hwmod_init_module(struct device *dev,
|
||||||
|
const struct ti_sysc_module_data *data,
|
||||||
|
struct ti_sysc_cookie *cookie)
|
||||||
|
{
|
||||||
|
struct omap_hwmod *oh;
|
||||||
|
struct sysc_regbits *sysc_fields;
|
||||||
|
u32 rev_offs, sysc_offs, syss_offs, sysc_flags, idlemodes;
|
||||||
|
int error;
|
||||||
|
|
||||||
|
if (!dev || !data)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
oh = _lookup(data->name);
|
||||||
|
if (!oh)
|
||||||
|
return -ENODEV;
|
||||||
|
|
||||||
|
cookie->data = oh;
|
||||||
|
|
||||||
|
error = omap_hwmod_init_regbits(dev, data, &sysc_fields);
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
error = omap_hwmod_init_reg_offs(dev, data, &rev_offs,
|
||||||
|
&sysc_offs, &syss_offs);
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
error = omap_hwmod_init_sysc_flags(dev, data, &sysc_flags);
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
error = omap_hwmod_init_idlemodes(dev, data, &idlemodes);
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
if (data->cfg->quirks & SYSC_QUIRK_NO_IDLE_ON_INIT)
|
||||||
|
oh->flags |= HWMOD_INIT_NO_IDLE;
|
||||||
|
if (data->cfg->quirks & SYSC_QUIRK_NO_RESET_ON_INIT)
|
||||||
|
oh->flags |= HWMOD_INIT_NO_RESET;
|
||||||
|
|
||||||
|
error = omap_hwmod_check_module(dev, oh, data, sysc_fields,
|
||||||
|
rev_offs, sysc_offs, syss_offs,
|
||||||
|
sysc_flags, idlemodes);
|
||||||
|
if (!error)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
return omap_hwmod_allocate_module(dev, oh, data, sysc_fields,
|
||||||
|
rev_offs, sysc_offs, syss_offs,
|
||||||
|
sysc_flags, idlemodes);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* omap_hwmod_setup_earlycon_flags - set up flags for early console
|
* omap_hwmod_setup_earlycon_flags - set up flags for early console
|
||||||
*
|
*
|
||||||
|
@ -3082,6 +3492,12 @@ static void __init omap_hwmod_setup_earlycon_flags(void)
|
||||||
if (np) {
|
if (np) {
|
||||||
uart = of_get_property(np, "ti,hwmods", NULL);
|
uart = of_get_property(np, "ti,hwmods", NULL);
|
||||||
oh = omap_hwmod_lookup(uart);
|
oh = omap_hwmod_lookup(uart);
|
||||||
|
if (!oh) {
|
||||||
|
uart = of_get_property(np->parent,
|
||||||
|
"ti,hwmods",
|
||||||
|
NULL);
|
||||||
|
oh = omap_hwmod_lookup(uart);
|
||||||
|
}
|
||||||
if (oh)
|
if (oh)
|
||||||
oh->flags |= DEBUG_OMAPUART_FLAGS;
|
oh->flags |= DEBUG_OMAPUART_FLAGS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -620,6 +620,13 @@ int omap_hwmod_parse_module_range(struct omap_hwmod *oh,
|
||||||
struct device_node *np,
|
struct device_node *np,
|
||||||
struct resource *res);
|
struct resource *res);
|
||||||
|
|
||||||
|
struct ti_sysc_module_data;
|
||||||
|
struct ti_sysc_cookie;
|
||||||
|
|
||||||
|
int omap_hwmod_init_module(struct device *dev,
|
||||||
|
const struct ti_sysc_module_data *data,
|
||||||
|
struct ti_sysc_cookie *cookie);
|
||||||
|
|
||||||
int omap_hwmod_enable(struct omap_hwmod *oh);
|
int omap_hwmod_enable(struct omap_hwmod *oh);
|
||||||
int omap_hwmod_idle(struct omap_hwmod *oh);
|
int omap_hwmod_idle(struct omap_hwmod *oh);
|
||||||
int omap_hwmod_shutdown(struct omap_hwmod *oh);
|
int omap_hwmod_shutdown(struct omap_hwmod *oh);
|
||||||
|
|
|
@ -17,12 +17,14 @@
|
||||||
#include <linux/wl12xx.h>
|
#include <linux/wl12xx.h>
|
||||||
#include <linux/mmc/card.h>
|
#include <linux/mmc/card.h>
|
||||||
#include <linux/mmc/host.h>
|
#include <linux/mmc/host.h>
|
||||||
|
#include <linux/power/smartreflex.h>
|
||||||
#include <linux/regulator/machine.h>
|
#include <linux/regulator/machine.h>
|
||||||
#include <linux/regulator/fixed.h>
|
#include <linux/regulator/fixed.h>
|
||||||
|
|
||||||
#include <linux/platform_data/pinctrl-single.h>
|
#include <linux/platform_data/pinctrl-single.h>
|
||||||
#include <linux/platform_data/hsmmc-omap.h>
|
#include <linux/platform_data/hsmmc-omap.h>
|
||||||
#include <linux/platform_data/iommu-omap.h>
|
#include <linux/platform_data/iommu-omap.h>
|
||||||
|
#include <linux/platform_data/ti-sysc.h>
|
||||||
#include <linux/platform_data/wkup_m3.h>
|
#include <linux/platform_data/wkup_m3.h>
|
||||||
#include <linux/platform_data/media/ir-rx51.h>
|
#include <linux/platform_data/media/ir-rx51.h>
|
||||||
#include <linux/platform_data/asoc-ti-mcbsp.h>
|
#include <linux/platform_data/asoc-ti-mcbsp.h>
|
||||||
|
@ -452,6 +454,43 @@ static void __init dra7x_evm_mmc_quirk(void)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static int ti_sysc_enable_module(struct device *dev,
|
||||||
|
const struct ti_sysc_cookie *cookie)
|
||||||
|
{
|
||||||
|
if (!cookie->data)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
return omap_hwmod_enable(cookie->data);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int ti_sysc_idle_module(struct device *dev,
|
||||||
|
const struct ti_sysc_cookie *cookie)
|
||||||
|
{
|
||||||
|
if (!cookie->data)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
return omap_hwmod_idle(cookie->data);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int ti_sysc_shutdown_module(struct device *dev,
|
||||||
|
const struct ti_sysc_cookie *cookie)
|
||||||
|
{
|
||||||
|
if (!cookie->data)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
return omap_hwmod_shutdown(cookie->data);
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct of_dev_auxdata omap_auxdata_lookup[];
|
||||||
|
|
||||||
|
static struct ti_sysc_platform_data ti_sysc_pdata = {
|
||||||
|
.auxdata = omap_auxdata_lookup,
|
||||||
|
.init_module = omap_hwmod_init_module,
|
||||||
|
.enable_module = ti_sysc_enable_module,
|
||||||
|
.idle_module = ti_sysc_idle_module,
|
||||||
|
.shutdown_module = ti_sysc_shutdown_module,
|
||||||
|
};
|
||||||
|
|
||||||
static struct pcs_pdata pcs_pdata;
|
static struct pcs_pdata pcs_pdata;
|
||||||
|
|
||||||
void omap_pcs_legacy_init(int irq, void (*rearm)(void))
|
void omap_pcs_legacy_init(int irq, void (*rearm)(void))
|
||||||
|
@ -513,7 +552,9 @@ static struct pdata_init auxdata_quirks[] __initdata = {
|
||||||
{ /* sentinel */ },
|
{ /* sentinel */ },
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct of_dev_auxdata omap_auxdata_lookup[] __initdata = {
|
struct omap_sr_data __maybe_unused omap_sr_pdata[OMAP_SR_NR];
|
||||||
|
|
||||||
|
static struct of_dev_auxdata omap_auxdata_lookup[] = {
|
||||||
#ifdef CONFIG_MACH_NOKIA_N8X0
|
#ifdef CONFIG_MACH_NOKIA_N8X0
|
||||||
OF_DEV_AUXDATA("ti,omap2420-mmc", 0x4809c000, "mmci-omap.0", NULL),
|
OF_DEV_AUXDATA("ti,omap2420-mmc", 0x4809c000, "mmci-omap.0", NULL),
|
||||||
OF_DEV_AUXDATA("menelaus", 0x72, "1-0072", &n8x0_menelaus_platform_data),
|
OF_DEV_AUXDATA("menelaus", 0x72, "1-0072", &n8x0_menelaus_platform_data),
|
||||||
|
@ -522,6 +563,10 @@ static struct of_dev_auxdata omap_auxdata_lookup[] __initdata = {
|
||||||
#ifdef CONFIG_ARCH_OMAP3
|
#ifdef CONFIG_ARCH_OMAP3
|
||||||
OF_DEV_AUXDATA("ti,omap2-iommu", 0x5d000000, "5d000000.mmu",
|
OF_DEV_AUXDATA("ti,omap2-iommu", 0x5d000000, "5d000000.mmu",
|
||||||
&omap3_iommu_pdata),
|
&omap3_iommu_pdata),
|
||||||
|
OF_DEV_AUXDATA("ti,omap3-smartreflex-core", 0x480cb000,
|
||||||
|
"480cb000.smartreflex", &omap_sr_pdata[OMAP_SR_CORE]),
|
||||||
|
OF_DEV_AUXDATA("ti,omap3-smartreflex-mpu-iva", 0x480c9000,
|
||||||
|
"480c9000.smartreflex", &omap_sr_pdata[OMAP_SR_MPU]),
|
||||||
OF_DEV_AUXDATA("ti,omap3-hsmmc", 0x4809c000, "4809c000.mmc", &mmc_pdata[0]),
|
OF_DEV_AUXDATA("ti,omap3-hsmmc", 0x4809c000, "4809c000.mmc", &mmc_pdata[0]),
|
||||||
OF_DEV_AUXDATA("ti,omap3-hsmmc", 0x480b4000, "480b4000.mmc", &mmc_pdata[1]),
|
OF_DEV_AUXDATA("ti,omap3-hsmmc", 0x480b4000, "480b4000.mmc", &mmc_pdata[1]),
|
||||||
OF_DEV_AUXDATA("nokia,n900-ir", 0, "n900-ir", &rx51_ir_data),
|
OF_DEV_AUXDATA("nokia,n900-ir", 0, "n900-ir", &rx51_ir_data),
|
||||||
|
@ -548,6 +593,12 @@ static struct of_dev_auxdata omap_auxdata_lookup[] __initdata = {
|
||||||
&omap4_iommu_pdata),
|
&omap4_iommu_pdata),
|
||||||
OF_DEV_AUXDATA("ti,omap4-iommu", 0x55082000, "55082000.mmu",
|
OF_DEV_AUXDATA("ti,omap4-iommu", 0x55082000, "55082000.mmu",
|
||||||
&omap4_iommu_pdata),
|
&omap4_iommu_pdata),
|
||||||
|
OF_DEV_AUXDATA("ti,omap4-smartreflex-iva", 0x4a0db000,
|
||||||
|
"4a0db000.smartreflex", &omap_sr_pdata[OMAP_SR_IVA]),
|
||||||
|
OF_DEV_AUXDATA("ti,omap4-smartreflex-core", 0x4a0dd000,
|
||||||
|
"4a0dd000.smartreflex", &omap_sr_pdata[OMAP_SR_CORE]),
|
||||||
|
OF_DEV_AUXDATA("ti,omap4-smartreflex-mpu", 0x4a0d9000,
|
||||||
|
"4a0d9000.smartreflex", &omap_sr_pdata[OMAP_SR_MPU]),
|
||||||
#endif
|
#endif
|
||||||
#ifdef CONFIG_SOC_DRA7XX
|
#ifdef CONFIG_SOC_DRA7XX
|
||||||
OF_DEV_AUXDATA("ti,dra7-hsmmc", 0x4809c000, "4809c000.mmc",
|
OF_DEV_AUXDATA("ti,dra7-hsmmc", 0x4809c000, "4809c000.mmc",
|
||||||
|
@ -558,6 +609,7 @@ static struct of_dev_auxdata omap_auxdata_lookup[] __initdata = {
|
||||||
&dra7_hsmmc_data_mmc3),
|
&dra7_hsmmc_data_mmc3),
|
||||||
#endif
|
#endif
|
||||||
/* Common auxdata */
|
/* Common auxdata */
|
||||||
|
OF_DEV_AUXDATA("ti,sysc", 0, NULL, &ti_sysc_pdata),
|
||||||
OF_DEV_AUXDATA("pinctrl-single", 0, NULL, &pcs_pdata),
|
OF_DEV_AUXDATA("pinctrl-single", 0, NULL, &pcs_pdata),
|
||||||
{ /* sentinel */ },
|
{ /* sentinel */ },
|
||||||
};
|
};
|
||||||
|
|
|
@ -89,18 +89,27 @@ static void __init sr_set_nvalues(struct omap_volt_data *volt_data,
|
||||||
sr_data->nvalue_count = j;
|
sr_data->nvalue_count = j;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern struct omap_sr_data omap_sr_pdata[];
|
||||||
|
|
||||||
static int __init sr_dev_init(struct omap_hwmod *oh, void *user)
|
static int __init sr_dev_init(struct omap_hwmod *oh, void *user)
|
||||||
{
|
{
|
||||||
struct omap_sr_data *sr_data;
|
struct omap_sr_data *sr_data = NULL;
|
||||||
struct platform_device *pdev;
|
|
||||||
struct omap_volt_data *volt_data;
|
struct omap_volt_data *volt_data;
|
||||||
struct omap_smartreflex_dev_attr *sr_dev_attr;
|
struct omap_smartreflex_dev_attr *sr_dev_attr;
|
||||||
char *name = "smartreflex";
|
|
||||||
static int i;
|
static int i;
|
||||||
|
|
||||||
sr_data = kzalloc(sizeof(*sr_data), GFP_KERNEL);
|
if (!strncmp(oh->name, "smartreflex_mpu_iva", 20) ||
|
||||||
if (!sr_data)
|
!strncmp(oh->name, "smartreflex_mpu", 16))
|
||||||
return -ENOMEM;
|
sr_data = &omap_sr_pdata[OMAP_SR_MPU];
|
||||||
|
else if (!strncmp(oh->name, "smartreflex_core", 17))
|
||||||
|
sr_data = &omap_sr_pdata[OMAP_SR_CORE];
|
||||||
|
else if (!strncmp(oh->name, "smartreflex_iva", 16))
|
||||||
|
sr_data = &omap_sr_pdata[OMAP_SR_IVA];
|
||||||
|
|
||||||
|
if (!sr_data) {
|
||||||
|
pr_err("%s: Unknown instance %s\n", __func__, oh->name);
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
sr_dev_attr = (struct omap_smartreflex_dev_attr *)oh->dev_attr;
|
sr_dev_attr = (struct omap_smartreflex_dev_attr *)oh->dev_attr;
|
||||||
if (!sr_dev_attr || !sr_dev_attr->sensor_voltdm_name) {
|
if (!sr_dev_attr || !sr_dev_attr->sensor_voltdm_name) {
|
||||||
|
@ -145,13 +154,9 @@ static int __init sr_dev_init(struct omap_hwmod *oh, void *user)
|
||||||
|
|
||||||
sr_data->enable_on_init = sr_enable_on_init;
|
sr_data->enable_on_init = sr_enable_on_init;
|
||||||
|
|
||||||
pdev = omap_device_build(name, i, oh, sr_data, sizeof(*sr_data));
|
|
||||||
if (IS_ERR(pdev))
|
|
||||||
pr_warn("%s: Could not build omap_device for %s: %s\n",
|
|
||||||
__func__, name, oh->name);
|
|
||||||
exit:
|
exit:
|
||||||
i++;
|
i++;
|
||||||
kfree(sr_data);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,22 +13,20 @@
|
||||||
|
|
||||||
#include <linux/io.h>
|
#include <linux/io.h>
|
||||||
#include <linux/clk.h>
|
#include <linux/clk.h>
|
||||||
|
#include <linux/clkdev.h>
|
||||||
|
#include <linux/delay.h>
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
#include <linux/platform_device.h>
|
#include <linux/platform_device.h>
|
||||||
|
#include <linux/pm_domain.h>
|
||||||
#include <linux/pm_runtime.h>
|
#include <linux/pm_runtime.h>
|
||||||
#include <linux/of_address.h>
|
#include <linux/of_address.h>
|
||||||
#include <linux/of_platform.h>
|
#include <linux/of_platform.h>
|
||||||
|
#include <linux/slab.h>
|
||||||
|
|
||||||
#include <linux/platform_data/ti-sysc.h>
|
#include <linux/platform_data/ti-sysc.h>
|
||||||
|
|
||||||
#include <dt-bindings/bus/ti-sysc.h>
|
#include <dt-bindings/bus/ti-sysc.h>
|
||||||
|
|
||||||
enum sysc_registers {
|
|
||||||
SYSC_REVISION,
|
|
||||||
SYSC_SYSCONFIG,
|
|
||||||
SYSC_SYSSTATUS,
|
|
||||||
SYSC_MAX_REGS,
|
|
||||||
};
|
|
||||||
|
|
||||||
static const char * const reg_names[] = { "rev", "sysc", "syss", };
|
static const char * const reg_names[] = { "rev", "sysc", "syss", };
|
||||||
|
|
||||||
enum sysc_clocks {
|
enum sysc_clocks {
|
||||||
|
@ -55,6 +53,7 @@ static const char * const clock_names[] = { "fck", "ick", };
|
||||||
* @cfg: interconnect target module configuration
|
* @cfg: interconnect target module configuration
|
||||||
* @name: name if available
|
* @name: name if available
|
||||||
* @revision: interconnect target module revision
|
* @revision: interconnect target module revision
|
||||||
|
* @needs_resume: runtime resume needed on resume from suspend
|
||||||
*/
|
*/
|
||||||
struct sysc {
|
struct sysc {
|
||||||
struct device *dev;
|
struct device *dev;
|
||||||
|
@ -66,8 +65,13 @@ struct sysc {
|
||||||
const char *legacy_mode;
|
const char *legacy_mode;
|
||||||
const struct sysc_capabilities *cap;
|
const struct sysc_capabilities *cap;
|
||||||
struct sysc_config cfg;
|
struct sysc_config cfg;
|
||||||
|
struct ti_sysc_cookie cookie;
|
||||||
const char *name;
|
const char *name;
|
||||||
u32 revision;
|
u32 revision;
|
||||||
|
bool enabled;
|
||||||
|
bool needs_resume;
|
||||||
|
bool child_needs_resume;
|
||||||
|
struct delayed_work idle_work;
|
||||||
};
|
};
|
||||||
|
|
||||||
static u32 sysc_read(struct sysc *ddata, int offset)
|
static u32 sysc_read(struct sysc *ddata, int offset)
|
||||||
|
@ -136,9 +140,6 @@ static int sysc_get_clocks(struct sysc *ddata)
|
||||||
{
|
{
|
||||||
int i, error;
|
int i, error;
|
||||||
|
|
||||||
if (ddata->legacy_mode)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
for (i = 0; i < SYSC_MAX_CLOCKS; i++) {
|
for (i = 0; i < SYSC_MAX_CLOCKS; i++) {
|
||||||
error = sysc_get_one_clock(ddata, i);
|
error = sysc_get_one_clock(ddata, i);
|
||||||
if (error && error != -ENOENT)
|
if (error && error != -ENOENT)
|
||||||
|
@ -197,12 +198,53 @@ static int sysc_parse_and_check_child_range(struct sysc *ddata)
|
||||||
ddata->module_pa = of_translate_address(np, ranges++);
|
ddata->module_pa = of_translate_address(np, ranges++);
|
||||||
ddata->module_size = be32_to_cpup(ranges);
|
ddata->module_size = be32_to_cpup(ranges);
|
||||||
|
|
||||||
dev_dbg(ddata->dev, "interconnect target 0x%llx size 0x%x for %pOF\n",
|
|
||||||
ddata->module_pa, ddata->module_size, np);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct device_node *stdout_path;
|
||||||
|
|
||||||
|
static void sysc_init_stdout_path(struct sysc *ddata)
|
||||||
|
{
|
||||||
|
struct device_node *np = NULL;
|
||||||
|
const char *uart;
|
||||||
|
|
||||||
|
if (IS_ERR(stdout_path))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (stdout_path)
|
||||||
|
return;
|
||||||
|
|
||||||
|
np = of_find_node_by_path("/chosen");
|
||||||
|
if (!np)
|
||||||
|
goto err;
|
||||||
|
|
||||||
|
uart = of_get_property(np, "stdout-path", NULL);
|
||||||
|
if (!uart)
|
||||||
|
goto err;
|
||||||
|
|
||||||
|
np = of_find_node_by_path(uart);
|
||||||
|
if (!np)
|
||||||
|
goto err;
|
||||||
|
|
||||||
|
stdout_path = np;
|
||||||
|
|
||||||
|
return;
|
||||||
|
|
||||||
|
err:
|
||||||
|
stdout_path = ERR_PTR(-ENODEV);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void sysc_check_quirk_stdout(struct sysc *ddata,
|
||||||
|
struct device_node *np)
|
||||||
|
{
|
||||||
|
sysc_init_stdout_path(ddata);
|
||||||
|
if (np != stdout_path)
|
||||||
|
return;
|
||||||
|
|
||||||
|
ddata->cfg.quirks |= SYSC_QUIRK_NO_IDLE_ON_INIT |
|
||||||
|
SYSC_QUIRK_NO_RESET_ON_INIT;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* sysc_check_one_child - check child configuration
|
* sysc_check_one_child - check child configuration
|
||||||
* @ddata: device driver data
|
* @ddata: device driver data
|
||||||
|
@ -221,6 +263,8 @@ static int sysc_check_one_child(struct sysc *ddata,
|
||||||
if (name)
|
if (name)
|
||||||
dev_warn(ddata->dev, "really a child ti,hwmods property?");
|
dev_warn(ddata->dev, "really a child ti,hwmods property?");
|
||||||
|
|
||||||
|
sysc_check_quirk_stdout(ddata, np);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -246,11 +290,8 @@ static int sysc_check_children(struct sysc *ddata)
|
||||||
*/
|
*/
|
||||||
static void sysc_check_quirk_16bit(struct sysc *ddata, struct resource *res)
|
static void sysc_check_quirk_16bit(struct sysc *ddata, struct resource *res)
|
||||||
{
|
{
|
||||||
if (resource_size(res) == 8) {
|
if (resource_size(res) == 8)
|
||||||
dev_dbg(ddata->dev,
|
|
||||||
"enabling 16-bit and clockactivity quirks\n");
|
|
||||||
ddata->cfg.quirks |= SYSC_QUIRK_16BIT | SYSC_QUIRK_USE_CLOCKACT;
|
ddata->cfg.quirks |= SYSC_QUIRK_16BIT | SYSC_QUIRK_USE_CLOCKACT;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -276,7 +317,6 @@ static int sysc_parse_one(struct sysc *ddata, enum sysc_registers reg)
|
||||||
res = platform_get_resource_byname(to_platform_device(ddata->dev),
|
res = platform_get_resource_byname(to_platform_device(ddata->dev),
|
||||||
IORESOURCE_MEM, name);
|
IORESOURCE_MEM, name);
|
||||||
if (!res) {
|
if (!res) {
|
||||||
dev_dbg(ddata->dev, "has no %s register\n", name);
|
|
||||||
ddata->offsets[reg] = -ENODEV;
|
ddata->offsets[reg] = -ENODEV;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -437,6 +477,14 @@ static int sysc_show_reg(struct sysc *ddata,
|
||||||
return sprintf(bufp, ":%x", ddata->offsets[reg]);
|
return sprintf(bufp, ":%x", ddata->offsets[reg]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int sysc_show_name(char *bufp, struct sysc *ddata)
|
||||||
|
{
|
||||||
|
if (!ddata->name)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return sprintf(bufp, ":%s", ddata->name);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* sysc_show_registers - show information about interconnect target module
|
* sysc_show_registers - show information about interconnect target module
|
||||||
* @ddata: device driver data
|
* @ddata: device driver data
|
||||||
|
@ -451,6 +499,7 @@ static void sysc_show_registers(struct sysc *ddata)
|
||||||
bufp += sysc_show_reg(ddata, bufp, i);
|
bufp += sysc_show_reg(ddata, bufp, i);
|
||||||
|
|
||||||
bufp += sysc_show_rev(bufp, ddata);
|
bufp += sysc_show_rev(bufp, ddata);
|
||||||
|
bufp += sysc_show_name(bufp, ddata);
|
||||||
|
|
||||||
dev_dbg(ddata->dev, "%llx:%x%s\n",
|
dev_dbg(ddata->dev, "%llx:%x%s\n",
|
||||||
ddata->module_pa, ddata->module_size,
|
ddata->module_pa, ddata->module_size,
|
||||||
|
@ -459,33 +508,70 @@ static void sysc_show_registers(struct sysc *ddata)
|
||||||
|
|
||||||
static int __maybe_unused sysc_runtime_suspend(struct device *dev)
|
static int __maybe_unused sysc_runtime_suspend(struct device *dev)
|
||||||
{
|
{
|
||||||
|
struct ti_sysc_platform_data *pdata;
|
||||||
struct sysc *ddata;
|
struct sysc *ddata;
|
||||||
int i;
|
int error = 0, i;
|
||||||
|
|
||||||
ddata = dev_get_drvdata(dev);
|
ddata = dev_get_drvdata(dev);
|
||||||
|
|
||||||
if (ddata->legacy_mode)
|
if (!ddata->enabled)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
if (ddata->legacy_mode) {
|
||||||
|
pdata = dev_get_platdata(ddata->dev);
|
||||||
|
if (!pdata)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (!pdata->idle_module)
|
||||||
|
return -ENODEV;
|
||||||
|
|
||||||
|
error = pdata->idle_module(dev, &ddata->cookie);
|
||||||
|
if (error)
|
||||||
|
dev_err(dev, "%s: could not idle: %i\n",
|
||||||
|
__func__, error);
|
||||||
|
|
||||||
|
goto idled;
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < SYSC_MAX_CLOCKS; i++) {
|
for (i = 0; i < SYSC_MAX_CLOCKS; i++) {
|
||||||
if (IS_ERR_OR_NULL(ddata->clocks[i]))
|
if (IS_ERR_OR_NULL(ddata->clocks[i]))
|
||||||
continue;
|
continue;
|
||||||
clk_disable(ddata->clocks[i]);
|
clk_disable(ddata->clocks[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
idled:
|
||||||
|
ddata->enabled = false;
|
||||||
|
|
||||||
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int __maybe_unused sysc_runtime_resume(struct device *dev)
|
static int __maybe_unused sysc_runtime_resume(struct device *dev)
|
||||||
{
|
{
|
||||||
|
struct ti_sysc_platform_data *pdata;
|
||||||
struct sysc *ddata;
|
struct sysc *ddata;
|
||||||
int i, error;
|
int error = 0, i;
|
||||||
|
|
||||||
ddata = dev_get_drvdata(dev);
|
ddata = dev_get_drvdata(dev);
|
||||||
|
|
||||||
if (ddata->legacy_mode)
|
if (ddata->enabled)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
if (ddata->legacy_mode) {
|
||||||
|
pdata = dev_get_platdata(ddata->dev);
|
||||||
|
if (!pdata)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (!pdata->enable_module)
|
||||||
|
return -ENODEV;
|
||||||
|
|
||||||
|
error = pdata->enable_module(dev, &ddata->cookie);
|
||||||
|
if (error)
|
||||||
|
dev_err(dev, "%s: could not enable: %i\n",
|
||||||
|
__func__, error);
|
||||||
|
|
||||||
|
goto awake;
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < SYSC_MAX_CLOCKS; i++) {
|
for (i = 0; i < SYSC_MAX_CLOCKS; i++) {
|
||||||
if (IS_ERR_OR_NULL(ddata->clocks[i]))
|
if (IS_ERR_OR_NULL(ddata->clocks[i]))
|
||||||
continue;
|
continue;
|
||||||
|
@ -494,20 +580,136 @@ static int __maybe_unused sysc_runtime_resume(struct device *dev)
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
awake:
|
||||||
|
ddata->enabled = true;
|
||||||
|
|
||||||
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_PM_SLEEP
|
||||||
|
static int sysc_suspend(struct device *dev)
|
||||||
|
{
|
||||||
|
struct sysc *ddata;
|
||||||
|
|
||||||
|
ddata = dev_get_drvdata(dev);
|
||||||
|
|
||||||
|
if (!ddata->enabled)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
ddata->needs_resume = true;
|
||||||
|
|
||||||
|
return sysc_runtime_suspend(dev);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int sysc_resume(struct device *dev)
|
||||||
|
{
|
||||||
|
struct sysc *ddata;
|
||||||
|
|
||||||
|
ddata = dev_get_drvdata(dev);
|
||||||
|
if (ddata->needs_resume) {
|
||||||
|
ddata->needs_resume = false;
|
||||||
|
|
||||||
|
return sysc_runtime_resume(dev);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static const struct dev_pm_ops sysc_pm_ops = {
|
static const struct dev_pm_ops sysc_pm_ops = {
|
||||||
|
SET_SYSTEM_SLEEP_PM_OPS(sysc_suspend, sysc_resume)
|
||||||
SET_RUNTIME_PM_OPS(sysc_runtime_suspend,
|
SET_RUNTIME_PM_OPS(sysc_runtime_suspend,
|
||||||
sysc_runtime_resume,
|
sysc_runtime_resume,
|
||||||
NULL)
|
NULL)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* Module revision register based quirks */
|
||||||
|
struct sysc_revision_quirk {
|
||||||
|
const char *name;
|
||||||
|
u32 base;
|
||||||
|
int rev_offset;
|
||||||
|
int sysc_offset;
|
||||||
|
int syss_offset;
|
||||||
|
u32 revision;
|
||||||
|
u32 revision_mask;
|
||||||
|
u32 quirks;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define SYSC_QUIRK(optname, optbase, optrev, optsysc, optsyss, \
|
||||||
|
optrev_val, optrevmask, optquirkmask) \
|
||||||
|
{ \
|
||||||
|
.name = (optname), \
|
||||||
|
.base = (optbase), \
|
||||||
|
.rev_offset = (optrev), \
|
||||||
|
.sysc_offset = (optsysc), \
|
||||||
|
.syss_offset = (optsyss), \
|
||||||
|
.revision = (optrev_val), \
|
||||||
|
.revision_mask = (optrevmask), \
|
||||||
|
.quirks = (optquirkmask), \
|
||||||
|
}
|
||||||
|
|
||||||
|
static const struct sysc_revision_quirk sysc_revision_quirks[] = {
|
||||||
|
/* These drivers need to be fixed to not use pm_runtime_irq_safe() */
|
||||||
|
SYSC_QUIRK("gpio", 0, 0, 0x10, 0x114, 0x50600801, 0xffffffff,
|
||||||
|
SYSC_QUIRK_LEGACY_IDLE),
|
||||||
|
SYSC_QUIRK("mmu", 0, 0, 0x10, 0x14, 0x00000020, 0xffffffff,
|
||||||
|
SYSC_QUIRK_LEGACY_IDLE),
|
||||||
|
SYSC_QUIRK("mmu", 0, 0, 0x10, 0x14, 0x00000030, 0xffffffff,
|
||||||
|
SYSC_QUIRK_LEGACY_IDLE),
|
||||||
|
SYSC_QUIRK("sham", 0, 0x100, 0x110, 0x114, 0x40000c03, 0xffffffff,
|
||||||
|
SYSC_QUIRK_LEGACY_IDLE),
|
||||||
|
SYSC_QUIRK("smartreflex", 0, -1, 0x24, -1, 0x00000000, 0xffffffff,
|
||||||
|
SYSC_QUIRK_LEGACY_IDLE),
|
||||||
|
SYSC_QUIRK("smartreflex", 0, -1, 0x38, -1, 0x00000000, 0xffffffff,
|
||||||
|
SYSC_QUIRK_LEGACY_IDLE),
|
||||||
|
SYSC_QUIRK("timer", 0, 0, 0x10, 0x14, 0x00000015, 0xffffffff,
|
||||||
|
SYSC_QUIRK_LEGACY_IDLE),
|
||||||
|
SYSC_QUIRK("uart", 0, 0x50, 0x54, 0x58, 0x00000052, 0xffffffff,
|
||||||
|
SYSC_QUIRK_LEGACY_IDLE),
|
||||||
|
};
|
||||||
|
|
||||||
|
static void sysc_init_revision_quirks(struct sysc *ddata)
|
||||||
|
{
|
||||||
|
const struct sysc_revision_quirk *q;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < ARRAY_SIZE(sysc_revision_quirks); i++) {
|
||||||
|
q = &sysc_revision_quirks[i];
|
||||||
|
|
||||||
|
if (q->base && q->base != ddata->module_pa)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (q->rev_offset >= 0 &&
|
||||||
|
q->rev_offset != ddata->offsets[SYSC_REVISION])
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (q->sysc_offset >= 0 &&
|
||||||
|
q->sysc_offset != ddata->offsets[SYSC_SYSCONFIG])
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (q->syss_offset >= 0 &&
|
||||||
|
q->syss_offset != ddata->offsets[SYSC_SYSSTATUS])
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (q->revision == ddata->revision ||
|
||||||
|
(q->revision & q->revision_mask) ==
|
||||||
|
(ddata->revision & q->revision_mask)) {
|
||||||
|
ddata->name = q->name;
|
||||||
|
ddata->cfg.quirks |= q->quirks;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* At this point the module is configured enough to read the revision */
|
/* At this point the module is configured enough to read the revision */
|
||||||
static int sysc_init_module(struct sysc *ddata)
|
static int sysc_init_module(struct sysc *ddata)
|
||||||
{
|
{
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
|
if (ddata->cfg.quirks & SYSC_QUIRK_NO_IDLE_ON_INIT) {
|
||||||
|
ddata->revision = sysc_read_revision(ddata);
|
||||||
|
goto rev_quirks;
|
||||||
|
}
|
||||||
|
|
||||||
error = pm_runtime_get_sync(ddata->dev);
|
error = pm_runtime_get_sync(ddata->dev);
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
pm_runtime_put_noidle(ddata->dev);
|
pm_runtime_put_noidle(ddata->dev);
|
||||||
|
@ -517,6 +719,9 @@ static int sysc_init_module(struct sysc *ddata)
|
||||||
ddata->revision = sysc_read_revision(ddata);
|
ddata->revision = sysc_read_revision(ddata);
|
||||||
pm_runtime_put_sync(ddata->dev);
|
pm_runtime_put_sync(ddata->dev);
|
||||||
|
|
||||||
|
rev_quirks:
|
||||||
|
sysc_init_revision_quirks(ddata);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -605,6 +810,196 @@ static int sysc_init_syss_mask(struct sysc *ddata)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Many child device drivers need to have fck available to get the clock
|
||||||
|
* rate for device internal configuration.
|
||||||
|
*/
|
||||||
|
static int sysc_child_add_fck(struct sysc *ddata,
|
||||||
|
struct device *child)
|
||||||
|
{
|
||||||
|
struct clk *fck;
|
||||||
|
struct clk_lookup *l;
|
||||||
|
const char *name = clock_names[SYSC_FCK];
|
||||||
|
|
||||||
|
if (IS_ERR_OR_NULL(ddata->clocks[SYSC_FCK]))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
fck = clk_get(child, name);
|
||||||
|
if (!IS_ERR(fck)) {
|
||||||
|
clk_put(fck);
|
||||||
|
|
||||||
|
return -EEXIST;
|
||||||
|
}
|
||||||
|
|
||||||
|
l = clkdev_create(ddata->clocks[SYSC_FCK], name, dev_name(child));
|
||||||
|
|
||||||
|
return l ? 0 : -ENODEV;
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct device_type sysc_device_type = {
|
||||||
|
};
|
||||||
|
|
||||||
|
static struct sysc *sysc_child_to_parent(struct device *dev)
|
||||||
|
{
|
||||||
|
struct device *parent = dev->parent;
|
||||||
|
|
||||||
|
if (!parent || parent->type != &sysc_device_type)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
return dev_get_drvdata(parent);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int __maybe_unused sysc_child_runtime_suspend(struct device *dev)
|
||||||
|
{
|
||||||
|
struct sysc *ddata;
|
||||||
|
int error;
|
||||||
|
|
||||||
|
ddata = sysc_child_to_parent(dev);
|
||||||
|
|
||||||
|
error = pm_generic_runtime_suspend(dev);
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
if (!ddata->enabled)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return sysc_runtime_suspend(ddata->dev);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int __maybe_unused sysc_child_runtime_resume(struct device *dev)
|
||||||
|
{
|
||||||
|
struct sysc *ddata;
|
||||||
|
int error;
|
||||||
|
|
||||||
|
ddata = sysc_child_to_parent(dev);
|
||||||
|
|
||||||
|
if (!ddata->enabled) {
|
||||||
|
error = sysc_runtime_resume(ddata->dev);
|
||||||
|
if (error < 0)
|
||||||
|
dev_err(ddata->dev,
|
||||||
|
"%s error: %i\n", __func__, error);
|
||||||
|
}
|
||||||
|
|
||||||
|
return pm_generic_runtime_resume(dev);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_PM_SLEEP
|
||||||
|
static int sysc_child_suspend_noirq(struct device *dev)
|
||||||
|
{
|
||||||
|
struct sysc *ddata;
|
||||||
|
int error;
|
||||||
|
|
||||||
|
ddata = sysc_child_to_parent(dev);
|
||||||
|
|
||||||
|
error = pm_generic_suspend_noirq(dev);
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
if (!pm_runtime_status_suspended(dev)) {
|
||||||
|
error = pm_generic_runtime_suspend(dev);
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
error = sysc_runtime_suspend(ddata->dev);
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
ddata->child_needs_resume = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int sysc_child_resume_noirq(struct device *dev)
|
||||||
|
{
|
||||||
|
struct sysc *ddata;
|
||||||
|
int error;
|
||||||
|
|
||||||
|
ddata = sysc_child_to_parent(dev);
|
||||||
|
|
||||||
|
if (ddata->child_needs_resume) {
|
||||||
|
ddata->child_needs_resume = false;
|
||||||
|
|
||||||
|
error = sysc_runtime_resume(ddata->dev);
|
||||||
|
if (error)
|
||||||
|
dev_err(ddata->dev,
|
||||||
|
"%s runtime resume error: %i\n",
|
||||||
|
__func__, error);
|
||||||
|
|
||||||
|
error = pm_generic_runtime_resume(dev);
|
||||||
|
if (error)
|
||||||
|
dev_err(ddata->dev,
|
||||||
|
"%s generic runtime resume: %i\n",
|
||||||
|
__func__, error);
|
||||||
|
}
|
||||||
|
|
||||||
|
return pm_generic_resume_noirq(dev);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct dev_pm_domain sysc_child_pm_domain = {
|
||||||
|
.ops = {
|
||||||
|
SET_RUNTIME_PM_OPS(sysc_child_runtime_suspend,
|
||||||
|
sysc_child_runtime_resume,
|
||||||
|
NULL)
|
||||||
|
USE_PLATFORM_PM_SLEEP_OPS
|
||||||
|
SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(sysc_child_suspend_noirq,
|
||||||
|
sysc_child_resume_noirq)
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sysc_legacy_idle_quirk - handle children in omap_device compatible way
|
||||||
|
* @ddata: device driver data
|
||||||
|
* @child: child device driver
|
||||||
|
*
|
||||||
|
* Allow idle for child devices as done with _od_runtime_suspend().
|
||||||
|
* Otherwise many child devices will not idle because of the permanent
|
||||||
|
* parent usecount set in pm_runtime_irq_safe().
|
||||||
|
*
|
||||||
|
* Note that the long term solution is to just modify the child device
|
||||||
|
* drivers to not set pm_runtime_irq_safe() and then this can be just
|
||||||
|
* dropped.
|
||||||
|
*/
|
||||||
|
static void sysc_legacy_idle_quirk(struct sysc *ddata, struct device *child)
|
||||||
|
{
|
||||||
|
if (!ddata->legacy_mode)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (ddata->cfg.quirks & SYSC_QUIRK_LEGACY_IDLE)
|
||||||
|
dev_pm_domain_set(child, &sysc_child_pm_domain);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int sysc_notifier_call(struct notifier_block *nb,
|
||||||
|
unsigned long event, void *device)
|
||||||
|
{
|
||||||
|
struct device *dev = device;
|
||||||
|
struct sysc *ddata;
|
||||||
|
int error;
|
||||||
|
|
||||||
|
ddata = sysc_child_to_parent(dev);
|
||||||
|
if (!ddata)
|
||||||
|
return NOTIFY_DONE;
|
||||||
|
|
||||||
|
switch (event) {
|
||||||
|
case BUS_NOTIFY_ADD_DEVICE:
|
||||||
|
error = sysc_child_add_fck(ddata, dev);
|
||||||
|
if (error && error != -EEXIST)
|
||||||
|
dev_warn(ddata->dev, "could not add %s fck: %i\n",
|
||||||
|
dev_name(dev), error);
|
||||||
|
sysc_legacy_idle_quirk(ddata, dev);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NOTIFY_DONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct notifier_block sysc_nb = {
|
||||||
|
.notifier_call = sysc_notifier_call,
|
||||||
|
};
|
||||||
|
|
||||||
/* Device tree configured quirks */
|
/* Device tree configured quirks */
|
||||||
struct sysc_dts_quirk {
|
struct sysc_dts_quirk {
|
||||||
const char *name;
|
const char *name;
|
||||||
|
@ -797,7 +1192,8 @@ static const struct sysc_capabilities sysc_34xx_sr = {
|
||||||
.type = TI_SYSC_OMAP34XX_SR,
|
.type = TI_SYSC_OMAP34XX_SR,
|
||||||
.sysc_mask = SYSC_OMAP2_CLOCKACTIVITY,
|
.sysc_mask = SYSC_OMAP2_CLOCKACTIVITY,
|
||||||
.regbits = &sysc_regbits_omap34xx_sr,
|
.regbits = &sysc_regbits_omap34xx_sr,
|
||||||
.mod_quirks = SYSC_QUIRK_USE_CLOCKACT | SYSC_QUIRK_UNCACHED,
|
.mod_quirks = SYSC_QUIRK_USE_CLOCKACT | SYSC_QUIRK_UNCACHED |
|
||||||
|
SYSC_QUIRK_LEGACY_IDLE,
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -818,12 +1214,13 @@ static const struct sysc_capabilities sysc_36xx_sr = {
|
||||||
.type = TI_SYSC_OMAP36XX_SR,
|
.type = TI_SYSC_OMAP36XX_SR,
|
||||||
.sysc_mask = SYSC_OMAP3_SR_ENAWAKEUP,
|
.sysc_mask = SYSC_OMAP3_SR_ENAWAKEUP,
|
||||||
.regbits = &sysc_regbits_omap36xx_sr,
|
.regbits = &sysc_regbits_omap36xx_sr,
|
||||||
.mod_quirks = SYSC_QUIRK_UNCACHED,
|
.mod_quirks = SYSC_QUIRK_UNCACHED | SYSC_QUIRK_LEGACY_IDLE,
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct sysc_capabilities sysc_omap4_sr = {
|
static const struct sysc_capabilities sysc_omap4_sr = {
|
||||||
.type = TI_SYSC_OMAP4_SR,
|
.type = TI_SYSC_OMAP4_SR,
|
||||||
.regbits = &sysc_regbits_omap36xx_sr,
|
.regbits = &sysc_regbits_omap36xx_sr,
|
||||||
|
.mod_quirks = SYSC_QUIRK_LEGACY_IDLE,
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -865,6 +1262,33 @@ static const struct sysc_capabilities sysc_omap4_usb_host_fs = {
|
||||||
.regbits = &sysc_regbits_omap4_usb_host_fs,
|
.regbits = &sysc_regbits_omap4_usb_host_fs,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static int sysc_init_pdata(struct sysc *ddata)
|
||||||
|
{
|
||||||
|
struct ti_sysc_platform_data *pdata = dev_get_platdata(ddata->dev);
|
||||||
|
struct ti_sysc_module_data mdata;
|
||||||
|
int error = 0;
|
||||||
|
|
||||||
|
if (!pdata || !ddata->legacy_mode)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
mdata.name = ddata->legacy_mode;
|
||||||
|
mdata.module_pa = ddata->module_pa;
|
||||||
|
mdata.module_size = ddata->module_size;
|
||||||
|
mdata.offsets = ddata->offsets;
|
||||||
|
mdata.nr_offsets = SYSC_MAX_REGS;
|
||||||
|
mdata.cap = ddata->cap;
|
||||||
|
mdata.cfg = &ddata->cfg;
|
||||||
|
|
||||||
|
if (!pdata->init_module)
|
||||||
|
return -ENODEV;
|
||||||
|
|
||||||
|
error = pdata->init_module(ddata->dev, &mdata, &ddata->cookie);
|
||||||
|
if (error == -EEXIST)
|
||||||
|
error = 0;
|
||||||
|
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
static int sysc_init_match(struct sysc *ddata)
|
static int sysc_init_match(struct sysc *ddata)
|
||||||
{
|
{
|
||||||
const struct sysc_capabilities *cap;
|
const struct sysc_capabilities *cap;
|
||||||
|
@ -880,8 +1304,19 @@ static int sysc_init_match(struct sysc *ddata)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void ti_sysc_idle(struct work_struct *work)
|
||||||
|
{
|
||||||
|
struct sysc *ddata;
|
||||||
|
|
||||||
|
ddata = container_of(work, struct sysc, idle_work.work);
|
||||||
|
|
||||||
|
if (pm_runtime_active(ddata->dev))
|
||||||
|
pm_runtime_put_sync(ddata->dev);
|
||||||
|
}
|
||||||
|
|
||||||
static int sysc_probe(struct platform_device *pdev)
|
static int sysc_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
|
struct ti_sysc_platform_data *pdata = dev_get_platdata(&pdev->dev);
|
||||||
struct sysc *ddata;
|
struct sysc *ddata;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
|
@ -920,6 +1355,10 @@ static int sysc_probe(struct platform_device *pdev)
|
||||||
if (error)
|
if (error)
|
||||||
goto unprepare;
|
goto unprepare;
|
||||||
|
|
||||||
|
error = sysc_init_pdata(ddata);
|
||||||
|
if (error)
|
||||||
|
goto unprepare;
|
||||||
|
|
||||||
pm_runtime_enable(ddata->dev);
|
pm_runtime_enable(ddata->dev);
|
||||||
|
|
||||||
error = sysc_init_module(ddata);
|
error = sysc_init_module(ddata);
|
||||||
|
@ -933,22 +1372,28 @@ static int sysc_probe(struct platform_device *pdev)
|
||||||
goto unprepare;
|
goto unprepare;
|
||||||
}
|
}
|
||||||
|
|
||||||
pm_runtime_use_autosuspend(ddata->dev);
|
|
||||||
|
|
||||||
sysc_show_registers(ddata);
|
sysc_show_registers(ddata);
|
||||||
|
|
||||||
|
ddata->dev->type = &sysc_device_type;
|
||||||
error = of_platform_populate(ddata->dev->of_node,
|
error = of_platform_populate(ddata->dev->of_node,
|
||||||
NULL, NULL, ddata->dev);
|
NULL, pdata ? pdata->auxdata : NULL,
|
||||||
|
ddata->dev);
|
||||||
if (error)
|
if (error)
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
pm_runtime_mark_last_busy(ddata->dev);
|
INIT_DELAYED_WORK(&ddata->idle_work, ti_sysc_idle);
|
||||||
pm_runtime_put_autosuspend(ddata->dev);
|
|
||||||
|
/* At least earlycon won't survive without deferred idle */
|
||||||
|
if (ddata->cfg.quirks & (SYSC_QUIRK_NO_IDLE_ON_INIT |
|
||||||
|
SYSC_QUIRK_NO_RESET_ON_INIT)) {
|
||||||
|
schedule_delayed_work(&ddata->idle_work, 3000);
|
||||||
|
} else {
|
||||||
|
pm_runtime_put(&pdev->dev);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
err:
|
err:
|
||||||
pm_runtime_dont_use_autosuspend(&pdev->dev);
|
|
||||||
pm_runtime_put_sync(&pdev->dev);
|
pm_runtime_put_sync(&pdev->dev);
|
||||||
pm_runtime_disable(&pdev->dev);
|
pm_runtime_disable(&pdev->dev);
|
||||||
unprepare:
|
unprepare:
|
||||||
|
@ -962,6 +1407,8 @@ static int sysc_remove(struct platform_device *pdev)
|
||||||
struct sysc *ddata = platform_get_drvdata(pdev);
|
struct sysc *ddata = platform_get_drvdata(pdev);
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
|
cancel_delayed_work_sync(&ddata->idle_work);
|
||||||
|
|
||||||
error = pm_runtime_get_sync(ddata->dev);
|
error = pm_runtime_get_sync(ddata->dev);
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
pm_runtime_put_noidle(ddata->dev);
|
pm_runtime_put_noidle(ddata->dev);
|
||||||
|
@ -971,7 +1418,6 @@ static int sysc_remove(struct platform_device *pdev)
|
||||||
|
|
||||||
of_platform_depopulate(&pdev->dev);
|
of_platform_depopulate(&pdev->dev);
|
||||||
|
|
||||||
pm_runtime_dont_use_autosuspend(&pdev->dev);
|
|
||||||
pm_runtime_put_sync(&pdev->dev);
|
pm_runtime_put_sync(&pdev->dev);
|
||||||
pm_runtime_disable(&pdev->dev);
|
pm_runtime_disable(&pdev->dev);
|
||||||
|
|
||||||
|
@ -1008,7 +1454,21 @@ static struct platform_driver sysc_driver = {
|
||||||
.pm = &sysc_pm_ops,
|
.pm = &sysc_pm_ops,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
module_platform_driver(sysc_driver);
|
|
||||||
|
static int __init sysc_init(void)
|
||||||
|
{
|
||||||
|
bus_register_notifier(&platform_bus_type, &sysc_nb);
|
||||||
|
|
||||||
|
return platform_driver_register(&sysc_driver);
|
||||||
|
}
|
||||||
|
module_init(sysc_init);
|
||||||
|
|
||||||
|
static void __exit sysc_exit(void)
|
||||||
|
{
|
||||||
|
bus_unregister_notifier(&platform_bus_type, &sysc_nb);
|
||||||
|
platform_driver_unregister(&sysc_driver);
|
||||||
|
}
|
||||||
|
module_exit(sysc_exit);
|
||||||
|
|
||||||
MODULE_DESCRIPTION("TI sysc interconnect target driver");
|
MODULE_DESCRIPTION("TI sysc interconnect target driver");
|
||||||
MODULE_LICENSE("GPL v2");
|
MODULE_LICENSE("GPL v2");
|
||||||
|
|
|
@ -132,12 +132,16 @@ static void sr_set_clk_length(struct omap_sr *sr)
|
||||||
struct clk *fck;
|
struct clk *fck;
|
||||||
u32 fclk_speed;
|
u32 fclk_speed;
|
||||||
|
|
||||||
fck = clk_get(&sr->pdev->dev, "fck");
|
/* Try interconnect target module fck first if it already exists */
|
||||||
|
fck = clk_get(sr->pdev->dev.parent, "fck");
|
||||||
if (IS_ERR(fck)) {
|
if (IS_ERR(fck)) {
|
||||||
dev_err(&sr->pdev->dev, "%s: unable to get fck for device %s\n",
|
fck = clk_get(&sr->pdev->dev, "fck");
|
||||||
__func__, dev_name(&sr->pdev->dev));
|
if (IS_ERR(fck)) {
|
||||||
return;
|
dev_err(&sr->pdev->dev,
|
||||||
|
"%s: unable to get fck for device %s\n",
|
||||||
|
__func__, dev_name(&sr->pdev->dev));
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fclk_speed = clk_get_rate(fck);
|
fclk_speed = clk_get_rate(fck);
|
||||||
|
@ -838,7 +842,7 @@ static int omap_sr_autocomp_store(void *data, u64 val)
|
||||||
DEFINE_SIMPLE_ATTRIBUTE(pm_sr_fops, omap_sr_autocomp_show,
|
DEFINE_SIMPLE_ATTRIBUTE(pm_sr_fops, omap_sr_autocomp_show,
|
||||||
omap_sr_autocomp_store, "%llu\n");
|
omap_sr_autocomp_store, "%llu\n");
|
||||||
|
|
||||||
static int __init omap_sr_probe(struct platform_device *pdev)
|
static int omap_sr_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct omap_sr *sr_info;
|
struct omap_sr *sr_info;
|
||||||
struct omap_sr_data *pdata = pdev->dev.platform_data;
|
struct omap_sr_data *pdata = pdev->dev.platform_data;
|
||||||
|
@ -898,6 +902,12 @@ static int __init omap_sr_probe(struct platform_device *pdev)
|
||||||
|
|
||||||
list_add(&sr_info->node, &sr_list);
|
list_add(&sr_info->node, &sr_list);
|
||||||
|
|
||||||
|
ret = pm_runtime_get_sync(&pdev->dev);
|
||||||
|
if (ret < 0) {
|
||||||
|
pm_runtime_put_noidle(&pdev->dev);
|
||||||
|
goto err_list_del;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Call into late init to do initializations that require
|
* Call into late init to do initializations that require
|
||||||
* both sr driver and sr class driver to be initiallized.
|
* both sr driver and sr class driver to be initiallized.
|
||||||
|
@ -966,12 +976,17 @@ static int __init omap_sr_probe(struct platform_device *pdev)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pm_runtime_put_sync(&pdev->dev);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
err_debugfs:
|
err_debugfs:
|
||||||
debugfs_remove_recursive(sr_info->dbg_dir);
|
debugfs_remove_recursive(sr_info->dbg_dir);
|
||||||
err_list_del:
|
err_list_del:
|
||||||
list_del(&sr_info->node);
|
list_del(&sr_info->node);
|
||||||
|
|
||||||
|
pm_runtime_put_sync(&pdev->dev);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1025,11 +1040,23 @@ static void omap_sr_shutdown(struct platform_device *pdev)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const struct of_device_id omap_sr_match[] = {
|
||||||
|
{ .compatible = "ti,omap3-smartreflex-core", },
|
||||||
|
{ .compatible = "ti,omap3-smartreflex-mpu-iva", },
|
||||||
|
{ .compatible = "ti,omap4-smartreflex-core", },
|
||||||
|
{ .compatible = "ti,omap4-smartreflex-mpu", },
|
||||||
|
{ .compatible = "ti,omap4-smartreflex-iva", },
|
||||||
|
{ },
|
||||||
|
};
|
||||||
|
MODULE_DEVICE_TABLE(of, omap_sr_match);
|
||||||
|
|
||||||
static struct platform_driver smartreflex_driver = {
|
static struct platform_driver smartreflex_driver = {
|
||||||
|
.probe = omap_sr_probe,
|
||||||
.remove = omap_sr_remove,
|
.remove = omap_sr_remove,
|
||||||
.shutdown = omap_sr_shutdown,
|
.shutdown = omap_sr_shutdown,
|
||||||
.driver = {
|
.driver = {
|
||||||
.name = DRIVER_NAME,
|
.name = DRIVER_NAME,
|
||||||
|
.of_match_table = omap_sr_match,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1048,7 +1075,7 @@ static int __init sr_init(void)
|
||||||
else
|
else
|
||||||
pr_warn("%s: No PMIC hook to init smartreflex\n", __func__);
|
pr_warn("%s: No PMIC hook to init smartreflex\n", __func__);
|
||||||
|
|
||||||
ret = platform_driver_probe(&smartreflex_driver, omap_sr_probe);
|
ret = platform_driver_register(&smartreflex_driver);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
pr_err("%s: platform driver register failed for SR\n",
|
pr_err("%s: platform driver register failed for SR\n",
|
||||||
__func__);
|
__func__);
|
||||||
|
|
|
@ -16,6 +16,10 @@ enum ti_sysc_module_type {
|
||||||
TI_SYSC_OMAP4_USB_HOST_FS,
|
TI_SYSC_OMAP4_USB_HOST_FS,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct ti_sysc_cookie {
|
||||||
|
void *data;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* struct sysc_regbits - TI OCP_SYSCONFIG register field offsets
|
* struct sysc_regbits - TI OCP_SYSCONFIG register field offsets
|
||||||
* @midle_shift: Offset of the midle bit
|
* @midle_shift: Offset of the midle bit
|
||||||
|
@ -41,6 +45,7 @@ struct sysc_regbits {
|
||||||
s8 emufree_shift;
|
s8 emufree_shift;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define SYSC_QUIRK_LEGACY_IDLE BIT(8)
|
||||||
#define SYSC_QUIRK_RESET_STATUS BIT(7)
|
#define SYSC_QUIRK_RESET_STATUS BIT(7)
|
||||||
#define SYSC_QUIRK_NO_IDLE_ON_INIT BIT(6)
|
#define SYSC_QUIRK_NO_IDLE_ON_INIT BIT(6)
|
||||||
#define SYSC_QUIRK_NO_RESET_ON_INIT BIT(5)
|
#define SYSC_QUIRK_NO_RESET_ON_INIT BIT(5)
|
||||||
|
@ -83,4 +88,49 @@ struct sysc_config {
|
||||||
u32 quirks;
|
u32 quirks;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum sysc_registers {
|
||||||
|
SYSC_REVISION,
|
||||||
|
SYSC_SYSCONFIG,
|
||||||
|
SYSC_SYSSTATUS,
|
||||||
|
SYSC_MAX_REGS,
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* struct ti_sysc_module_data - ti-sysc to hwmod translation data for a module
|
||||||
|
* @name: legacy "ti,hwmods" module name
|
||||||
|
* @module_pa: physical address of the interconnect target module
|
||||||
|
* @module_size: size of the interconnect target module
|
||||||
|
* @offsets: array of register offsets as listed in enum sysc_registers
|
||||||
|
* @nr_offsets: number of registers
|
||||||
|
* @cap: interconnect target module capabilities
|
||||||
|
* @cfg: interconnect target module configuration
|
||||||
|
*
|
||||||
|
* This data is enough to allocate a new struct omap_hwmod_class_sysconfig
|
||||||
|
* based on device tree data parsed by ti-sysc driver.
|
||||||
|
*/
|
||||||
|
struct ti_sysc_module_data {
|
||||||
|
const char *name;
|
||||||
|
u64 module_pa;
|
||||||
|
u32 module_size;
|
||||||
|
int *offsets;
|
||||||
|
int nr_offsets;
|
||||||
|
const struct sysc_capabilities *cap;
|
||||||
|
struct sysc_config *cfg;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct device;
|
||||||
|
|
||||||
|
struct ti_sysc_platform_data {
|
||||||
|
struct of_dev_auxdata *auxdata;
|
||||||
|
int (*init_module)(struct device *dev,
|
||||||
|
const struct ti_sysc_module_data *data,
|
||||||
|
struct ti_sysc_cookie *cookie);
|
||||||
|
int (*enable_module)(struct device *dev,
|
||||||
|
const struct ti_sysc_cookie *cookie);
|
||||||
|
int (*idle_module)(struct device *dev,
|
||||||
|
const struct ti_sysc_cookie *cookie);
|
||||||
|
int (*shutdown_module)(struct device *dev,
|
||||||
|
const struct ti_sysc_cookie *cookie);
|
||||||
|
};
|
||||||
|
|
||||||
#endif /* __TI_SYSC_DATA_H__ */
|
#endif /* __TI_SYSC_DATA_H__ */
|
||||||
|
|
|
@ -143,6 +143,13 @@
|
||||||
#define OMAP3430_SR_ERRWEIGHT 0x04
|
#define OMAP3430_SR_ERRWEIGHT 0x04
|
||||||
#define OMAP3430_SR_ERRMAXLIMIT 0x02
|
#define OMAP3430_SR_ERRMAXLIMIT 0x02
|
||||||
|
|
||||||
|
enum sr_instance {
|
||||||
|
OMAP_SR_MPU, /* shared with iva on omap3 */
|
||||||
|
OMAP_SR_CORE,
|
||||||
|
OMAP_SR_IVA,
|
||||||
|
OMAP_SR_NR,
|
||||||
|
};
|
||||||
|
|
||||||
struct omap_sr {
|
struct omap_sr {
|
||||||
char *name;
|
char *name;
|
||||||
struct list_head node;
|
struct list_head node;
|
||||||
|
@ -207,7 +214,6 @@ struct omap_smartreflex_dev_attr {
|
||||||
const char *sensor_voltdm_name;
|
const char *sensor_voltdm_name;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef CONFIG_POWER_AVS_OMAP
|
|
||||||
/*
|
/*
|
||||||
* The smart reflex driver supports CLASS1 CLASS2 and CLASS3 SR.
|
* The smart reflex driver supports CLASS1 CLASS2 and CLASS3 SR.
|
||||||
* The smartreflex class driver should pass the class type.
|
* The smartreflex class driver should pass the class type.
|
||||||
|
@ -290,6 +296,8 @@ struct omap_sr_data {
|
||||||
struct voltagedomain *voltdm;
|
struct voltagedomain *voltdm;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef CONFIG_POWER_AVS_OMAP
|
||||||
|
|
||||||
/* Smartreflex module enable/disable interface */
|
/* Smartreflex module enable/disable interface */
|
||||||
void omap_sr_enable(struct voltagedomain *voltdm);
|
void omap_sr_enable(struct voltagedomain *voltdm);
|
||||||
void omap_sr_disable(struct voltagedomain *voltdm);
|
void omap_sr_disable(struct voltagedomain *voltdm);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче