Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/arm/omap Work in progress on a driver for the graph...



details:   https://anonhg.NetBSD.org/src/rev/03e7d942397f
branches:  trunk
changeset: 797390:03e7d942397f
user:      bouyer <bouyer%NetBSD.org@localhost>
date:      Wed Jul 16 18:30:43 2014 +0000

description:
Work in progress on a driver for the graphic controller found in TI am355x SoCs,
based on the FreeBSD driver.
Only dumb framebuffer mode supported.
At this time, the video timings are hardcoded in the driver's source.
The timings inclued here are for the 12" 1280x800 LCD+LVDS cape from
Chalk Elec.
A better way to define video modes is clearly needed.

diffstat:

 sys/arch/arm/omap/tifb.c    |  1068 +++++++++++++++++++++++++++++++++++++++++++
 sys/arch/arm/omap/tifbreg.h |   124 ++++
 2 files changed, 1192 insertions(+), 0 deletions(-)

diffs (truncated from 1200 to 300 lines):

diff -r b060dcc9b520 -r 03e7d942397f sys/arch/arm/omap/tifb.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/arm/omap/tifb.c  Wed Jul 16 18:30:43 2014 +0000
@@ -0,0 +1,1068 @@
+/*     $NetBSD: tifb.c,v 1.1 2014/07/16 18:30:43 bouyer Exp $  */
+
+/*
+ * Copyright (c) 2010 Michael Lorenz
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Copyright 2013 Oleksandr Tymoshenko <gonzo%freebsd.org@localhost>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * A framebuffer driver for TI 35xx built-in video controller
+ * tested on beaglebone
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: tifb.c,v 1.1 2014/07/16 18:30:43 bouyer Exp $");
+
+#include "opt_omap.h"
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/device.h>
+#include <sys/malloc.h>
+#include <sys/lwp.h>
+#include <sys/kauth.h>
+
+#include <uvm/uvm_extern.h>
+
+#include <dev/videomode/videomode.h>
+
+#include <sys/bus.h>
+#include <arm/omap/tifbreg.h>
+#include <arm/omap/omap_var.h>
+#include <arm/omap/omap2_obiovar.h>
+#include <arm/omap/omap2_obioreg.h>
+#ifdef TI_AM335X
+#  include <arm/omap/am335x_prcm.h>
+#  include <arm/omap/omap2_prcm.h>
+#  include <arm/omap/sitara_cm.h>
+#  include <arm/omap/sitara_cmreg.h>
+#endif
+
+#include <dev/wscons/wsdisplayvar.h>
+#include <dev/wscons/wsconsio.h>
+#include <dev/wsfont/wsfont.h>
+#include <dev/rasops/rasops.h>
+#include <dev/wscons/wsdisplay_vconsvar.h>
+
+#include <dev/videomode/edidvar.h>
+
+#include "locators.h"
+
+struct panel_info {
+       uint32_t panel_width;
+       uint32_t panel_height;
+       uint32_t panel_hfp;
+       uint32_t panel_hbp;
+       uint32_t panel_hsw;
+       uint32_t panel_vfp;
+       uint32_t panel_vbp;
+       uint32_t panel_vsw;
+       uint32_t ac_bias;
+       uint32_t ac_bias_intrpt;
+       uint32_t dma_burst_sz;
+       uint32_t bpp;
+       uint32_t fdd;
+       uint32_t invert_line_clock;
+       uint32_t invert_frm_clock;
+       uint32_t sync_edge;
+       uint32_t sync_ctrl;
+       uint32_t panel_pxl_clk;
+       uint32_t panel_invert_pxl_clk;
+};
+
+/* for chalk elec cape with 12" panel */
+struct panel_info default_panel_info = {
+       .panel_width = 1280,
+       .panel_height = 800,
+       .panel_hfp = 48,
+       .panel_hbp = 80,
+       .panel_hsw = 32,
+       .panel_vfp = 2,
+       .panel_vbp = 15,
+       .panel_vsw = 6,
+       .ac_bias = 255,
+       .ac_bias_intrpt = 0,
+       .dma_burst_sz = 16,
+       .bpp = 16,
+       .fdd = 16,
+       .invert_line_clock = 0,
+       .invert_frm_clock = 0,
+       .sync_edge = 0,
+       .sync_ctrl = 1,
+       .panel_pxl_clk = 69300000,
+       .panel_invert_pxl_clk = 0,
+};
+
+struct tifb_softc {
+       device_t sc_dev;
+
+       void *sc_ih;
+       bus_space_tag_t sc_iot;
+       bus_dma_tag_t sc_dmat;
+       bus_space_handle_t sc_regh;
+       bus_dmamap_t sc_dmamap;
+       bus_dma_segment_t sc_dmamem[1];
+       size_t sc_vramsize;
+       size_t sc_palettesize;
+
+       int sc_stride;
+       int sc_locked;
+       void *sc_fbaddr, *sc_vramaddr;
+
+       bus_addr_t sc_fbhwaddr;
+       uint16_t *sc_palette;
+       uint32_t sc_dispc_config;
+       struct vcons_screen sc_console_screen;
+       struct wsscreen_descr sc_defaultscreen_descr;
+       const struct wsscreen_descr *sc_screens[1];
+       struct wsscreen_list sc_screenlist;
+       struct vcons_data vd;
+       int sc_mode;
+       uint8_t sc_cmap_red[256], sc_cmap_green[256], sc_cmap_blue[256];
+       void (*sc_putchar)(void *, int, int, u_int, long);
+
+       uint8_t sc_edid_data[1024];
+       size_t sc_edid_size;
+
+       struct panel_info *sc_panel;
+};
+
+#define TIFB_READ(sc, reg) bus_space_read_4(sc->sc_iot, sc->sc_regh, reg)
+#define TIFB_WRITE(sc, reg, val) bus_space_write_4(sc->sc_iot, sc->sc_regh, reg, val)
+
+static int     tifb_match(device_t, cfdata_t, void *);
+static void    tifb_attach(device_t, device_t, void *);
+static int     tifb_intr(void *);
+
+
+#ifdef TI_AM335X
+static void am335x_clk_lcdc_activate(void);
+static int  am335x_clk_get_arm_disp_freq(unsigned int *);
+#endif
+
+
+CFATTACH_DECL_NEW(tifb, sizeof(struct tifb_softc),
+    tifb_match, tifb_attach, NULL, NULL);
+
+static int     tifb_ioctl(void *, void *, u_long, void *, int,
+                            struct lwp *);
+static paddr_t tifb_mmap(void *, void *, off_t, int);
+static void    tifb_init_screen(void *, struct vcons_screen *, int, long *);
+
+static int     tifb_putcmap(struct tifb_softc *, struct wsdisplay_cmap *);
+static int     tifb_getcmap(struct tifb_softc *, struct wsdisplay_cmap *);
+#if 0
+static void    tifb_restore_palette(struct tifb_softc *);
+static void    tifb_putpalreg(struct tifb_softc *, int, uint8_t,
+                           uint8_t, uint8_t);
+
+static int     tifb_set_depth(struct tifb_softc *, int);
+#endif
+static void    tifb_set_video(struct tifb_softc *, int);
+
+struct wsdisplay_accessops tifb_accessops = {
+       tifb_ioctl,
+       tifb_mmap,
+       NULL,   /* alloc_screen */
+       NULL,   /* free_screen */
+       NULL,   /* show_screen */
+       NULL,   /* load_font */
+       NULL,   /* pollc */
+       NULL    /* scroll */
+};
+
+extern const u_char rasops_cmap[768];
+
+static struct evcnt ev_sync_lost;
+static struct evcnt ev_palette;
+static struct evcnt ev_eof0;
+static struct evcnt ev_eof1;
+static struct evcnt ev_fifo_underflow;
+static struct evcnt ev_ac_bias;
+static struct evcnt ev_others;
+
+
+static uint32_t
+am335x_lcd_calc_divisor(uint32_t reference, uint32_t freq)
+{
+       uint32_t div;
+       /* Raster mode case: divisors are in range from 2 to 255 */
+       for (div = 2; div < 255; div++)
+               if (reference/div <= freq)
+                       return (div);
+
+       return (255);
+}
+
+static int
+tifb_match(device_t parent, cfdata_t match, void *aux)
+{
+       struct obio_attach_args *obio = aux;
+
+       if ((obio->obio_addr == -1) || (obio->obio_size == 0))
+               return 0;
+       return 1;
+}
+
+static void
+tifb_attach(device_t parent, device_t self, void *aux)
+{
+       struct tifb_softc       *sc = device_private(self);
+       struct obio_attach_args *obio = aux;
+       struct rasops_info      *ri;
+       struct wsemuldisplaydev_attach_args aa;
+       prop_dictionary_t       dict;
+       /* prop_data_t          edid_data; XXX */
+       unsigned long           defattr;
+       bool                    is_console = false;
+       uint32_t                reg, timing0, timing1, timing2, burst_log;
+       int                     segs, i, div, ref_freq;
+
+#ifdef TI_AM335X
+       int ret;
+       const char *mode;
+       u_int state;
+       struct tifb_padconf {
+               const char *padname;
+               const char *padmode;
+       };
+       const struct tifb_padconf tifb_padconf_data[] = {
+               {"LCD_DATA0",  "lcd_data0"},
+               {"LCD_DATA1",  "lcd_data1"},
+               {"LCD_DATA2",  "lcd_data2"},
+               {"LCD_DATA3",  "lcd_data3"},
+               {"LCD_DATA4",  "lcd_data4"},
+               {"LCD_DATA5",  "lcd_data5"},
+               {"LCD_DATA6",  "lcd_data6"},
+               {"LCD_DATA7",  "lcd_data7"},
+               {"LCD_DATA8",  "lcd_data8"},
+               {"LCD_DATA9",  "lcd_data9"},
+               {"LCD_DATA10", "lcd_data10"},
+               {"LCD_DATA11", "lcd_data11"},
+               {"LCD_DATA12", "lcd_data12"},
+               {"LCD_DATA13", "lcd_data13"},
+               {"LCD_DATA14", "lcd_data14"},
+               {"LCD_DATA15", "lcd_data15"},
+               {"GPMC_AD15",  "lcd_data16"},
+               {"GPMC_AD14",  "lcd_data17"},
+               {"GPMC_AD13",  "lcd_data18"},
+               {"GPMC_AD12",  "lcd_data19"},



Home | Main Index | Thread Index | Old Index