• Home
  • Raw
  • Download

Lines Matching refs:ctx

119 static int ld9040_clear_error(struct ld9040 *ctx)  in ld9040_clear_error()  argument
121 int ret = ctx->error; in ld9040_clear_error()
123 ctx->error = 0; in ld9040_clear_error()
127 static int ld9040_spi_write_word(struct ld9040 *ctx, u16 data) in ld9040_spi_write_word() argument
129 struct spi_device *spi = to_spi_device(ctx->dev); in ld9040_spi_write_word()
142 static void ld9040_dcs_write(struct ld9040 *ctx, const u8 *data, size_t len) in ld9040_dcs_write() argument
146 if (ctx->error < 0 || len == 0) in ld9040_dcs_write()
149 dev_dbg(ctx->dev, "writing dcs seq: %*ph\n", (int)len, data); in ld9040_dcs_write()
150 ret = ld9040_spi_write_word(ctx, *data); in ld9040_dcs_write()
154 ret = ld9040_spi_write_word(ctx, *data | 0x100); in ld9040_dcs_write()
158 dev_err(ctx->dev, "error %d writing dcs seq: %*ph\n", ret, in ld9040_dcs_write()
160 ctx->error = ret; in ld9040_dcs_write()
166 #define ld9040_dcs_write_seq_static(ctx, seq...) \ argument
169 ld9040_dcs_write(ctx, d, ARRAY_SIZE(d));\
172 static void ld9040_brightness_set(struct ld9040 *ctx) in ld9040_brightness_set() argument
174 ld9040_dcs_write(ctx, ld9040_gammas[ctx->brightness], in ld9040_brightness_set()
175 ARRAY_SIZE(ld9040_gammas[ctx->brightness])); in ld9040_brightness_set()
177 ld9040_dcs_write_seq_static(ctx, MCS_GAMMA_CTRL, 0x02, 0x5a); in ld9040_brightness_set()
180 static void ld9040_init(struct ld9040 *ctx) in ld9040_init() argument
182 ld9040_dcs_write_seq_static(ctx, MCS_USER_SETTING, 0x5a, 0x5a); in ld9040_init()
183 ld9040_dcs_write_seq_static(ctx, MCS_PANEL_CONDITION, in ld9040_init()
187 ld9040_dcs_write_seq_static(ctx, MCS_DISPCTL, in ld9040_init()
189 ld9040_dcs_write_seq_static(ctx, MCS_MANPWR, 0x04); in ld9040_init()
190 ld9040_dcs_write_seq_static(ctx, MCS_POWER_CTRL, in ld9040_init()
192 ld9040_dcs_write_seq_static(ctx, MCS_ELVSS_ON, 0x0d, 0x00, 0x16); in ld9040_init()
193 ld9040_dcs_write_seq_static(ctx, MCS_GTCON, 0x09, 0x00, 0x00); in ld9040_init()
194 ld9040_brightness_set(ctx); in ld9040_init()
195 ld9040_dcs_write_seq_static(ctx, MIPI_DCS_EXIT_SLEEP_MODE); in ld9040_init()
196 ld9040_dcs_write_seq_static(ctx, MIPI_DCS_SET_DISPLAY_ON); in ld9040_init()
199 static int ld9040_power_on(struct ld9040 *ctx) in ld9040_power_on() argument
203 ret = regulator_bulk_enable(ARRAY_SIZE(ctx->supplies), ctx->supplies); in ld9040_power_on()
207 msleep(ctx->power_on_delay); in ld9040_power_on()
208 gpiod_set_value(ctx->reset_gpio, 0); in ld9040_power_on()
209 msleep(ctx->reset_delay); in ld9040_power_on()
210 gpiod_set_value(ctx->reset_gpio, 1); in ld9040_power_on()
211 msleep(ctx->reset_delay); in ld9040_power_on()
216 static int ld9040_power_off(struct ld9040 *ctx) in ld9040_power_off() argument
218 return regulator_bulk_disable(ARRAY_SIZE(ctx->supplies), ctx->supplies); in ld9040_power_off()
228 struct ld9040 *ctx = panel_to_ld9040(panel); in ld9040_unprepare() local
231 ld9040_dcs_write_seq_static(ctx, MIPI_DCS_SET_DISPLAY_OFF); in ld9040_unprepare()
232 ld9040_dcs_write_seq_static(ctx, MIPI_DCS_ENTER_SLEEP_MODE); in ld9040_unprepare()
235 ld9040_clear_error(ctx); in ld9040_unprepare()
237 return ld9040_power_off(ctx); in ld9040_unprepare()
242 struct ld9040 *ctx = panel_to_ld9040(panel); in ld9040_prepare() local
245 ret = ld9040_power_on(ctx); in ld9040_prepare()
249 ld9040_init(ctx); in ld9040_prepare()
251 ret = ld9040_clear_error(ctx); in ld9040_prepare()
267 struct ld9040 *ctx = panel_to_ld9040(panel); in ld9040_get_modes() local
276 drm_display_mode_from_videomode(&ctx->vm, mode); in ld9040_get_modes()
277 mode->width_mm = ctx->width_mm; in ld9040_get_modes()
278 mode->height_mm = ctx->height_mm; in ld9040_get_modes()
296 static int ld9040_parse_dt(struct ld9040 *ctx) in ld9040_parse_dt() argument
298 struct device *dev = ctx->dev; in ld9040_parse_dt()
302 ret = of_get_videomode(np, &ctx->vm, 0); in ld9040_parse_dt()
306 of_property_read_u32(np, "power-on-delay", &ctx->power_on_delay); in ld9040_parse_dt()
307 of_property_read_u32(np, "reset-delay", &ctx->reset_delay); in ld9040_parse_dt()
308 of_property_read_u32(np, "panel-width-mm", &ctx->width_mm); in ld9040_parse_dt()
309 of_property_read_u32(np, "panel-height-mm", &ctx->height_mm); in ld9040_parse_dt()
317 struct ld9040 *ctx; in ld9040_probe() local
320 ctx = devm_kzalloc(dev, sizeof(struct ld9040), GFP_KERNEL); in ld9040_probe()
321 if (!ctx) in ld9040_probe()
324 spi_set_drvdata(spi, ctx); in ld9040_probe()
326 ctx->dev = dev; in ld9040_probe()
327 ctx->brightness = ARRAY_SIZE(ld9040_gammas) - 1; in ld9040_probe()
329 ret = ld9040_parse_dt(ctx); in ld9040_probe()
333 ctx->supplies[0].supply = "vdd3"; in ld9040_probe()
334 ctx->supplies[1].supply = "vci"; in ld9040_probe()
335 ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(ctx->supplies), in ld9040_probe()
336 ctx->supplies); in ld9040_probe()
340 ctx->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH); in ld9040_probe()
341 if (IS_ERR(ctx->reset_gpio)) { in ld9040_probe()
343 PTR_ERR(ctx->reset_gpio)); in ld9040_probe()
344 return PTR_ERR(ctx->reset_gpio); in ld9040_probe()
354 drm_panel_init(&ctx->panel); in ld9040_probe()
355 ctx->panel.dev = dev; in ld9040_probe()
356 ctx->panel.funcs = &ld9040_drm_funcs; in ld9040_probe()
358 return drm_panel_add(&ctx->panel); in ld9040_probe()
363 struct ld9040 *ctx = spi_get_drvdata(spi); in ld9040_remove() local
365 ld9040_power_off(ctx); in ld9040_remove()
366 drm_panel_remove(&ctx->panel); in ld9040_remove()