Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/sgimips/dev add DDC2 support. Not too useful yet.
details: https://anonhg.NetBSD.org/src/rev/beed6c334e7c
branches: trunk
changeset: 763699:beed6c334e7c
user: macallan <macallan%NetBSD.org@localhost>
date: Thu Mar 31 00:01:08 2011 +0000
description:
add DDC2 support. Not too useful yet.
diffstat:
sys/arch/sgimips/dev/crmfb.c | 147 +++++++++++++++++++++++++++++++++++++++-
sys/arch/sgimips/dev/crmfbreg.h | 6 +-
2 files changed, 148 insertions(+), 5 deletions(-)
diffs (220 lines):
diff -r 6b80b45d42e2 -r beed6c334e7c sys/arch/sgimips/dev/crmfb.c
--- a/sys/arch/sgimips/dev/crmfb.c Wed Mar 30 22:57:24 2011 +0000
+++ b/sys/arch/sgimips/dev/crmfb.c Thu Mar 31 00:01:08 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: crmfb.c,v 1.29 2011/03/30 19:16:35 macallan Exp $ */
+/* $NetBSD: crmfb.c,v 1.30 2011/03/31 00:01:08 macallan Exp $ */
/*-
* Copyright (c) 2007 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: crmfb.c,v 1.29 2011/03/30 19:16:35 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: crmfb.c,v 1.30 2011/03/31 00:01:08 macallan Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -54,6 +54,12 @@
#include <dev/rasops/rasops.h>
#include <dev/wscons/wsdisplay_vconsvar.h>
+#include <dev/i2c/i2cvar.h>
+#include <dev/i2c/i2c_bitbang.h>
+#include <dev/i2c/ddcvar.h>
+#include <dev/videomode/videomode.h>
+#include <dev/videomode/edidvar.h>
+
#include <arch/sgimips/dev/crmfbreg.h>
/*#define CRMFB_DEBUG*/
@@ -120,6 +126,8 @@
struct crmfb_softc {
device_t sc_dev;
struct vcons_data sc_vd;
+ struct i2c_controller sc_i2c;
+ int sc_dir;
bus_space_tag_t sc_iot;
bus_space_handle_t sc_ioh;
@@ -182,6 +190,33 @@
static void crmfb_cursor(void *, int, int, int);
static void crmfb_putchar(void *, int, int, u_int, long);
+/* I2C glue */
+static int crmfb_i2c_acquire_bus(void *, int);
+static void crmfb_i2c_release_bus(void *, int);
+static int crmfb_i2c_send_start(void *, int);
+static int crmfb_i2c_send_stop(void *, int);
+static int crmfb_i2c_initiate_xfer(void *, i2c_addr_t, int);
+static int crmfb_i2c_read_byte(void *, uint8_t *, int);
+static int crmfb_i2c_write_byte(void *, uint8_t, int);
+
+/* I2C bitbang glue */
+static void crmfb_i2cbb_set_bits(void *, uint32_t);
+static void crmfb_i2cbb_set_dir(void *, uint32_t);
+static uint32_t crmfb_i2cbb_read(void *);
+
+static const struct i2c_bitbang_ops crmfb_i2cbb_ops = {
+ crmfb_i2cbb_set_bits,
+ crmfb_i2cbb_set_dir,
+ crmfb_i2cbb_read,
+ {
+ CRMFB_I2C_SDA,
+ CRMFB_I2C_SCL,
+ 0,
+ 1
+ }
+};
+static void crmfb_setup_ddc(struct crmfb_softc *);
+
CFATTACH_DECL_NEW(crmfb, sizeof(struct crmfb_softc),
crmfb_match, crmfb_attach, NULL, NULL);
@@ -223,6 +258,8 @@
if (rv)
panic("crmfb_attach: can't map rendering engine");
+ //crmfb_setup_ddc(sc);
+
/* determine mode configured by firmware */
d = bus_space_read_4(sc->sc_iot, sc->sc_ioh, CRMFB_VT_HCMAP);
sc->sc_width = (d >> CRMFB_VT_HCMAP_ON_SHIFT) & 0xfff;
@@ -351,6 +388,7 @@
#ifdef CRMFB_DEBUG
crmfb_test_mte(sc);
#endif
+ crmfb_setup_ddc(sc);
return;
}
@@ -1435,3 +1473,108 @@
}
}
}
+
+static void
+crmfb_setup_ddc(struct crmfb_softc *sc)
+{
+ int i;
+ char edid_data[128];
+ struct edid_info ei;
+
+ memset(edid_data, 0, 128);
+ sc->sc_i2c.ic_cookie = sc;
+ sc->sc_i2c.ic_acquire_bus = crmfb_i2c_acquire_bus;
+ sc->sc_i2c.ic_release_bus = crmfb_i2c_release_bus;
+ sc->sc_i2c.ic_send_start = crmfb_i2c_send_start;
+ sc->sc_i2c.ic_send_stop = crmfb_i2c_send_stop;
+ sc->sc_i2c.ic_initiate_xfer = crmfb_i2c_initiate_xfer;
+ sc->sc_i2c.ic_read_byte = crmfb_i2c_read_byte;
+ sc->sc_i2c.ic_write_byte = crmfb_i2c_write_byte;
+ sc->sc_i2c.ic_exec = NULL;
+ i = 0;
+ while (edid_data[1] == 0 && i++ < 10)
+ ddc_read_edid(&sc->sc_i2c, edid_data, 128);
+ if (i > 1)
+ aprint_debug_dev(sc->sc_dev,
+ "had to try %d times to get EDID data\n", i);
+ if (i < 11) {
+ edid_parse(edid_data, &ei);
+ edid_print(&ei);
+ }
+}
+
+/* I2C bitbanging */
+static void
+crmfb_i2cbb_set_bits(void *cookie, uint32_t bits)
+{
+ struct crmfb_softc *sc = cookie;
+
+ bus_space_write_4(sc->sc_iot, sc->sc_ioh, CRMFB_I2C_VGA, bits ^ 3);
+}
+
+static void
+crmfb_i2cbb_set_dir(void *cookie, uint32_t dir)
+{
+
+ /* Nothing to do */
+}
+
+static uint32_t
+crmfb_i2cbb_read(void *cookie)
+{
+ struct crmfb_softc *sc = cookie;
+
+ return bus_space_read_4(sc->sc_iot, sc->sc_ioh, CRMFB_I2C_VGA) ^ 3;
+}
+
+/* higher level I2C stuff */
+static int
+crmfb_i2c_acquire_bus(void *cookie, int flags)
+{
+
+ /* private bus */
+ return 0;
+}
+
+static void
+crmfb_i2c_release_bus(void *cookie, int flags)
+{
+
+ /* private bus */
+}
+
+static int
+crmfb_i2c_send_start(void *cookie, int flags)
+{
+
+ return i2c_bitbang_send_start(cookie, flags, &crmfb_i2cbb_ops);
+}
+
+static int
+crmfb_i2c_send_stop(void *cookie, int flags)
+{
+
+ return i2c_bitbang_send_stop(cookie, flags, &crmfb_i2cbb_ops);
+}
+
+static int
+crmfb_i2c_initiate_xfer(void *cookie, i2c_addr_t addr, int flags)
+{
+
+ return i2c_bitbang_initiate_xfer(cookie, addr, flags,
+ &crmfb_i2cbb_ops);
+}
+
+static int
+crmfb_i2c_read_byte(void *cookie, uint8_t *valp, int flags)
+{
+
+ return i2c_bitbang_read_byte(cookie, valp, flags, &crmfb_i2cbb_ops);
+}
+
+static int
+crmfb_i2c_write_byte(void *cookie, uint8_t val, int flags)
+{
+
+ return i2c_bitbang_write_byte(cookie, val, flags, &crmfb_i2cbb_ops);
+}
diff -r 6b80b45d42e2 -r beed6c334e7c sys/arch/sgimips/dev/crmfbreg.h
--- a/sys/arch/sgimips/dev/crmfbreg.h Wed Mar 30 22:57:24 2011 +0000
+++ b/sys/arch/sgimips/dev/crmfbreg.h Thu Mar 31 00:01:08 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: crmfbreg.h,v 1.12 2011/03/30 18:25:31 macallan Exp $ */
+/* $NetBSD: crmfbreg.h,v 1.13 2011/03/31 00:01:08 macallan Exp $ */
/*-
* Copyright (c) 2007 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -74,8 +74,8 @@
#define CRMFB_DOTCLOCK_TUPI 0x02000000 /* ? */
#define CRMFB_I2C_VGA 0x00000008
-#define CRMFB_I2C_SDA 0x00000001
-#define CRMFB_I2C_SCL 0x00000002
+#define CRMFB_I2C_SDA 0x00000001 /* these bits are */
+#define CRMFB_I2C_SCL 0x00000002 /* low active */
#define CRMFB_SYSCLK 0x0000000c
Home |
Main Index |
Thread Index |
Old Index