--- zzzz-none-000/linux-3.10.107/drivers/media/platform/blackfin/ppi.c 2017-06-27 09:49:32.000000000 +0000 +++ scorpion-7490-727/linux-3.10.107/drivers/media/platform/blackfin/ppi.c 2021-02-04 17:41:59.000000000 +0000 @@ -19,6 +19,7 @@ #include #include +#include #include #include @@ -205,6 +206,22 @@ int dma_config, bytes_per_line; int hcount, hdelay, samples_per_line; +#ifdef CONFIG_PINCTRL + static const char * const pin_state[] = {"8bit", "16bit", "24bit"}; + struct pinctrl *pctrl; + struct pinctrl_state *pstate; + + if (params->dlen > 24 || params->dlen <= 0) + return -EINVAL; + pctrl = devm_pinctrl_get(ppi->dev); + if (IS_ERR(pctrl)) + return PTR_ERR(pctrl); + pstate = pinctrl_lookup_state(pctrl, + pin_state[(params->dlen + 7) / 8 - 1]); + if (pinctrl_select_state(pctrl, pstate)) + return -EINVAL; +#endif + bytes_per_line = params->width * params->bpp / 8; /* convert parameters unit from pixels to samples */ hcount = params->width * params->bpp / params->dlen; @@ -266,6 +283,18 @@ bfin_write32(®->vcnt, params->height); if (params->int_mask) bfin_write32(®->imsk, params->int_mask & 0xFF); + if (ppi->ppi_control & PORT_DIR) { + u32 hsync_width, vsync_width, vsync_period; + + hsync_width = params->hsync + * params->bpp / params->dlen; + vsync_width = params->vsync * samples_per_line; + vsync_period = samples_per_line * params->frame; + bfin_write32(®->fs1_wlhb, hsync_width); + bfin_write32(®->fs1_paspl, samples_per_line); + bfin_write32(®->fs2_wlvb, vsync_width); + bfin_write32(®->fs2_palpf, vsync_period); + } break; } default: @@ -295,26 +324,30 @@ set_dma_start_addr(ppi->info->dma_ch, addr); } -struct ppi_if *ppi_create_instance(const struct ppi_info *info) +struct ppi_if *ppi_create_instance(struct platform_device *pdev, + const struct ppi_info *info) { struct ppi_if *ppi; if (!info || !info->pin_req) return NULL; +#ifndef CONFIG_PINCTRL if (peripheral_request_list(info->pin_req, KBUILD_MODNAME)) { - pr_err("request peripheral failed\n"); + dev_err(&pdev->dev, "request peripheral failed\n"); return NULL; } +#endif ppi = kzalloc(sizeof(*ppi), GFP_KERNEL); if (!ppi) { peripheral_free_list(info->pin_req); - pr_err("unable to allocate memory for ppi handle\n"); + dev_err(&pdev->dev, "unable to allocate memory for ppi handle\n"); return NULL; } ppi->ops = &ppi_ops; ppi->info = info; + ppi->dev = &pdev->dev; pr_info("ppi probe success\n"); return ppi;