18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-or-later 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * This file supports the /sys/firmware/sgi_uv interfaces for SGI UV. 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (c) 2008 Silicon Graphics, Inc. All Rights Reserved. 68c2ecf20Sopenharmony_ci * Copyright (c) Russ Anderson 78c2ecf20Sopenharmony_ci */ 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ci#include <linux/device.h> 108c2ecf20Sopenharmony_ci#include <asm/uv/bios.h> 118c2ecf20Sopenharmony_ci#include <asm/uv/uv.h> 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_cistruct kobject *sgi_uv_kobj; 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_cistatic ssize_t partition_id_show(struct kobject *kobj, 168c2ecf20Sopenharmony_ci struct kobj_attribute *attr, char *buf) 178c2ecf20Sopenharmony_ci{ 188c2ecf20Sopenharmony_ci return snprintf(buf, PAGE_SIZE, "%ld\n", sn_partition_id); 198c2ecf20Sopenharmony_ci} 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_cistatic ssize_t coherence_id_show(struct kobject *kobj, 228c2ecf20Sopenharmony_ci struct kobj_attribute *attr, char *buf) 238c2ecf20Sopenharmony_ci{ 248c2ecf20Sopenharmony_ci return snprintf(buf, PAGE_SIZE, "%ld\n", sn_coherency_id); 258c2ecf20Sopenharmony_ci} 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_cistatic struct kobj_attribute partition_id_attr = 288c2ecf20Sopenharmony_ci __ATTR(partition_id, S_IRUGO, partition_id_show, NULL); 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_cistatic struct kobj_attribute coherence_id_attr = 318c2ecf20Sopenharmony_ci __ATTR(coherence_id, S_IRUGO, coherence_id_show, NULL); 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_cistatic int __init sgi_uv_sysfs_init(void) 358c2ecf20Sopenharmony_ci{ 368c2ecf20Sopenharmony_ci unsigned long ret; 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_ci if (!is_uv_system()) 398c2ecf20Sopenharmony_ci return -ENODEV; 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_ci if (!sgi_uv_kobj) 428c2ecf20Sopenharmony_ci sgi_uv_kobj = kobject_create_and_add("sgi_uv", firmware_kobj); 438c2ecf20Sopenharmony_ci if (!sgi_uv_kobj) { 448c2ecf20Sopenharmony_ci printk(KERN_WARNING "kobject_create_and_add sgi_uv failed\n"); 458c2ecf20Sopenharmony_ci return -EINVAL; 468c2ecf20Sopenharmony_ci } 478c2ecf20Sopenharmony_ci 488c2ecf20Sopenharmony_ci ret = sysfs_create_file(sgi_uv_kobj, &partition_id_attr.attr); 498c2ecf20Sopenharmony_ci if (ret) { 508c2ecf20Sopenharmony_ci printk(KERN_WARNING "sysfs_create_file partition_id failed\n"); 518c2ecf20Sopenharmony_ci return ret; 528c2ecf20Sopenharmony_ci } 538c2ecf20Sopenharmony_ci 548c2ecf20Sopenharmony_ci ret = sysfs_create_file(sgi_uv_kobj, &coherence_id_attr.attr); 558c2ecf20Sopenharmony_ci if (ret) { 568c2ecf20Sopenharmony_ci printk(KERN_WARNING "sysfs_create_file coherence_id failed\n"); 578c2ecf20Sopenharmony_ci return ret; 588c2ecf20Sopenharmony_ci } 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_ci return 0; 618c2ecf20Sopenharmony_ci} 628c2ecf20Sopenharmony_ci 638c2ecf20Sopenharmony_cidevice_initcall(sgi_uv_sysfs_init); 64