drm/nouveau/gpio: split g92 class from nv50
authorBen Skeggs <bskeggs@redhat.com>
Mon, 12 May 2014 05:22:42 +0000 (15:22 +1000)
committerBen Skeggs <bskeggs@redhat.com>
Wed, 11 Jun 2014 06:09:14 +0000 (16:09 +1000)
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
drivers/gpu/drm/nouveau/Makefile
drivers/gpu/drm/nouveau/core/engine/device/nv50.c
drivers/gpu/drm/nouveau/core/engine/device/nvc0.c
drivers/gpu/drm/nouveau/core/include/subdev/gpio.h
drivers/gpu/drm/nouveau/core/subdev/gpio/base.c
drivers/gpu/drm/nouveau/core/subdev/gpio/nv10.c
drivers/gpu/drm/nouveau/core/subdev/gpio/nv50.c
drivers/gpu/drm/nouveau/core/subdev/gpio/nv92.c [new file with mode: 0644]
drivers/gpu/drm/nouveau/core/subdev/gpio/nvd0.c
drivers/gpu/drm/nouveau/core/subdev/gpio/nve0.c
drivers/gpu/drm/nouveau/core/subdev/gpio/priv.h

index 1aaa2ef577d9eb7a71d2f3d71631d042763bf234..4b60483f64022d1c4c679b43c4b680710ef583ff 100644 (file)
@@ -125,6 +125,7 @@ nouveau-y += core/subdev/fb/gddr5.o
 nouveau-y += core/subdev/gpio/base.o
 nouveau-y += core/subdev/gpio/nv10.o
 nouveau-y += core/subdev/gpio/nv50.o
+nouveau-y += core/subdev/gpio/nv92.o
 nouveau-y += core/subdev/gpio/nvd0.o
 nouveau-y += core/subdev/gpio/nve0.o
 nouveau-y += core/subdev/i2c/base.o
index 72999a8c7448da66e53ab4a5cfc5e2adb42acce6..4f35781e5e8070370e8429f931a74bb514616c72 100644 (file)
@@ -141,7 +141,7 @@ nv50_identify(struct nouveau_device *device)
        case 0x92:
                device->cname = "G92";
                device->oclass[NVDEV_SUBDEV_VBIOS  ] = &nouveau_bios_oclass;
-               device->oclass[NVDEV_SUBDEV_GPIO   ] =  nv50_gpio_oclass;
+               device->oclass[NVDEV_SUBDEV_GPIO   ] =  nv92_gpio_oclass;
                device->oclass[NVDEV_SUBDEV_I2C    ] = &nv50_i2c_oclass;
                device->oclass[NVDEV_SUBDEV_CLOCK  ] =  nv84_clock_oclass;
                device->oclass[NVDEV_SUBDEV_THERM  ] = &nv84_therm_oclass;
@@ -169,7 +169,7 @@ nv50_identify(struct nouveau_device *device)
        case 0x94:
                device->cname = "G94";
                device->oclass[NVDEV_SUBDEV_VBIOS  ] = &nouveau_bios_oclass;
-               device->oclass[NVDEV_SUBDEV_GPIO   ] =  nv50_gpio_oclass;
+               device->oclass[NVDEV_SUBDEV_GPIO   ] =  nv92_gpio_oclass;
                device->oclass[NVDEV_SUBDEV_I2C    ] = &nv94_i2c_oclass;
                device->oclass[NVDEV_SUBDEV_CLOCK  ] =  nv84_clock_oclass;
                device->oclass[NVDEV_SUBDEV_THERM  ] = &nv84_therm_oclass;
@@ -197,7 +197,7 @@ nv50_identify(struct nouveau_device *device)
        case 0x96:
                device->cname = "G96";
                device->oclass[NVDEV_SUBDEV_VBIOS  ] = &nouveau_bios_oclass;
