#define cal_dbg(level, cal, fmt, arg...) \
do { \
if (debug >= (level)) \
- dev_printk(KERN_DEBUG, &(cal)->pdev->dev, \
- fmt, ##arg); \
+ dev_printk(KERN_DEBUG, (cal)->dev, fmt, ##arg); \
} while (0)
#define cal_info(cal, fmt, arg...) \
- dev_info(&(cal)->pdev->dev, fmt, ##arg)
+ dev_info((cal)->dev, fmt, ##arg)
#define cal_err(cal, fmt, arg...) \
- dev_err(&(cal)->pdev->dev, fmt, ##arg)
+ dev_err((cal)->dev, fmt, ##arg)
#define ctx_dbg(level, ctx, fmt, arg...) \
cal_dbg(level, (ctx)->cal, "ctx%u: " fmt, (ctx)->index, ##arg)
struct cal_camerarx {
void __iomem *base;
struct resource *res;
- struct platform_device *pdev;
+ struct device *dev;
struct regmap_field *fields[F_MAX_FIELDS];
struct cal_dev *cal;
int irq;
void __iomem *base;
struct resource *res;
- struct platform_device *pdev;
+ struct device *dev;
const struct cal_data *data;
* Here we update the reg offset with the
* value found in DT
*/
- phy->fields[i] = devm_regmap_field_alloc(&cal->pdev->dev,
+ phy->fields[i] = devm_regmap_field_alloc(cal->dev,
cal->syscon_camerrx,
field);
if (IS_ERR(phy->fields[i])) {
static int cal_camerarx_parse_dt(struct cal_camerarx *phy)
{
struct v4l2_fwnode_endpoint *endpoint = &phy->endpoint;
- struct platform_device *pdev = phy->cal->pdev;
struct device_node *ep_node;
char data_lanes[V4L2_FWNODE_CSI2_MAX_DATA_LANES * 2];
unsigned int i;
* Find the endpoint node for the port corresponding to the PHY
* instance, and parse its CSI-2-related properties.
*/
- ep_node = of_graph_get_endpoint_by_regs(pdev->dev.of_node,
+ ep_node = of_graph_get_endpoint_by_regs(phy->cal->dev->of_node,
phy->instance, 0);
if (!ep_node) {
/*
static struct cal_camerarx *cal_camerarx_create(struct cal_dev *cal,
unsigned int instance)
{
- struct platform_device *pdev = cal->pdev;
+ struct platform_device *pdev = to_platform_device(cal->dev);
struct cal_camerarx *phy;
int ret;
(instance == 0) ?
"cal_rx_core0" :
"cal_rx_core1");
- phy->base = devm_ioremap_resource(&pdev->dev, phy->res);
+ phy->base = devm_ioremap_resource(cal->dev, phy->res);
if (IS_ERR(phy->base)) {
cal_err(cal, "failed to ioremap\n");
ret = PTR_ERR(phy->base);
static int cal_camerarx_init_regmap(struct cal_dev *cal)
{
- struct device_node *np = cal->pdev->dev.of_node;
+ struct platform_device *pdev = to_platform_device(cal->dev);
+ struct device_node *np = cal->dev->of_node;
struct regmap_config config = { };
struct regmap *syscon;
struct resource *res;
return 0;
}
- dev_warn(&cal->pdev->dev, "failed to get ti,camerrx-control: %ld\n",
+ dev_warn(cal->dev, "failed to get ti,camerrx-control: %ld\n",
PTR_ERR(syscon));
/*
* Backward DTS compatibility. If syscon entry is not present then
* check if the camerrx_control resource is present.
*/
- res = platform_get_resource_byname(cal->pdev, IORESOURCE_MEM,
+ res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
"camerrx_control");
- base = devm_ioremap_resource(&cal->pdev->dev, res);
+ base = devm_ioremap_resource(cal->dev, res);
if (IS_ERR(base)) {
cal_err(cal, "failed to ioremap camerrx_control\n");
return PTR_ERR(base);
*
* Instead of failing here just use 8 bpp as a default.
*/
- dev_warn_once(&ctx->cal->pdev->dev,
+ dev_warn_once(ctx->cal->dev,
"%s:%d:%s: bpp:%d unsupported! Overwritten with 8.\n",
__FILE__, __LINE__, __func__, ctx->fmt->bpp);
extract = CAL_PIX_PROC_EXTRACT_B8;
reg_write(cal, CAL_HL_IRQSTATUS(0), status);
if (status & CAL_HL_IRQ_OCPO_ERR_MASK)
- dev_err_ratelimited(&cal->pdev->dev, "OCPO ERROR\n");
+ dev_err_ratelimited(cal->dev, "OCPO ERROR\n");
for (i = 0; i < CAL_NUM_CSI2_PORTS; ++i) {
if (status & CAL_HL_IRQ_CIO_MASK(i)) {
u32 cio_stat = reg_read(cal,
CAL_CSI2_COMPLEXIO_IRQSTATUS(i));
- dev_err_ratelimited(&cal->pdev->dev,
+ dev_err_ratelimited(cal->dev,
"CIO%u error: %#08x\n", i, cio_stat);
reg_write(cal, CAL_CSI2_COMPLEXIO_IRQSTATUS(i),
strscpy(cap->card, CAL_MODULE_NAME, sizeof(cap->card));
snprintf(cap->bus_info, sizeof(cap->bus_info),
- "platform:%s", dev_name(&ctx->cal->pdev->dev));
+ "platform:%s", dev_name(ctx->cal->dev));
return 0;
}
goto err;
}
- pm_runtime_get_sync(&ctx->cal->pdev->dev);
+ pm_runtime_get_sync(ctx->cal->dev);
cal_ctx_csi2_config(ctx);
cal_ctx_pix_proc_config(ctx);
if (ret) {
v4l2_subdev_call(ctx->phy->sensor, core, s_power, 0);
ctx_err(ctx, "stream on failed in subdev\n");
- pm_runtime_put_sync(&ctx->cal->pdev->dev);
+ pm_runtime_put_sync(ctx->cal->dev);
goto err;
}
ctx->next_frm = NULL;
spin_unlock_irqrestore(&ctx->slock, flags);
- pm_runtime_put_sync(&ctx->cal->pdev->dev);
+ pm_runtime_put_sync(ctx->cal->dev);
}
static const struct vb2_ops cal_video_qops = {
q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
q->lock = &ctx->mutex;
q->min_buffers_needed = 3;
- q->dev = &ctx->cal->pdev->dev;
+ q->dev = ctx->cal->dev;
ret = vb2_queue_init(q);
if (ret)
* Initialize the V4L2 device (despite the function name, this performs
* initialization, not registration).
*/
- ret = v4l2_device_register(&cal->pdev->dev, &cal->v4l2_dev);
+ ret = v4l2_device_register(cal->dev, &cal->v4l2_dev);
if (ret) {
cal_err(cal, "Failed to register V4L2 device\n");
return ret;
}
- vb2_dma_contig_set_max_seg_size(&cal->pdev->dev, DMA_BIT_MASK(32));
+ vb2_dma_contig_set_max_seg_size(cal->dev, DMA_BIT_MASK(32));
return 0;
}
}
v4l2_device_unregister(&cal->v4l2_dev);
- vb2_dma_contig_clear_max_seg_size(&cal->pdev->dev);
+ vb2_dma_contig_clear_max_seg_size(cal->dev);
}
/* ------------------------------------------------------------------
struct cal_ctx *ctx;
int ret;
- ctx = devm_kzalloc(&cal->pdev->dev, sizeof(*ctx), GFP_KERNEL);
+ ctx = devm_kzalloc(cal->dev, sizeof(*ctx), GFP_KERNEL);
if (!ctx)
return NULL;
return -ENODEV;
}
- cal->pdev = pdev;
+ cal->dev = &pdev->dev;
platform_set_drvdata(pdev, cal);
/* Acquire resources: clocks, CAMERARX regmap, I/O memory and IRQ. */