Linux-MIPS Archive on lore.kernel.org
 help / color / Atom feed
From: Fredrik Noring <noring@nocrew.org>
To: Paul Burton <paul.burton@mips.com>, linux-mips@vger.kernel.org
Cc: "Maciej W. Rozycki" <macro@linux-mips.org>,
	"Jürgen Urban" <JuergenUrban@gmx.de>
Subject: [PATCH 091/120] MIPS: PS2: GS: Show privileged registers with sysfs
Date: Sun, 1 Sep 2019 18:25:16 +0200
Message-ID: <ecc74e0565aa949a4a2a6a1e7cb65442010b7c9d.1567326213.git.noring@nocrew.org> (raw)
In-Reply-To: <cover.1567326213.git.noring@nocrew.org>

Reading arbitrary numerical and symbolical privileged GS register bit
fields is supported. For example, the PMODE register can be inspected
with:

    # cat /sys/devices/platform/gs/registers/pmode
    en1 1
    en2 0
    crtmd 1
    mmod circuit1
    amod circuit1
    slbg circuit2
    alp 0

The implementation uses a fair amount of macro expansions. This greatly
simplifies register definitions, which in the case of PMODE is:

    SYSFS_RW_REG(pmode, pmode,
    	SYSFS_DECNUM_FIELD(en1),
    	SYSFS_DECNUM_FIELD(en2),
    	SYSFS_DECNUM_FIELD(crtmd),
    	SYSFS_SYMBOL_FIELD(mmod, circuit1, alp),
    	SYSFS_SYMBOL_FIELD(amod, circuit1, circuit2),
    	SYSFS_SYMBOL_FIELD(slbg, circuit2, bgcolor),
    	SYSFS_DECNUM_FIELD(alp));

It relies on the following enum and struct definitions:

    enum gs_pmode_mmod { gs_mmod_circuit1, gs_mmod_alp };
    enum gs_pmode_amod { gs_amod_circuit1, gs_amod_circuit2 };
    enum gs_pmode_slbg { gs_slbg_circuit2, gs_slbg_bgcolor };
    struct gs_pmode {
    	u64 en1 : 1;		/* Enable read circuit 1 */
    	u64 en2 : 1;		/* Enable read circuit 2 */
    	u64 crtmd : 3;		/* CRT output switching (always 001) */
    	u64 mmod : 1;		/* Alpha blending value */
    	u64 amod : 1;		/* OUT1 alpha output */
    	u64 slbg : 1;		/* Alpha blending method */
    	u64 alp : 8;		/* Fixed alpha (0xff = 1.0) */
    	u64 zero : 1;		/* Must be zero */
    	u64 : 47;
    };

Signed-off-by: Fredrik Noring <noring@nocrew.org>
---
 drivers/ps2/Makefile   |   1 +
 drivers/ps2/gs-sysfs.c | 457 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 458 insertions(+)
 create mode 100644 drivers/ps2/gs-sysfs.c

diff --git a/drivers/ps2/Makefile b/drivers/ps2/Makefile
index 28fb55803199..86ba1d3908dd 100644
--- a/drivers/ps2/Makefile
+++ b/drivers/ps2/Makefile
@@ -2,6 +2,7 @@ obj-$(CONFIG_PS2_GS)		+= gif.o
 obj-$(CONFIG_PS2_GS)		+= gs.o
 obj-$(CONFIG_PS2_GS)		+= gs-irq.o
 obj-$(CONFIG_PS2_GS)		+= gs-registers.o
+obj-$(CONFIG_PS2_GS)		+= gs-sysfs.o
 
 obj-m				+= iop-heap.o
 obj-m				+= iop-irq.o