-               device->oclass[NVDEV_SUBDEV_GPIO   ] =  nv50_gpio_oclass;
+               device->oclass[NVDEV_SUBDEV_GPIO   ] =  nv92_gpio_oclass;
                device->oclass[NVDEV_SUBDEV_I2C    ] = &nv94_i2c_oclass;
                device->oclass[NVDEV_SUBDEV_CLOCK  ] =  nv84_clock_oclass;
                device->oclass[NVDEV_SUBDEV_THERM  ] = &nv84_therm_oclass;
@@ -225,7 +225,7 @@ nv50_identify(struct nouveau_device *device)
        case 0x98:
                device->cname = "G98";
                device->oclass[NVDEV_SUBDEV_VBIOS  ] = &nouveau_bios_oclass;
-               device->oclass[NVDEV_SUBDEV_GPIO   ] =  nv50_gpio_oclass;
+               device->oclass[NVDEV_SUBDEV_GPIO   ] =  nv92_gpio_oclass;
                device->oclass[NVDEV_SUBDEV_I2C    ] = &nv94_i2c_oclass;
                device->oclass[NVDEV_SUBDEV_CLOCK  ] =  nv84_clock_oclass;
                device->oclass[NVDEV_SUBDEV_THERM  ] = &nv84_therm_oclass;
@@ -253,7 +253,7 @@ nv50_identify(struct nouveau_device *device)
        case 0xa0:
                device->cname = "G200";
                device->oclass[NVDEV_SUBDEV_VBIOS  ] = &nouveau_bios_oclass;
-               device->oclass[NVDEV_SUBDEV_GPIO   ] =  nv50_gpio_oclass;
+               device->oclass[NVDEV_SUBDEV_GPIO   ] =  nv92_gpio_oclass;
                device->oclass[NVDEV_SUBDEV_I2C    ] = &nv50_i2c_oclass;
                device->oclass[NVDEV_SUBDEV_CLOCK  ] =  nv84_clock_oclass;
                device->oclass[NVDEV_SUBDEV_THERM  ] = &nv84_therm_oclass;
@@ -281,7 +281,7 @@ nv50_identify(struct nouveau_device *device)
        case 0xaa:
                device->cname = "MCP77/MCP78";
                device->oclass[NVDEV_SUBDEV_VBIOS  ] = &nouveau_bios_oclass;
-               device->oclass[NVDEV_SUBDEV_GPIO   ] =  nv50_gpio_oclass;
+               device->oclass[NVDEV_SUBDEV_GPIO   ] =  nv92_gpio_oclass;
                device->oclass[NVDEV_SUBDEV_I2C    ] = &nv94_i2c_oclass;
                device->oclass[NVDEV_SUBDEV_CLOCK  ] =  nvaa_clock_oclass;
                device->oclass[NVDEV_SUBDEV_THERM  ] = &nv84_therm_oclass;
@@ -309,7 +309,7 @@ nv50_identify(struct nouveau_device *device)
        case 0xac:
                device->cname = "MCP79/MCP7A";
                device->oclass[NVDEV_SUBDEV_VBIOS  ] = &nouveau_bios_oclass;
-               device->oclass[NVDEV_SUBDEV_GPIO   ] =  nv50_gpio_oclass;
+               device->oclass[NVDEV_SUBDEV_GPIO   ] =  nv92_gpio_oclass;
                device->oclass[NVDEV_SUBDEV_I2C    ] = &nv94_i2c_oclass;
                device->oclass[NVDEV_SUBDEV_CLOCK  ] =  nvaa_clock_oclass;
                device->oclass[NVDEV_SUBDEV_THERM  ] = &nv84_therm_oclass;
@@ -337,7 +337,7 @@ nv50_identify(struct nouveau_device *device)
        case 0xa3:
                device->cname = "GT215";
                device->oclass[NVDEV_SUBDEV_VBIOS  ] = &nouveau_bios_oclass;
