diff options
author | Sonic Zhang <sonic.zhang@analog.com> | 2014-07-23 05:57:16 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <m.chehab@samsung.com> | 2014-07-26 16:15:16 -0400 |
commit | 0a6824bc10de58dac8beca4ad6744753f1cf9a6f (patch) | |
tree | 6e8dd0af3ed69dfcfaf2ec2431fa4c6ccc9f0cb0 /drivers/media | |
parent | 7ba3c21c17d0fec397dc5e0337a3548eb14220bd (diff) |
[media] v4l2: blackfin: select proper pinctrl state in ppi_set_params if CONFIG_PINCTRL is enabled
Multiple pinctrl states are defined for 8, 16 and 24 data pin groups in PPI peripheral.
The driver should select correct group before set up further PPI parameters.
Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>
Acked-by: Scott Jiang <scott.jiang.linux@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Diffstat (limited to 'drivers/media')
-rw-r--r-- | drivers/media/platform/blackfin/ppi.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/drivers/media/platform/blackfin/ppi.c b/drivers/media/platform/blackfin/ppi.c index 90c4a936e3ae..cff63e511e6d 100644 --- a/drivers/media/platform/blackfin/ppi.c +++ b/drivers/media/platform/blackfin/ppi.c | |||
@@ -206,6 +206,20 @@ static int ppi_set_params(struct ppi_if *ppi, struct ppi_params *params) | |||
206 | int dma_config, bytes_per_line; | 206 | int dma_config, bytes_per_line; |
207 | int hcount, hdelay, samples_per_line; | 207 | int hcount, hdelay, samples_per_line; |
208 | 208 | ||
209 | #ifdef CONFIG_PINCTRL | ||
210 | static const char * const pin_state[] = {"8bit", "16bit", "24bit"}; | ||
211 | struct pinctrl *pctrl; | ||
212 | struct pinctrl_state *pstate; | ||
213 | |||
214 | if (params->dlen > 24 || params->dlen <= 0) | ||
215 | return -EINVAL; | ||
216 | pctrl = devm_pinctrl_get(ppi->dev); | ||
217 | pstate = pinctrl_lookup_state(pctrl, | ||
218 | pin_state[(params->dlen + 7) / 8 - 1]); | ||
219 | if (pinctrl_select_state(pctrl, pstate)) | ||
220 | return -EINVAL; | ||
221 | #endif | ||
222 | |||
209 | bytes_per_line = params->width * params->bpp / 8; | 223 | bytes_per_line = params->width * params->bpp / 8; |
210 | /* convert parameters unit from pixels to samples */ | 224 | /* convert parameters unit from pixels to samples */ |
211 | hcount = params->width * params->bpp / params->dlen; | 225 | hcount = params->width * params->bpp / params->dlen; |
@@ -316,10 +330,12 @@ struct ppi_if *ppi_create_instance(struct platform_device *pdev, | |||
316 | if (!info || !info->pin_req) | 330 | if (!info || !info->pin_req) |
317 | return NULL; | 331 | return NULL; |
318 | 332 | ||
333 | #ifndef CONFIG_PINCTRL | ||
319 | if (peripheral_request_list(info->pin_req, KBUILD_MODNAME)) { | 334 | if (peripheral_request_list(info->pin_req, KBUILD_MODNAME)) { |
320 | dev_err(&pdev->dev, "request peripheral failed\n"); | 335 | dev_err(&pdev->dev, "request peripheral failed\n"); |
321 | return NULL; | 336 | return NULL; |
322 | } | 337 | } |
338 | #endif | ||
323 | 339 | ||
324 | ppi = kzalloc(sizeof(*ppi), GFP_KERNEL); | 340 | ppi = kzalloc(sizeof(*ppi), GFP_KERNEL); |
325 | if (!ppi) { | 341 | if (!ppi) { |
@@ -329,6 +345,7 @@ struct ppi_if *ppi_create_instance(struct platform_device *pdev, | |||
329 | } | 345 | } |
330 | ppi->ops = &ppi_ops; | 346 | ppi->ops = &ppi_ops; |
331 | ppi->info = info; | 347 | ppi->info = info; |
348 | ppi->dev = &pdev->dev; | ||
332 | 349 | ||
333 | pr_info("ppi probe success\n"); | 350 | pr_info("ppi probe success\n"); |
334 | return ppi; | 351 | return ppi; |