diff --git a/drivers/ps2/gs-sysfs.c b/drivers/ps2/gs-sysfs.c
new file mode 100644
index 000000000000..2429de3e0094
--- /dev/null
+++ b/drivers/ps2/gs-sysfs.c
@@ -0,0 +1,457 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * PlayStation 2 Graphics Synthesizer (GS) sysfs driver
+ *
+ * Copyright (C) 2019 Fredrik Noring
+ *
+ * Reading arbitrary numerical and symbolical privileged GS register
+ * bit fields is supported. For example, the PMODE register can be
+ * inspected with:
+ *
+ *	# cat /sys/devices/platform/gs/registers/pmode
+ *	en1 1
+ *	en2 0
+ *	crtmd 1
+ *	mmod circuit1
+ *	amod circuit1
+ *	slbg circuit2
+ *	alp 0
+ *
+ * The implementation uses a fair amount of macro expansions. This greatly
+ * simplifies register definitions, which in the case of PMODE is:
+ *
+ *	SYSFS_RW_REG(pmode, pmode,
+ *		SYSFS_DECNUM_FIELD(en1),
+ *		SYSFS_DECNUM_FIELD(en2),
+ *		SYSFS_DECNUM_FIELD(crtmd),
+ *		SYSFS_SYMBOL_FIELD(mmod, circuit1, alp),
+ *		SYSFS_SYMBOL_FIELD(amod, circuit1, circuit2),
+ *		SYSFS_SYMBOL_FIELD(slbg, circuit2, bgcolor),
+ *		SYSFS_DECNUM_FIELD(alp));
+ *
+ * It relies on the following enum and struct definitions:
+ *
+ *	enum gs_pmode_mmod { gs_mmod_circuit1, gs_mmod_alp };
+ *	enum gs_pmode_amod { gs_amod_circuit1, gs_amod_circuit2 };
+ *	enum gs_pmode_slbg { gs_slbg_circuit2, gs_slbg_bgcolor };
+ *	struct gs_pmode {
+ *		u64 en1 : 1;		// Enable read circuit 1
+ *		u64 en2 : 1;		// Enable read circuit 2
+ *		u64 crtmd : 3;		// CRT output switching (always 001)
+ *		u64 mmod : 1;		// Alpha blending value
+ *		u64 amod : 1;		// OUT1 alpha output
+ *		u64 slbg : 1;		// Alpha blending method
+ *		u64 alp : 8;		// Fixed alpha (0xff = 1.0)
+ *		u64 zero : 1;		// Must be zero
+ *		u64 : 47;
+ *	};
+ */
+
+#include <linux/ctype.h>
+#include <linux/errno.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/types.h>
+#include <linux/uaccess.h>
+
+#include <asm/page.h>
+#include <asm/uaccess.h>
+
+#include <asm/mach-ps2/gs.h>
+#include <asm/mach-ps2/gs-registers.h>
+
+#include <uapi/asm/gs.h>
+
+static struct kobject *registers_kobj;
+
+#define SYSFS_STATEMENT1(prefix_, macro_)				\
+	prefix_##macro_;
+
+#define SYSFS_STATEMENT2(prefix_, macro_, ...)				\
+	prefix_##macro_;						\
+	SYSFS_STATEMENT1(prefix_, __VA_ARGS__)
+
+#define SYSFS_STATEMENT3(prefix_, macro_, ...)				\
+	prefix_##macro_;						\
+	SYSFS_STATEMENT2(prefix_, __VA_ARGS__)
+
+#define SYSFS_STATEMENT4(prefix_, macro_, ...)				\
+	prefix_##macro_;						\
+	SYSFS_STATEMENT3(prefix_, __VA_ARGS__)
+
+#define SYSFS_STATEMENT5(prefix_, macro_, ...)				\
+	prefix_##macro_;						\
+	SYSFS_STATEMENT4(prefix_, __VA_ARGS__)
+
+#define SYSFS_STATEMENT6(prefix_, macro_, ...)				\
+	prefix_##macro_;						\
+	SYSFS_STATEMENT5(prefix_, __VA_ARGS__)
+
+#define SYSFS_STATEMENT7(prefix_, macro_, ...)				\
+	prefix_##macro_;						\
+	SYSFS_STATEMENT6(prefix_, __VA_ARGS__)
+
+#define SYSFS_STATEMENT8(prefix_, macro_, ...)				\
+	prefix_##macro_;						\
+	SYSFS_STATEMENT7(prefix_, __VA_ARGS__)
+
+#define SYSFS_STATEMENT9(prefix_, macro_, ...)				\
+	prefix_##macro_;						\
+	SYSFS_STATEMENT8(prefix_, __VA_ARGS__)
+
+#define SYSFS_STATEMENT10(prefix_, macro_, ...)				\
+	prefix_##macro_;						\
+	SYSFS_STATEMENT9(prefix_, __VA_ARGS__)
+
+#define SYSFS_STATEMENT11(prefix_, macro_, ...)				\
+	prefix_##macro_;						\
+	SYSFS_STATEMENT10(prefix_, __VA_ARGS__)
+
+#define SYSFS_STATEMENT12(prefix_, macro_, ...)				\
+	prefix_##macro_;						\
+	SYSFS_STATEMENT11(prefix_, __VA_ARGS__)
+
+#define SYSFS_STATEMENT13(prefix_, macro_, ...)				\
+	prefix_##macro_;						\
+	SYSFS_STATEMENT12(prefix_, __VA_ARGS__)
+
+#define SYSFS_STATEMENT14(prefix_, macro_, ...)				\
+	prefix_##macro_;						\
+	SYSFS_STATEMENT13(prefix_, __VA_ARGS__)
+
+#define SYSFS_STATEMENT15(prefix_, macro_, ...)				\
+	prefix_##macro_;						\
+	SYSFS_STATEMENT14(prefix_, __VA_ARGS__)
+
+#define SYSFS_STATEMENT16(prefix_, macro_, ...)				\
+	prefix_##macro_;						\
+	SYSFS_STATEMENT15(prefix_, __VA_ARGS__)
+
+#define SYSFS_STATEMENT17(prefix_, macro_, ...)				\
+	prefix_##macro_;						\
+	SYSFS_STATEMENT16(prefix_, __VA_ARGS__)
+
+#define SYSFS_STATEMENT18(prefix_, macro_, ...)				\
+	prefix_##macro_;						\
+	SYSFS_STATEMENT17(prefix_, __VA_ARGS__)
+
+#define SYSFS_STATEMENT19(prefix_, macro_, ...)				\
+	prefix_##macro_;						\
+	SYSFS_STATEMENT18(prefix_, __VA_ARGS__)
+
+#define SYSFS_STATEMENT20(prefix_, macro_, ...)				\
+	prefix_##macro_;						\
+	SYSFS_STATEMENT19(prefix_, __VA_ARGS__)
+
+#define SYSFS_STATEMENT21(prefix_, macro_, ...)				\
+	prefix_##macro_;						\
+	SYSFS_STATEMENT20(prefix_, __VA_ARGS__)
+
+#define SYSFS_STATEMENT22(prefix_, macro_, ...)				\
+	prefix_##macro_;						\
+	SYSFS_STATEMENT21(prefix_, __VA_ARGS__)
+
+#define SYSFS_STATEMENT23(prefix_, macro_, ...)				\
+	prefix_##macro_;						\
+	SYSFS_STATEMENT22(prefix_, __VA_ARGS__)
+
+#define SYSFS_STATEMENT24(prefix_, macro_, ...)				\
+	prefix_##macro_;						\
+	SYSFS_STATEMENT23(prefix_, __VA_ARGS__)
+
+#define SYSFS_STATEMENT25(prefix_, macro_, ...)				\
+	prefix_##macro_;						\
+	SYSFS_STATEMENT24(prefix_, __VA_ARGS__)
+
+#define SHOW_SYSFS_DECNUM_FIELD(field_, ...)				\
+	do {								\
+		if (valid)						\
+			n += scnprintf(&buf[n], PAGE_SIZE - n,		\
+				#field_ " %u\n", value.field_);		\
+		else							\
+			n += scnprintf(&buf[n], PAGE_SIZE - n,		\
+				#field_ "\n");				\
+	} while (false)
+
+#define SHOW_SYSFS_HEXNUM_FIELD(field_, ...)				\
+	do {								\
+		if (valid)						\
+			n += scnprintf(&buf[n], PAGE_SIZE - n,		\
+				#field_ " 0x%x\n", value.field_);	\
+		else							\
+			n += scnprintf(&buf[n], PAGE_SIZE - n,		\
+				#field_ "\n");				\
+	} while (false)
+
+#define SHOW_SYSFS_SYMBOL_STRING_ENTRY(field_, prefix_, value_)		\
+	value.field_ == prefix_##_##value_ ? " " #value_ :
+
+#define SHOW_SYSFS_SYMBOL_STRING1(field_, prefix_, value_)		\
+	SHOW_SYSFS_SYMBOL_STRING_ENTRY(field_, prefix_, value_) "-"
+
+#define SHOW_SYSFS_SYMBOL_STRING2(field_, prefix_, value_, ...)		\
+	SHOW_SYSFS_SYMBOL_STRING_ENTRY(field_, prefix_, value_)		\
+	SHOW_SYSFS_SYMBOL_STRING1(field_, prefix_, __VA_ARGS__)
+
+#define SHOW_SYSFS_SYMBOL_STRING3(field_, prefix_, value_, ...)		\
+	SHOW_SYSFS_SYMBOL_STRING_ENTRY(field_, prefix_, value_)		\
+	SHOW_SYSFS_SYMBOL_STRING2(field_, prefix_, __VA_ARGS__)
+
+#define SHOW_SYSFS_SYMBOL_STRING4(field_, prefix_, value_, ...)		\
+	SHOW_SYSFS_SYMBOL_STRING_ENTRY(field_, prefix_, value_)		\
+	SHOW_SYSFS_SYMBOL_STRING3(field_, prefix_, __VA_ARGS__)
+
+#define SHOW_SYSFS_SYMBOL_STRING5(field_, prefix_, value_, ...)		\
+	SHOW_SYSFS_SYMBOL_STRING_ENTRY(field_, prefix_, value_)		\
+	SHOW_SYSFS_SYMBOL_STRING4(field_, prefix_, __VA_ARGS__)
+
+#define SHOW_SYSFS_SYMBOL_STRING(field_, prefix_, ...)			\
+	!valid ? "" :							\
+	CONCATENATE(SHOW_SYSFS_SYMBOL_STRING,				\
+		COUNT_ARGS(__VA_ARGS__))(field_, prefix_, __VA_ARGS__)
+
+#define SHOW_SYSFS_SYMBOL_FIELD(field_, ...)			\
+	n += scnprintf(&buf[n], PAGE_SIZE - n, #field_ "%s\n",		\
+		SHOW_SYSFS_SYMBOL_STRING(field_, gs_##field_, __VA_ARGS__))
+
+#define SHOW_SYSFS_REGISTER(reg, str, ...)				\
+	static ssize_t show_##reg(struct device *device,		\
+		struct device_attribute *attr, char *buf)		\
+	{								\
+		const bool valid = gs_valid_##reg();			\
+		const struct gs_##str value = valid ?			\
+			gs_read_##reg() : (struct gs_##str) { };	\
+		size_t n = 0;						\
+		__VA_ARGS__;						\
+		return n;						\
+	}
+
+#define SYSFS_SHOW(reg, str, ...)					\
+	SHOW_SYSFS_REGISTER(reg, str,					\
+		CONCATENATE(SYSFS_STATEMENT,				\
+			COUNT_ARGS(__VA_ARGS__))(SHOW_, __VA_ARGS__))
+
+#define SYSFS_RO_REG(reg, str, ...)					\
+	SYSFS_SHOW(reg, str, __VA_ARGS__)				\
+	static DEVICE_ATTR(reg, S_IRUGO, show_##reg, NULL)
+
+#define SYSFS_RW_REG(reg, str, ...)					\
+	SYSFS_SHOW(reg, str, __VA_ARGS__)				\
+	static DEVICE_ATTR(reg, S_IRUGO, show_##reg, NULL)
+
+SYSFS_RW_REG(pmode, pmode,
+	SYSFS_DECNUM_FIELD(en1),
+	SYSFS_DECNUM_FIELD(en2),
+	SYSFS_DECNUM_FIELD(crtmd),
+	SYSFS_SYMBOL_FIELD(mmod, circuit1, alp),
+	SYSFS_SYMBOL_FIELD(amod, circuit1, circuit2),
+	SYSFS_SYMBOL_FIELD(slbg, circuit2, bgcolor),
+	SYSFS_DECNUM_FIELD(alp));
+
+SYSFS_RW_REG(smode1, smode1,
+	SYSFS_DECNUM_FIELD(rc),
+	SYSFS_DECNUM_FIELD(lc),
+	SYSFS_DECNUM_FIELD(t1248),
+	SYSFS_DECNUM_FIELD(slck),
+	SYSFS_SYMBOL_FIELD(cmod, vesa, ntsc, pal),
+	SYSFS_DECNUM_FIELD(ex),
+	SYSFS_DECNUM_FIELD(prst),
+	SYSFS_DECNUM_FIELD(sint),
+	SYSFS_DECNUM_FIELD(xpck),
+	SYSFS_DECNUM_FIELD(pck2),
+	SYSFS_DECNUM_FIELD(spml),
+	SYSFS_SYMBOL_FIELD(gcont, rgbyc, ycrcb),
+	SYSFS_DECNUM_FIELD(phs),
+	SYSFS_DECNUM_FIELD(pvs),
+	SYSFS_DECNUM_FIELD(pehs),
+	SYSFS_DECNUM_FIELD(pevs),
+	SYSFS_DECNUM_FIELD(clksel),
+	SYSFS_DECNUM_FIELD(nvck),
+	SYSFS_DECNUM_FIELD(slck2),
+	SYSFS_DECNUM_FIELD(vcksel),
+	SYSFS_DECNUM_FIELD(vhp));
+
+SYSFS_RW_REG(smode2, smode2,
+	SYSFS_SYMBOL_FIELD(intm, progressive, interlace),
+	SYSFS_SYMBOL_FIELD(ffmd, field, frame),
+	SYSFS_SYMBOL_FIELD(dpms, on, standby, suspend, off));
+
+SYSFS_RW_REG(srfsh, srfsh,
+	SYSFS_DECNUM_FIELD(rfsh));
+
+SYSFS_RW_REG(synch1, synch1,
+	SYSFS_DECNUM_FIELD(hfp),
+	SYSFS_DECNUM_FIELD(hbp),
+	SYSFS_DECNUM_FIELD(hseq),
+	SYSFS_DECNUM_FIELD(hsvs),
+	SYSFS_DECNUM_FIELD(hs));
+
+SYSFS_RW_REG(synch2, synch2,
+	SYSFS_DECNUM_FIELD(hf),
+	SYSFS_DECNUM_FIELD(hb));
+
+SYSFS_RW_REG(syncv, syncv,
+	SYSFS_DECNUM_FIELD(vfp),
+	SYSFS_DECNUM_FIELD(vfpe),
+	SYSFS_DECNUM_FIELD(vbp),
+	SYSFS_DECNUM_FIELD(vbpe),
+	SYSFS_DECNUM_FIELD(vdp),
+	SYSFS_DECNUM_FIELD(vs));
+
+SYSFS_RW_REG(dispfb1, dispfb,
+	SYSFS_DECNUM_FIELD(fbp),
+	SYSFS_DECNUM_FIELD(fbw),
+	SYSFS_SYMBOL_FIELD(psm, ct32, ct24, ct16, ct16s, gpu24),
+	SYSFS_DECNUM_FIELD(dbx),
+	SYSFS_DECNUM_FIELD(dby));
+
+SYSFS_RW_REG(display1, display,
+	SYSFS_DECNUM_FIELD(dx),
+	SYSFS_DECNUM_FIELD(dy),
+	SYSFS_DECNUM_FIELD(magh),
+	SYSFS_DECNUM_FIELD(magv),
+	SYSFS_DECNUM_FIELD(dw),
+	SYSFS_DECNUM_FIELD(dh));
+
+SYSFS_RW_REG(dispfb2, dispfb,
+	SYSFS_DECNUM_FIELD(fbp),
+	SYSFS_DECNUM_FIELD(fbw),
+	SYSFS_SYMBOL_FIELD(psm, ct32, ct24, ct16, ct16s),
+	SYSFS_DECNUM_FIELD(dbx),
+	SYSFS_DECNUM_FIELD(dby));
+
+SYSFS_RW_REG(display2, display,
+	SYSFS_DECNUM_FIELD(dx),
+	SYSFS_DECNUM_FIELD(dy),
+	SYSFS_DECNUM_FIELD(magh),
+	SYSFS_DECNUM_FIELD(magv),
+	SYSFS_DECNUM_FIELD(dw),
+	SYSFS_DECNUM_FIELD(dh));
+
+SYSFS_RW_REG(extbuf, extbuf,
+	SYSFS_DECNUM_FIELD(exbp),
+	SYSFS_DECNUM_FIELD(exbw),
+	SYSFS_SYMBOL_FIELD(fbin, out1, out2),
+	SYSFS_SYMBOL_FIELD(wffmd, field, frame),
+	SYSFS_SYMBOL_FIELD(emoda, alpha, y, yhalf, zero),
+	SYSFS_SYMBOL_FIELD(emodc, rgb, y, ycbcr, alpha),
+	SYSFS_DECNUM_FIELD(wdx),
+	SYSFS_DECNUM_FIELD(wdy));
+
+SYSFS_RW_REG(extdata, extdata,
+	SYSFS_DECNUM_FIELD(sx),
+	SYSFS_DECNUM_FIELD(sy),
+	SYSFS_DECNUM_FIELD(smph),
+	SYSFS_DECNUM_FIELD(smpv),
+	SYSFS_DECNUM_FIELD(ww),
+	SYSFS_DECNUM_FIELD(wh));
+
+SYSFS_RW_REG(extwrite, extwrite,
+	SYSFS_SYMBOL_FIELD(write, complete_current, start_next));
+
+SYSFS_RW_REG(bgcolor, bgcolor,
+	SYSFS_DECNUM_FIELD(r),
+	SYSFS_DECNUM_FIELD(g),
+	SYSFS_DECNUM_FIELD(b));
+
+SYSFS_RO_REG(csr, csr,
+	SYSFS_DECNUM_FIELD(signal),
+	SYSFS_DECNUM_FIELD(finish),
+	SYSFS_DECNUM_FIELD(hsint),
+	SYSFS_DECNUM_FIELD(vsint),
+	SYSFS_DECNUM_FIELD(edwint),
+	SYSFS_DECNUM_FIELD(flush),
+	SYSFS_DECNUM_FIELD(reset),
+	SYSFS_DECNUM_FIELD(nfield),
+	SYSFS_SYMBOL_FIELD(field, even, odd),
+	SYSFS_SYMBOL_FIELD(fifo, neither, empty, almost_full),
+	SYSFS_HEXNUM_FIELD(rev),
+	SYSFS_HEXNUM_FIELD(id));
+
+SYSFS_RO_REG(imr, imr,
+	SYSFS_DECNUM_FIELD(sigmsk),
+	SYSFS_DECNUM_FIELD(finishmsk),
+	SYSFS_DECNUM_FIELD(hsmsk),
+	SYSFS_DECNUM_FIELD(vsmsk),
+	SYSFS_DECNUM_FIELD(edwmsk),
+	SYSFS_DECNUM_FIELD(ones));
+
+SYSFS_RO_REG(busdir, busdir,
+	SYSFS_SYMBOL_FIELD(dir, host_to_local, local_to_host));
+
+SYSFS_RW_REG(siglblid, siglblid,
+	SYSFS_DECNUM_FIELD(sigid),
+	SYSFS_DECNUM_FIELD(lblid));
+
+static struct attribute *gs_registers_attributes[] = {
+	&dev_attr_pmode.attr,
+	&dev_attr_smode1.attr,
+	&dev_attr_smode2.attr,
+	&dev_attr_srfsh.attr,
+	&dev_attr_synch1.attr,
+	&dev_attr_synch2.attr,
+	&dev_attr_syncv.attr,
+	&dev_attr_dispfb1.attr,
+	&dev_attr_display1.attr,
+	&dev_attr_dispfb2.attr,
+	&dev_attr_display2.attr,
+	&dev_attr_extbuf.attr,
+	&dev_attr_extdata.attr,
+	&dev_attr_extwrite.attr,
+	&dev_attr_bgcolor.attr,
+	&dev_attr_csr.attr,		/* FIXME: Too lowlevel for sysfs? */
+	&dev_attr_imr.attr,		/* FIXME: Too lowlevel for sysfs? */
+	&dev_attr_busdir.attr,		/* FIXME: Too lowlevel for sysfs? */
+	&dev_attr_siglblid.attr,	/* FIXME: Too lowlevel for sysfs? */
+	NULL
+};
+
+static struct attribute_group gs_registers_attribute_group = {
+	.attrs = gs_registers_attributes
+};
+
+static int __init gs_sysfs_init(void)
+{
+	struct device *gs_dev = gs_device();	/* FIXME: Is this method appropriate? */
+	int err;
+
+	if (!gs_dev) {
+		pr_err("gs-sysfs: Failed to retrieve gs device\n");
+		err = -ENXIO;
+		goto gs_dev_err;
+	}
+
+	registers_kobj = kobject_create_and_add("registers", &gs_dev->kobj);
+	if (!registers_kobj) {
+		pr_err("gs-sysfs: Failed to create and add register kernel object\n");
+		err = -ENOMEM;
+		goto kobj_err;
+	}
+
+	err = sysfs_create_group(registers_kobj, &gs_registers_attribute_group);
+	if (err) {
+		pr_err("gs-sysfs: Failed to create register sysfs group\n");
+		goto group_err;
+	}
+
+	return 0;
+
+group_err:
+	kobject_del(registers_kobj);
+
+kobj_err:
+gs_dev_err:
+	return err;
+}
+
+static void __exit gs_sysfs_exit(void)
+{
+	kobject_del(registers_kobj);
+}
+
+module_init(gs_sysfs_init);
+module_exit(gs_sysfs_exit);
+
+MODULE_DESCRIPTION("PlayStation 2 Graphics Synthesizer sysfs driver");
+MODULE_AUTHOR("Fredrik Noring");
+MODULE_LICENSE("GPL");
-- 
2.21.0


  parent reply index

Thread overview: 152+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-01 15:35 [PATCH 000/120] Linux for the PlayStation 2 Fredrik Noring
2019-09-01 15:35 ` [PATCH 001/120] MIPS: R5900: Initial support for the Emotion Engine in " Fredrik Noring
2019-09-01 21:14   ` Maciej W. Rozycki
2019-09-02 15:09     ` Fredrik Noring
2019-09-01 15:36 ` [PATCH 002/120] MIPS: R5900: Trap the RDHWR instruction as an SQ address exception Fredrik Noring
2019-09-01 22:00   ` Maciej W. Rozycki
2019-09-01 15:36 ` [PATCH 003/120] MIPS: R5900: Sign-extend o32 system call registers Fredrik Noring
2019-09-01 15:37 ` [PATCH 004/120] MIPS: R5900: Reset bits 127..64 of GPRs in RESTORE_SOME Fredrik Noring
2019-09-01 15:38 ` [PATCH 005/120] MIPS: R5900: Reset the funnel shift amount (SA) register " Fredrik Noring
2019-09-01 15:38 ` [PATCH 006/120] MIPS: R5900: Workaround for the short loop bug Fredrik Noring
2019-09-01 15:39 ` [PATCH 007/120] MIPS: R5900: Add the SYNC.P instruction Fredrik Noring
2019-09-01 15:39 ` [PATCH 008/120] MIPS: R5900: Add implicit SYNC.P to the UASM_i_M[FT]C0 macros Fredrik Noring
2019-09-01 15:39 ` [PATCH 009/120] MIPS: R5900: Add mandatory SYNC.P to all M[FT]C0 instructions Fredrik Noring
2019-09-01 15:39 ` [PATCH 010/120] MIPS: R5900: Workaround exception NOP execution bug (FLX05) Fredrik Noring
2019-09-01 23:01   ` Philippe Mathieu-Daudé
2019-09-01 15:40 ` [PATCH 011/120] MIPS: R5900: Avoid pipeline hazard with the TLBP instruction Fredrik Noring
2019-09-01 17:15   ` Sergei Shtylyov
2019-09-01 17:36     ` Fredrik Noring
2019-09-01 15:40 ` [PATCH 012/120] MIPS: R5900: Avoid pipeline hazards with the TLBW[IR] instructions Fredrik Noring
2019-09-01 15:40 ` [PATCH 013/120] MIPS: R5900: Avoid pipeline hazard with the TLBR instruction Fredrik Noring
2019-09-01 15:41 ` [PATCH 014/120] MIPS: R5900: Install final length of TLB refill handler rather than 256 bytes Fredrik Noring
2019-09-01 15:41 ` [PATCH 015/120] MIPS: R5900: Verify that the TLB refill handler does not overflow Fredrik Noring
2019-09-01 15:41 ` [PATCH 016/120] MIPS: R5900: The ERET instruction has issues with delay slot and CACHE Fredrik Noring
2019-09-01 15:42 ` [PATCH 017/120] MIPS: R5900: Define CACHE instruction operation field encodings Fredrik Noring
2019-09-01 15:42 ` [PATCH 018/120] MIPS: R5900: Workaround where MSB must be 0 for the instruction cache Fredrik Noring
2019-09-01 15:42 ` [PATCH 019/120] MIPS: R5900: Use SYNC.L for data cache and SYNC.P for " Fredrik Noring
2019-09-01 15:43 ` [PATCH 020/120] MIPS: R5900: Define CP0.Config register fields Fredrik Noring
2019-09-01 23:04   ` Philippe Mathieu-Daudé
2019-09-01 15:43 ` [PATCH 021/120] MIPS: R5900: Workaround for CACHE instruction near branch delay slot Fredrik Noring
2019-09-01 15:46 ` [PATCH 022/120] MIPS: R5900: Support 64-bit inq() and outq() macros in 32-bit kernels Fredrik Noring
2019-09-04  1:04   ` Jiaxun Yang
2019-09-04 16:00     ` Maciej W. Rozycki
2019-09-01 15:46 ` [PATCH 023/120] MIPS: R5900: Add MFSA and MTSA instructions for the special SA register Fredrik Noring
2019-09-01 15:46 ` [PATCH 024/120] MIPS: PS2: Define PlayStation 2 I/O port, ROM and RAM address spaces Fredrik Noring
2019-09-01 15:47 ` [PATCH 025/120] MIPS: PS2: Define interrupt controller, DMA and timer IRQs Fredrik Noring
2019-09-01 15:47 ` [PATCH 026/120] MIPS: PS2: Interrupt controller (INTC) IRQ support Fredrik Noring
2019-09-01 15:47 ` [PATCH 027/120] MIPS: PS2: DMAC: Define DMA controller registers Fredrik Noring
2019-09-01 15:47 ` [PATCH 028/120] MIPS: PS2: DMAC: Define tag structures Fredrik Noring
2019-09-01 15:48 ` [PATCH 029/120] MIPS: PS2: DMAC: IRQ support Fredrik Noring
2019-09-01 15:48 ` [PATCH 030/120] MIPS: PS2: Timer support Fredrik Noring
2019-09-01 15:48 ` [PATCH 031/120] MIPS: PS2: SCMD: System command support Fredrik Noring
2019-09-01 15:48 ` [PATCH 032/120] MIPS: PS2: SCMD: System power off command Fredrik Noring
2019-09-01 15:48 ` [PATCH 033/120] MIPS: PS2: SCMD: Read system machine name command Fredrik Noring
2019-09-01 15:49 ` [PATCH 034/120] MIPS: PS2: SCMD: Read system command for the real-time clock (RTC) Fredrik Noring
2019-09-01 15:49 ` [PATCH 035/120] MIPS: PS2: SCMD: Set " Fredrik Noring
2019-09-01 15:49 ` [PATCH 036/120] MIPS: PS2: ROM: Iterate over the files in a given ROM directory Fredrik Noring
2019-09-01 15:49 ` [PATCH 037/120] MIPS: PS2: ROM: Find ROM files with a given name, if they exist Fredrik Noring
2019-09-01 15:50 ` [PATCH 038/120] MIPS: PS2: ROM: Read data for a given ROM file name Fredrik Noring
2019-09-02  9:05   ` Sergei Shtylyov
2019-09-04 11:46     ` Sergei Shtylyov
2019-09-06 13:07       ` Fredrik Noring
2019-09-01 15:50 ` [PATCH 039/120] MIPS: PS2: ROM: Read extended information for a given ROM file Fredrik Noring
2019-09-01 15:50 ` [PATCH 040/120] MIPS: PS2: ROM: Read and decode the ROMVER file Fredrik Noring
2019-09-01 15:52 ` [PATCH 041/120] MIPS: PS2: ROM: Resolve the name for the type in " Fredrik Noring
2019-09-01 15:52 ` [PATCH 042/120] MIPS: PS2: ROM: Resolve the name for the region " Fredrik Noring
2019-09-01 15:53 ` [PATCH 043/120] MIPS: PS2: ROM: Permit /dev/mem to access read-only memory Fredrik Noring
2019-09-01 15:53 ` [PATCH 044/120] MIPS: PS2: ROM: Sysfs module to inspect ROM files Fredrik Noring
2019-09-01 15:54 ` [PATCH 045/120] MIPS: PS2: ROM: Provide extended file information via sysfs Fredrik Noring
2019-09-01 15:54 ` [PATCH 046/120] MIPS: PS2: Identify the machine by model name Fredrik Noring
2019-09-01 15:54 ` [PATCH 047/120] MIPS: PS2: Let the system type be Sony PlayStation 2 Fredrik Noring
2019-09-01 23:09   ` Philippe Mathieu-Daudé
2019-09-01 15:55 ` [PATCH 048/120] MIPS: Define and use cpu_relax_forever() for various halting loops Fredrik Noring
2019-09-01 15:55 ` [PATCH 049/120] MIPS: PS2: Power off support Fredrik Noring
2019-09-01 15:55 ` [PATCH 050/120] MIPS: PS2: Real-time clock (RTC) driver Fredrik Noring
2019-09-01 15:56 ` [PATCH 051/120] MIPS: PS2: IOP: I/O processor DMA register PCR2 set and clear Fredrik Noring
2019-09-01 15:57 ` [PATCH 052/120] MIPS: PS2: SIF: Sub-system interface reset of the I/O processor (IOP) Fredrik Noring
2019-09-01 15:57 ` [PATCH 053/120] MIPS: PS2: IOP: Define error numbers, descriptions and errno mapping Fredrik Noring
2019-09-01 15:58 ` [PATCH 054/120] MIPS: PS2: SIF: SIF register write command support Fredrik Noring
2019-09-01 15:58 ` [PATCH 055/120] MIPS: PS2: SIF: Respond to remote procedure call (RPC) bind command Fredrik Noring
2019-09-01 15:58 ` [PATCH 056/120] MIPS: PS2: SIF: Respond to RPC bind end command Fredrik Noring
2019-09-01 15:59 ` [PATCH 057/120] MIPS: PS2: SIF: Reset the SIF0 (sub-to-main) DMA controller Fredrik Noring
2019-09-01 15:59 ` [PATCH 058/120] MIPS: PS2: SIF: Handle SIF0 (sub-to-main) RPCs via interrupts Fredrik Noring
2019-09-01 15:59 ` [PATCH 059/120] MIPS: PS2: SIF: Enable the IOP to issue SIF commands Fredrik Noring
2019-09-01 16:00 ` [PATCH 060/120] MIPS: PS2: SIF: Enable the IOP to issue SIF RPCs Fredrik Noring
2019-09-01 16:01 ` [PATCH 061/120] MIPS: PS2: SIF: sif_rpc_bind() to request an RPC server connection Fredrik Noring
2019-09-01 16:02 ` [PATCH 062/120] MIPS: PS2: SIF: sif_rpc_unbind() to release " Fredrik Noring
2019-09-01 16:02 ` [PATCH 063/120] MIPS: PS2: SIF: sif_rpc() to issue a remote procedure call Fredrik Noring
2019-09-01 16:03 ` [PATCH 064/120] MIPS: PS2: IOP: Permit /dev/mem to access IOP memory Fredrik Noring
2019-09-01 16:03 ` [PATCH 065/120] MIPS: PS2: IOP: I/O processor memory support Fredrik Noring
2019-09-01 16:10 ` [PATCH 066/120] FIXME: Export _dma_cache_{wback,wback_inv,inv} Fredrik Noring
2019-09-01 16:10 ` [PATCH 067/120] MIPS: PS2: IOP: Module linking support Fredrik Noring
2019-09-01 16:11 ` [PATCH 068/120] MIPS: PS2: IOP: Verify that modules are IRX objects Fredrik Noring
2019-09-01 16:11 ` [PATCH 069/120] MIPS: PS2: IOP: Module version compatibility verification Fredrik Noring
2019-09-01 16:11 ` [PATCH 070/120] MIPS: PS2: IOP: Avoid linking already linked library modules Fredrik Noring
2019-09-01 16:12 ` [PATCH 071/120] MIPS: PS2: IOP: Resolve module dependencies Fredrik Noring
2019-09-01 16:12 ` [PATCH 072/120] MIPS: PS2: IOP: SIF printk command support Fredrik Noring
2019-09-01 17:44   ` Sergei Shtylyov
2019-09-01 18:08     ` Fredrik Noring
2019-09-01 16:16 ` [PATCH 073/120] MIPS: PS2: IOP: Heap memory allocate and free Fredrik Noring
2019-09-01 16:16 ` [PATCH 074/120] MIPS: PS2: SIF: Request RPC IRQ command Fredrik Noring
2019-09-01 16:17 ` [PATCH 075/120] MIPS: PS2: IOP: IRQ support Fredrik Noring
2019-09-01 16:17 ` [PATCH 076/120] MIPS: PS2: GS: Define privileged Graphics Synthesizer registers Fredrik Noring
2019-09-01 16:18 ` [PATCH 077/120] MIPS: PS2: GS: Write privileged registers Fredrik Noring
2019-09-01 16:18 ` [PATCH 078/120] MIPS: PS2: GS: Read " Fredrik Noring
2019-09-01 16:18 ` [PATCH 079/120] MIPS: PS2: GS: Define privileged register structures Fredrik Noring
2019-09-01 16:19 ` [PATCH 080/120] MIPS: PS2: GS: Define gs_xorq_imr() Fredrik Noring
2019-09-01 16:20 ` [PATCH 081/120] MIPS: PS2: GS: Privileged register write macros with named fields Fredrik Noring
2019-09-01 16:20 ` [PATCH 082/120] MIPS: PS2: GS: IRQ support Fredrik Noring
2019-09-01 16:21 ` [PATCH 083/120] MIPS: PS2: GS: Define Graphics Synthesizer primitive structures Fredrik Noring
2019-09-01 16:21 ` [PATCH 084/120] MIPS: PS2: GIF: Define Graphics Synthesizer interface structures Fredrik Noring
2019-09-01 16:22 ` [PATCH 085/120] MIPS: PS2: GIF: Graphics Synthesizer interface support Fredrik Noring
2019-09-01 16:22 ` [PATCH 086/120] MIPS: PS2: GS: Graphics Synthesizer device init and video clock Fredrik Noring
2019-09-01 16:23 ` [PATCH 087/120] MIPS: PS2: GS: Compute block count and indices Fredrik Noring
2019-09-01 16:23 ` [PATCH 088/120] MIPS: PS2: GS: Primitive and texel coordinate transformations Fredrik Noring
2019-09-01 16:23 ` [PATCH 089/120] MIPS: PS2: GS: Approximate video region with ROM region Fredrik Noring
2019-09-01 16:24 ` [PATCH 090/120] macro: Extend COUNT_ARGS() from 12 to 32 arguments Fredrik Noring
2019-09-01 16:25 ` Fredrik Noring [this message]
2019-09-01 16:25 ` [PATCH 092/120] MIPS: PS2: GS: Store privileged registers with sysfs Fredrik Noring
2019-09-01 16:25 ` [PATCH 093/120] fbdev: Add fb_warn_once() variant that only prints a warning once Fredrik Noring
2019-09-01 23:12   ` Philippe Mathieu-Daudé
2019-09-01 16:26 ` [PATCH 094/120] MIPS: PS2: FB: Frame buffer driver for the PlayStation 2 Fredrik Noring
2019-09-02  1:12   ` Jiaxun Yang
2019-09-02 14:40     ` Fredrik Noring
2019-09-02 17:47       ` Aaro Koskinen
2019-09-03 14:32         ` Fredrik Noring
2019-09-03  4:01       ` Jiaxun Yang
2019-09-03 17:42         ` Fredrik Noring
2019-09-03 17:59           ` Maciej W. Rozycki
2019-09-03 18:46             ` Fredrik Noring
2019-09-01 16:30 ` [PATCH 095/120] MIPS: PS2: FB: fb_set_par() standard-definition television support Fredrik Noring
2019-09-01 16:30 ` [PATCH 096/120] MIPS: PS2: FB: fb_set_par() high-definition " Fredrik Noring
2019-09-01 16:31 ` [PATCH 097/120] MIPS: PS2: FB: fb_set_par() VESA computer display mode support Fredrik Noring
2019-09-01 16:31 ` [PATCH 098/120] MIPS: PS2: FB: Preconfigure standard PAL, NTSC and VESA display modes Fredrik Noring
2019-09-01 16:31 ` [PATCH 099/120] MIPS: PS2: FB: Reset the Graphics Synthesizer drawing environment Fredrik Noring
2019-09-01 16:32 ` [PATCH 100/120] MIPS: PS2: FB: Clear the display buffer when changing video modes Fredrik Noring
2019-09-01 16:32 ` [PATCH 101/120] MIPS: PS2: FB: fb_setcolreg() 256 colour pseudo palette support Fredrik Noring
2019-09-01 16:32 ` [PATCH 102/120] MIPS: PS2: FB: fb_settile() with font stored as palette indexed textures Fredrik Noring
2019-09-01 16:32 ` [PATCH 103/120] MIPS: PS2: FB: Hardware accelerated fb_tilecopy() support Fredrik Noring
2019-09-01 16:33 ` [PATCH 104/120] MIPS: PS2: FB: Hardware accelerated fb_tilefill() support Fredrik Noring
2019-09-01 16:33 ` [PATCH 105/120] MIPS: PS2: FB: Simplified fb_tileblit() support Fredrik Noring
2019-09-01 16:33 ` [PATCH 106/120] MIPS: PS2: FB: fb_tilecursor() placeholder Fredrik Noring
2019-09-01 16:33 ` [PATCH 107/120] MIPS: PS2: FB: Hardware accelerated fb_pan_display() support Fredrik Noring
2019-09-01 16:34 ` [PATCH 108/120] MIPS: PS2: FB: fb_blank() display power management signaling (DPMS) Fredrik Noring
2019-09-01 16:34 ` [PATCH 109/120] MIPS: PS2: FB: Disable GIF DMA completion interrupts Fredrik Noring
2019-09-01 16:34 ` [PATCH 110/120] MIPS: PS2: FB: PAL and NTSC grayscale support Fredrik Noring
2019-09-01 16:34 ` [PATCH 111/120] MIPS: PS2: FB: Analogue display mode adjustment module parameter Fredrik Noring
2019-09-01 16:35 ` [PATCH 112/120] USB: OHCI: Support for the PlayStation 2 Fredrik Noring
2019-09-01 16:35 ` [PATCH 113/120] USB: OHCI: OHCI_INTR_MIE workaround for freeze on " Fredrik Noring
2019-09-01 16:35 ` [PATCH 114/120] MIPS: PS2: Workaround for unexpected uLaunchELF CP0 Status user mode Fredrik Noring
2019-09-01 16:35 ` [PATCH 115/120] MIPS: PS2: Define initial PlayStation 2 devices Fredrik Noring
2019-09-01 16:35 ` [PATCH 116/120] MIPS: PS2: Define workarounds related to the PlayStation 2 Fredrik Noring
2019-09-01 16:36 ` [PATCH 117/120] MIPS: PS2: Define R5900 feature overrides Fredrik Noring
2019-09-01 16:36 ` [PATCH 118/120] MIPS: PS2: Define the PlayStation 2 platform Fredrik Noring
2019-09-01 16:36 ` [PATCH 119/120] MIPS: PS2: Initial support for the Sony PlayStation 2 Fredrik Noring
2019-09-01 16:37 ` [PATCH 120/120] MIPS: Fix name of BOOT_MEM_ROM_DATA Fredrik Noring
2019-09-01 23:15   ` Philippe Mathieu-Daudé
2019-09-02  1:02   ` Jiaxun Yang
2019-09-02 15:26     ` Fredrik Noring
2019-09-03  3:50       ` Jiaxun Yang
2019-09-03 16:06         ` Fredrik Noring
2019-09-04 14:19 ` [PATCH 000/120] Linux for the PlayStation 2 Paul Burton
2019-09-05 18:32   ` Fredrik Noring

Reply instructions:

You may reply publically to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ecc74e0565aa949a4a2a6a1e7cb65442010b7c9d.1567326213.git.noring@nocrew.org \
    --to=noring@nocrew.org \
    --cc=JuergenUrban@gmx.de \
    --cc=linux-mips@vger.kernel.org \
    --cc=macro@linux-mips.org \
    --cc=paul.burton@mips.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Linux-MIPS Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-mips/0 linux-mips/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-mips linux-mips/ https://lore.kernel.org/linux-mips \
		linux-mips@vger.kernel.org linux-mips@archiver.kernel.org
	public-inbox-index linux-mips

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-mips


AGPL code for this site: git clone https://public-inbox.org/ public-inbox