-               device->oclass[NVDEV_SUBDEV_GPIO   ] =  nv50_gpio_oclass;
+               device->oclass[NVDEV_SUBDEV_GPIO   ] =  nv92_gpio_oclass;
                device->oclass[NVDEV_SUBDEV_I2C    ] = &nv94_i2c_oclass;
                device->oclass[NVDEV_SUBDEV_CLOCK  ] = &nva3_clock_oclass;
                device->oclass[NVDEV_SUBDEV_THERM  ] = &nva3_therm_oclass;
@@ -367,7 +367,7 @@ nv50_identify(struct nouveau_device *device)
        case 0xa5:
                device->cname = "GT216";
                device->oclass[NVDEV_SUBDEV_VBIOS  ] = &nouveau_bios_oclass;
-               device->oclass[NVDEV_SUBDEV_GPIO   ] =  nv50_gpio_oclass;
+               device->oclass[NVDEV_SUBDEV_GPIO   ] =  nv92_gpio_oclass;
                device->oclass[NVDEV_SUBDEV_I2C    ] = &nv94_i2c_oclass;
                device->oclass[NVDEV_SUBDEV_CLOCK  ] = &nva3_clock_oclass;
                device->oclass[NVDEV_SUBDEV_THERM  ] = &nva3_therm_oclass;
@@ -396,7 +396,7 @@ nv50_identify(struct nouveau_device *device)
        case 0xa8:
                device->cname = "GT218";
                device->oclass[NVDEV_SUBDEV_VBIOS  ] = &nouveau_bios_oclass;
-               device->oclass[NVDEV_SUBDEV_GPIO   ] =  nv50_gpio_oclass;
+               device->oclass[NVDEV_SUBDEV_GPIO   ] =  nv92_gpio_oclass;
                device->oclass[NVDEV_SUBDEV_I2C    ] = &nv94_i2c_oclass;
                device->oclass[NVDEV_SUBDEV_CLOCK  ] = &nva3_clock_oclass;
                device->oclass[NVDEV_SUBDEV_THERM  ] = &nva3_therm_oclass;
@@ -425,7 +425,7 @@ nv50_identify(struct nouveau_device *device)
        case 0xaf:
                device->cname = "MCP89";
                device->oclass[NVDEV_SUBDEV_VBIOS  ] = &nouveau_bios_oclass;
-               device->oclass[NVDEV_SUBDEV_GPIO   ] =  nv50_gpio_oclass;
+               device->oclass[NVDEV_SUBDEV_GPIO   ] =  nv92_gpio_oclass;
                device->oclass[NVDEV_SUBDEV_I2C    ] = &nv94_i2c_oclass;
                device->oclass[NVDEV_SUBDEV_CLOCK  ] = &nva3_clock_oclass;
                device->oclass[NVDEV_SUBDEV_THERM  ] = &nva3_therm_oclass;
index e62a25294a9e12b70d69b7f0f7dadcf4809197ff..4bef0e4cfb2507acbf42a3ffaba828c0eb6c30f0 100644 (file)
@@ -60,7 +60,7 @@ nvc0_identify(struct nouveau_device *device)
        case 0xc0:
                device->cname = "GF100";
                device->oclass[NVDEV_SUBDEV_VBIOS  ] = &nouveau_bios_oclass;
-               device->oclass[NVDEV_SUBDEV_GPIO   ] =  nv50_gpio_oclass;
+               device->oclass[NVDEV_SUBDEV_GPIO   ] =  nv92_gpio_oclass;
                device->oclass[NVDEV_SUBDEV_I2C    ] = &nv94_i2c_oclass;
                device->oclass[NVDEV_SUBDEV_CLOCK  ] = &nvc0_clock_oclass;
                device->oclass[NVDEV_SUBDEV_THERM  ] = &nva3_therm_oclass;
@@ -92,7 +92,7 @@ nvc0_identify(struct nouveau_device *device)
        case 0xc4:
                device->cname = "GF104";
                device->oclass[NVDEV_SUBDEV_VBIOS  ] = &nouveau_bios_oclass;
