Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[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>

authored by

Sonic Zhang and committed by
Mauro Carvalho Chehab
0a6824bc 7ba3c21c

+18
+17
drivers/media/platform/blackfin/ppi.c
··· 206 206 int dma_config, bytes_per_line; 207 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 223 bytes_per_line = params->width * params->bpp / 8; 210 224 /* convert parameters unit from pixels to samples */ 211 225 hcount = params->width * params->bpp / params->dlen; ··· 330 316 if (!info || !info->pin_req) 331 317 return NULL; 332 318 319 + #ifndef CONFIG_PINCTRL 333 320 if (peripheral_request_list(info->pin_req, KBUILD_MODNAME)) { 334 321 dev_err(&pdev->dev, "request peripheral failed\n"); 335 322 return NULL; 336 323 } 324 + #endif 337 325 338 326 ppi = kzalloc(sizeof(*ppi), GFP_KERNEL); 339 327 if (!ppi) { ··· 345 329 } 346 330 ppi->ops = &ppi_ops; 347 331 ppi->info = info; 332 + ppi->dev = &pdev->dev; 348 333 349 334 pr_info("ppi probe success\n"); 350 335 return ppi;
+1
include/media/blackfin/ppi.h
··· 83 83 }; 84 84 85 85 struct ppi_if { 86 + struct device *dev; 86 87 unsigned long ppi_control; 87 88 const struct ppi_ops *ops; 88 89 const struct ppi_info *info;