18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * drivers/sh/superhyway/superhyway-sysfs.c
38c2ecf20Sopenharmony_ci *
48c2ecf20Sopenharmony_ci * SuperHyway Bus sysfs interface
58c2ecf20Sopenharmony_ci *
68c2ecf20Sopenharmony_ci * Copyright (C) 2004, 2005  Paul Mundt <lethal@linux-sh.org>
78c2ecf20Sopenharmony_ci *
88c2ecf20Sopenharmony_ci * This file is subject to the terms and conditions of the GNU General Public
98c2ecf20Sopenharmony_ci * License.  See the file "COPYING" in the main directory of this archive
108c2ecf20Sopenharmony_ci * for more details.
118c2ecf20Sopenharmony_ci */
128c2ecf20Sopenharmony_ci#include <linux/kernel.h>
138c2ecf20Sopenharmony_ci#include <linux/device.h>
148c2ecf20Sopenharmony_ci#include <linux/types.h>
158c2ecf20Sopenharmony_ci#include <linux/superhyway.h>
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ci#define superhyway_ro_attr(name, fmt, field)				\
188c2ecf20Sopenharmony_cistatic ssize_t name##_show(struct device *dev, struct device_attribute *attr, char *buf)		\
198c2ecf20Sopenharmony_ci{									\
208c2ecf20Sopenharmony_ci	struct superhyway_device *s = to_superhyway_device(dev);	\
218c2ecf20Sopenharmony_ci	return sprintf(buf, fmt, s->field);				\
228c2ecf20Sopenharmony_ci}									\
238c2ecf20Sopenharmony_cistatic DEVICE_ATTR_RO(name);
248c2ecf20Sopenharmony_ci
258c2ecf20Sopenharmony_ci/* VCR flags */
268c2ecf20Sopenharmony_cisuperhyway_ro_attr(perr_flags, "0x%02x\n", vcr.perr_flags);
278c2ecf20Sopenharmony_cisuperhyway_ro_attr(merr_flags, "0x%02x\n", vcr.merr_flags);
288c2ecf20Sopenharmony_cisuperhyway_ro_attr(mod_vers, "0x%04x\n", vcr.mod_vers);
298c2ecf20Sopenharmony_cisuperhyway_ro_attr(mod_id, "0x%04x\n", vcr.mod_id);
308c2ecf20Sopenharmony_cisuperhyway_ro_attr(bot_mb, "0x%02x\n", vcr.bot_mb);
318c2ecf20Sopenharmony_cisuperhyway_ro_attr(top_mb, "0x%02x\n", vcr.top_mb);
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_ci/* Misc */
348c2ecf20Sopenharmony_cisuperhyway_ro_attr(resource, "0x%08lx\n", resource[0].start);
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_cistatic struct attribute *superhyway_dev_attrs[] = {
378c2ecf20Sopenharmony_ci	&dev_attr_perr_flags.attr,
388c2ecf20Sopenharmony_ci	&dev_attr_merr_flags.attr,
398c2ecf20Sopenharmony_ci	&dev_attr_mod_vers.attr,
408c2ecf20Sopenharmony_ci	&dev_attr_mod_id.attr,
418c2ecf20Sopenharmony_ci	&dev_attr_bot_mb.attr,
428c2ecf20Sopenharmony_ci	&dev_attr_top_mb.attr,
438c2ecf20Sopenharmony_ci	&dev_attr_resource.attr,
448c2ecf20Sopenharmony_ci	NULL,
458c2ecf20Sopenharmony_ci};
468c2ecf20Sopenharmony_ci
478c2ecf20Sopenharmony_cistatic const struct attribute_group superhyway_dev_group = {
488c2ecf20Sopenharmony_ci	.attrs = superhyway_dev_attrs,
498c2ecf20Sopenharmony_ci};
508c2ecf20Sopenharmony_ci
518c2ecf20Sopenharmony_ciconst struct attribute_group *superhyway_dev_groups[] = {
528c2ecf20Sopenharmony_ci	&superhyway_dev_group,
538c2ecf20Sopenharmony_ci	NULL,
548c2ecf20Sopenharmony_ci};
55