-               device->oclass[NVDEV_SUBDEV_GPIO   ] =  nv50_gpio_oclass;
+               device->oclass[NVDEV_SUBDEV_GPIO   ] =  nv92_gpio_oclass;
                device->oclass[NVDEV_SUBDEV_I2C    ] = &nv94_i2c_oclass;
                device->oclass[NVDEV_SUBDEV_CLOCK  ] = &nvc0_clock_oclass;
                device->oclass[NVDEV_SUBDEV_THERM  ] = &nva3_therm_oclass;
@@ -124,7 +124,7 @@ nvc0_identify(struct nouveau_device *device)
        case 0xc3:
                device->cname = "GF106";
                device->oclass[NVDEV_SUBDEV_VBIOS  ] = &nouveau_bios_oclass;
-               device->oclass[NVDEV_SUBDEV_GPIO   ] =  nv50_gpio_oclass;
+               device->oclass[NVDEV_SUBDEV_GPIO   ] =  nv92_gpio_oclass;
                device->oclass[NVDEV_SUBDEV_I2C    ] = &nv94_i2c_oclass;
                device->oclass[NVDEV_SUBDEV_CLOCK  ] = &nvc0_clock_oclass;
                device->oclass[NVDEV_SUBDEV_THERM  ] = &nva3_therm_oclass;
@@ -155,7 +155,7 @@ nvc0_identify(struct nouveau_device *device)
        case 0xce:
                device->cname = "GF114";
                device->oclass[NVDEV_SUBDEV_VBIOS  ] = &nouveau_bios_oclass;
-               device->oclass[NVDEV_SUBDEV_GPIO   ] =  nv50_gpio_oclass;
+               device->oclass[NVDEV_SUBDEV_GPIO   ] =  nv92_gpio_oclass;
                device->oclass[NVDEV_SUBDEV_I2C    ] = &nv94_i2c_oclass;
                device->oclass[NVDEV_SUBDEV_CLOCK  ] = &nvc0_clock_oclass;
                device->oclass[NVDEV_SUBDEV_THERM  ] = &nva3_therm_oclass;
@@ -187,7 +187,7 @@ nvc0_identify(struct nouveau_device *device)
        case 0xcf:
                device->cname = "GF116";
                device->oclass[NVDEV_SUBDEV_VBIOS  ] = &nouveau_bios_oclass;
-               device->oclass[NVDEV_SUBDEV_GPIO   ] =  nv50_gpio_oclass;
+               device->oclass[NVDEV_SUBDEV_GPIO   ] =  nv92_gpio_oclass;
                device->oclass[NVDEV_SUBDEV_I2C    ] = &nv94_i2c_oclass;
                device->oclass[NVDEV_SUBDEV_CLOCK  ] = &nvc0_clock_oclass;
                device->oclass[NVDEV_SUBDEV_THERM  ] = &nva3_therm_oclass;
@@ -219,7 +219,7 @@ nvc0_identify(struct nouveau_device *device)
        case 0xc1:
                device->cname = "GF108";
                device->oclass[NVDEV_SUBDEV_VBIOS  ] = &nouveau_bios_oclass;
-               device->oclass[NVDEV_SUBDEV_GPIO   ] =  nv50_gpio_oclass;
+               device->oclass[NVDEV_SUBDEV_GPIO   ] =  nv92_gpio_oclass;
                device->oclass[NVDEV_SUBDEV_I2C    ] = &nv94_i2c_oclass;
                device->oclass[NVDEV_SUBDEV_CLOCK  ] = &nvc0_clock_oclass;
                device->oclass[NVDEV_SUBDEV_THERM  ] = &nva3_therm_oclass;
@@ -250,7 +250,7 @@ nvc0_identify(struct nouveau_device *device)
        case 0xc8:
                device->cname = "GF110";
                device->oclass[NVDEV_SUBDEV_VBIOS  ] = &nouveau_bios_oclass;
