]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - arch/powerpc/kernel/sysfs.c
Merge branch 'linux-2.6'
[linux-2.6-omap-h63xx.git] / arch / powerpc / kernel / sysfs.c
index 400ab2b946e760964bd164f282ec1f270579ac6a..25d9a96484ddeb914ff0d7fe63aa1b0c3baf7e8e 100644 (file)
@@ -66,16 +66,17 @@ static int __init smt_setup(void)
        if (!cpu_has_feature(CPU_FTR_SMT))
                return -ENODEV;
 
-       options = find_path_device("/options");
+       options = of_find_node_by_path("/options");
        if (!options)
                return -ENODEV;
 
-       val = get_property(options, "ibm,smt-snooze-delay", NULL);
+       val = of_get_property(options, "ibm,smt-snooze-delay", NULL);
        if (!smt_snooze_cmdline && val) {
                for_each_possible_cpu(cpu)
                        per_cpu(smt_snooze_delay, cpu) = *val;
        }
 
+       of_node_put(options);
        return 0;
 }
 __initcall(smt_setup);
@@ -169,6 +170,11 @@ static ssize_t __attribute_used__ \
        return count; \
 }
 
+
+/* Let's define all possible registers, we'll only hook up the ones
+ * that are implemented on the current processor
+ */
+
 SYSFS_PMCSETUP(mmcr0, SPRN_MMCR0);
 SYSFS_PMCSETUP(mmcr1, SPRN_MMCR1);
 SYSFS_PMCSETUP(mmcra, SPRN_MMCRA);
@@ -184,55 +190,147 @@ SYSFS_PMCSETUP(purr, SPRN_PURR);
 SYSFS_PMCSETUP(spurr, SPRN_SPURR);
 SYSFS_PMCSETUP(dscr, SPRN_DSCR);
 
-static SYSDEV_ATTR(mmcr0, 0600, show_mmcr0, store_mmcr0);
-static SYSDEV_ATTR(mmcr1, 0600, show_mmcr1, store_mmcr1);
+SYSFS_PMCSETUP(pa6t_pmc0, SPRN_PA6T_PMC0);
+SYSFS_PMCSETUP(pa6t_pmc1, SPRN_PA6T_PMC1);
+SYSFS_PMCSETUP(pa6t_pmc2, SPRN_PA6T_PMC2);
+SYSFS_PMCSETUP(pa6t_pmc3, SPRN_PA6T_PMC3);
+SYSFS_PMCSETUP(pa6t_pmc4, SPRN_PA6T_PMC4);
+SYSFS_PMCSETUP(pa6t_pmc5, SPRN_PA6T_PMC5);
+
+#ifdef CONFIG_DEBUG_KERNEL
+SYSFS_PMCSETUP(hid0, SPRN_HID0);
+SYSFS_PMCSETUP(hid1, SPRN_HID1);
+SYSFS_PMCSETUP(hid4, SPRN_HID4);
+SYSFS_PMCSETUP(hid5, SPRN_HID5);
+SYSFS_PMCSETUP(ima0, SPRN_PA6T_IMA0);
+SYSFS_PMCSETUP(ima1, SPRN_PA6T_IMA1);
+SYSFS_PMCSETUP(ima2, SPRN_PA6T_IMA2);
+SYSFS_PMCSETUP(ima3, SPRN_PA6T_IMA3);
+SYSFS_PMCSETUP(ima4, SPRN_PA6T_IMA4);
+SYSFS_PMCSETUP(ima5, SPRN_PA6T_IMA5);
+SYSFS_PMCSETUP(ima6, SPRN_PA6T_IMA6);
+SYSFS_PMCSETUP(ima7, SPRN_PA6T_IMA7);
+SYSFS_PMCSETUP(ima8, SPRN_PA6T_IMA8);
+SYSFS_PMCSETUP(ima9, SPRN_PA6T_IMA9);
+SYSFS_PMCSETUP(imaat, SPRN_PA6T_IMAAT);
+SYSFS_PMCSETUP(btcr, SPRN_PA6T_BTCR);
+SYSFS_PMCSETUP(pccr, SPRN_PA6T_PCCR);
+SYSFS_PMCSETUP(rpccr, SPRN_PA6T_RPCCR);
+SYSFS_PMCSETUP(der, SPRN_PA6T_DER);
+SYSFS_PMCSETUP(mer, SPRN_PA6T_MER);
+SYSFS_PMCSETUP(ber, SPRN_PA6T_BER);
+SYSFS_PMCSETUP(ier, SPRN_PA6T_IER);
+SYSFS_PMCSETUP(sier, SPRN_PA6T_SIER);
+SYSFS_PMCSETUP(siar, SPRN_PA6T_SIAR);
+SYSFS_PMCSETUP(tsr0, SPRN_PA6T_TSR0);
+SYSFS_PMCSETUP(tsr1, SPRN_PA6T_TSR1);
+SYSFS_PMCSETUP(tsr2, SPRN_PA6T_TSR2);
+SYSFS_PMCSETUP(tsr3, SPRN_PA6T_TSR3);
+#endif /* CONFIG_DEBUG_KERNEL */
+
 static SYSDEV_ATTR(mmcra, 0600, show_mmcra, store_mmcra);
