at v4.12 245 lines 8.2 kB view raw
1#include <linux/debugfs.h> 2#include <linux/slab.h> 3 4#define BIG_BUFFER_SIZE (1024) 5 6static char big_buffer[BIG_BUFFER_SIZE]; 7 8struct mbxfb_debugfs_data { 9 struct dentry *dir; 10 struct dentry *sysconf; 11 struct dentry *clock; 12 struct dentry *display; 13 struct dentry *gsctl; 14 struct dentry *sdram; 15 struct dentry *misc; 16}; 17 18static ssize_t write_file_dummy(struct file *file, const char __user *buf, 19 size_t count, loff_t *ppos) 20{ 21 return count; 22} 23 24static ssize_t sysconf_read_file(struct file *file, char __user *userbuf, 25 size_t count, loff_t *ppos) 26{ 27 char * s = big_buffer; 28 29 s += sprintf(s, "SYSCFG = %08x\n", readl(SYSCFG)); 30 s += sprintf(s, "PFBASE = %08x\n", readl(PFBASE)); 31 s += sprintf(s, "PFCEIL = %08x\n", readl(PFCEIL)); 32 s += sprintf(s, "POLLFLAG = %08x\n", readl(POLLFLAG)); 33 s += sprintf(s, "SYSRST = %08x\n", readl(SYSRST)); 34 35 return simple_read_from_buffer(userbuf, count, ppos, 36 big_buffer, s-big_buffer); 37} 38 39 40static ssize_t gsctl_read_file(struct file *file, char __user *userbuf, 41 size_t count, loff_t *ppos) 42{ 43 char * s = big_buffer; 44 45 s += sprintf(s, "GSCTRL = %08x\n", readl(GSCTRL)); 46 s += sprintf(s, "VSCTRL = %08x\n", readl(VSCTRL)); 47 s += sprintf(s, "GBBASE = %08x\n", readl(GBBASE)); 48 s += sprintf(s, "VBBASE = %08x\n", readl(VBBASE)); 49 s += sprintf(s, "GDRCTRL = %08x\n", readl(GDRCTRL)); 50 s += sprintf(s, "VCMSK = %08x\n", readl(VCMSK)); 51 s += sprintf(s, "GSCADR = %08x\n", readl(GSCADR)); 52 s += sprintf(s, "VSCADR = %08x\n", readl(VSCADR)); 53 s += sprintf(s, "VUBASE = %08x\n", readl(VUBASE)); 54 s += sprintf(s, "VVBASE = %08x\n", readl(VVBASE)); 55 s += sprintf(s, "GSADR = %08x\n", readl(GSADR)); 56 s += sprintf(s, "VSADR = %08x\n", readl(VSADR)); 57 s += sprintf(s, "HCCTRL = %08x\n", readl(HCCTRL)); 58 s += sprintf(s, "HCSIZE = %08x\n", readl(HCSIZE)); 59 s += sprintf(s, "HCPOS = %08x\n", readl(HCPOS)); 60 s += sprintf(s, "HCBADR = %08x\n", readl(HCBADR)); 61 s += sprintf(s, "HCCKMSK = %08x\n", readl(HCCKMSK)); 62 s += sprintf(s, "GPLUT = %08x\n", readl(GPLUT)); 63 64 return simple_read_from_buffer(userbuf, count, ppos, 65 big_buffer, s-big_buffer); 66} 67 68static ssize_t display_read_file(struct file *file, char __user *userbuf, 69 size_t count, loff_t *ppos) 70{ 71 char * s = big_buffer; 72 73 s += sprintf(s, "DSCTRL = %08x\n", readl(DSCTRL)); 74 s += sprintf(s, "DHT01 = %08x\n", readl(DHT01)); 75 s += sprintf(s, "DHT02 = %08x\n", readl(DHT02)); 76 s += sprintf(s, "DHT03 = %08x\n", readl(DHT03)); 77 s += sprintf(s, "DVT01 = %08x\n", readl(DVT01)); 78 s += sprintf(s, "DVT02 = %08x\n", readl(DVT02)); 79 s += sprintf(s, "DVT03 = %08x\n", readl(DVT03)); 80 s += sprintf(s, "DBCOL = %08x\n", readl(DBCOL)); 81 s += sprintf(s, "BGCOLOR = %08x\n", readl(BGCOLOR)); 82 s += sprintf(s, "DINTRS = %08x\n", readl(DINTRS)); 83 s += sprintf(s, "DINTRE = %08x\n", readl(DINTRE)); 84 s += sprintf(s, "DINTRCNT = %08x\n", readl(DINTRCNT)); 85 s += sprintf(s, "DSIG = %08x\n", readl(DSIG)); 86 s += sprintf(s, "DMCTRL = %08x\n", readl(DMCTRL)); 87 s += sprintf(s, "CLIPCTRL = %08x\n", readl(CLIPCTRL)); 88 s += sprintf(s, "SPOCTRL = %08x\n", readl(SPOCTRL)); 89 s += sprintf(s, "SVCTRL = %08x\n", readl(SVCTRL)); 90 s += sprintf(s, "DLSTS = %08x\n", readl(DLSTS)); 91 s += sprintf(s, "DLLCTRL = %08x\n", readl(DLLCTRL)); 92 s += sprintf(s, "DVLNUM = %08x\n", readl(DVLNUM)); 93 s += sprintf(s, "DUCTRL = %08x\n", readl(DUCTRL)); 94 s += sprintf(s, "DVECTRL = %08x\n", readl(DVECTRL)); 95 s += sprintf(s, "DHDET = %08x\n", readl(DHDET)); 96 s += sprintf(s, "DVDET = %08x\n", readl(DVDET)); 97 s += sprintf(s, "DODMSK = %08x\n", readl(DODMSK)); 98 s += sprintf(s, "CSC01 = %08x\n", readl(CSC01)); 99 s += sprintf(s, "CSC02 = %08x\n", readl(CSC02)); 100 s += sprintf(s, "CSC03 = %08x\n", readl(CSC03)); 101 s += sprintf(s, "CSC04 = %08x\n", readl(CSC04)); 102 s += sprintf(s, "CSC05 = %08x\n", readl(CSC05)); 103 104 return simple_read_from_buffer(userbuf, count, ppos, 105 big_buffer, s-big_buffer); 106} 107 108static ssize_t clock_read_file(struct file *file, char __user *userbuf, 109 size_t count, loff_t *ppos) 110{ 111 char * s = big_buffer; 112 113 s += sprintf(s, "SYSCLKSRC = %08x\n", readl(SYSCLKSRC)); 114 s += sprintf(s, "PIXCLKSRC = %08x\n", readl(PIXCLKSRC)); 115 s += sprintf(s, "CLKSLEEP = %08x\n", readl(CLKSLEEP)); 116 s += sprintf(s, "COREPLL = %08x\n", readl(COREPLL)); 117 s += sprintf(s, "DISPPLL = %08x\n", readl(DISPPLL)); 118 s += sprintf(s, "PLLSTAT = %08x\n", readl(PLLSTAT)); 119 s += sprintf(s, "VOVRCLK = %08x\n", readl(VOVRCLK)); 120 s += sprintf(s, "PIXCLK = %08x\n", readl(PIXCLK)); 121 s += sprintf(s, "MEMCLK = %08x\n", readl(MEMCLK)); 122 s += sprintf(s, "M24CLK = %08x\n", readl(M24CLK)); 123 s += sprintf(s, "MBXCLK = %08x\n", readl(MBXCLK)); 124 s += sprintf(s, "SDCLK = %08x\n", readl(SDCLK)); 125 s += sprintf(s, "PIXCLKDIV = %08x\n", readl(PIXCLKDIV)); 126 127 return simple_read_from_buffer(userbuf, count, ppos, 128 big_buffer, s-big_buffer); 129} 130 131static ssize_t sdram_read_file(struct file *file, char __user *userbuf, 132 size_t count, loff_t *ppos) 133{ 134 char * s = big_buffer; 135 136 s += sprintf(s, "LMRST = %08x\n", readl(LMRST)); 137 s += sprintf(s, "LMCFG = %08x\n", readl(LMCFG)); 138 s += sprintf(s, "LMPWR = %08x\n", readl(LMPWR)); 139 s += sprintf(s, "LMPWRSTAT = %08x\n", readl(LMPWRSTAT)); 140 s += sprintf(s, "LMCEMR = %08x\n", readl(LMCEMR)); 141 s += sprintf(s, "LMTYPE = %08x\n", readl(LMTYPE)); 142 s += sprintf(s, "LMTIM = %08x\n", readl(LMTIM)); 143 s += sprintf(s, "LMREFRESH = %08x\n", readl(LMREFRESH)); 144 s += sprintf(s, "LMPROTMIN = %08x\n", readl(LMPROTMIN)); 145 s += sprintf(s, "LMPROTMAX = %08x\n", readl(LMPROTMAX)); 146 s += sprintf(s, "LMPROTCFG = %08x\n", readl(LMPROTCFG)); 147 s += sprintf(s, "LMPROTERR = %08x\n", readl(LMPROTERR)); 148 149 return simple_read_from_buffer(userbuf, count, ppos, 150 big_buffer, s-big_buffer); 151} 152 153static ssize_t misc_read_file(struct file *file, char __user *userbuf, 154 size_t count, loff_t *ppos) 155{ 156 char * s = big_buffer; 157 158 s += sprintf(s, "LCD_CONFIG = %08x\n", readl(LCD_CONFIG)); 159 s += sprintf(s, "ODFBPWR = %08x\n", readl(ODFBPWR)); 160 s += sprintf(s, "ODFBSTAT = %08x\n", readl(ODFBSTAT)); 161 s += sprintf(s, "ID = %08x\n", readl(ID)); 162 163 return simple_read_from_buffer(userbuf, count, ppos, 164 big_buffer, s-big_buffer); 165} 166 167 168static const struct file_operations sysconf_fops = { 169 .read = sysconf_read_file, 170 .write = write_file_dummy, 171 .open = simple_open, 172 .llseek = default_llseek, 173}; 174 175static const struct file_operations clock_fops = { 176 .read = clock_read_file, 177 .write = write_file_dummy, 178 .open = simple_open, 179 .llseek = default_llseek, 180}; 181 182static const struct file_operations display_fops = { 183 .read = display_read_file, 184 .write = write_file_dummy, 185 .open = simple_open, 186 .llseek = default_llseek, 187}; 188 189static const struct file_operations gsctl_fops = { 190 .read = gsctl_read_file, 191 .write = write_file_dummy, 192 .open = simple_open, 193 .llseek = default_llseek, 194}; 195 196static const struct file_operations sdram_fops = { 197 .read = sdram_read_file, 198 .write = write_file_dummy, 199 .open = simple_open, 200 .llseek = default_llseek, 201}; 202 203static const struct file_operations misc_fops = { 204 .read = misc_read_file, 205 .write = write_file_dummy, 206 .open = simple_open, 207 .llseek = default_llseek, 208}; 209 210static void mbxfb_debugfs_init(struct fb_info *fbi) 211{ 212 struct mbxfb_info *mfbi = fbi->par; 213 struct mbxfb_debugfs_data *dbg; 214 215 dbg = kzalloc(sizeof(struct mbxfb_debugfs_data), GFP_KERNEL); 216 mfbi->debugfs_data = dbg; 217 218 dbg->dir = debugfs_create_dir("mbxfb", NULL); 219 dbg->sysconf = debugfs_create_file("sysconf", 0444, dbg->dir, 220 fbi, &sysconf_fops); 221 dbg->clock = debugfs_create_file("clock", 0444, dbg->dir, 222 fbi, &clock_fops); 223 dbg->display = debugfs_create_file("display", 0444, dbg->dir, 224 fbi, &display_fops); 225 dbg->gsctl = debugfs_create_file("gsctl", 0444, dbg->dir, 226 fbi, &gsctl_fops); 227 dbg->sdram = debugfs_create_file("sdram", 0444, dbg->dir, 228 fbi, &sdram_fops); 229 dbg->misc = debugfs_create_file("misc", 0444, dbg->dir, 230 fbi, &misc_fops); 231} 232 233static void mbxfb_debugfs_remove(struct fb_info *fbi) 234{ 235 struct mbxfb_info *mfbi = fbi->par; 236 struct mbxfb_debugfs_data *dbg = mfbi->debugfs_data; 237 238 debugfs_remove(dbg->misc); 239 debugfs_remove(dbg->sdram); 240 debugfs_remove(dbg->gsctl); 241 debugfs_remove(dbg->display); 242 debugfs_remove(dbg->clock); 243 debugfs_remove(dbg->sysconf); 244 debugfs_remove(dbg->dir); 245}