-               device->oclass[NVDEV_SUBDEV_GPIO   ] =  nv50_gpio_oclass;
+               device->oclass[NVDEV_SUBDEV_GPIO   ] =  nv92_gpio_oclass;
                device->oclass[NVDEV_SUBDEV_I2C    ] = &nv94_i2c_oclass;
                device->oclass[NVDEV_SUBDEV_CLOCK  ] = &nvc0_clock_oclass;
                device->oclass[NVDEV_SUBDEV_THERM  ] = &nva3_therm_oclass;
index 0cab56ff68130561c724888c5f6b4c3cdcf8f24a..856216aa3b33d3009fe9afd85e5f0a89af4e7240 100644 (file)
@@ -31,22 +31,9 @@ nouveau_gpio(void *obj)
        return (void *)nv_device(obj)->subdev[NVDEV_SUBDEV_GPIO];
 }
 
-#define nouveau_gpio_create(p,e,o,l,d)                                         \
-       nouveau_gpio_create_((p), (e), (o), (l), sizeof(**d), (void **)d)
-#define nouveau_gpio_destroy(p) ({                                             \
-       struct nouveau_gpio *gpio = (p);                                       \
-       _nouveau_gpio_dtor(nv_object(gpio));                                   \
-})
-#define nouveau_gpio_fini(p,s)                                                 \
-       nouveau_subdev_fini(&(p)->base, (s))
-
-int  nouveau_gpio_create_(struct nouveau_object *, struct nouveau_object *,
-                         struct nouveau_oclass *, int, int, void **);
-void _nouveau_gpio_dtor(struct nouveau_object *);
-int  nouveau_gpio_init(struct nouveau_gpio *);
-
 extern struct nouveau_oclass *nv10_gpio_oclass;
 extern struct nouveau_oclass *nv50_gpio_oclass;
+extern struct nouveau_oclass *nv92_gpio_oclass;
 extern struct nouveau_oclass *nvd0_gpio_oclass;
 extern struct nouveau_oclass *nve0_gpio_oclass;
 
index c2f074274d9d0b05360d95ac31bae9a52cc3d46e..20cb5f2e2298672928bc77684b4eeacb562918f2 100644 (file)
  * Authors: Ben Skeggs
  */
 
-#include <subdev/gpio.h>
 #include <subdev/bios.h>
 #include <subdev/bios/gpio.h>
 
+#include "priv.h"
+
 static int
 nouveau_gpio_drive(struct nouveau_gpio *gpio,
                   int idx, int line, int dir, int out)
@@ -113,9 +114,10 @@ _nouveau_gpio_dtor(struct nouveau_object *object)
 int
 nouveau_gpio_create_(struct nouveau_object *parent,
                     struct nouveau_object *engine,
-                    struct nouveau_oclass *oclass, int lines,
+                    struct nouveau_oclass *oclass,
                     int length, void **pobject)
 {
+       const struct nouveau_gpio_impl *impl = (void *)oclass;
        struct nouveau_gpio *gpio;
        int ret;
 
@@ -125,7 +127,7 @@ nouveau_gpio_create_(struct nouveau_object *parent,
        if (ret)
                return ret;
 
-       ret = nouveau_event_create(1, lines, &gpio->events);
+       ret = nouveau_event_create(1, impl->lines, &gpio->events);
        if (ret)
                return ret;
 
index e655531f13154c250a64056282c7e013a2f903f3..b76e63493f6b17d88d3f2286bee40409363540aa 100644 (file)
@@ -121,7 +121,7 @@ nv10_gpio_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
        struct nv10_gpio_priv *priv;
        int ret;
 
-       ret = nouveau_gpio_create(parent, engine, oclass, 16, &priv);
+       ret = nouveau_gpio_create(parent, engine, oclass, &priv);
        *pobject = nv_object(priv);
        if (ret)
                return ret;
@@ -166,12 +166,13 @@ nv10_gpio_fini(struct nouveau_object *object, bool suspend)
 }
 
 struct nouveau_oclass *
-nv10_gpio_oclass = &(struct nouveau_oclass) {
-       .handle = NV_SUBDEV(GPIO, 0x10),
-       .ofuncs = &(struct nouveau_ofuncs) {
+nv10_gpio_oclass = &(struct nouveau_gpio_impl) {
+       .base.handle = NV_SUBDEV(GPIO, 0x10),
+       .base.ofuncs = &(struct nouveau_ofuncs) {
                .ctor = nv10_gpio_ctor,
                .dtor = nv10_gpio_dtor,
                .init = nv10_gpio_init,
                .fini = nv10_gpio_fini,
        },
-};
+       .lines = 16,
+}.base;
index 19529d0ca76b321584cbc75baa5e5c3213caa0a6..59ad54a7651b37924af42044443dbf31d02d4b28 100644 (file)
@@ -138,7 +138,7 @@ nv50_gpio_intr_disable(struct nouveau_event *event, int line)
        nv_mask(event->priv, addr + 0x00, mask, 0x00000000);
 }
 
-static int
+int
 nv50_gpio_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
               struct nouveau_oclass *oclass, void *data, u32 size,
               struct nouveau_object **pobject)
