aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2018-03-07 10:26:43 -0500
committerArnd Bergmann <arnd@arndb.de>2018-03-07 10:26:43 -0500
commit3bf5c70d06ce1d91cc73cee68bc6c4f850192cb0 (patch)
tree7d1fab0c67d26ebde22ea4c5e7eb8625f388ccf1
parent18b4788badeae8ed3a9bd3c240d83dffe5db8f37 (diff)
parent695eea3d2c7f3e70e852226c338d464a6251c70b (diff)
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
-rw-r--r--arch/arm/mach-omap2/board-n8x0.c4
-rw-r--r--arch/arm/mach-omap2/omap_device.c5
-rw-r--r--arch/arm/mach-omap2/omap_hwmod.c418
-rw-r--r--arch/arm/mach-omap2/omap_hwmod.h7
-rw-r--r--arch/arm/mach-omap2/pdata-quirks.c54
-rw-r--r--arch/arm/mach-omap2/sr_device.c27
-rw-r--r--drivers/bus/ti-sysc.c526
-rw-r--r--drivers/power/avs/smartreflex.c41
-rw-r--r--include/linux/platform_data/ti-sysc.h50
-rw-r--r--include/linux/power/smartreflex.h10
10 files changed, 1086 insertions, 56 deletions
diff --git a/arch/arm/mach-omap2/board-n8x0.c b/arch/arm/mach-omap2/board-n8x0.c
index 20f25539d572..75bc18646df6 100644
--- a/arch/arm/mach-omap2/board-n8x0.c
+++ b/arch/arm/mach-omap2/board-n8x0.c
@@ -566,11 +566,11 @@ static int n8x0_menelaus_late_init(struct device *dev)
566} 566}
567#endif 567#endif
568 568
569struct menelaus_platform_data n8x0_menelaus_platform_data __initdata = { 569struct menelaus_platform_data n8x0_menelaus_platform_data = {
570 .late_init = n8x0_menelaus_late_init, 570 .late_init = n8x0_menelaus_late_init,
571}; 571};
572 572
573struct aic3x_pdata n810_aic33_data __initdata = { 573struct aic3x_pdata n810_aic33_data = {
574 .gpio_reset = 118, 574 .gpio_reset = 118,
575}; 575};
576 576
diff --git a/arch/arm/mach-omap2/omap_device.c b/arch/arm/mach-omap2/omap_device.c
index f0388058b7da..3b829a50d1db 100644
--- a/arch/arm/mach-omap2/omap_device.c
+++ b/arch/arm/mach-omap2/omap_device.c
@@ -140,6 +140,7 @@ static int omap_device_build_from_dt(struct platform_device *pdev)
140 struct omap_device *od; 140 struct omap_device *od;
141 struct omap_hwmod *oh; 141 struct omap_hwmod *oh;
142 struct device_node *node = pdev->dev.of_node; 142 struct device_node *node = pdev->dev.of_node;
143 struct resource res;
143 const char *oh_name; 144 const char *oh_name;
144 int oh_cnt, i, ret = 0; 145 int oh_cnt, i, ret = 0;
145 bool device_active = false; 146 bool device_active = false;
@@ -150,6 +151,10 @@ static int omap_device_build_from_dt(struct platform_device *pdev)
150 return -ENODEV; 151 return -ENODEV;
151 } 152 }
152 153
154 /* Use ti-sysc driver instead of omap_device? */
155 if (!omap_hwmod_parse_module_range(NULL, node, &res))
156 return -ENODEV;
157
153 hwmods = kzalloc(sizeof(struct omap_hwmod *) * oh_cnt, GFP_KERNEL); 158 hwmods = kzalloc(sizeof(struct omap_hwmod *) * oh_cnt, GFP_KERNEL);
154 if (!hwmods) { 159 if (!hwmods) {
155 ret = -ENOMEM; 160 ret = -ENOMEM;
diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index 34156eca8e23..e7d23e200ecc 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -145,6 +145,8 @@
145 145
146#include <linux/platform_data/ti-sysc.h> 146#include <linux/platform_data/ti-sysc.h>
147 147
148#include <dt-bindings/bus/ti-sysc.h>
149
148#include <asm/system_misc.h> 150#include <asm/system_misc.h>
149 151
150#include "clock.h" 152#include "clock.h"
@@ -2498,7 +2500,7 @@ static void __init _setup_postsetup(struct omap_hwmod *oh)
2498 * affects the IP block hardware, or system integration hardware 2500 * affects the IP block hardware, or system integration hardware
2499 * associated with the IP block. Returns 0. 2501 * associated with the IP block. Returns 0.
2500 */ 2502 */
2501static int __init _setup(struct omap_hwmod *oh, void *data) 2503static int _setup(struct omap_hwmod *oh, void *data)
2502{ 2504{
2503 if (oh->_state != _HWMOD_STATE_INITIALIZED) 2505 if (oh->_state != _HWMOD_STATE_INITIALIZED)
2504 return 0; 2506 return 0;
@@ -3060,6 +3062,414 @@ int __init omap_hwmod_setup_one(const char *oh_name)
3060 return 0; 3062 return 0;
3061} 3063}
3062 3064
3065static void omap_hwmod_check_one(struct device *dev,
3066 const char *name, s8 v1, u8 v2)
3067{
3068 if (v1 < 0)
3069 return;
3070
3071 if (v1 != v2)
3072 dev_warn(dev, "%s %d != %d\n", name, v1, v2);
3073}
3074
3075/**
3076 * omap_hwmod_check_sysc - check sysc against platform sysc
3077 * @dev: struct device
3078 * @data: module data
3079 * @sysc_fields: new sysc configuration
3080 */
3081static int omap_hwmod_check_sysc(struct device *dev,
3082 const struct ti_sysc_module_data *data,
3083 struct sysc_regbits *sysc_fields)
3084{
3085 const struct sysc_regbits *regbits = data->cap->regbits;
3086
3087 omap_hwmod_check_one(dev, "dmadisable_shift",
3088 regbits->dmadisable_shift,
3089 sysc_fields->dmadisable_shift);
3090 omap_hwmod_check_one(dev, "midle_shift",
3091 regbits->midle_shift,
3092 sysc_fields->midle_shift);
3093 omap_hwmod_check_one(dev, "sidle_shift",
3094 regbits->sidle_shift,
3095 sysc_fields->sidle_shift);
3096 omap_hwmod_check_one(dev, "clkact_shift",
3097 regbits->clkact_shift,
3098 sysc_fields->clkact_shift);
3099 omap_hwmod_check_one(dev, "enwkup_shift",
3100 regbits->enwkup_shift,
3101 sysc_fields->enwkup_shift);
3102 omap_hwmod_check_one(dev, "srst_shift",
3103 regbits->srst_shift,
3104 sysc_fields->srst_shift);
3105 omap_hwmod_check_one(dev, "autoidle_shift",
3106 regbits->autoidle_shift,
3107 sysc_fields->autoidle_shift);
3108
3109 return 0;
3110}
3111
3112/**
3113 * omap_hwmod_init_regbits - init sysconfig specific register bits
3114 * @dev: struct device
3115 * @data: module data
3116 * @sysc_fields: new sysc configuration
3117 */
3118static int omap_hwmod_init_regbits(struct device *dev,
3119 const struct ti_sysc_module_data *data,
3120 struct sysc_regbits **sysc_fields)
3121{
3122 *sysc_fields = NULL;
3123
3124 switch (data->cap->type) {
3125 case TI_SYSC_OMAP2:
3126 case TI_SYSC_OMAP2_TIMER:
3127 *sysc_fields = &omap_hwmod_sysc_type1;
3128 break;
3129 case TI_SYSC_OMAP3_SHAM:
3130 *sysc_fields = &omap3_sham_sysc_fields;
3131 break;
3132 case TI_SYSC_OMAP3_AES:
3133 *sysc_fields = &omap3xxx_aes_sysc_fields;
3134 break;
3135 case TI_SYSC_OMAP4:
3136 case TI_SYSC_OMAP4_TIMER:
3137 *sysc_fields = &omap_hwmod_sysc_type2;
3138 break;
3139 case TI_SYSC_OMAP4_SIMPLE:
3140 *sysc_fields = &omap_hwmod_sysc_type3;
3141 break;
3142 case TI_SYSC_OMAP34XX_SR:
3143 *sysc_fields = &omap34xx_sr_sysc_fields;
3144 break;
3145 case TI_SYSC_OMAP36XX_SR:
3146 *sysc_fields = &omap36xx_sr_sysc_fields;
3147 break;
3148 case TI_SYSC_OMAP4_SR:
3149 *sysc_fields = &omap36xx_sr_sysc_fields;
3150 break;
3151 case TI_SYSC_OMAP4_MCASP:
3152 *sysc_fields = &omap_hwmod_sysc_type_mcasp;
3153 break;
3154 case TI_SYSC_OMAP4_USB_HOST_FS:
3155 *sysc_fields = &omap_hwmod_sysc_type_usb_host_fs;
3156 break;
3157 default:
3158 return -EINVAL;
3159 }
3160
3161 return omap_hwmod_check_sysc(dev, data, *sysc_fields);
3162}
3163
3164/**
3165 * omap_hwmod_init_reg_offs - initialize sysconfig register offsets
3166 * @dev: struct device
3167 * @data: module data
3168 * @rev_offs: revision register offset
3169 * @sysc_offs: sysc register offset
3170 * @syss_offs: syss register offset
3171 */
3172int omap_hwmod_init_reg_offs(struct device *dev,
3173 const struct ti_sysc_module_data *data,
3174 u32 *rev_offs, u32 *sysc_offs, u32 *syss_offs)
3175{
3176 *rev_offs = 0;
3177 *sysc_offs = 0;
3178 *syss_offs = 0;
3179
3180 if (data->offsets[SYSC_REVISION] > 0)
3181 *rev_offs = data->offsets[SYSC_REVISION];
3182
3183 if (data->offsets[SYSC_SYSCONFIG] > 0)
3184 *sysc_offs = data->offsets[SYSC_SYSCONFIG];
3185
3186 if (data->offsets[SYSC_SYSSTATUS] > 0)
3187 *syss_offs = data->offsets[SYSC_SYSSTATUS];
3188
3189 return 0;
3190}
3191
3192/**
3193 * omap_hwmod_init_sysc_flags - initialize sysconfig features
3194 * @dev: struct device
3195 * @data: module data
3196 * @sysc_flags: module configuration
3197 */
3198int omap_hwmod_init_sysc_flags(struct device *dev,
3199 const struct ti_sysc_module_data *data,
3200 u32 *sysc_flags)
3201{
3202 *sysc_flags = 0;
3203
3204 switch (data->cap->type) {
3205 case TI_SYSC_OMAP2:
3206 case TI_SYSC_OMAP2_TIMER:
3207 /* See SYSC_OMAP2_* in include/dt-bindings/bus/ti-sysc.h */
3208 if (data->cfg->sysc_val & SYSC_OMAP2_CLOCKACTIVITY)
3209 *sysc_flags |= SYSC_HAS_CLOCKACTIVITY;
3210 if (data->cfg->sysc_val & SYSC_OMAP2_EMUFREE)
3211 *sysc_flags |= SYSC_HAS_EMUFREE;
3212 if (data->cfg->sysc_val & SYSC_OMAP2_ENAWAKEUP)
3213 *sysc_flags |= SYSC_HAS_ENAWAKEUP;
3214 if (data->cfg->sysc_val & SYSC_OMAP2_SOFTRESET)
3215 *sysc_flags |= SYSC_HAS_SOFTRESET;
3216 if (data->cfg->sysc_val & SYSC_OMAP2_AUTOIDLE)
3217 *sysc_flags |= SYSC_HAS_AUTOIDLE;
3218 break;
3219 case TI_SYSC_OMAP4:
3220 case TI_SYSC_OMAP4_TIMER:
3221 /* See SYSC_OMAP4_* in include/dt-bindings/bus/ti-sysc.h */
3222 if (data->cfg->sysc_val & SYSC_OMAP4_DMADISABLE)
3223 *sysc_flags |= SYSC_HAS_DMADISABLE;
3224 if (data->cfg->sysc_val & SYSC_OMAP4_FREEEMU)
3225 *sysc_flags |= SYSC_HAS_EMUFREE;
3226 if (data->cfg->sysc_val & SYSC_OMAP4_SOFTRESET)
3227 *sysc_flags |= SYSC_HAS_SOFTRESET;
3228 break;
3229 case TI_SYSC_OMAP34XX_SR:
3230 case TI_SYSC_OMAP36XX_SR:
3231 /* See SYSC_OMAP3_SR_* in include/dt-bindings/bus/ti-sysc.h */
3232 if (data->cfg->sysc_val & SYSC_OMAP3_SR_ENAWAKEUP)
3233 *sysc_flags |= SYSC_HAS_ENAWAKEUP;
3234 break;
3235 default:
3236 if (data->cap->regbits->emufree_shift >= 0)
3237 *sysc_flags |= SYSC_HAS_EMUFREE;
3238 if (data->cap->regbits->enwkup_shift >= 0)
3239 *sysc_flags |= SYSC_HAS_ENAWAKEUP;
3240 if (data->cap->regbits->srst_shift >= 0)
3241 *sysc_flags |= SYSC_HAS_SOFTRESET;
3242 if (data->cap->regbits->autoidle_shift >= 0)
3243 *sysc_flags |= SYSC_HAS_AUTOIDLE;
3244 break;
3245 }
3246
3247 if (data->cap->regbits->midle_shift >= 0 &&
3248 data->cfg->midlemodes)
3249 *sysc_flags |= SYSC_HAS_MIDLEMODE;
3250
3251 if (data->cap->regbits->sidle_shift >= 0 &&
3252 data->cfg->sidlemodes)
3253 *sysc_flags |= SYSC_HAS_SIDLEMODE;
3254
3255 if (data->cfg->quirks & SYSC_QUIRK_UNCACHED)
3256 *sysc_flags |= SYSC_NO_CACHE;
3257 if (data->cfg->quirks & SYSC_QUIRK_RESET_STATUS)
3258 *sysc_flags |= SYSC_HAS_RESET_STATUS;
3259
3260 if (data->cfg->syss_mask & 1)
3261 *sysc_flags |= SYSS_HAS_RESET_STATUS;
3262
3263 return 0;
3264}
3265
3266/**
3267 * omap_hwmod_init_idlemodes - initialize module idle modes
3268 * @dev: struct device
3269 * @data: module data
3270 * @idlemodes: module supported idle modes
3271 */
3272int omap_hwmod_init_idlemodes(struct device *dev,
3273 const struct ti_sysc_module_data *data,
3274 u32 *idlemodes)
3275{
3276 *idlemodes = 0;
3277
3278 if (data->cfg->midlemodes & BIT(SYSC_IDLE_FORCE))
3279 *idlemodes |= MSTANDBY_FORCE;
3280 if (data->cfg->midlemodes & BIT(SYSC_IDLE_NO))
3281 *idlemodes |= MSTANDBY_NO;
3282 if (data->cfg->midlemodes & BIT(SYSC_IDLE_SMART))
3283 *idlemodes |= MSTANDBY_SMART;
3284 if (data->cfg->midlemodes & BIT(SYSC_IDLE_SMART_WKUP))
3285 *idlemodes |= MSTANDBY_SMART_WKUP;
3286
3287 if (data->cfg->sidlemodes & BIT(SYSC_IDLE_FORCE))
3288 *idlemodes |= SIDLE_FORCE;
3289 if (data->cfg->sidlemodes & BIT(SYSC_IDLE_NO))
3290 *idlemodes |= SIDLE_NO;
3291 if (data->cfg->sidlemodes & BIT(SYSC_IDLE_SMART))
3292 *idlemodes |= SIDLE_SMART;
3293 if (data->cfg->sidlemodes & BIT(SYSC_IDLE_SMART_WKUP))
3294 *idlemodes |= SIDLE_SMART_WKUP;
3295
3296 return 0;
3297}
3298
3299/**
3300 * omap_hwmod_check_module - check new module against platform data
3301 * @dev: struct device
3302 * @oh: module
3303 * @data: new module data
3304 * @sysc_fields: sysc register bits
3305 * @rev_offs: revision register offset
3306 * @sysc_offs: sysconfig register offset
3307 * @syss_offs: sysstatus register offset
3308 * @sysc_flags: sysc specific flags
3309 * @idlemodes: sysc supported idlemodes
3310 */
3311static int omap_hwmod_check_module(struct device *dev,
3312 struct omap_hwmod *oh,
3313 const struct ti_sysc_module_data *data,
3314 struct sysc_regbits *sysc_fields,
3315 u32 rev_offs, u32 sysc_offs,
3316 u32 syss_offs, u32 sysc_flags,
3317 u32 idlemodes)
3318{
3319 if (!oh->class->sysc)
3320 return -ENODEV;
3321
3322 if (sysc_fields != oh->class->sysc->sysc_fields)
3323 dev_warn(dev, "sysc_fields %p != %p\n", sysc_fields,
3324 oh->class->sysc->sysc_fields);
3325
3326 if (rev_offs != oh->class->sysc->rev_offs)
3327 dev_warn(dev, "rev_offs %08x != %08x\n", rev_offs,
3328 oh->class->sysc->rev_offs);
3329 if (sysc_offs != oh->class->sysc->sysc_offs)
3330 dev_warn(dev, "sysc_offs %08x != %08x\n", sysc_offs,
3331 oh->class->sysc->sysc_offs);
3332 if (syss_offs != oh->class->sysc->syss_offs)
3333 dev_warn(dev, "syss_offs %08x != %08x\n", syss_offs,
3334 oh->class->sysc->syss_offs);
3335
3336 if (sysc_flags != oh->class->sysc->sysc_flags)
3337 dev_warn(dev, "sysc_flags %08x != %08x\n", sysc_flags,
3338 oh->class->sysc->sysc_flags);
3339
3340 if (idlemodes != oh->class->sysc->idlemodes)
3341 dev_warn(dev, "idlemodes %08x != %08x\n", idlemodes,
3342 oh->class->sysc->idlemodes);
3343
3344 if (data->cfg->srst_udelay != oh->class->sysc->srst_udelay)
3345 dev_warn(dev, "srst_udelay %i != %i\n",
3346 data->cfg->srst_udelay,
3347 oh->class->sysc->srst_udelay);
3348
3349 return 0;
3350}
3351
3352/**
3353 * omap_hwmod_allocate_module - allocate new module
3354 * @dev: struct device
3355 * @oh: module
3356 * @sysc_fields: sysc register bits
3357 * @rev_offs: revision register offset
3358 * @sysc_offs: sysconfig register offset
3359 * @syss_offs: sysstatus register offset
3360 * @sysc_flags: sysc specific flags
3361 * @idlemodes: sysc supported idlemodes
3362 *
3363 * Note that the allocations here cannot use devm as ti-sysc can rebind.
3364 */
3365int omap_hwmod_allocate_module(struct device *dev, struct omap_hwmod *oh,
3366 const struct ti_sysc_module_data *data,
3367 struct sysc_regbits *sysc_fields,
3368 u32 rev_offs, u32 sysc_offs, u32 syss_offs,
3369 u32 sysc_flags, u32 idlemodes)
3370{
3371 struct omap_hwmod_class_sysconfig *sysc;
3372 struct omap_hwmod_class *class;
3373 void __iomem *regs = NULL;
3374 unsigned long flags;
3375
3376 sysc = kzalloc(sizeof(*sysc), GFP_KERNEL);
3377 if (!sysc)
3378 return -ENOMEM;
3379
3380 sysc->sysc_fields = sysc_fields;
3381 sysc->rev_offs = rev_offs;
3382 sysc->sysc_offs = sysc_offs;
3383 sysc->syss_offs = syss_offs;
3384 sysc->sysc_flags = sysc_flags;
3385 sysc->idlemodes = idlemodes;
3386 sysc->srst_udelay = data->cfg->srst_udelay;
3387
3388 if (!oh->_mpu_rt_va) {
3389 regs = ioremap(data->module_pa,
3390 data->module_size);
3391 if (!regs)
3392 return -ENOMEM;
3393 }
3394
3395 /*
3396 * We need new oh->class as the other devices in the same class
3397 * may not yet have ioremapped their registers.
3398 */
3399 class = kmemdup(oh->class, sizeof(*oh->class), GFP_KERNEL);
3400 if (!class)
3401 return -ENOMEM;
3402
3403 class->sysc = sysc;
3404
3405 spin_lock_irqsave(&oh->_lock, flags);
3406 if (regs)
3407 oh->_mpu_rt_va = regs;
3408 oh->class = class;
3409 oh->_state = _HWMOD_STATE_INITIALIZED;
3410 _setup(oh, NULL);
3411 spin_unlock_irqrestore(&oh->_lock, flags);
3412
3413 return 0;
3414}
3415
3416/**
3417 * omap_hwmod_init_module - initialize new module
3418 * @dev: struct device
3419 * @data: module data
3420 * @cookie: cookie for the caller to use for later calls
3421 */
3422int omap_hwmod_init_module(struct device *dev,
3423 const struct ti_sysc_module_data *data,
3424 struct ti_sysc_cookie *cookie)
3425{
3426 struct omap_hwmod *oh;
3427 struct sysc_regbits *sysc_fields;
3428 u32 rev_offs, sysc_offs, syss_offs, sysc_flags, idlemodes;
3429 int error;
3430
3431 if (!dev || !data)
3432 return -EINVAL;
3433
3434 oh = _lookup(data->name);
3435 if (!oh)
3436 return -ENODEV;
3437
3438 cookie->data = oh;
3439
3440 error = omap_hwmod_init_regbits(dev, data, &sysc_fields);
3441 if (error)
3442 return error;
3443
3444 error = omap_hwmod_init_reg_offs(dev, data, &rev_offs,
3445 &sysc_offs, &syss_offs);
3446 if (error)
3447 return error;
3448
3449 error = omap_hwmod_init_sysc_flags(dev, data, &sysc_flags);
3450 if (error)
3451 return error;
3452
3453 error = omap_hwmod_init_idlemodes(dev, data, &idlemodes);
3454 if (error)
3455 return error;
3456
3457 if (data->cfg->quirks & SYSC_QUIRK_NO_IDLE_ON_INIT)
3458 oh->flags |= HWMOD_INIT_NO_IDLE;
3459 if (data->cfg->quirks & SYSC_QUIRK_NO_RESET_ON_INIT)
3460 oh->flags |= HWMOD_INIT_NO_RESET;
3461
3462 error = omap_hwmod_check_module(dev, oh, data, sysc_fields,
3463 rev_offs, sysc_offs, syss_offs,
3464 sysc_flags, idlemodes);
3465 if (!error)
3466 return error;
3467
3468 return omap_hwmod_allocate_module(dev, oh, data, sysc_fields,
3469 rev_offs, sysc_offs, syss_offs,
3470 sysc_flags, idlemodes);
3471}
3472
3063/** 3473/**
3064 * omap_hwmod_setup_earlycon_flags - set up flags for early console 3474 * omap_hwmod_setup_earlycon_flags - set up flags for early console
3065 * 3475 *
@@ -3082,6 +3492,12 @@ static void __init omap_hwmod_setup_earlycon_flags(void)
3082 if (np) { 3492 if (np) {
3083 uart = of_get_property(np, "ti,hwmods", NULL); 3493 uart = of_get_property(np, "ti,hwmods", NULL);
3084 oh = omap_hwmod_lookup(uart); 3494 oh = omap_hwmod_lookup(uart);
3495 if (!oh) {
3496 uart = of_get_property(np->parent,
3497 "ti,hwmods",
3498 NULL);
3499 oh = omap_hwmod_lookup(uart);
3500 }
3085 if (oh) 3501 if (oh)
3086 oh->flags |= DEBUG_OMAPUART_FLAGS; 3502 oh->flags |= DEBUG_OMAPUART_FLAGS;
3087 } 3503 }
diff --git a/arch/arm/mach-omap2/omap_hwmod.h b/arch/arm/mach-omap2/omap_hwmod.h
index 0b8e19f40402..c7122abbf977 100644
--- a/arch/arm/mach-omap2/omap_hwmod.h
+++ b/arch/arm/mach-omap2/omap_hwmod.h
@@ -620,6 +620,13 @@ int omap_hwmod_parse_module_range(struct omap_hwmod *oh,
620 struct device_node *np, 620 struct device_node *np,
621 struct resource *res); 621 struct resource *res);
622 622
623struct ti_sysc_module_data;
624struct ti_sysc_cookie;
625
626int omap_hwmod_init_module(struct device *dev,
627 const struct ti_sysc_module_data *data,
628 struct ti_sysc_cookie *cookie);
629
623int omap_hwmod_enable(struct omap_hwmod *oh); 630int omap_hwmod_enable(struct omap_hwmod *oh);
624int omap_hwmod_idle(struct omap_hwmod *oh); 631int omap_hwmod_idle(struct omap_hwmod *oh);
625int omap_hwmod_shutdown(struct omap_hwmod *oh); 632int omap_hwmod_shutdown(struct omap_hwmod *oh);
diff --git a/arch/arm/mach-omap2/pdata-quirks.c b/arch/arm/mach-omap2/pdata-quirks.c
index e7d7fc7ddaa2..6459816c2879 100644
--- a/arch/arm/mach-omap2/pdata-quirks.c
+++ b/arch/arm/mach-omap2/pdata-quirks.c
@@ -17,12 +17,14 @@
17#include <linux/wl12xx.h> 17#include <linux/wl12xx.h>
18#include <linux/mmc/card.h> 18#include <linux/mmc/card.h>
19#include <linux/mmc/host.h> 19#include <linux/mmc/host.h>
20#include <linux/power/smartreflex.h>
20#include <linux/regulator/machine.h> 21#include <linux/regulator/machine.h>
21#include <linux/regulator/fixed.h> 22#include <linux/regulator/fixed.h>
22 23
23#include <linux/platform_data/pinctrl-single.h> 24#include <linux/platform_data/pinctrl-single.h>
24#include <linux/platform_data/hsmmc-omap.h> 25#include <linux/platform_data/hsmmc-omap.h>
25#include <linux/platform_data/iommu-omap.h> 26#include <linux/platform_data/iommu-omap.h>
27#include <linux/platform_data/ti-sysc.h>
26#include <linux/platform_data/wkup_m3.h> 28#include <linux/platform_data/wkup_m3.h>
27#include <linux/platform_data/media/ir-rx51.h> 29#include <linux/platform_data/media/ir-rx51.h>
28#include <linux/platform_data/asoc-ti-mcbsp.h> 30#include <linux/platform_data/asoc-ti-mcbsp.h>
@@ -452,6 +454,43 @@ static void __init dra7x_evm_mmc_quirk(void)
452} 454}
453#endif 455#endif
454 456
457static int ti_sysc_enable_module(struct device *dev,
458 const struct ti_sysc_cookie *cookie)
459{
460 if (!cookie->data)
461 return -EINVAL;
462
463 return omap_hwmod_enable(cookie->data);
464}
465
466static int ti_sysc_idle_module(struct device *dev,
467 const struct ti_sysc_cookie *cookie)
468{
469 if (!cookie->data)
470 return -EINVAL;
471
472 return omap_hwmod_idle(cookie->data);
473}
474
475static int ti_sysc_shutdown_module(struct device *dev,
476 const struct ti_sysc_cookie *cookie)
477{
478 if (!cookie->data)
479 return -EINVAL;
480
481 return omap_hwmod_shutdown(cookie->data);
482}
483
484static struct of_dev_auxdata omap_auxdata_lookup[];
485
486static struct ti_sysc_platform_data ti_sysc_pdata = {
487 .auxdata = omap_auxdata_lookup,
488 .init_module = omap_hwmod_init_module,
489 .enable_module = ti_sysc_enable_module,
490 .idle_module = ti_sysc_idle_module,
491 .shutdown_module = ti_sysc_shutdown_module,
492};
493
455static struct pcs_pdata pcs_pdata; 494static struct pcs_pdata pcs_pdata;
456 495
457void omap_pcs_legacy_init(int irq, void (*rearm)(void)) 496void omap_pcs_legacy_init(int irq, void (*rearm)(void))
@@ -513,7 +552,9 @@ static struct pdata_init auxdata_quirks[] __initdata = {
513 { /* sentinel */ }, 552 { /* sentinel */ },
514}; 553};
515 554
516static struct of_dev_auxdata omap_auxdata_lookup[] __initdata = { 555struct omap_sr_data __maybe_unused omap_sr_pdata[OMAP_SR_NR];
556
557static struct of_dev_auxdata omap_auxdata_lookup[] = {
517#ifdef CONFIG_MACH_NOKIA_N8X0 558#ifdef CONFIG_MACH_NOKIA_N8X0
518 OF_DEV_AUXDATA("ti,omap2420-mmc", 0x4809c000, "mmci-omap.0", NULL), 559 OF_DEV_AUXDATA("ti,omap2420-mmc", 0x4809c000, "mmci-omap.0", NULL),
519 OF_DEV_AUXDATA("menelaus", 0x72, "1-0072", &n8x0_menelaus_platform_data), 560 OF_DEV_AUXDATA("menelaus", 0x72, "1-0072", &n8x0_menelaus_platform_data),
@@ -522,6 +563,10 @@ static struct of_dev_auxdata omap_auxdata_lookup[] __initdata = {
522#ifdef CONFIG_ARCH_OMAP3 563#ifdef CONFIG_ARCH_OMAP3
523 OF_DEV_AUXDATA("ti,omap2-iommu", 0x5d000000, "5d000000.mmu", 564 OF_DEV_AUXDATA("ti,omap2-iommu", 0x5d000000, "5d000000.mmu",
524 &omap3_iommu_pdata), 565 &omap3_iommu_pdata),
566 OF_DEV_AUXDATA("ti,omap3-smartreflex-core", 0x480cb000,
567 "480cb000.smartreflex", &omap_sr_pdata[OMAP_SR_CORE]),
568 OF_DEV_AUXDATA("ti,omap3-smartreflex-mpu-iva", 0x480c9000,
569 "480c9000.smartreflex", &omap_sr_pdata[OMAP_SR_MPU]),
525 OF_DEV_AUXDATA("ti,omap3-hsmmc", 0x4809c000, "4809c000.mmc", &mmc_pdata[0]), 570 OF_DEV_AUXDATA("ti,omap3-hsmmc", 0x4809c000, "4809c000.mmc", &mmc_pdata[0]),
526 OF_DEV_AUXDATA("ti,omap3-hsmmc", 0x480b4000, "480b4000.mmc", &mmc_pdata[1]), 571 OF_DEV_AUXDATA("ti,omap3-hsmmc", 0x480b4000, "480b4000.mmc", &mmc_pdata[1]),
527 OF_DEV_AUXDATA("nokia,n900-ir", 0, "n900-ir", &rx51_ir_data), 572 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 = {
548 &omap4_iommu_pdata), 593 &omap4_iommu_pdata),
549 OF_DEV_AUXDATA("ti,omap4-iommu", 0x55082000, "55082000.mmu", 594 OF_DEV_AUXDATA("ti,omap4-iommu", 0x55082000, "55082000.mmu",
550 &omap4_iommu_pdata), 595 &omap4_iommu_pdata),
596 OF_DEV_AUXDATA("ti,omap4-smartreflex-iva", 0x4a0db000,
597 "4a0db000.smartreflex", &omap_sr_pdata[OMAP_SR_IVA]),
598 OF_DEV_AUXDATA("ti,omap4-smartreflex-core", 0x4a0dd000,
599 "4a0dd000.smartreflex", &omap_sr_pdata[OMAP_SR_CORE]),
600 OF_DEV_AUXDATA("ti,omap4-smartreflex-mpu", 0x4a0d9000,
601 "4a0d9000.smartreflex", &omap_sr_pdata[OMAP_SR_MPU]),
551#endif 602#endif
552#ifdef CONFIG_SOC_DRA7XX 603#ifdef CONFIG_SOC_DRA7XX
553 OF_DEV_AUXDATA("ti,dra7-hsmmc", 0x4809c000, "4809c000.mmc", 604 OF_DEV_AUXDATA("ti,dra7-hsmmc", 0x4809c000, "4809c000.mmc",
@@ -558,6 +609,7 @@ static struct of_dev_auxdata omap_auxdata_lookup[] __initdata = {
558 &dra7_hsmmc_data_mmc3), 609 &dra7_hsmmc_data_mmc3),
559#endif 610#endif
560 /* Common auxdata */ 611 /* Common auxdata */
612 OF_DEV_AUXDATA("ti,sysc", 0, NULL, &ti_sysc_pdata),
561 OF_DEV_AUXDATA("pinctrl-single", 0, NULL, &pcs_pdata), 613 OF_DEV_AUXDATA("pinctrl-single", 0, NULL, &pcs_pdata),
562 { /* sentinel */ }, 614 { /* sentinel */ },
563}; 615};
diff --git a/arch/arm/mach-omap2/sr_device.c b/arch/arm/mach-omap2/sr_device.c
index eef6935e0403..0854ed9ff379 100644
--- a/arch/arm/mach-omap2/sr_device.c
+++ b/arch/arm/mach-omap2/sr_device.c
@@ -89,18 +89,27 @@ static void __init sr_set_nvalues(struct omap_volt_data *volt_data,
89 sr_data->nvalue_count = j; 89 sr_data->nvalue_count = j;
90} 90}
91 91
92extern struct omap_sr_data omap_sr_pdata[];
93
92static int __init sr_dev_init(struct omap_hwmod *oh, void *user) 94static int __init sr_dev_init(struct omap_hwmod *oh, void *user)
93{ 95{
94 struct omap_sr_data *sr_data; 96 struct omap_sr_data *sr_data = NULL;
95 struct platform_device *pdev;
96 struct omap_volt_data *volt_data; 97 struct omap_volt_data *volt_data;
97 struct omap_smartreflex_dev_attr *sr_dev_attr; 98 struct omap_smartreflex_dev_attr *sr_dev_attr;
98 char *name = "smartreflex";
99 static int i; 99 static int i;
100 100
101 sr_data = kzalloc(sizeof(*sr_data), GFP_KERNEL); 101 if (!strncmp(oh->name, "smartreflex_mpu_iva", 20) ||
102 if (!sr_data) 102 !strncmp(oh->name, "smartreflex_mpu", 16))
103 return -ENOMEM; 103 sr_data = &omap_sr_pdata[OMAP_SR_MPU];
104 else if (!strncmp(oh->name, "smartreflex_core", 17))
105 sr_data = &omap_sr_pdata[OMAP_SR_CORE];
106 else if (!strncmp(oh->name, "smartreflex_iva", 16))
107 sr_data = &omap_sr_pdata[OMAP_SR_IVA];
108
109 if (!sr_data) {
110 pr_err("%s: Unknown instance %s\n", __func__, oh->name);
111 return -EINVAL;
112 }
104 113
105 sr_dev_attr = (struct omap_smartreflex_dev_attr *)oh->dev_attr; 114 sr_dev_attr = (struct omap_smartreflex_dev_attr *)oh->dev_attr;
106 if (!sr_dev_attr || !sr_dev_attr->sensor_voltdm_name) { 115 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)
145 154
146 sr_data->enable_on_init = sr_enable_on_init; 155 sr_data->enable_on_init = sr_enable_on_init;
147 156
148 pdev = omap_device_build(name, i, oh, sr_data, sizeof(*sr_data));
149 if (IS_ERR(pdev))
150 pr_warn("%s: Could not build omap_device for %s: %s\n",
151 __func__, name, oh->name);
152exit: 157exit:
153 i++; 158 i++;
154 kfree(sr_data); 159
155 return 0; 160 return 0;
156} 161}
157 162
diff --git a/drivers/bus/ti-sysc.c b/drivers/bus/ti-sysc.c
index cdaeeea7999c..7cd2fd04b212 100644
--- a/drivers/bus/ti-sysc.c
+++ b/drivers/bus/ti-sysc.c
@@ -13,22 +13,20 @@
13 13
14#include <linux/io.h> 14#include <linux/io.h>
15#include <linux/clk.h> 15#include <linux/clk.h>
16#include <linux/clkdev.h>
17#include <linux/delay.h>
16#include <linux/module.h> 18#include <linux/module.h>
17#include <linux/platform_device.h> 19#include <linux/platform_device.h>
20#include <linux/pm_domain.h>
18#include <linux/pm_runtime.h> 21#include <linux/pm_runtime.h>
19#include <linux/of_address.h> 22#include <linux/of_address.h>
20#include <linux/of_platform.h> 23#include <linux/of_platform.h>
24#include <linux/slab.h>
25
21#include <linux/platform_data/ti-sysc.h> 26#include <linux/platform_data/ti-sysc.h>
22 27
23#include <dt-bindings/bus/ti-sysc.h> 28#include <dt-bindings/bus/ti-sysc.h>
24 29
25enum sysc_registers {
26 SYSC_REVISION,
27 SYSC_SYSCONFIG,
28 SYSC_SYSSTATUS,
29 SYSC_MAX_REGS,
30};
31
32static const char * const reg_names[] = { "rev", "sysc", "syss", }; 30static const char * const reg_names[] = { "rev", "sysc", "syss", };
33 31
34enum sysc_clocks { 32enum sysc_clocks {
@@ -55,6 +53,7 @@ static const char * const clock_names[] = { "fck", "ick", };
55 * @cfg: interconnect target module configuration 53 * @cfg: interconnect target module configuration
56 * @name: name if available 54 * @name: name if available
57 * @revision: interconnect target module revision 55 * @revision: interconnect target module revision
56 * @needs_resume: runtime resume needed on resume from suspend
58 */ 57 */
59struct sysc { 58struct sysc {
60 struct device *dev; 59 struct device *dev;
@@ -66,8 +65,13 @@ struct sysc {
66 const char *legacy_mode; 65 const char *legacy_mode;
67 const struct sysc_capabilities *cap; 66 const struct sysc_capabilities *cap;
68 struct sysc_config cfg; 67 struct sysc_config cfg;
68 struct ti_sysc_cookie cookie;
69 const char *name; 69 const char *name;
70 u32 revision; 70 u32 revision;
71 bool enabled;
72 bool needs_resume;
73 bool child_needs_resume;
74 struct delayed_work idle_work;
71}; 75};
72 76
73static u32 sysc_read(struct sysc *ddata, int offset) 77static u32 sysc_read(struct sysc *ddata, int offset)
@@ -136,9 +140,6 @@ static int sysc_get_clocks(struct sysc *ddata)
136{ 140{
137 int i, error; 141 int i, error;
138 142
139 if (ddata->legacy_mode)
140 return 0;
141
142 for (i = 0; i < SYSC_MAX_CLOCKS; i++) { 143 for (i = 0; i < SYSC_MAX_CLOCKS; i++) {
143 error = sysc_get_one_clock(ddata, i); 144 error = sysc_get_one_clock(ddata, i);
144 if (error && error != -ENOENT) 145 if (error && error != -ENOENT)
@@ -197,12 +198,53 @@ static int sysc_parse_and_check_child_range(struct sysc *ddata)
197 ddata->module_pa = of_translate_address(np, ranges++); 198 ddata->module_pa = of_translate_address(np, ranges++);
198 ddata->module_size = be32_to_cpup(ranges); 199 ddata->module_size = be32_to_cpup(ranges);
199 200
200 dev_dbg(ddata->dev, "interconnect target 0x%llx size 0x%x for %pOF\n",
201 ddata->module_pa, ddata->module_size, np);
202
203 return 0; 201 return 0;
204} 202}
205 203
204static struct device_node *stdout_path;
205
206static void sysc_init_stdout_path(struct sysc *ddata)
207{
208 struct device_node *np = NULL;
209 const char *uart;
210
211 if (IS_ERR(stdout_path))
212 return;
213
214 if (stdout_path)
215 return;
216
217 np = of_find_node_by_path("/chosen");
218 if (!np)
219 goto err;
220
221 uart = of_get_property(np, "stdout-path", NULL);
222 if (!uart)
223 goto err;
224
225 np = of_find_node_by_path(uart);
226 if (!np)
227 goto err;
228
229 stdout_path = np;
230
231 return;
232
233err:
234 stdout_path = ERR_PTR(-ENODEV);
235}
236
237static void sysc_check_quirk_stdout(struct sysc *ddata,
238 struct device_node *np)
239{
240 sysc_init_stdout_path(ddata);
241 if (np != stdout_path)
242 return;
243
244 ddata->cfg.quirks |= SYSC_QUIRK_NO_IDLE_ON_INIT |
245 SYSC_QUIRK_NO_RESET_ON_INIT;
246}
247
206/** 248/**
207 * sysc_check_one_child - check child configuration 249 * sysc_check_one_child - check child configuration
208 * @ddata: device driver data 250 * @ddata: device driver data
@@ -221,6 +263,8 @@ static int sysc_check_one_child(struct sysc *ddata,
221 if (name) 263 if (name)
222 dev_warn(ddata->dev, "really a child ti,hwmods property?"); 264 dev_warn(ddata->dev, "really a child ti,hwmods property?");
223 265
266 sysc_check_quirk_stdout(ddata, np);
267
224 return 0; 268 return 0;
225} 269}
226 270
@@ -246,11 +290,8 @@ static int sysc_check_children(struct sysc *ddata)
246 */ 290 */
247static void sysc_check_quirk_16bit(struct sysc *ddata, struct resource *res) 291static void sysc_check_quirk_16bit(struct sysc *ddata, struct resource *res)
248{ 292{
249 if (resource_size(res) == 8) { 293 if (resource_size(res) == 8)
250 dev_dbg(ddata->dev,
251 "enabling 16-bit and clockactivity quirks\n");
252 ddata->cfg.quirks |= SYSC_QUIRK_16BIT | SYSC_QUIRK_USE_CLOCKACT; 294 ddata->cfg.quirks |= SYSC_QUIRK_16BIT | SYSC_QUIRK_USE_CLOCKACT;
253 }
254} 295}
255 296
256/** 297/**
@@ -276,7 +317,6 @@ static int sysc_parse_one(struct sysc *ddata, enum sysc_registers reg)
276 res = platform_get_resource_byname(to_platform_device(ddata->dev), 317 res = platform_get_resource_byname(to_platform_device(ddata->dev),
277 IORESOURCE_MEM, name); 318 IORESOURCE_MEM, name);
278 if (!res) { 319 if (!res) {
279 dev_dbg(ddata->dev, "has no %s register\n", name);
280 ddata->offsets[reg] = -ENODEV; 320 ddata->offsets[reg] = -ENODEV;
281 321
282 return 0; 322 return 0;
@@ -437,6 +477,14 @@ static int sysc_show_reg(struct sysc *ddata,
437 return sprintf(bufp, ":%x", ddata->offsets[reg]); 477 return sprintf(bufp, ":%x", ddata->offsets[reg]);
438} 478}
439 479
480static int sysc_show_name(char *bufp, struct sysc *ddata)
481{
482 if (!ddata->name)
483 return 0;
484
485 return sprintf(bufp, ":%s", ddata->name);
486}
487
440/** 488/**
441 * sysc_show_registers - show information about interconnect target module 489 * sysc_show_registers - show information about interconnect target module
442 * @ddata: device driver data 490 * @ddata: device driver data
@@ -451,6 +499,7 @@ static void sysc_show_registers(struct sysc *ddata)
451 bufp += sysc_show_reg(ddata, bufp, i); 499 bufp += sysc_show_reg(ddata, bufp, i);
452 500
453 bufp += sysc_show_rev(bufp, ddata); 501 bufp += sysc_show_rev(bufp, ddata);
502 bufp += sysc_show_name(bufp, ddata);
454 503
455 dev_dbg(ddata->dev, "%llx:%x%s\n", 504 dev_dbg(ddata->dev, "%llx:%x%s\n",
456 ddata->module_pa, ddata->module_size, 505 ddata->module_pa, ddata->module_size,
@@ -459,33 +508,70 @@ static void sysc_show_registers(struct sysc *ddata)
459 508
460static int __maybe_unused sysc_runtime_suspend(struct device *dev) 509static int __maybe_unused sysc_runtime_suspend(struct device *dev)
461{ 510{
511 struct ti_sysc_platform_data *pdata;
462 struct sysc *ddata; 512 struct sysc *ddata;
463 int i; 513 int error = 0, i;
464 514
465 ddata = dev_get_drvdata(dev); 515 ddata = dev_get_drvdata(dev);
466 516
467 if (ddata->legacy_mode) 517 if (!ddata->enabled)
468 return 0; 518 return 0;
469 519
520 if (ddata->legacy_mode) {
521 pdata = dev_get_platdata(ddata->dev);
522 if (!pdata)
523 return 0;
524
525 if (!pdata->idle_module)
526 return -ENODEV;
527
528 error = pdata->idle_module(dev, &ddata->cookie);
529 if (error)
530 dev_err(dev, "%s: could not idle: %i\n",
531 __func__, error);
532
533 goto idled;
534 }
535
470 for (i = 0; i < SYSC_MAX_CLOCKS; i++) { 536 for (i = 0; i < SYSC_MAX_CLOCKS; i++) {
471 if (IS_ERR_OR_NULL(ddata->clocks[i])) 537 if (IS_ERR_OR_NULL(ddata->clocks[i]))
472 continue; 538 continue;
473 clk_disable(ddata->clocks[i]); 539 clk_disable(ddata->clocks[i]);
474 } 540 }
475 541
476 return 0; 542idled:
543 ddata->enabled = false;
544
545 return error;
477} 546}
478 547
479static int __maybe_unused sysc_runtime_resume(struct device *dev) 548static int __maybe_unused sysc_runtime_resume(struct device *dev)
480{ 549{
550 struct ti_sysc_platform_data *pdata;
481 struct sysc *ddata; 551 struct sysc *ddata;
482 int i, error; 552 int error = 0, i;
483 553
484 ddata = dev_get_drvdata(dev); 554 ddata = dev_get_drvdata(dev);
485 555
486 if (ddata->legacy_mode) 556 if (ddata->enabled)
487 return 0; 557 return 0;
488 558
559 if (ddata->legacy_mode) {
560 pdata = dev_get_platdata(ddata->dev);
561 if (!pdata)
562 return 0;
563
564 if (!pdata->enable_module)
565 return -ENODEV;
566
567 error = pdata->enable_module(dev, &ddata->cookie);
568 if (error)
569 dev_err(dev, "%s: could not enable: %i\n",
570 __func__, error);
571
572 goto awake;
573 }
574
489 for (i = 0; i < SYSC_MAX_CLOCKS; i++) { 575 for (i = 0; i < SYSC_MAX_CLOCKS; i++) {
490 if (IS_ERR_OR_NULL(ddata->clocks[i])) 576 if (IS_ERR_OR_NULL(ddata->clocks[i]))
491 continue; 577 continue;
@@ -494,20 +580,136 @@ static int __maybe_unused sysc_runtime_resume(struct device *dev)
494 return error; 580 return error;
495 } 581 }
496 582
583awake:
584 ddata->enabled = true;
585
586 return error;
587}
588
589#ifdef CONFIG_PM_SLEEP
590static int sysc_suspend(struct device *dev)
591{
592 struct sysc *ddata;
593
594 ddata = dev_get_drvdata(dev);
595
596 if (!ddata->enabled)
597 return 0;
598
599 ddata->needs_resume = true;
600
601 return sysc_runtime_suspend(dev);
602}
603
604static int sysc_resume(struct device *dev)
605{
606 struct sysc *ddata;
607
608 ddata = dev_get_drvdata(dev);
609 if (ddata->needs_resume) {
610 ddata->needs_resume = false;
611
612 return sysc_runtime_resume(dev);
613 }
614
497 return 0; 615 return 0;
498} 616}
617#endif
499 618
500static const struct dev_pm_ops sysc_pm_ops = { 619static const struct dev_pm_ops sysc_pm_ops = {
620 SET_SYSTEM_SLEEP_PM_OPS(sysc_suspend, sysc_resume)
501 SET_RUNTIME_PM_OPS(sysc_runtime_suspend, 621 SET_RUNTIME_PM_OPS(sysc_runtime_suspend,
502 sysc_runtime_resume, 622 sysc_runtime_resume,
503 NULL) 623 NULL)
504}; 624};
505 625
626/* Module revision register based quirks */
627struct sysc_revision_quirk {
628 const char *name;
629 u32 base;
630 int rev_offset;
631 int sysc_offset;
632 int syss_offset;
633 u32 revision;
634 u32 revision_mask;
635 u32 quirks;
636};
637
638#define SYSC_QUIRK(optname, optbase, optrev, optsysc, optsyss, \
639 optrev_val, optrevmask, optquirkmask) \
640 { \
641 .name = (optname), \
642 .base = (optbase), \
643 .rev_offset = (optrev), \
644 .sysc_offset = (optsysc), \
645 .syss_offset = (optsyss), \
646 .revision = (optrev_val), \
647 .revision_mask = (optrevmask), \
648 .quirks = (optquirkmask), \
649 }
650
651static const struct sysc_revision_quirk sysc_revision_quirks[] = {
652 /* These drivers need to be fixed to not use pm_runtime_irq_safe() */
653 SYSC_QUIRK("gpio", 0, 0, 0x10, 0x114, 0x50600801, 0xffffffff,
654 SYSC_QUIRK_LEGACY_IDLE),
655 SYSC_QUIRK("mmu", 0, 0, 0x10, 0x14, 0x00000020, 0xffffffff,
656 SYSC_QUIRK_LEGACY_IDLE),
657 SYSC_QUIRK("mmu", 0, 0, 0x10, 0x14, 0x00000030, 0xffffffff,
658 SYSC_QUIRK_LEGACY_IDLE),
659 SYSC_QUIRK("sham", 0, 0x100, 0x110, 0x114, 0x40000c03, 0xffffffff,
660 SYSC_QUIRK_LEGACY_IDLE),
661 SYSC_QUIRK("smartreflex", 0, -1, 0x24, -1, 0x00000000, 0xffffffff,
662 SYSC_QUIRK_LEGACY_IDLE),
663 SYSC_QUIRK("smartreflex", 0, -1, 0x38, -1, 0x00000000, 0xffffffff,
664 SYSC_QUIRK_LEGACY_IDLE),
665 SYSC_QUIRK("timer", 0, 0, 0x10, 0x14, 0x00000015, 0xffffffff,
666 SYSC_QUIRK_LEGACY_IDLE),
667 SYSC_QUIRK("uart", 0, 0x50, 0x54, 0x58, 0x00000052, 0xffffffff,
668 SYSC_QUIRK_LEGACY_IDLE),
669};
670
671static void sysc_init_revision_quirks(struct sysc *ddata)
672{
673 const struct sysc_revision_quirk *q;
674 int i;
675
676 for (i = 0; i < ARRAY_SIZE(sysc_revision_quirks); i++) {
677 q = &sysc_revision_quirks[i];
678
679 if (q->base && q->base != ddata->module_pa)
680 continue;
681
682 if (q->rev_offset >= 0 &&
683 q->rev_offset != ddata->offsets[SYSC_REVISION])
684 continue;
685
686 if (q->sysc_offset >= 0 &&
687 q->sysc_offset != ddata->offsets[SYSC_SYSCONFIG])
688 continue;
689
690 if (q->syss_offset >= 0 &&
691 q->syss_offset != ddata->offsets[SYSC_SYSSTATUS])
692 continue;
693
694 if (q->revision == ddata->revision ||
695 (q->revision & q->revision_mask) ==
696 (ddata->revision & q->revision_mask)) {
697 ddata->name = q->name;
698 ddata->cfg.quirks |= q->quirks;
699 }
700 }
701}
702
506/* At this point the module is configured enough to read the revision */ 703/* At this point the module is configured enough to read the revision */
507static int sysc_init_module(struct sysc *ddata) 704static int sysc_init_module(struct sysc *ddata)
508{ 705{
509 int error; 706 int error;
510 707
708 if (ddata->cfg.quirks & SYSC_QUIRK_NO_IDLE_ON_INIT) {
709 ddata->revision = sysc_read_revision(ddata);
710 goto rev_quirks;
711 }
712
511 error = pm_runtime_get_sync(ddata->dev); 713 error = pm_runtime_get_sync(ddata->dev);
512 if (error < 0) { 714 if (error < 0) {
513 pm_runtime_put_noidle(ddata->dev); 715 pm_runtime_put_noidle(ddata->dev);
@@ -517,6 +719,9 @@ static int sysc_init_module(struct sysc *ddata)
517 ddata->revision = sysc_read_revision(ddata); 719 ddata->revision = sysc_read_revision(ddata);
518 pm_runtime_put_sync(ddata->dev); 720 pm_runtime_put_sync(ddata->dev);
519 721
722rev_quirks:
723 sysc_init_revision_quirks(ddata);
724
520 return 0; 725 return 0;
521} 726}
522 727
@@ -605,6 +810,196 @@ static int sysc_init_syss_mask(struct sysc *ddata)
605 return 0; 810 return 0;
606} 811}
607 812
813/*
814 * Many child device drivers need to have fck available to get the clock
815 * rate for device internal configuration.
816 */
817static int sysc_child_add_fck(struct sysc *ddata,
818 struct device *child)
819{
820 struct clk *fck;
821 struct clk_lookup *l;
822 const char *name = clock_names[SYSC_FCK];
823
824 if (IS_ERR_OR_NULL(ddata->clocks[SYSC_FCK]))
825 return 0;
826
827 fck = clk_get(child, name);
828 if (!IS_ERR(fck)) {
829 clk_put(fck);
830
831 return -EEXIST;
832 }
833
834 l = clkdev_create(ddata->clocks[SYSC_FCK], name, dev_name(child));
835
836 return l ? 0 : -ENODEV;
837}
838
839static struct device_type sysc_device_type = {
840};
841
842static struct sysc *sysc_child_to_parent(struct device *dev)
843{
844 struct device *parent = dev->parent;
845
846 if (!parent || parent->type != &sysc_device_type)
847 return NULL;
848
849 return dev_get_drvdata(parent);
850}
851
852static int __maybe_unused sysc_child_runtime_suspend(struct device *dev)
853{
854 struct sysc *ddata;
855 int error;
856
857 ddata = sysc_child_to_parent(dev);
858
859 error = pm_generic_runtime_suspend(dev);
860 if (error)
861 return error;
862
863 if (!ddata->enabled)
864 return 0;
865
866 return sysc_runtime_suspend(ddata->dev);
867}
868
869static int __maybe_unused sysc_child_runtime_resume(struct device *dev)
870{
871 struct sysc *ddata;
872 int error;
873
874 ddata = sysc_child_to_parent(dev);
875
876 if (!ddata->enabled) {
877 error = sysc_runtime_resume(ddata->dev);
878 if (error < 0)
879 dev_err(ddata->dev,
880 "%s error: %i\n", __func__, error);
881 }
882
883 return pm_generic_runtime_resume(dev);
884}
885
886#ifdef CONFIG_PM_SLEEP
887static int sysc_child_suspend_noirq(struct device *dev)
888{
889 struct sysc *ddata;
890 int error;
891
892 ddata = sysc_child_to_parent(dev);
893
894 error = pm_generic_suspend_noirq(dev);
895 if (error)
896 return error;
897
898 if (!pm_runtime_status_suspended(dev)) {
899 error = pm_generic_runtime_suspend(dev);
900 if (error)
901 return error;
902
903 error = sysc_runtime_suspend(ddata->dev);
904 if (error)
905 return error;
906
907 ddata->child_needs_resume = true;
908 }
909
910 return 0;
911}
912
913static int sysc_child_resume_noirq(struct device *dev)
914{
915 struct sysc *ddata;
916 int error;
917
918 ddata = sysc_child_to_parent(dev);
919
920 if (ddata->child_needs_resume) {
921 ddata->child_needs_resume = false;
922
923 error = sysc_runtime_resume(ddata->dev);
924 if (error)
925 dev_err(ddata->dev,
926 "%s runtime resume error: %i\n",
927 __func__, error);
928
929 error = pm_generic_runtime_resume(dev);
930 if (error)
931 dev_err(ddata->dev,
932 "%s generic runtime resume: %i\n",
933 __func__, error);
934 }
935
936 return pm_generic_resume_noirq(dev);
937}
938#endif
939
940struct dev_pm_domain sysc_child_pm_domain = {
941 .ops = {
942 SET_RUNTIME_PM_OPS(sysc_child_runtime_suspend,
943 sysc_child_runtime_resume,
944 NULL)
945 USE_PLATFORM_PM_SLEEP_OPS
946 SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(sysc_child_suspend_noirq,
947 sysc_child_resume_noirq)
948 }
949};
950
951/**
952 * sysc_legacy_idle_quirk - handle children in omap_device compatible way
953 * @ddata: device driver data
954 * @child: child device driver
955 *
956 * Allow idle for child devices as done with _od_runtime_suspend().
957 * Otherwise many child devices will not idle because of the permanent
958 * parent usecount set in pm_runtime_irq_safe().
959 *
960 * Note that the long term solution is to just modify the child device
961 * drivers to not set pm_runtime_irq_safe() and then this can be just
962 * dropped.
963 */
964static void sysc_legacy_idle_quirk(struct sysc *ddata, struct device *child)
965{
966 if (!ddata->legacy_mode)
967 return;
968
969 if (ddata->cfg.quirks & SYSC_QUIRK_LEGACY_IDLE)
970 dev_pm_domain_set(child, &sysc_child_pm_domain);
971}
972
973static int sysc_notifier_call(struct notifier_block *nb,
974 unsigned long event, void *device)
975{
976 struct device *dev = device;
977 struct sysc *ddata;
978 int error;
979
980 ddata = sysc_child_to_parent(dev);
981 if (!ddata)
982 return NOTIFY_DONE;
983
984 switch (event) {
985 case BUS_NOTIFY_ADD_DEVICE:
986 error = sysc_child_add_fck(ddata, dev);
987 if (error && error != -EEXIST)
988 dev_warn(ddata->dev, "could not add %s fck: %i\n",
989 dev_name(dev), error);
990 sysc_legacy_idle_quirk(ddata, dev);
991 break;
992 default:
993 break;
994 }
995
996 return NOTIFY_DONE;
997}
998
999static struct notifier_block sysc_nb = {
1000 .notifier_call = sysc_notifier_call,
1001};
1002
608/* Device tree configured quirks */ 1003/* Device tree configured quirks */
609struct sysc_dts_quirk { 1004struct sysc_dts_quirk {
610 const char *name; 1005 const char *name;
@@ -797,7 +1192,8 @@ static const struct sysc_capabilities sysc_34xx_sr = {
797 .type = TI_SYSC_OMAP34XX_SR, 1192 .type = TI_SYSC_OMAP34XX_SR,
798 .sysc_mask = SYSC_OMAP2_CLOCKACTIVITY, 1193 .sysc_mask = SYSC_OMAP2_CLOCKACTIVITY,
799 .regbits = &sysc_regbits_omap34xx_sr, 1194 .regbits = &sysc_regbits_omap34xx_sr,
800 .mod_quirks = SYSC_QUIRK_USE_CLOCKACT | SYSC_QUIRK_UNCACHED, 1195 .mod_quirks = SYSC_QUIRK_USE_CLOCKACT | SYSC_QUIRK_UNCACHED |
1196 SYSC_QUIRK_LEGACY_IDLE,
801}; 1197};
802 1198
803/* 1199/*
@@ -818,12 +1214,13 @@ static const struct sysc_capabilities sysc_36xx_sr = {
818 .type = TI_SYSC_OMAP36XX_SR, 1214 .type = TI_SYSC_OMAP36XX_SR,
819 .sysc_mask = SYSC_OMAP3_SR_ENAWAKEUP, 1215 .sysc_mask = SYSC_OMAP3_SR_ENAWAKEUP,
820 .regbits = &sysc_regbits_omap36xx_sr, 1216 .regbits = &sysc_regbits_omap36xx_sr,
821 .mod_quirks = SYSC_QUIRK_UNCACHED, 1217 .mod_quirks = SYSC_QUIRK_UNCACHED | SYSC_QUIRK_LEGACY_IDLE,
822}; 1218};
823 1219
824static const struct sysc_capabilities sysc_omap4_sr = { 1220static const struct sysc_capabilities sysc_omap4_sr = {
825 .type = TI_SYSC_OMAP4_SR, 1221 .type = TI_SYSC_OMAP4_SR,
826 .regbits = &sysc_regbits_omap36xx_sr, 1222 .regbits = &sysc_regbits_omap36xx_sr,
1223 .mod_quirks = SYSC_QUIRK_LEGACY_IDLE,
827}; 1224};
828 1225
829/* 1226/*
@@ -865,6 +1262,33 @@ static const struct sysc_capabilities sysc_omap4_usb_host_fs = {
865 .regbits = &sysc_regbits_omap4_usb_host_fs, 1262 .regbits = &sysc_regbits_omap4_usb_host_fs,
866}; 1263};
867 1264
1265static int sysc_init_pdata(struct sysc *ddata)
1266{
1267 struct ti_sysc_platform_data *pdata = dev_get_platdata(ddata->dev);
1268 struct ti_sysc_module_data mdata;
1269 int error = 0;
1270
1271 if (!pdata || !ddata->legacy_mode)
1272 return 0;
1273
1274 mdata.name = ddata->legacy_mode;
1275 mdata.module_pa = ddata->module_pa;
1276 mdata.module_size = ddata->module_size;
1277 mdata.offsets = ddata->offsets;
1278 mdata.nr_offsets = SYSC_MAX_REGS;
1279 mdata.cap = ddata->cap;
1280 mdata.cfg = &ddata->cfg;
1281
1282 if (!pdata->init_module)
1283 return -ENODEV;
1284
1285 error = pdata->init_module(ddata->dev, &mdata, &ddata->cookie);
1286 if (error == -EEXIST)
1287 error = 0;
1288
1289 return error;
1290}
1291
868static int sysc_init_match(struct sysc *ddata) 1292static int sysc_init_match(struct sysc *ddata)
869{ 1293{
870 const struct sysc_capabilities *cap; 1294 const struct sysc_capabilities *cap;
@@ -880,8 +1304,19 @@ static int sysc_init_match(struct sysc *ddata)
880 return 0; 1304 return 0;
881} 1305}
882 1306
1307static void ti_sysc_idle(struct work_struct *work)
1308{
1309 struct sysc *ddata;
1310
1311 ddata = container_of(work, struct sysc, idle_work.work);
1312
1313 if (pm_runtime_active(ddata->dev))
1314 pm_runtime_put_sync(ddata->dev);
1315}
1316
883static int sysc_probe(struct platform_device *pdev) 1317static int sysc_probe(struct platform_device *pdev)
884{ 1318{
1319 struct ti_sysc_platform_data *pdata = dev_get_platdata(&pdev->dev);
885 struct sysc *ddata; 1320 struct sysc *ddata;
886 int error; 1321 int error;
887 1322
@@ -920,6 +1355,10 @@ static int sysc_probe(struct platform_device *pdev)
920 if (error) 1355 if (error)
921 goto unprepare; 1356 goto unprepare;
922 1357
1358 error = sysc_init_pdata(ddata);
1359 if (error)
1360 goto unprepare;
1361
923 pm_runtime_enable(ddata->dev); 1362 pm_runtime_enable(ddata->dev);
924 1363
925 error = sysc_init_module(ddata); 1364 error = sysc_init_module(ddata);
@@ -933,22 +1372,28 @@ static int sysc_probe(struct platform_device *pdev)
933 goto unprepare; 1372 goto unprepare;
934 } 1373 }
935 1374
936 pm_runtime_use_autosuspend(ddata->dev);
937
938 sysc_show_registers(ddata); 1375 sysc_show_registers(ddata);
939 1376
1377 ddata->dev->type = &sysc_device_type;
940 error = of_platform_populate(ddata->dev->of_node, 1378 error = of_platform_populate(ddata->dev->of_node,
941 NULL, NULL, ddata->dev); 1379 NULL, pdata ? pdata->auxdata : NULL,
1380 ddata->dev);
942 if (error) 1381 if (error)
943 goto err; 1382 goto err;
944 1383
945 pm_runtime_mark_last_busy(ddata->dev); 1384 INIT_DELAYED_WORK(&ddata->idle_work, ti_sysc_idle);
946 pm_runtime_put_autosuspend(ddata->dev); 1385
1386 /* At least earlycon won't survive without deferred idle */
1387 if (ddata->cfg.quirks & (SYSC_QUIRK_NO_IDLE_ON_INIT |
1388 SYSC_QUIRK_NO_RESET_ON_INIT)) {
1389 schedule_delayed_work(&ddata->idle_work, 3000);
1390 } else {
1391 pm_runtime_put(&pdev->dev);
1392 }
947 1393
948 return 0; 1394 return 0;
949 1395
950err: 1396err:
951 pm_runtime_dont_use_autosuspend(&pdev->dev);
952 pm_runtime_put_sync(&pdev->dev); 1397 pm_runtime_put_sync(&pdev->dev);
953 pm_runtime_disable(&pdev->dev); 1398 pm_runtime_disable(&pdev->dev);
954unprepare: 1399unprepare:
@@ -962,6 +1407,8 @@ static int sysc_remove(struct platform_device *pdev)
962 struct sysc *ddata = platform_get_drvdata(pdev); 1407 struct sysc *ddata = platform_get_drvdata(pdev);
963 int error; 1408 int error;
964 1409
1410 cancel_delayed_work_sync(&ddata->idle_work);
1411
965 error = pm_runtime_get_sync(ddata->dev); 1412 error = pm_runtime_get_sync(ddata->dev);
966 if (error < 0) { 1413 if (error < 0) {
967 pm_runtime_put_noidle(ddata->dev); 1414 pm_runtime_put_noidle(ddata->dev);
@@ -971,7 +1418,6 @@ static int sysc_remove(struct platform_device *pdev)
971 1418
972 of_platform_depopulate(&pdev->dev); 1419 of_platform_depopulate(&pdev->dev);
973 1420
974 pm_runtime_dont_use_autosuspend(&pdev->dev);
975 pm_runtime_put_sync(&pdev->dev); 1421 pm_runtime_put_sync(&pdev->dev);
976 pm_runtime_disable(&pdev->dev); 1422 pm_runtime_disable(&pdev->dev);
977 1423
@@ -1008,7 +1454,21 @@ static struct platform_driver sysc_driver = {
1008 .pm = &sysc_pm_ops, 1454 .pm = &sysc_pm_ops,
1009 }, 1455 },
1010}; 1456};
1011module_platform_driver(sysc_driver); 1457
1458static int __init sysc_init(void)
1459{
1460 bus_register_notifier(&platform_bus_type, &sysc_nb);
1461
1462 return platform_driver_register(&sysc_driver);
1463}
1464module_init(sysc_init);
1465
1466static void __exit sysc_exit(void)
1467{
1468 bus_unregister_notifier(&platform_bus_type, &sysc_nb);
1469 platform_driver_unregister(&sysc_driver);
1470}
1471module_exit(sysc_exit);
1012 1472
1013MODULE_DESCRIPTION("TI sysc interconnect target driver"); 1473MODULE_DESCRIPTION("TI sysc interconnect target driver");
1014MODULE_LICENSE("GPL v2"); 1474MODULE_LICENSE("GPL v2");
diff --git a/drivers/power/avs/smartreflex.c b/drivers/power/avs/smartreflex.c
index 89bf4d6cb486..cb0237143dbe 100644
--- a/drivers/power/avs/smartreflex.c
+++ b/drivers/power/avs/smartreflex.c
@@ -132,12 +132,16 @@ static void sr_set_clk_length(struct omap_sr *sr)
132 struct clk *fck; 132 struct clk *fck;
133 u32 fclk_speed; 133 u32 fclk_speed;
134 134
135 fck = clk_get(&sr->pdev->dev, "fck"); 135 /* Try interconnect target module fck first if it already exists */
136 136 fck = clk_get(sr->pdev->dev.parent, "fck");
137 if (IS_ERR(fck)) { 137 if (IS_ERR(fck)) {
138 dev_err(&sr->pdev->dev, "%s: unable to get fck for device %s\n", 138 fck = clk_get(&sr->pdev->dev, "fck");
139 __func__, dev_name(&sr->pdev->dev)); 139 if (IS_ERR(fck)) {
140 return; 140 dev_err(&sr->pdev->dev,
141 "%s: unable to get fck for device %s\n",
142 __func__, dev_name(&sr->pdev->dev));
143 return;
144 }
141 } 145 }
142 146
143 fclk_speed = clk_get_rate(fck); 147 fclk_speed = clk_get_rate(fck);
@@ -838,7 +842,7 @@ static int omap_sr_autocomp_store(void *data, u64 val)
838DEFINE_SIMPLE_ATTRIBUTE(pm_sr_fops, omap_sr_autocomp_show, 842DEFINE_SIMPLE_ATTRIBUTE(pm_sr_fops, omap_sr_autocomp_show,
839 omap_sr_autocomp_store, "%llu\n"); 843 omap_sr_autocomp_store, "%llu\n");
840 844
841static int __init omap_sr_probe(struct platform_device *pdev) 845static int omap_sr_probe(struct platform_device *pdev)
842{ 846{
843 struct omap_sr *sr_info; 847 struct omap_sr *sr_info;
844 struct omap_sr_data *pdata = pdev->dev.platform_data; 848 struct omap_sr_data *pdata = pdev->dev.platform_data;
@@ -898,6 +902,12 @@ static int __init omap_sr_probe(struct platform_device *pdev)
898 902
899 list_add(&sr_info->node, &sr_list); 903 list_add(&sr_info->node, &sr_list);
900 904
905 ret = pm_runtime_get_sync(&pdev->dev);
906 if (ret < 0) {
907 pm_runtime_put_noidle(&pdev->dev);
908 goto err_list_del;
909 }
910
901 /* 911 /*
902 * Call into late init to do initializations that require 912 * Call into late init to do initializations that require
903 * both sr driver and sr class driver to be initiallized. 913 * both sr driver and sr class driver to be initiallized.
@@ -966,12 +976,17 @@ static int __init omap_sr_probe(struct platform_device *pdev)
966 976
967 } 977 }
968 978
979 pm_runtime_put_sync(&pdev->dev);
980
969 return ret; 981 return ret;
970 982
971err_debugfs: 983err_debugfs:
972 debugfs_remove_recursive(sr_info->dbg_dir); 984 debugfs_remove_recursive(sr_info->dbg_dir);
973err_list_del: 985err_list_del:
974 list_del(&sr_info->node); 986 list_del(&sr_info->node);
987
988 pm_runtime_put_sync(&pdev->dev);
989
975 return ret; 990 return ret;
976} 991}
977 992
@@ -1025,11 +1040,23 @@ static void omap_sr_shutdown(struct platform_device *pdev)
1025 return; 1040 return;
1026} 1041}
1027 1042
1043static const struct of_device_id omap_sr_match[] = {
1044 { .compatible = "ti,omap3-smartreflex-core", },
1045 { .compatible = "ti,omap3-smartreflex-mpu-iva", },
1046 { .compatible = "ti,omap4-smartreflex-core", },
1047 { .compatible = "ti,omap4-smartreflex-mpu", },
1048 { .compatible = "ti,omap4-smartreflex-iva", },
1049 { },
1050};
1051MODULE_DEVICE_TABLE(of, omap_sr_match);
1052
1028static struct platform_driver smartreflex_driver = { 1053static struct platform_driver smartreflex_driver = {
1054 .probe = omap_sr_probe,
1029 .remove = omap_sr_remove, 1055 .remove = omap_sr_remove,
1030 .shutdown = omap_sr_shutdown, 1056 .shutdown = omap_sr_shutdown,
1031 .driver = { 1057 .driver = {
1032 .name = DRIVER_NAME, 1058 .name = DRIVER_NAME,
1059 .of_match_table = omap_sr_match,
1033 }, 1060 },
1034}; 1061};
1035 1062
@@ -1048,7 +1075,7 @@ static int __init sr_init(void)
1048 else 1075 else
1049 pr_warn("%s: No PMIC hook to init smartreflex\n", __func__); 1076 pr_warn("%s: No PMIC hook to init smartreflex\n", __func__);
1050 1077
1051 ret = platform_driver_probe(&smartreflex_driver, omap_sr_probe); 1078 ret = platform_driver_register(&smartreflex_driver);
1052 if (ret) { 1079 if (ret) {
1053 pr_err("%s: platform driver register failed for SR\n", 1080 pr_err("%s: platform driver register failed for SR\n",
1054 __func__); 1081 __func__);
diff --git a/include/linux/platform_data/ti-sysc.h b/include/linux/platform_data/ti-sysc.h
index 1be356330b96..80ce28d40832 100644
--- a/include/linux/platform_data/ti-sysc.h
+++ b/include/linux/platform_data/ti-sysc.h
@@ -16,6 +16,10 @@ enum ti_sysc_module_type {
16 TI_SYSC_OMAP4_USB_HOST_FS, 16 TI_SYSC_OMAP4_USB_HOST_FS,
17}; 17};
18 18
19struct ti_sysc_cookie {
20 void *data;
21};
22
19/** 23/**
20 * struct sysc_regbits - TI OCP_SYSCONFIG register field offsets 24 * struct sysc_regbits - TI OCP_SYSCONFIG register field offsets
21 * @midle_shift: Offset of the midle bit 25 * @midle_shift: Offset of the midle bit
@@ -41,6 +45,7 @@ struct sysc_regbits {
41 s8 emufree_shift; 45 s8 emufree_shift;
42}; 46};
43 47
48#define SYSC_QUIRK_LEGACY_IDLE BIT(8)
44#define SYSC_QUIRK_RESET_STATUS BIT(7) 49#define SYSC_QUIRK_RESET_STATUS BIT(7)
45#define SYSC_QUIRK_NO_IDLE_ON_INIT BIT(6) 50#define SYSC_QUIRK_NO_IDLE_ON_INIT BIT(6)
46#define SYSC_QUIRK_NO_RESET_ON_INIT BIT(5) 51#define SYSC_QUIRK_NO_RESET_ON_INIT BIT(5)
@@ -83,4 +88,49 @@ struct sysc_config {
83 u32 quirks; 88 u32 quirks;
84}; 89};
85 90
91enum sysc_registers {
92 SYSC_REVISION,
93 SYSC_SYSCONFIG,
94 SYSC_SYSSTATUS,
95 SYSC_MAX_REGS,
96};
97
98/**
99 * struct ti_sysc_module_data - ti-sysc to hwmod translation data for a module
100 * @name: legacy "ti,hwmods" module name
101 * @module_pa: physical address of the interconnect target module
102 * @module_size: size of the interconnect target module
103 * @offsets: array of register offsets as listed in enum sysc_registers
104 * @nr_offsets: number of registers
105 * @cap: interconnect target module capabilities
106 * @cfg: interconnect target module configuration
107 *
108 * This data is enough to allocate a new struct omap_hwmod_class_sysconfig
109 * based on device tree data parsed by ti-sysc driver.
110 */
111struct ti_sysc_module_data {
112 const char *name;
113 u64 module_pa;
114 u32 module_size;
115 int *offsets;
116 int nr_offsets;
117 const struct sysc_capabilities *cap;
118 struct sysc_config *cfg;
119};
120
121struct device;
122
123struct ti_sysc_platform_data {
124 struct of_dev_auxdata *auxdata;
125 int (*init_module)(struct device *dev,
126 const struct ti_sysc_module_data *data,
127 struct ti_sysc_cookie *cookie);
128 int (*enable_module)(struct device *dev,
129 const struct ti_sysc_cookie *cookie);
130 int (*idle_module)(struct device *dev,
131 const struct ti_sysc_cookie *cookie);
132 int (*shutdown_module)(struct device *dev,
133 const struct ti_sysc_cookie *cookie);
134};
135
86#endif /* __TI_SYSC_DATA_H__ */ 136#endif /* __TI_SYSC_DATA_H__ */
diff --git a/include/linux/power/smartreflex.h b/include/linux/power/smartreflex.h
index d8b187c3925d..7b81dad712de 100644
--- a/include/linux/power/smartreflex.h
+++ b/include/linux/power/smartreflex.h
@@ -143,6 +143,13 @@
143#define OMAP3430_SR_ERRWEIGHT 0x04 143#define OMAP3430_SR_ERRWEIGHT 0x04
144#define OMAP3430_SR_ERRMAXLIMIT 0x02 144#define OMAP3430_SR_ERRMAXLIMIT 0x02
145 145
146enum sr_instance {
147 OMAP_SR_MPU, /* shared with iva on omap3 */
148 OMAP_SR_CORE,
149 OMAP_SR_IVA,
150 OMAP_SR_NR,
151};
152
146struct omap_sr { 153struct omap_sr {
147 char *name; 154 char *name;
148 struct list_head node; 155 struct list_head node;
@@ -207,7 +214,6 @@ struct omap_smartreflex_dev_attr {
207 const char *sensor_voltdm_name; 214 const char *sensor_voltdm_name;
208}; 215};
209 216
210#ifdef CONFIG_POWER_AVS_OMAP
211/* 217/*
212 * The smart reflex driver supports CLASS1 CLASS2 and CLASS3 SR. 218 * The smart reflex driver supports CLASS1 CLASS2 and CLASS3 SR.
213 * The smartreflex class driver should pass the class type. 219 * The smartreflex class driver should pass the class type.
@@ -290,6 +296,8 @@ struct omap_sr_data {
290 struct voltagedomain *voltdm; 296 struct voltagedomain *voltdm;
291}; 297};
292 298
299#ifdef CONFIG_POWER_AVS_OMAP
300
293/* Smartreflex module enable/disable interface */ 301/* Smartreflex module enable/disable interface */
294void omap_sr_enable(struct voltagedomain *voltdm); 302void omap_sr_enable(struct voltagedomain *voltdm);
295void omap_sr_disable(struct voltagedomain *voltdm); 303void omap_sr_disable(struct voltagedomain *voltdm);