Lines Matching refs:cfg
153 static u32 read_hw_register(const struct ssd2828_config *cfg, u8 regnum) in read_hw_register() argument
155 soft_spi_xfer_24bit_3wire(cfg, 0x700000 | regnum); in read_hw_register()
156 return soft_spi_xfer_24bit_3wire(cfg, 0x730000); in read_hw_register()
162 static void write_hw_register(const struct ssd2828_config *cfg, u8 regnum, in write_hw_register() argument
165 soft_spi_xfer_24bit_3wire(cfg, 0x700000 | regnum); in write_hw_register()
166 soft_spi_xfer_24bit_3wire(cfg, 0x720000 | val); in write_hw_register()
172 static void send_mipi_dcs_command(const struct ssd2828_config *cfg, u8 cmdnum) in send_mipi_dcs_command() argument
175 write_hw_register(cfg, SSD2828_PSCR1, 1); in send_mipi_dcs_command()
177 write_hw_register(cfg, SSD2828_PDR, cmdnum); in send_mipi_dcs_command()
183 static void ssd2828_reset(const struct ssd2828_config *cfg) in ssd2828_reset() argument
186 gpio_set_value(cfg->reset_pin, 0); in ssd2828_reset()
188 gpio_set_value(cfg->reset_pin, 1); in ssd2828_reset()
192 static int ssd2828_enable_gpio(const struct ssd2828_config *cfg) in ssd2828_enable_gpio() argument
194 if (gpio_request(cfg->csx_pin, "ssd2828_csx")) { in ssd2828_enable_gpio()
198 if (gpio_request(cfg->sck_pin, "ssd2828_sck")) { in ssd2828_enable_gpio()
199 gpio_free(cfg->csx_pin); in ssd2828_enable_gpio()
203 if (gpio_request(cfg->sdi_pin, "ssd2828_sdi")) { in ssd2828_enable_gpio()
204 gpio_free(cfg->csx_pin); in ssd2828_enable_gpio()
205 gpio_free(cfg->sck_pin); in ssd2828_enable_gpio()
209 if (gpio_request(cfg->reset_pin, "ssd2828_reset")) { in ssd2828_enable_gpio()
210 gpio_free(cfg->csx_pin); in ssd2828_enable_gpio()
211 gpio_free(cfg->sck_pin); in ssd2828_enable_gpio()
212 gpio_free(cfg->sdi_pin); in ssd2828_enable_gpio()
216 if (cfg->sdo_pin != -1 && gpio_request(cfg->sdo_pin, "ssd2828_sdo")) { in ssd2828_enable_gpio()
217 gpio_free(cfg->csx_pin); in ssd2828_enable_gpio()
218 gpio_free(cfg->sck_pin); in ssd2828_enable_gpio()
219 gpio_free(cfg->sdi_pin); in ssd2828_enable_gpio()
220 gpio_free(cfg->reset_pin); in ssd2828_enable_gpio()
224 gpio_direction_output(cfg->reset_pin, 0); in ssd2828_enable_gpio()
225 gpio_direction_output(cfg->csx_pin, 1); in ssd2828_enable_gpio()
226 gpio_direction_output(cfg->sck_pin, 1); in ssd2828_enable_gpio()
227 gpio_direction_output(cfg->sdi_pin, 1); in ssd2828_enable_gpio()
228 if (cfg->sdo_pin != -1) in ssd2828_enable_gpio()
229 gpio_direction_input(cfg->sdo_pin); in ssd2828_enable_gpio()
234 static int ssd2828_free_gpio(const struct ssd2828_config *cfg) in ssd2828_free_gpio() argument
236 gpio_free(cfg->csx_pin); in ssd2828_free_gpio()
237 gpio_free(cfg->sck_pin); in ssd2828_free_gpio()
238 gpio_free(cfg->sdi_pin); in ssd2828_free_gpio()
239 gpio_free(cfg->reset_pin); in ssd2828_free_gpio()
240 if (cfg->sdo_pin != -1) in ssd2828_free_gpio()
241 gpio_free(cfg->sdo_pin); in ssd2828_free_gpio()
288 static int ssd2828_configure_video_interface(const struct ssd2828_config *cfg, in ssd2828_configure_video_interface() argument
294 write_hw_register(cfg, SSD2828_VICR1, (mode->vsync_len << 8) | in ssd2828_configure_video_interface()
300 write_hw_register(cfg, SSD2828_VICR2, (vbp << 8) | hbp); in ssd2828_configure_video_interface()
303 write_hw_register(cfg, SSD2828_VICR3, (mode->lower_margin << 8) | in ssd2828_configure_video_interface()
307 write_hw_register(cfg, SSD2828_VICR4, mode->xres); in ssd2828_configure_video_interface()
310 write_hw_register(cfg, SSD2828_VICR5, mode->yres); in ssd2828_configure_video_interface()
314 switch (cfg->ssd2828_color_depth) { in ssd2828_configure_video_interface()
319 val |= cfg->mipi_dsi_loosely_packed_pixel_format ? in ssd2828_configure_video_interface()
330 write_hw_register(cfg, SSD2828_VICR6, val); in ssd2828_configure_video_interface()
333 write_hw_register(cfg, SSD2828_LCFR, in ssd2828_configure_video_interface()
334 cfg->mipi_dsi_number_of_data_lanes - 1); in ssd2828_configure_video_interface()
339 int ssd2828_init(const struct ssd2828_config *cfg, in ssd2828_init() argument
355 if (ssd2828_enable_gpio(cfg) != 0) in ssd2828_init()
359 ssd2828_reset(cfg); in ssd2828_init()
366 if (cfg->sdo_pin != -1) { in ssd2828_init()
367 if (read_hw_register(cfg, SSD2828_DIR) != 0x2828 || in ssd2828_init()
368 read_hw_register(cfg, SSD2828_CFGR) != cfgr_reg) { in ssd2828_init()
370 ssd2828_free_gpio(cfg); in ssd2828_init()
382 reference_freq_khz = cfg->ssd2828_tx_clk_khz; in ssd2828_init()
392 if (ssd2828_configure_video_interface(cfg, mode) != 0) { in ssd2828_init()
393 ssd2828_free_gpio(cfg); in ssd2828_init()
401 write_hw_register(cfg, SSD2828_CFGR, cfgr_reg); in ssd2828_init()
405 cfg->mipi_dsi_bitrate_per_data_lane_mbps * 1000, in ssd2828_init()
407 write_hw_register(cfg, SSD2828_PLCR, pll_config); in ssd2828_init()
413 write_hw_register(cfg, SSD2828_VCR, 0); in ssd2828_init()
416 write_hw_register(cfg, SSD2828_CCR, SSD2828_LP_CLOCK_DIVIDER(lp_div)); in ssd2828_init()
419 write_hw_register(cfg, SSD2828_PCR, 1); /* Enable PLL */ in ssd2828_init()
424 send_mipi_dcs_command(cfg, MIPI_DCS_EXIT_SLEEP_MODE); in ssd2828_init()
425 mdelay(cfg->mipi_dsi_delay_after_exit_sleep_mode_ms); in ssd2828_init()
427 send_mipi_dcs_command(cfg, MIPI_DCS_SET_DISPLAY_ON); in ssd2828_init()
428 mdelay(cfg->mipi_dsi_delay_after_set_display_on_ms); in ssd2828_init()
432 write_hw_register(cfg, SSD2828_CFGR, cfgr_reg); in ssd2828_init()