#define SSD1307FB_SET_COL_RANGE 0x21
#define SSD1307FB_SET_PAGE_RANGE 0x22
#define SSD1307FB_CONTRAST 0x81
+#define SSD1307FB_SET_LOOKUP_TABLE 0x91
#define SSD1307FB_CHARGE_PUMP 0x8d
#define SSD1307FB_SEG_REMAP_ON 0xa1
#define SSD1307FB_DISPLAY_OFF 0xae
#define SSD1307FB_START_PAGE_ADDRESS 0xb0
#define SSD1307FB_SET_DISPLAY_OFFSET 0xd3
#define SSD1307FB_SET_CLOCK_FREQ 0xd5
+#define SSD1307FB_SET_AREA_COLOR_MODE 0xd8
#define SSD1307FB_SET_PRECHARGE_PERIOD 0xd9
#define SSD1307FB_SET_COM_PINS_CONFIG 0xda
#define SSD1307FB_SET_VCOMH 0xdb
};
struct ssd1307fb_par {
- u32 com_invdir;
- u32 com_lrremap;
+ unsigned area_color_enable : 1;
+ unsigned com_invdir : 1;
+ unsigned com_lrremap : 1;
+ unsigned com_seq : 1;
+ unsigned lookup_table_set : 1;
+ unsigned low_power : 1;
+ unsigned seg_remap : 1;
u32 com_offset;
- u32 com_seq;
u32 contrast;
u32 dclk_div;
u32 dclk_frq;
struct i2c_client *client;
u32 height;
struct fb_info *info;
+ u8 lookup_table[4];
u32 page_offset;
u32 prechargep1;
u32 prechargep2;
u32 pwm_period;
struct gpio_desc *reset;
struct regulator *vbat_reg;
- u32 seg_remap;
u32 vcomh;
u32 width;
};
static const struct fb_var_screeninfo ssd1307fb_var = {
.bits_per_pixel = 1,
+ .red = { .length = 1 },
+ .green = { .length = 1 },
+ .blue = { .length = 1 },
};
static struct ssd1307fb_array *ssd1307fb_alloc_array(u32 len, u8 type)
}
/* Set COM direction */
- com_invdir = 0xc0 | (par->com_invdir & 0x1) << 3;
+ com_invdir = 0xc0 | par->com_invdir << 3;
ret = ssd1307fb_write_cmd(par->client, com_invdir);
if (ret < 0)
return ret;
if (ret < 0)
return ret;
+ /* Set Set Area Color Mode ON/OFF & Low Power Display Mode */
+ if (par->area_color_enable || par->low_power) {
+ u32 mode;
+
+ ret = ssd1307fb_write_cmd(par->client,
+ SSD1307FB_SET_AREA_COLOR_MODE);
+ if (ret < 0)
+ return ret;
+
+ mode = (par->area_color_enable ? 0x30 : 0) |
+ (par->low_power ? 5 : 0);
+ ret = ssd1307fb_write_cmd(par->client, mode);
+ if (ret < 0)
+ return ret;
+ }
+
/* Set precharge period in number of ticks from the internal clock */
ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_PRECHARGE_PERIOD);
if (ret < 0)
if (ret < 0)
return ret;
- compins = 0x02 | !(par->com_seq & 0x1) << 4
- | (par->com_lrremap & 0x1) << 5;
+ compins = 0x02 | !par->com_seq << 4 | par->com_lrremap << 5;
ret = ssd1307fb_write_cmd(par->client, compins);
if (ret < 0)
return ret;
if (ret < 0)
return ret;
+ /* Set lookup table */
+ if (par->lookup_table_set) {
+ int i;
+
+ ret = ssd1307fb_write_cmd(par->client,
+ SSD1307FB_SET_LOOKUP_TABLE);
+ if (ret < 0)
+ return ret;
+
+ for (i = 0; i < ARRAY_SIZE(par->lookup_table); ++i) {
+ u8 val = par->lookup_table[i];
+
+ if (val < 31 || val > 63)
+ dev_warn(&par->client->dev,
+ "lookup table index %d value out of range 31 <= %d <= 63\n",
+ i, val);
+ ret = ssd1307fb_write_cmd(par->client, val);
+ if (ret < 0)
+ return ret;
+ }
+ }
+
/* Switch to horizontal addressing mode */
ret = ssd1307fb_write_cmd(par->client, SSD1307FB_SET_ADDRESS_MODE);
if (ret < 0)
if (of_property_read_u32(node, "solomon,prechargep2", &par->prechargep2))
par->prechargep2 = 2;
+ if (!of_property_read_u8_array(node, "solomon,lookup-table",
+ par->lookup_table,
+ ARRAY_SIZE(par->lookup_table)))
+ par->lookup_table_set = 1;
+
par->seg_remap = !of_property_read_bool(node, "solomon,segment-no-remap");
par->com_seq = of_property_read_bool(node, "solomon,com-seq");
par->com_lrremap = of_property_read_bool(node, "solomon,com-lrremap");
par->com_invdir = of_property_read_bool(node, "solomon,com-invdir");
+ par->area_color_enable =
+ of_property_read_bool(node, "solomon,area-color-enable");
+ par->low_power = of_property_read_bool(node, "solomon,low-power");
par->contrast = 127;
par->vcomh = par->device_info->default_vcomh;
/* Setup display timing */
- par->dclk_div = par->device_info->default_dclk_div;
- par->dclk_frq = par->device_info->default_dclk_frq;
+ if (of_property_read_u32(node, "solomon,dclk-div", &par->dclk_div))
+ par->dclk_div = par->device_info->default_dclk_div;
+ if (of_property_read_u32(node, "solomon,dclk-frq", &par->dclk_frq))
+ par->dclk_frq = par->device_info->default_dclk_frq;
vmem_size = DIV_ROUND_UP(par->width, 8) * par->height;
info->var.yres = par->height;
info->var.yres_virtual = par->height;
- info->var.red.length = 1;
- info->var.red.offset = 0;
- info->var.green.length = 1;
- info->var.green.offset = 0;
- info->var.blue.length = 1;
- info->var.blue.offset = 0;
-
info->screen_buffer = vmem;
info->fix.smem_start = __pa(vmem);
info->fix.smem_len = vmem_size;