Lines Matching refs:host
187 #define mxsfb_is_v3(host) (host->devdata->ipversion == 3) argument
188 #define mxsfb_is_v4(host) (host->devdata->ipversion == 4) argument
214 static inline u32 set_hsync_pulse_width(struct mxsfb_info *host, unsigned val) in set_hsync_pulse_width() argument
216 return (val & host->devdata->hs_wdth_mask) << in set_hsync_pulse_width()
217 host->devdata->hs_wdth_shift; in set_hsync_pulse_width()
220 static inline u32 get_hsync_pulse_width(struct mxsfb_info *host, unsigned val) in get_hsync_pulse_width() argument
222 return (val >> host->devdata->hs_wdth_shift) & in get_hsync_pulse_width()
223 host->devdata->hs_wdth_mask; in get_hsync_pulse_width()
272 struct mxsfb_info *host = to_imxfb_host(fb_info); in mxsfb_check_var() local
290 switch (host->ld_intf_width) { in mxsfb_check_var()
319 static inline void mxsfb_enable_axi_clk(struct mxsfb_info *host) in mxsfb_enable_axi_clk() argument
321 if (host->clk_axi) in mxsfb_enable_axi_clk()
322 clk_prepare_enable(host->clk_axi); in mxsfb_enable_axi_clk()
325 static inline void mxsfb_disable_axi_clk(struct mxsfb_info *host) in mxsfb_disable_axi_clk() argument
327 if (host->clk_axi) in mxsfb_disable_axi_clk()
328 clk_disable_unprepare(host->clk_axi); in mxsfb_disable_axi_clk()
333 struct mxsfb_info *host = to_imxfb_host(fb_info); in mxsfb_enable_controller() local
337 dev_dbg(&host->pdev->dev, "%s\n", __func__); in mxsfb_enable_controller()
339 if (host->reg_lcd) { in mxsfb_enable_controller()
340 ret = regulator_enable(host->reg_lcd); in mxsfb_enable_controller()
342 dev_err(&host->pdev->dev, in mxsfb_enable_controller()
348 if (host->clk_disp_axi) in mxsfb_enable_controller()
349 clk_prepare_enable(host->clk_disp_axi); in mxsfb_enable_controller()
350 clk_prepare_enable(host->clk); in mxsfb_enable_controller()
351 clk_set_rate(host->clk, PICOS2KHZ(fb_info->var.pixclock) * 1000U); in mxsfb_enable_controller()
353 mxsfb_enable_axi_clk(host); in mxsfb_enable_controller()
356 writel(CTRL_DOTCLK_MODE, host->base + LCDC_CTRL + REG_SET); in mxsfb_enable_controller()
359 reg = readl(host->base + LCDC_VDCTRL4); in mxsfb_enable_controller()
361 writel(reg, host->base + LCDC_VDCTRL4); in mxsfb_enable_controller()
363 writel(CTRL_RUN, host->base + LCDC_CTRL + REG_SET); in mxsfb_enable_controller()
365 host->enabled = 1; in mxsfb_enable_controller()
370 struct mxsfb_info *host = to_imxfb_host(fb_info); in mxsfb_disable_controller() local
375 dev_dbg(&host->pdev->dev, "%s\n", __func__); in mxsfb_disable_controller()
381 writel(CTRL_DOTCLK_MODE, host->base + LCDC_CTRL + REG_CLR); in mxsfb_disable_controller()
385 reg = readl(host->base + LCDC_CTRL); in mxsfb_disable_controller()
391 reg = readl(host->base + LCDC_VDCTRL4); in mxsfb_disable_controller()
392 writel(reg & ~VDCTRL4_SYNC_SIGNALS_ON, host->base + LCDC_VDCTRL4); in mxsfb_disable_controller()
394 mxsfb_disable_axi_clk(host); in mxsfb_disable_controller()
396 clk_disable_unprepare(host->clk); in mxsfb_disable_controller()
397 if (host->clk_disp_axi) in mxsfb_disable_controller()
398 clk_disable_unprepare(host->clk_disp_axi); in mxsfb_disable_controller()
400 host->enabled = 0; in mxsfb_disable_controller()
402 if (host->reg_lcd) { in mxsfb_disable_controller()
403 ret = regulator_disable(host->reg_lcd); in mxsfb_disable_controller()
405 dev_err(&host->pdev->dev, in mxsfb_disable_controller()
412 struct mxsfb_info *host = to_imxfb_host(fb_info); in mxsfb_set_par() local
430 if (host->enabled) { in mxsfb_set_par()
435 mxsfb_enable_axi_clk(host); in mxsfb_set_par()
438 writel(CTRL1_FIFO_CLEAR, host->base + LCDC_CTRL1 + REG_SET); in mxsfb_set_par()
441 CTRL_SET_BUS_WIDTH(host->ld_intf_width); in mxsfb_set_par()
445 dev_dbg(&host->pdev->dev, "Setting up RGB565 mode\n"); in mxsfb_set_par()
447 writel(CTRL1_SET_BYTE_PACKAGING(0xf), host->base + LCDC_CTRL1); in mxsfb_set_par()
450 dev_dbg(&host->pdev->dev, "Setting up RGB888/666 mode\n"); in mxsfb_set_par()
452 switch (host->ld_intf_width) { in mxsfb_set_par()
454 mxsfb_disable_axi_clk(host); in mxsfb_set_par()
455 dev_err(&host->pdev->dev, in mxsfb_set_par()
465 writel(CTRL1_SET_BYTE_PACKAGING(0x7), host->base + LCDC_CTRL1); in mxsfb_set_par()
468 mxsfb_disable_axi_clk(host); in mxsfb_set_par()
469 dev_err(&host->pdev->dev, "Unhandled color depth of %u\n", in mxsfb_set_par()
474 writel(ctrl, host->base + LCDC_CTRL); in mxsfb_set_par()
478 host->base + host->devdata->transfer_count); in mxsfb_set_par()
488 if (host->sync & MXSFB_SYNC_DATA_ENABLE_HIGH_ACT) in mxsfb_set_par()
490 if (host->sync & MXSFB_SYNC_DOTCLK_FALLING_ACT) in mxsfb_set_par()
493 writel(vdctrl0, host->base + LCDC_VDCTRL0); in mxsfb_set_par()
498 host->base + LCDC_VDCTRL1); in mxsfb_set_par()
501 writel(set_hsync_pulse_width(host, fb_info->var.hsync_len) | in mxsfb_set_par()
505 host->base + LCDC_VDCTRL2); in mxsfb_set_par()
511 host->base + LCDC_VDCTRL3); in mxsfb_set_par()
514 if (mxsfb_is_v4(host)) in mxsfb_set_par()
515 vdctrl4 |= VDCTRL4_SET_DOTCLK_DLY(host->dotclk_delay); in mxsfb_set_par()
516 writel(vdctrl4, host->base + LCDC_VDCTRL4); in mxsfb_set_par()
520 host->base + host->devdata->next_buf); in mxsfb_set_par()
522 mxsfb_disable_axi_clk(host); in mxsfb_set_par()
572 struct mxsfb_info *host = to_imxfb_host(fb_info); in mxsfb_blank() local
579 if (host->enabled) in mxsfb_blank()
584 if (!host->enabled) in mxsfb_blank()
594 struct mxsfb_info *host = to_imxfb_host(fb_info); in mxsfb_pan_display() local
602 mxsfb_enable_axi_clk(host); in mxsfb_pan_display()
606 host->base + host->devdata->next_buf); in mxsfb_pan_display()
608 mxsfb_disable_axi_clk(host); in mxsfb_pan_display()
625 static int mxsfb_restore_mode(struct mxsfb_info *host, in mxsfb_restore_mode() argument
628 struct fb_info *fb_info = &host->fb_info; in mxsfb_restore_mode()
635 mxsfb_enable_axi_clk(host); in mxsfb_restore_mode()
638 ctrl = readl(host->base + LCDC_CTRL); in mxsfb_restore_mode()
644 vdctrl0 = readl(host->base + LCDC_VDCTRL0); in mxsfb_restore_mode()
645 vdctrl2 = readl(host->base + LCDC_VDCTRL2); in mxsfb_restore_mode()
646 vdctrl3 = readl(host->base + LCDC_VDCTRL3); in mxsfb_restore_mode()
647 vdctrl4 = readl(host->base + LCDC_VDCTRL4); in mxsfb_restore_mode()
649 transfer_count = readl(host->base + host->devdata->transfer_count); in mxsfb_restore_mode()
669 vmode->pixclock = KHZ2PICOS(clk_get_rate(host->clk) / 1000U); in mxsfb_restore_mode()
670 vmode->hsync_len = get_hsync_pulse_width(host, vdctrl2); in mxsfb_restore_mode()
675 period = readl(host->base + LCDC_VDCTRL1); in mxsfb_restore_mode()
695 host->ld_intf_width = CTRL_GET_BUS_WIDTH(ctrl); in mxsfb_restore_mode()
696 host->dotclk_delay = VDCTRL4_GET_DOTCLK_DLY(vdctrl4); in mxsfb_restore_mode()
700 pa = readl(host->base + host->devdata->cur_buf); in mxsfb_restore_mode()
713 writel(fb_info->fix.smem_start, host->base + host->devdata->next_buf); in mxsfb_restore_mode()
719 clk_prepare_enable(host->clk); in mxsfb_restore_mode()
720 host->enabled = 1; in mxsfb_restore_mode()
724 mxsfb_disable_axi_clk(host); in mxsfb_restore_mode()
729 static int mxsfb_init_fbinfo_dt(struct mxsfb_info *host, in mxsfb_init_fbinfo_dt() argument
732 struct fb_info *fb_info = &host->fb_info; in mxsfb_init_fbinfo_dt()
734 struct device *dev = &host->pdev->dev; in mxsfb_init_fbinfo_dt()
735 struct device_node *np = host->pdev->dev.of_node; in mxsfb_init_fbinfo_dt()
755 host->ld_intf_width = STMLCDIF_8BIT; in mxsfb_init_fbinfo_dt()
758 host->ld_intf_width = STMLCDIF_16BIT; in mxsfb_init_fbinfo_dt()
761 host->ld_intf_width = STMLCDIF_18BIT; in mxsfb_init_fbinfo_dt()
764 host->ld_intf_width = STMLCDIF_24BIT; in mxsfb_init_fbinfo_dt()
790 host->sync |= MXSFB_SYNC_DATA_ENABLE_HIGH_ACT; in mxsfb_init_fbinfo_dt()
792 host->sync |= MXSFB_SYNC_DOTCLK_FALLING_ACT; in mxsfb_init_fbinfo_dt()
799 static int mxsfb_init_fbinfo(struct mxsfb_info *host, in mxsfb_init_fbinfo() argument
803 struct fb_info *fb_info = &host->fb_info; in mxsfb_init_fbinfo()
817 ret = mxsfb_init_fbinfo_dt(host, vmode); in mxsfb_init_fbinfo()
838 if (mxsfb_restore_mode(host, vmode)) in mxsfb_init_fbinfo()
844 static void mxsfb_free_videomem(struct mxsfb_info *host) in mxsfb_free_videomem() argument
846 struct fb_info *fb_info = &host->fb_info; in mxsfb_free_videomem()
876 struct mxsfb_info *host; in mxsfb_probe() local
895 host = to_imxfb_host(fb_info); in mxsfb_probe()
898 host->base = devm_ioremap_resource(&pdev->dev, res); in mxsfb_probe()
899 if (IS_ERR(host->base)) { in mxsfb_probe()
900 ret = PTR_ERR(host->base); in mxsfb_probe()
904 host->pdev = pdev; in mxsfb_probe()
905 platform_set_drvdata(pdev, host); in mxsfb_probe()
907 host->devdata = &mxsfb_devdata[pdev->id_entry->driver_data]; in mxsfb_probe()
909 host->clk = devm_clk_get(&host->pdev->dev, NULL); in mxsfb_probe()
910 if (IS_ERR(host->clk)) { in mxsfb_probe()
911 ret = PTR_ERR(host->clk); in mxsfb_probe()
915 host->clk_axi = devm_clk_get(&host->pdev->dev, "axi"); in mxsfb_probe()
916 if (IS_ERR(host->clk_axi)) in mxsfb_probe()
917 host->clk_axi = NULL; in mxsfb_probe()
919 host->clk_disp_axi = devm_clk_get(&host->pdev->dev, "disp_axi"); in mxsfb_probe()
920 if (IS_ERR(host->clk_disp_axi)) in mxsfb_probe()
921 host->clk_disp_axi = NULL; in mxsfb_probe()
923 host->reg_lcd = devm_regulator_get(&pdev->dev, "lcd"); in mxsfb_probe()
924 if (IS_ERR(host->reg_lcd)) in mxsfb_probe()
925 host->reg_lcd = NULL; in mxsfb_probe()
934 ret = mxsfb_init_fbinfo(host, mode); in mxsfb_probe()
951 if (!host->enabled) { in mxsfb_probe()
952 mxsfb_enable_axi_clk(host); in mxsfb_probe()
953 writel(0, host->base + LCDC_CTRL); in mxsfb_probe()
954 mxsfb_disable_axi_clk(host); in mxsfb_probe()
964 if (host->enabled) in mxsfb_probe()
965 clk_disable_unprepare(host->clk); in mxsfb_probe()
975 struct mxsfb_info *host = to_imxfb_host(fb_info); in mxsfb_remove() local
977 if (host->enabled) in mxsfb_remove()
981 mxsfb_free_videomem(host); in mxsfb_remove()
991 struct mxsfb_info *host = to_imxfb_host(fb_info); in mxsfb_shutdown() local
993 mxsfb_enable_axi_clk(host); in mxsfb_shutdown()
999 writel(CTRL_RUN, host->base + LCDC_CTRL + REG_CLR); in mxsfb_shutdown()
1001 mxsfb_disable_axi_clk(host); in mxsfb_shutdown()