-static SYSDEV_ATTR(pmc1, 0600, show_pmc1, store_pmc1);
-static SYSDEV_ATTR(pmc2, 0600, show_pmc2, store_pmc2);
-static SYSDEV_ATTR(pmc3, 0600, show_pmc3, store_pmc3);
-static SYSDEV_ATTR(pmc4, 0600, show_pmc4, store_pmc4);
-static SYSDEV_ATTR(pmc5, 0600, show_pmc5, store_pmc5);
-static SYSDEV_ATTR(pmc6, 0600, show_pmc6, store_pmc6);
-static SYSDEV_ATTR(pmc7, 0600, show_pmc7, store_pmc7);
-static SYSDEV_ATTR(pmc8, 0600, show_pmc8, store_pmc8);
-static SYSDEV_ATTR(purr, 0600, show_purr, NULL);
 static SYSDEV_ATTR(spurr, 0600, show_spurr, NULL);
 static SYSDEV_ATTR(dscr, 0600, show_dscr, store_dscr);
+static SYSDEV_ATTR(purr, 0600, show_purr, store_purr);
+
+static struct sysdev_attribute ibm_common_attrs[] = {
+       _SYSDEV_ATTR(mmcr0, 0600, show_mmcr0, store_mmcr0),
+       _SYSDEV_ATTR(mmcr1, 0600, show_mmcr1, store_mmcr1),
+};
+
+static struct sysdev_attribute ibm_pmc_attrs[] = {
+       _SYSDEV_ATTR(pmc1, 0600, show_pmc1, store_pmc1),
+       _SYSDEV_ATTR(pmc2, 0600, show_pmc2, store_pmc2),
+       _SYSDEV_ATTR(pmc3, 0600, show_pmc3, store_pmc3),
+       _SYSDEV_ATTR(pmc4, 0600, show_pmc4, store_pmc4),
+       _SYSDEV_ATTR(pmc5, 0600, show_pmc5, store_pmc5),
+       _SYSDEV_ATTR(pmc6, 0600, show_pmc6, store_pmc6),
+       _SYSDEV_ATTR(pmc7, 0600, show_pmc7, store_pmc7),
+       _SYSDEV_ATTR(pmc8, 0600, show_pmc8, store_pmc8),
+};
+
+static struct sysdev_attribute pa6t_attrs[] = {
+       _SYSDEV_ATTR(mmcr0, 0600, show_mmcr0, store_mmcr0),
+       _SYSDEV_ATTR(mmcr1, 0600, show_mmcr1, store_mmcr1),
+       _SYSDEV_ATTR(pmc0, 0600, show_pa6t_pmc0, store_pa6t_pmc0),
+       _SYSDEV_ATTR(pmc1, 0600, show_pa6t_pmc1, store_pa6t_pmc1),
+       _SYSDEV_ATTR(pmc2, 0600, show_pa6t_pmc2, store_pa6t_pmc2),
+       _SYSDEV_ATTR(pmc3, 0600, show_pa6t_pmc3, store_pa6t_pmc3),
+       _SYSDEV_ATTR(pmc4, 0600, show_pa6t_pmc4, store_pa6t_pmc4),
+       _SYSDEV_ATTR(pmc5, 0600, show_pa6t_pmc5, store_pa6t_pmc5),
+#ifdef CONFIG_DEBUG_KERNEL
+       _SYSDEV_ATTR(hid0, 0600, show_hid0, store_hid0),
+       _SYSDEV_ATTR(hid1, 0600, show_hid1, store_hid1),
+       _SYSDEV_ATTR(hid4, 0600, show_hid4, store_hid4),
+       _SYSDEV_ATTR(hid5, 0600, show_hid5, store_hid5),
+       _SYSDEV_ATTR(ima0, 0600, show_ima0, store_ima0),
+       _SYSDEV_ATTR(ima1, 0600, show_ima1, store_ima1),
+       _SYSDEV_ATTR(ima2, 0600, show_ima2, store_ima2),
+       _SYSDEV_ATTR(ima3, 0600, show_ima3, store_ima3),
+       _SYSDEV_ATTR(ima4, 0600, show_ima4, store_ima4),
+       _SYSDEV_ATTR(ima5, 0600, show_ima5, store_ima5),
+       _SYSDEV_ATTR(ima6, 0600, show_ima6, store_ima6),
+       _SYSDEV_ATTR(ima7, 0600, show_ima7, store_ima7),
+       _SYSDEV_ATTR(ima8, 0600, show_ima8, store_ima8),
+       _SYSDEV_ATTR(ima9, 0600, show_ima9, store_ima9),
+       _SYSDEV_ATTR(imaat, 0600, show_imaat, store_imaat),
+       _SYSDEV_ATTR(btcr, 0600, show_btcr, store_btcr),
+       _SYSDEV_ATTR(pccr, 0600, show_pccr, store_pccr),
+       _SYSDEV_ATTR(rpccr, 0600, show_rpccr, store_rpccr),
+       _SYSDEV_ATTR(der, 0600, show_der, store_der),
+       _SYSDEV_ATTR(mer, 0600, show_mer, store_mer),
+       _SYSDEV_ATTR(ber, 0600, show_ber, store_ber),
+       _SYSDEV_ATTR(ier, 0600, show_ier, store_ier),
+       _SYSDEV_ATTR(sier, 0600, show_sier, store_sier),
+       _SYSDEV_ATTR(siar, 0600, show_siar, store_siar),
+       _SYSDEV_ATTR(tsr0, 0600, show_tsr0, store_tsr0),
+       _SYSDEV_ATTR(tsr1, 0600, show_tsr1, store_tsr1),
+       _SYSDEV_ATTR(tsr2, 0600, show_tsr2, store_tsr2),
+       _SYSDEV_ATTR(tsr3, 0600, show_tsr3, store_tsr3),
+#endif /* CONFIG_DEBUG_KERNEL */
+};
+
 
 static void register_cpu_online(unsigned int cpu)
 {
        struct cpu *c = &per_cpu(cpu_devices, cpu);
        struct sys_device *s = &c->sysdev;
+       struct sysdev_attribute *attrs, *pmc_attrs;
+       int i, nattrs;
 
        if (!firmware_has_feature(FW_FEATURE_ISERIES) &&
                        cpu_has_feature(CPU_FTR_SMT))
                sysdev_create_file(s, &attr_smt_snooze_delay);
 
        /* PMC stuff */
+       switch (cur_cpu_spec->pmc_type) {
+       case PPC_PMC_IBM:
+               attrs = ibm_common_attrs;
+               nattrs = sizeof(ibm_common_attrs) / sizeof(struct sysdev_attribute);
+               pmc_attrs = ibm_pmc_attrs;
+               break;
+       case PPC_PMC_PA6T:
+               /* PA Semi starts counting at PMC0 */
+               attrs = pa6t_attrs;
+               nattrs = sizeof(pa6t_attrs) / sizeof(struct sysdev_attribute);
+               pmc_attrs = NULL;
+               break;
+       default:
+               attrs = NULL;
+               nattrs = 0;
+               pmc_attrs = NULL;
+       }
+
+       for (i = 0; i < nattrs; i++)
+               sysdev_create_file(s, &attrs[i]);
 
-       sysdev_create_file(s, &attr_mmcr0);
-       sysdev_create_file(s, &attr_mmcr1);
+       if (pmc_attrs)
+               for (i = 0; i < cur_cpu_spec->num_pmcs; i++)
+                       sysdev_create_file(s, &pmc_attrs[i]);
 
        if (cpu_has_feature(CPU_FTR_MMCRA))
                sysdev_create_file(s, &attr_mmcra);
 
-       if (cur_cpu_spec->num_pmcs >= 1)
-               sysdev_create_file(s, &attr_pmc1);
-       if (cur_cpu_spec->num_pmcs >= 2)
-               sysdev_create_file(s, &attr_pmc2);
-       if (cur_cpu_spec->num_pmcs >= 3)
-               sysdev_create_file(s, &attr_pmc3);
-       if (cur_cpu_spec->num_pmcs >= 4)
-               sysdev_create_file(s, &attr_pmc4);
-       if (cur_cpu_spec->num_pmcs >= 5)
-               sysdev_create_file(s, &attr_pmc5);
-       if (cur_cpu_spec->num_pmcs >= 6)
-               sysdev_create_file(s, &attr_pmc6);
-       if (cur_cpu_spec->num_pmcs >= 7)
-               sysdev_create_file(s, &attr_pmc7);
-       if (cur_cpu_spec->num_pmcs >= 8)
-               sysdev_create_file(s, &attr_pmc8);
-
        if (cpu_has_feature(CPU_FTR_PURR))
                sysdev_create_file(s, &attr_purr);
 
@@ -248,6 +346,8 @@ static void unregister_cpu_online(unsigned int cpu)
 {
        struct cpu *c = &per_cpu(cpu_devices, cpu);
        struct sys_device *s = &c->sysdev;
+       struct sysdev_attribute *attrs, *pmc_attrs;
+       int i, nattrs;
 
        BUG_ON(!c->hotpluggable);
 
@@ -256,30 +356,34 @@ static void unregister_cpu_online(unsigned int cpu)
                sysdev_remove_file(s, &attr_smt_snooze_delay);
 
        /* PMC stuff */
+       switch (cur_cpu_spec->pmc_type) {
+       case PPC_PMC_IBM:
+               attrs = ibm_common_attrs;
+               nattrs = sizeof(ibm_common_attrs) / sizeof(struct sysdev_attribute);
+               pmc_attrs = ibm_pmc_attrs;
+               break;
+       case PPC_PMC_PA6T:
+               /* PA Semi starts counting at PMC0 */
+               attrs = pa6t_attrs;
+               nattrs = sizeof(pa6t_attrs) / sizeof(struct sysdev_attribute);
+               pmc_attrs = NULL;
+               break;
+       default:
+               attrs = NULL;
+               nattrs = 0;
+               pmc_attrs = NULL;
+       }
+
+       for (i = 0; i < nattrs; i++)
+               sysdev_remove_file(s, &attrs[i]);
 
-       sysdev_remove_file(s, &attr_mmcr0);
-       sysdev_remove_file(s, &attr_mmcr1);
+       if (pmc_attrs)
+               for (i = 0; i < cur_cpu_spec->num_pmcs; i++)
+                       sysdev_remove_file(s, &pmc_attrs[i]);
 
        if (cpu_has_feature(CPU_FTR_MMCRA))
                sysdev_remove_file(s, &attr_mmcra);
 
-       if (cur_cpu_spec->num_pmcs >= 1)
-               sysdev_remove_file(s, &attr_pmc1);
-       if (cur_cpu_spec->num_pmcs >= 2)
-               sysdev_remove_file(s, &attr_pmc2);
-       if (cur_cpu_spec->num_pmcs >= 3)
-               sysdev_remove_file(s, &attr_pmc3);
-       if (cur_cpu_spec->num_pmcs >= 4)
-               sysdev_remove_file(s, &attr_pmc4);
-       if (cur_cpu_spec->num_pmcs >= 5)
-               sysdev_remove_file(s, &attr_pmc5);
-       if (cur_cpu_spec->num_pmcs >= 6)
-               sysdev_remove_file(s, &attr_pmc6);
-       if (cur_cpu_spec->num_pmcs >= 7)
-               sysdev_remove_file(s, &attr_pmc7);
-       if (cur_cpu_spec->num_pmcs >= 8)
-               sysdev_remove_file(s, &attr_pmc8);
-
        if (cpu_has_feature(CPU_FTR_PURR))
                sysdev_remove_file(s, &attr_purr);
 
@@ -298,10 +402,12 @@ static int __cpuinit sysfs_cpu_notify(struct notifier_block *self,
 
        switch (action) {
        case CPU_ONLINE:
+       case CPU_ONLINE_FROZEN:
                register_cpu_online(cpu);
                break;
 #ifdef CONFIG_HOTPLUG_CPU
        case CPU_DEAD:
+       case CPU_DEAD_FROZEN:
                unregister_cpu_online(cpu);
                break;
 #endif
@@ -334,12 +440,14 @@ int cpu_add_sysdev_attr_group(struct attribute_group *attrs)
 {
        int cpu;
        struct sys_device *sysdev;
+       int ret;
 
        mutex_lock(&cpu_mutex);
 
        for_each_possible_cpu(cpu) {
                sysdev = get_cpu_sysdev(cpu);
-               sysfs_create_group(&sysdev->kobj, attrs);
+               ret = sysfs_create_group(&sysdev->kobj, attrs);
+               WARN_ON(ret != 0);
        }
 
        mutex_unlock(&cpu_mutex);
@@ -396,12 +504,14 @@ int sysfs_add_device_to_node(struct sys_device *dev, int nid)
        return sysfs_create_link(&node->sysdev.kobj, &dev->kobj,
                        kobject_name(&dev->kobj));
 }
+EXPORT_SYMBOL_GPL(sysfs_add_device_to_node);
 
 void sysfs_remove_device_from_node(struct sys_device *dev, int nid)
 {
        struct node *node = &node_devices[nid];
        sysfs_remove_link(&node->sysdev.kobj, kobject_name(&dev->kobj));
 }
+EXPORT_SYMBOL_GPL(sysfs_remove_device_from_node);
 
 #else
 static void register_nodes(void)
@@ -411,9 +521,6 @@ static void register_nodes(void)
 
 #endif
 
-EXPORT_SYMBOL_GPL(sysfs_add_device_to_node);
-EXPORT_SYMBOL_GPL(sysfs_remove_device_from_node);
-
 /* Only valid if CPU is present. */
 static ssize_t show_physical_id(struct sys_device *dev, char *buf)
 {
@@ -455,4 +562,4 @@ static int __init topology_init(void)
 
        return 0;
 }
-__initcall(topology_init);
+subsys_initcall(topology_init);