Subject: cell: add initial throttling setup to thermal module init. This patch adds a function to cbe_thermal, to initialize the throttling registers with some default temperature values, to protect the cpu in overheating scenarios. This code is likely to change, as soon as dynamic throttling comes into play. Signed-off-by: Christian Krafft Index: linux-2.6/arch/powerpc/platforms/cell/cbe_thermal.c =================================================================== --- linux-2.6.orig/arch/powerpc/platforms/cell/cbe_thermal.c +++ linux-2.6/arch/powerpc/platforms/cell/cbe_thermal.c @@ -133,6 +133,65 @@ static struct sysdev_attribute attr_ppe_ .store = NULL, }; +/* + * initialize throttling with default values + */ +static void __init init_default_values(void) +{ + int cpu; + struct cbe_pmd_regs *pmd_regs; + struct sys_device *sysdev; + union ppe_spe_reg tpr; + union spe_reg str1; + u64 str2; + union spe_reg cr1; + u64 cr2; + + /* TPR defaults */ + /* ppe + * 1F - no full stop + * 08 - dynamic throttling starts if over 80 degrees + * 03 - dynamic throttling ceases if below 70 degrees */ + tpr.ppe = 0x1F0803; + /* spe + * 10 - full stopped when over 96 degrees + * 08 - dynamic throttling starts if over 80 degrees + * 03 - dynamic throttling ceases if below 70 degrees + */ + tpr.spe = 0x100803; + + /* STR defaults */ + /* str1 + * 10 - stop 16 of 32 cycles + */ + str1.val = 0x1010101010101010; + /* str2 + * 10 - stop 16 of 32 cycles + */ + str2 = 0x10; + + /* CR defaults */ + /* cr1 + * 4 - normal operation + */ + cr1.val = 0x0404040404040404; + /* cr2 + * 4 - normal operation + */ + cr2 = 0x04; + + for_each_possible_cpu (cpu) { + pr_debug("processing cpu %d\n", cpu); + sysdev = get_cpu_sysdev(cpu); + pmd_regs = cbe_get_cpu_pmd_regs(sysdev->id); + + out_be64(&pmd_regs->tm_str2, str2); + out_be64(&pmd_regs->tm_str1.val, str1.val); + out_be64(&pmd_regs->tm_tpr.val, tpr.val); + out_be64(&pmd_regs->tm_cr1.val, cr1.val); + out_be64(&pmd_regs->tm_cr2, cr2); + } +} static struct sysdev_attribute attr_ppe_temperature1 = { .attr = {.name = "temperature1", .mode = 0400 }, @@ -145,6 +204,8 @@ static int __init thermal_init(void) spu_add_sysdev_attr(&attr_spu_temperature); cpu_add_sysdev_attr(&attr_ppe_temperature0); cpu_add_sysdev_attr(&attr_ppe_temperature1); + + init_default_values(); return 0; } module_init(thermal_init);