@@ -146,9 +146,7 @@ nv50_gpio_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
        struct nv50_gpio_priv *priv;
        int ret;
 
-       ret = nouveau_gpio_create(parent, engine, oclass,
-                                 nv_device(parent)->chipset > 0x92 ? 32 : 16,
-                                 &priv);
+       ret = nouveau_gpio_create(parent, engine, oclass, &priv);
        *pobject = nv_object(priv);
        if (ret)
                return ret;
@@ -202,12 +200,13 @@ nv50_gpio_fini(struct nouveau_object *object, bool suspend)
 }
 
 struct nouveau_oclass *
-nv50_gpio_oclass = &(struct nouveau_oclass) {
-       .handle = NV_SUBDEV(GPIO, 0x50),
-       .ofuncs = &(struct nouveau_ofuncs) {
+nv50_gpio_oclass = &(struct nouveau_gpio_impl) {
+       .base.handle = NV_SUBDEV(GPIO, 0x50),
+       .base.ofuncs = &(struct nouveau_ofuncs) {
                .ctor = nv50_gpio_ctor,
                .dtor = nv50_gpio_dtor,
                .init = nv50_gpio_init,
                .fini = nv50_gpio_fini,
        },
-};
+       .lines = 16.
+}.base;
diff --git a/drivers/gpu/drm/nouveau/core/subdev/gpio/nv92.c b/drivers/gpu/drm/nouveau/core/subdev/gpio/nv92.c
new file mode 100644 (file)
index 0000000..b4e7fc3
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2012 Red Hat Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Authors: Ben Skeggs
+ */
+
+#include "priv.h"
+
+struct nouveau_oclass *
+nv92_gpio_oclass = &(struct nouveau_gpio_impl) {
+       .base.handle = NV_SUBDEV(GPIO, 0x92),
+       .base.ofuncs = &(struct nouveau_ofuncs) {
+               .ctor = nv50_gpio_ctor,
+               .dtor = nv50_gpio_dtor,
+               .init = nv50_gpio_init,
+               .fini = nv50_gpio_fini,
+       },
+       .lines = 32.
+}.base;
index 388c07866b0f69f631110943710fa003702a4777..4c618a8d0c6d44299038f41d2a8874169c94aa2a 100644 (file)
@@ -80,7 +80,7 @@ nvd0_gpio_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
        struct nvd0_gpio_priv *priv;
        int ret;
 
-       ret = nouveau_gpio_create(parent, engine, oclass, 32, &priv);
+       ret = nouveau_gpio_create(parent, engine, oclass, &priv);
        *pobject = nv_object(priv);
        if (ret)
                return ret;
@@ -96,12 +96,13 @@ nvd0_gpio_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
 }
 
 struct nouveau_oclass *
