Lines Matching +full:boston +full:- +full:lcd
1 // SPDX-License-Identifier: GPL-2.0-or-later
22 * struct img_ascii_lcd_config - Configuration information about an LCD model
23 * @num_chars: the number of characters the LCD can display
25 * @update: function called to update the LCD
34 * struct img_ascii_lcd_ctx - Private data structure
35 * @pdev: the ASCII LCD platform device
36 * @base: the base address of the LCD registers
37 * @regmap: the regmap through which LCD registers are accessed
38 * @offset: the offset within regmap to the start of the LCD registers
39 * @cfg: pointer to the LCD model configuration
40 * @message: the full message to display or scroll on the LCD
45 * @curr: the string currently displayed on the LCD
64 * MIPS Boston development board
72 val = *((u64 *)&ctx->curr[0]); in boston_update()
73 __raw_writeq(val, ctx->base); in boston_update()
75 val = *((u32 *)&ctx->curr[0]); in boston_update()
76 __raw_writel(val, ctx->base); in boston_update()
77 val = *((u32 *)&ctx->curr[4]); in boston_update()
78 __raw_writel(val, ctx->base + 4); in boston_update()
98 for (i = 0; i < ctx->cfg->num_chars; i++) { in malta_update()
99 err = regmap_write(ctx->regmap, in malta_update()
100 ctx->offset + (i * 8), ctx->curr[i]); in malta_update()
106 pr_err_ratelimited("Failed to update LCD display: %d\n", err); in malta_update()
135 err = regmap_read(ctx->regmap, in sead3_wait_sm_idle()
136 ctx->offset + SEAD3_REG_CPLD_STATUS, in sead3_wait_sm_idle()
156 err = regmap_read(ctx->regmap, in sead3_wait_lcd_idle()
157 ctx->offset + SEAD3_REG_LCD_CTRL, in sead3_wait_lcd_idle()
166 err = regmap_read(ctx->regmap, in sead3_wait_lcd_idle()
167 ctx->offset + SEAD3_REG_CPLD_DATA, in sead3_wait_lcd_idle()
181 for (i = 0; i < ctx->cfg->num_chars; i++) { in sead3_update()
186 err = regmap_write(ctx->regmap, in sead3_update()
187 ctx->offset + SEAD3_REG_LCD_CTRL, in sead3_update()
196 err = regmap_write(ctx->regmap, in sead3_update()
197 ctx->offset + SEAD3_REG_LCD_DATA, in sead3_update()
198 ctx->curr[i]); in sead3_update()
204 pr_err_ratelimited("Failed to update LCD display: %d\n", err); in sead3_update()
214 { .compatible = "img,boston-lcd", .data = &boston_config },
215 { .compatible = "mti,malta-lcd", .data = &malta_config },
216 { .compatible = "mti,sead3-lcd", .data = &sead3_config },
222 * img_ascii_lcd_scroll() - scroll the display by a character
225 * Scroll the current message along the LCD by one character, rearming the
231 unsigned int i, ch = ctx->scroll_pos; in img_ascii_lcd_scroll()
232 unsigned int num_chars = ctx->cfg->num_chars; in img_ascii_lcd_scroll()
237 for (; i < num_chars && ch < ctx->message_len; i++, ch++) in img_ascii_lcd_scroll()
238 ctx->curr[i] = ctx->message[ch]; in img_ascii_lcd_scroll()
244 /* update the LCD */ in img_ascii_lcd_scroll()
245 ctx->cfg->update(ctx); in img_ascii_lcd_scroll()
248 ctx->scroll_pos++; in img_ascii_lcd_scroll()
249 ctx->scroll_pos %= ctx->message_len; in img_ascii_lcd_scroll()
252 if (ctx->message_len > ctx->cfg->num_chars) in img_ascii_lcd_scroll()
253 mod_timer(&ctx->timer, jiffies + ctx->scroll_rate); in img_ascii_lcd_scroll()
257 * img_ascii_lcd_display() - set the message to be displayed
260 * @count: length of msg, or -1
262 * Display a new message @msg on the LCD. @msg can be longer than the number of
263 * characters the LCD can display, in which case it will begin scrolling across
264 * the LCD display.
266 * Return: 0 on success, -ENOMEM on memory allocation failure
274 del_timer_sync(&ctx->timer); in img_ascii_lcd_display()
276 if (count == -1) in img_ascii_lcd_display()
280 if (msg[count - 1] == '\n') in img_ascii_lcd_display()
281 count--; in img_ascii_lcd_display()
284 /* clear the LCD */ in img_ascii_lcd_display()
285 devm_kfree(&ctx->pdev->dev, ctx->message); in img_ascii_lcd_display()
286 ctx->message = NULL; in img_ascii_lcd_display()
287 ctx->message_len = 0; in img_ascii_lcd_display()
288 memset(ctx->curr, ' ', ctx->cfg->num_chars); in img_ascii_lcd_display()
289 ctx->cfg->update(ctx); in img_ascii_lcd_display()
293 new_msg = devm_kmalloc(&ctx->pdev->dev, count + 1, GFP_KERNEL); in img_ascii_lcd_display()
295 return -ENOMEM; in img_ascii_lcd_display()
300 if (ctx->message) in img_ascii_lcd_display()
301 devm_kfree(&ctx->pdev->dev, ctx->message); in img_ascii_lcd_display()
303 ctx->message = new_msg; in img_ascii_lcd_display()
304 ctx->message_len = count; in img_ascii_lcd_display()
305 ctx->scroll_pos = 0; in img_ascii_lcd_display()
307 /* update the LCD */ in img_ascii_lcd_display()
308 img_ascii_lcd_scroll(&ctx->timer); in img_ascii_lcd_display()
314 * message_show() - read message via sysfs
315 * @dev: the LCD device
316 * @attr: the LCD message attribute
319 * Read the current message being displayed or scrolled across the LCD display
329 return sprintf(buf, "%s\n", ctx->message); in message_show()
333 * message_store() - write a new message via sysfs
334 * @dev: the LCD device
335 * @attr: the LCD message attribute
339 * Write a new message to display or scroll across the LCD display from sysfs.
341 * Return: the size of the message on success, else -ERRNO
356 * img_ascii_lcd_probe() - probe an LCD display device
357 * @pdev: the LCD platform device
359 * Probe an LCD display device, ensuring that we have the required resources in
360 * order to access the LCD & setting up private data as well as sysfs files.
362 * Return: 0 on success, else -ERRNO
371 match = of_match_device(img_ascii_lcd_matches, &pdev->dev); in img_ascii_lcd_probe()
373 return -ENODEV; in img_ascii_lcd_probe()
375 cfg = match->data; in img_ascii_lcd_probe()
376 ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx) + cfg->num_chars, in img_ascii_lcd_probe()
379 return -ENOMEM; in img_ascii_lcd_probe()
381 if (cfg->external_regmap) { in img_ascii_lcd_probe()
382 ctx->regmap = syscon_node_to_regmap(pdev->dev.parent->of_node); in img_ascii_lcd_probe()
383 if (IS_ERR(ctx->regmap)) in img_ascii_lcd_probe()
384 return PTR_ERR(ctx->regmap); in img_ascii_lcd_probe()
386 if (of_property_read_u32(pdev->dev.of_node, "offset", in img_ascii_lcd_probe()
387 &ctx->offset)) in img_ascii_lcd_probe()
388 return -EINVAL; in img_ascii_lcd_probe()
390 ctx->base = devm_platform_ioremap_resource(pdev, 0); in img_ascii_lcd_probe()
391 if (IS_ERR(ctx->base)) in img_ascii_lcd_probe()
392 return PTR_ERR(ctx->base); in img_ascii_lcd_probe()
395 ctx->pdev = pdev; in img_ascii_lcd_probe()
396 ctx->cfg = cfg; in img_ascii_lcd_probe()
397 ctx->message = NULL; in img_ascii_lcd_probe()
398 ctx->scroll_pos = 0; in img_ascii_lcd_probe()
399 ctx->scroll_rate = HZ / 2; in img_ascii_lcd_probe()
402 timer_setup(&ctx->timer, img_ascii_lcd_scroll, 0); in img_ascii_lcd_probe()
407 err = img_ascii_lcd_display(ctx, "Linux " UTS_RELEASE " ", -1); in img_ascii_lcd_probe()
411 err = device_create_file(&pdev->dev, &dev_attr_message); in img_ascii_lcd_probe()
417 del_timer_sync(&ctx->timer); in img_ascii_lcd_probe()
422 * img_ascii_lcd_remove() - remove an LCD display device
423 * @pdev: the LCD platform device
425 * Remove an LCD display device, freeing private resources & ensuring that the
426 * driver stops using the LCD display registers.
434 device_remove_file(&pdev->dev, &dev_attr_message); in img_ascii_lcd_remove()
435 del_timer_sync(&ctx->timer); in img_ascii_lcd_remove()
441 .name = "img-ascii-lcd",
449 MODULE_DESCRIPTION("Imagination Technologies ASCII LCD Display");