{"action":"closed","issue":{"url":"https://api.github.com/repos/notro/fbtft/issues/175","labels_url":"https://api.github.com/repos/notro/fbtft/issues/175/labels{/name}","comments_url":"https://api.github.com/repos/notro/fbtft/issues/175/comments","events_url":"https://api.github.com/repos/notro/fbtft/issues/175/events","html_url":"https://github.com/notro/fbtft/issues/175","id":48528913,"number":175,"title":"Driver for DOGS102","user":{"login":"woodym","id":9698209,"avatar_url":"https://avatars.githubusercontent.com/u/9698209?v=3","gravatar_id":"","url":"https://api.github.com/users/woodym","html_url":"https://github.com/woodym","followers_url":"https://api.github.com/users/woodym/followers","following_url":"https://api.github.com/users/woodym/following{/other_user}","gists_url":"https://api.github.com/users/woodym/gists{/gist_id}","starred_url":"https://api.github.com/users/woodym/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/woodym/subscriptions","organizations_url":"https://api.github.com/users/woodym/orgs","repos_url":"https://api.github.com/users/woodym/repos","events_url":"https://api.github.com/users/woodym/events{/privacy}","received_events_url":"https://api.github.com/users/woodym/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2014-11-12T16:16:17Z","updated_at":"2015-02-01T00:29:06Z","closed_at":"2015-02-01T00:29:06Z","body":"DOGS102 are a Display from ELECTRONIC ASSEMBLY with Controller UC1701.\r\nThis are a black and White Display (or many other background-Colors) with 102*64 Pixels. The Display have a great temperature range -20..+70°C and is powerd with single 3,3V. The Connection can made without a reset-line (only MOSI,MISO,CS and A0 required).\r\nI have testet on rpi B+\r\n\r\nthe Driver fb_uc1701.c\r\n```\r\n/*\r\n * FB driver for the UC1701 LCD Controller\r\n *\r\n * The display is monochrome and the video memory is RGB565.\r\n * Any pixel value except 0 turns the pixel on.\r\n *\r\n * Copyright (C) 2014 Juergen Holzmann\r\n *\r\n * This program is free software; you can redistribute it and/or modify\r\n * it under the terms of the GNU General Public License as published by\r\n * the Free Software Foundation; either version 2 of the License, or\r\n * (at your option) any later version.\r\n *\r\n * This program is distributed in the hope that it will be useful,\r\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\r\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r\n * GNU General Public License for more details.\r\n *\r\n * You should have received a copy of the GNU General Public License\r\n * along with this program; if not, write to the Free Software\r\n * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\r\n */\r\n\r\n#include <linux/module.h>\r\n#include <linux/kernel.h>\r\n#include <linux/init.h>\r\n#include <linux/gpio.h>\r\n#include <linux/spi/spi.h>\r\n#include <linux/delay.h>\r\n\r\n#include \"fbtft.h\"\r\n\r\n#define DRVNAME        \"fb_uc1701\"\r\n#define WIDTH          102\r\n#define HEIGHT         64\r\n#define PAGES          (HEIGHT/8)\r\n\r\n#define LCD_DISPLAY_ENABLE    0xAE  //1: Display on/off\r\n#define LCD_START_LINE        0x40  //2: display start line set\r\n#define LCD_PAGE_ADDRESS      0xB0  //3: Page address set (lower 4 bits select one of the pages)\r\n#define LCD_COL_ADDRESS       0x10  //4: column address\r\n#define LCD_BOTTOMVIEW        0xA0  //8: select orientation\r\n#define LCD_DISPLAY_INVERT    0xA6  //9: inverted display\r\n#define LCD_ALL_PIXEL         0xA4  //10: show memory content or switch all pixels on\r\n#define LCD_BIAS              0xA2  //11: lcd bias set\r\n#define LCD_RESET_CMD         0xE2  //14: Reset Controller\r\n#define LCD_SCAN_DIR          0xC0  //15: output mode select (turns display upside-down)\r\n#define LCD_POWER_CONTROL     0x28  //16: power control set\r\n#define LCD_VOLTAGE           0x20  //17: voltage regulator resistor ratio set\r\n#define LCD_VOLUME_MODE       0x81  //18: Volume mode set\r\n#define LCD_NO_OP             0xE3  //22: NOP command\r\n#define LCD_ADV_PROG_CTRL     0xFA  //25: advanced program control\r\n#define LCD_ADV_PROG_CTRL2    0x10  //25: advanced program control2\r\n#define LCD_TEMPCOMP_HIGH     0x80\r\n#define SHIFT_ADDR_NORMAL  0   //column offset for normal orientation\r\n#define SHIFT_ADDR_TOPVIEW 30  //column offset for bottom view orientation\r\n\r\n\r\nstatic int init_display(struct fbtft_par *par)\r\n{\r\n        fbtft_par_dbg(DEBUG_INIT_DISPLAY, par, \"%s()\\n\", __func__);\r\n\r\n        par->fbtftops.reset(par);\r\n\r\n        // softreset of LCD\r\n        write_reg(par, LCD_RESET_CMD);\r\n        mdelay(10);\r\n\r\n        // set startpoint\r\n        write_reg(par, LCD_START_LINE); // LCD_START_LINE | (pos & 0x3F)\r\n\r\n        // select orientation BOTTOMVIEW\r\n        write_reg(par, LCD_BOTTOMVIEW | 1);\r\n        // output mode select (turns display upside-down)\r\n        write_reg(par, LCD_SCAN_DIR | 0x00);\r\n\r\n        // Normal Pixel mode\r\n        write_reg(par, LCD_ALL_PIXEL | 0);\r\n\r\n        // positive display\r\n        write_reg(par, LCD_DISPLAY_INVERT | 0);\r\n\r\n        // bias 1/9\r\n        write_reg(par, LCD_BIAS | 0);\r\n\r\n        // power control mode: all features on\r\n        write_reg(par, LCD_POWER_CONTROL | 0x07); // LCD_POWER_CONTROL | (val&0x07)\r\n\r\n        // set voltage regulator R/R\r\n        write_reg(par, LCD_VOLTAGE | 0x07); // LCD_VOLTAGE | (val&0x07)\r\n\r\n        // volume mode set\r\n        write_reg(par, LCD_VOLUME_MODE); // LCD_VOLUME_MODE,val&0x3f,LCD_NO_OP\r\n        write_reg(par, 0x09); // LCD_VOLUME_MODE,val&0x3f,LCD_NO_OP\r\n        // ????\r\n        write_reg(par, LCD_NO_OP); // LCD_VOLUME_MODE,val&0x3f,LCD_NO_OP\r\n\r\n        // advanced program control\r\n        write_reg(par, LCD_ADV_PROG_CTRL);\r\n        write_reg(par, LCD_ADV_PROG_CTRL2|LCD_TEMPCOMP_HIGH);\r\n\r\n        // enable display\r\n        write_reg(par, LCD_DISPLAY_ENABLE | 1);\r\n\r\n        return 0;\r\n}\r\n\r\nstatic void set_addr_win(struct fbtft_par *par, int xs, int ys, int xe, int ye)\r\n{\r\n        fbtft_par_dbg(DEBUG_SET_ADDR_WIN, par, \"%s(xs=%d, ys=%d, xe=%d, ye=%d)\\n\", __func__, xs, ys, xe, ye);\r\n\r\n        // goto address\r\n        write_reg(par, LCD_PAGE_ADDRESS); // LCD_PAGE_ADDRESS | ((page) & 0x1F), (((col)+SHIFT_ADDR_NORMAL) & 0x0F), LCD_COL_ADDRESS | ((((col)+SHIFT_ADDR_NORMAL)>>4) & 0x0F)\r\n        write_reg(par, 0x00); // LCD_PAGE_ADDRESS | ((page) & 0x1F), (((col)+SHIFT_ADDR_NORMAL) & 0x0F), LCD_COL_ADDRESS | ((((col)+SHIFT_ADDR_NORMAL)>>4) & 0x0F)\r\n        write_reg(par, LCD_COL_ADDRESS); // LCD_PAGE_ADDRESS | ((page) & 0x1F), (((col)+SHIFT_ADDR_NORMAL) & 0x0F), LCD_COL_ADDRESS | ((((col)+SHIFT_ADDR_NORMAL)>>4) & 0x0F)\r\n}\r\n\r\nstatic int write_vmem(struct fbtft_par *par, size_t offset, size_t len)\r\n{\r\n        u16 *vmem16 = (u16 *)par->info->screen_base;\r\n        u8 *buf = par->txbuf.buf;\r\n        int x, y, i;\r\n        int ret = 0;\r\n\r\n        fbtft_par_dbg(DEBUG_WRITE_VMEM, par, \"%s()\\n\", __func__);\r\n\r\n        for (y=0;y<PAGES;y++)\r\n        {\r\n                buf = par->txbuf.buf;\r\n                for (x=0;x<WIDTH;x++)\r\n                {\r\n                        *buf = 0x00;\r\n                        for (i=0;i<8;i++)\r\n                        {\r\n                                *buf |= (vmem16[((y*8*WIDTH)+(i*WIDTH))+x] ? 1 : 0) << i;\r\n                        }\r\n                        buf++;\r\n                }\r\n                write_reg(par, LCD_PAGE_ADDRESS|(u8)y); // LCD_PAGE_ADDRESS | ((page) & 0x1F), (((col)+SHIFT_ADDR_NORMAL) & 0x0F), LCD_COL_ADDRESS | ((((col)+SHIFT_ADDR_NORMAL)>>4) & 0x0F)\r\n                write_reg(par, 0x00); // LCD_PAGE_ADDRESS | ((page) & 0x1F), (((col)+SHIFT_ADDR_NORMAL) & 0x0F), LCD_COL_ADDRESS | ((((col)+SHIFT_ADDR_NORMAL)>>4) & 0x0F)\r\n                write_reg(par, LCD_COL_ADDRESS); // LCD_PAGE_ADDRESS | ((page) & 0x1F), (((col)+SHIFT_ADDR_NORMAL) & 0x0F), LCD_COL_ADDRESS | ((((col)+SHIFT_ADDR_NORMAL)>>4) & 0x0F)\r\n                gpio_set_value(par->gpio.dc, 1);\r\n                ret = par->fbtftops.write(par, par->txbuf.buf, WIDTH);\r\n                gpio_set_value(par->gpio.dc, 0);\r\n        }\r\n\r\n        if (ret < 0)\r\n                dev_err(par->info->device, \"%s: write failed and returned: %d\\n\", __func__, ret);\r\n\r\n        return ret;\r\n}\r\n\r\n\r\nstatic struct fbtft_display display = {\r\n        .regwidth = 8,\r\n        .width = WIDTH,\r\n        .height = HEIGHT,\r\n        .fbtftops = {\r\n                .init_display = init_display,\r\n                .set_addr_win = set_addr_win,\r\n                .write_vmem = write_vmem,\r\n        },\r\n        .backlight = 1,\r\n};\r\nFBTFT_REGISTER_DRIVER(DRVNAME, \"UltraChip,uc1701\", &display);\r\n\r\nMODULE_ALIAS(\"spi:\" DRVNAME);\r\nMODULE_ALIAS(\"spi:uc1701\");\r\n\r\nMODULE_DESCRIPTION(\"FB driver for the UC1701 LCD Controller\");\r\nMODULE_AUTHOR(\"Juergen Holzmann\");\r\nMODULE_LICENSE(\"GPL\");\r\n\r\n```\r\nand the changes for fbtft_device\r\n```\r\n{\r\n                .name = \"dogs102\",\r\n                .spi = &(struct spi_board_info) {\r\n                        .modalias = \"fb_uc1701\",\r\n                        .max_speed_hz = 8000000,\r\n                        .mode = SPI_MODE_0,\r\n                        .platform_data = &(struct fbtft_platform_data) {\r\n                                .display = {\r\n                                        .buswidth = 8,\r\n                                },\r\n                                .bgr = true,\r\n                                .gpios = (const struct fbtft_gpio []) {\r\n                                        { \"reset\", 13 },\r\n                                        { \"dc\", 6 },\r\n                                        {},\r\n                                },\r\n                        }\r\n                }\r\n        },\r\n```\r\n\r\n\r\n![ea-dogs102w-a_2d](https://cloud.githubusercontent.com/assets/9698209/5013376/836f825c-6a8d-11e4-9437-7f1e6559e1d1.jpg)\r\n"}}