-nvd0_gpio_oclass = &(struct nouveau_oclass) {
-       .handle = NV_SUBDEV(GPIO, 0xd0),
-       .ofuncs = &(struct nouveau_ofuncs) {
+nvd0_gpio_oclass = &(struct nouveau_gpio_impl) {
+       .base.handle = NV_SUBDEV(GPIO, 0xd0),
+       .base.ofuncs = &(struct nouveau_ofuncs) {
                .ctor = nvd0_gpio_ctor,
                .dtor = nv50_gpio_dtor,
                .init = nv50_gpio_init,
                .fini = nv50_gpio_fini,
        },
-};
+       .lines = 32,
+}.base;
index 87f6304b6ab1189de488120167e6ba4eadc8b351..277693aa472e181cc38e8748160a1db18705b088 100644 (file)
@@ -104,7 +104,7 @@ nve0_gpio_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
        struct nve0_gpio_priv *priv;
        int ret;
 
-       ret = nouveau_gpio_create(parent, engine, oclass, 32, &priv);
+       ret = nouveau_gpio_create(parent, engine, oclass, &priv);
        *pobject = nv_object(priv);
        if (ret)
                return ret;
@@ -120,12 +120,13 @@ nve0_gpio_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
 }
 
 struct nouveau_oclass *
-nve0_gpio_oclass = &(struct nouveau_oclass) {
-       .handle = NV_SUBDEV(GPIO, 0xe0),
-       .ofuncs = &(struct nouveau_ofuncs) {
+nve0_gpio_oclass = &(struct nouveau_gpio_impl) {
+       .base.handle = NV_SUBDEV(GPIO, 0xe0),
+       .base.ofuncs = &(struct nouveau_ofuncs) {
                .ctor = nve0_gpio_ctor,
                .dtor = nv50_gpio_dtor,
                .init = nve0_gpio_init,
                .fini = nve0_gpio_fini,
        },
-};
+       .lines = 32,
+}.base;
index 2ee1c895c7825ab46d21ca8a67ceb1762f90fd38..d0e0ba19dcb8211c809a4775bb992bbd4ba2808e 100644 (file)
@@ -3,6 +3,23 @@
 
 #include <subdev/gpio.h>
 
+#define nouveau_gpio_create(p,e,o,d)                                           \
+       nouveau_gpio_create_((p), (e), (o), sizeof(**d), (void **)d)
+#define nouveau_gpio_destroy(p) ({                                             \
+       struct nouveau_gpio *gpio = (p);                                       \
+       _nouveau_gpio_dtor(nv_object(gpio));                                   \
+})
+#define nouveau_gpio_fini(p,s)                                                 \
+       nouveau_subdev_fini(&(p)->base, (s))
+
+int  nouveau_gpio_create_(struct nouveau_object *, struct nouveau_object *,
+                         struct nouveau_oclass *, int, void **);
+void _nouveau_gpio_dtor(struct nouveau_object *);
+int  nouveau_gpio_init(struct nouveau_gpio *);
+
+int  nv50_gpio_ctor(struct nouveau_object *, struct nouveau_object *,
+                   struct nouveau_oclass *, void *, u32,
+                   struct nouveau_object **);
 void nv50_gpio_dtor(struct nouveau_object *);
 int  nv50_gpio_init(struct nouveau_object *);
 int  nv50_gpio_fini(struct nouveau_object *, bool);
@@ -14,4 +31,10 @@ void nvd0_gpio_reset(struct nouveau_gpio *, u8);
 int  nvd0_gpio_drive(struct nouveau_gpio *, int, int, int);
 int  nvd0_gpio_sense(struct nouveau_gpio *, int);
 
+struct nouveau_gpio_impl {
+       struct nouveau_oclass base;
+       int lines;
+};
+
+
 #endif