drivers/media/pci/netup_unidvb/netup_unidvb_ci.c

Source file repositories/reference/linux-study-clean/drivers/media/pci/netup_unidvb/netup_unidvb_ci.c

File Facts

System
Linux kernel
Corpus path
drivers/media/pci/netup_unidvb/netup_unidvb_ci.c
Extension
.c
Size
7102 bytes
Lines
240
Domain
Driver Families
Bucket
drivers/media
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * netup_unidvb_ci.c
 *
 * DVB CAM support for NetUP Universal Dual DVB-CI
 *
 * Copyright (C) 2014 NetUP Inc.
 * Copyright (C) 2014 Sergey Kozlov <serjk@netup.ru>
 * Copyright (C) 2014 Abylay Ospan <aospan@netup.ru>
 */

#include <linux/init.h>
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/kmod.h>
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/interrupt.h>
#include <linux/delay.h>
#include "netup_unidvb.h"

/* CI slot 0 base address */
#define CAM0_CONFIG		0x0
#define CAM0_IO			0x8000
#define CAM0_MEM		0x10000
#define CAM0_SZ			32
/* CI slot 1 base address */
#define CAM1_CONFIG		0x20000
#define CAM1_IO			0x28000
#define CAM1_MEM		0x30000
#define CAM1_SZ			32
/* ctrlstat registers */
#define CAM_CTRLSTAT_READ_SET	0x4980
#define CAM_CTRLSTAT_CLR	0x4982
/* register bits */
#define BIT_CAM_STCHG		(1<<0)
#define BIT_CAM_PRESENT		(1<<1)
#define BIT_CAM_RESET		(1<<2)
#define BIT_CAM_BYPASS		(1<<3)
#define BIT_CAM_READY		(1<<4)
#define BIT_CAM_ERROR		(1<<5)
#define BIT_CAM_OVERCURR	(1<<6)
/* BIT_CAM_BYPASS bit shift for SLOT 1 */
#define CAM1_SHIFT 8

irqreturn_t netup_ci_interrupt(struct netup_unidvb_dev *ndev)
{
	writew(0x101, ndev->bmmio0 + CAM_CTRLSTAT_CLR);
	return IRQ_HANDLED;
}

static int netup_unidvb_ci_slot_ts_ctl(struct dvb_ca_en50221 *en50221,
				       int slot)
{
	struct netup_ci_state *state = en50221->data;
	struct netup_unidvb_dev *dev = state->dev;
	u16 shift = (state->nr == 1) ? CAM1_SHIFT : 0;

	dev_dbg(&dev->pci_dev->dev, "%s(): CAM_CTRLSTAT=0x%x\n",
		__func__, readw(dev->bmmio0 + CAM_CTRLSTAT_READ_SET));
	if (slot != 0)
		return -EINVAL;
	/* pass data to CAM module */
	writew(BIT_CAM_BYPASS << shift, dev->bmmio0 + CAM_CTRLSTAT_CLR);
	dev_dbg(&dev->pci_dev->dev, "%s(): CAM_CTRLSTAT=0x%x done\n",
		__func__, readw(dev->bmmio0 + CAM_CTRLSTAT_READ_SET));
	return 0;
}

static int netup_unidvb_ci_slot_shutdown(struct dvb_ca_en50221 *en50221,
					 int slot)
{
	struct netup_ci_state *state = en50221->data;
	struct netup_unidvb_dev *dev = state->dev;

	dev_dbg(&dev->pci_dev->dev, "%s()\n", __func__);
	return 0;
}

static int netup_unidvb_ci_slot_reset(struct dvb_ca_en50221 *en50221,
				      int slot)
{
	struct netup_ci_state *state = en50221->data;
	struct netup_unidvb_dev *dev = state->dev;
	unsigned long timeout = 0;
	u16 shift = (state->nr == 1) ? CAM1_SHIFT : 0;
	u16 ci_stat = 0;
	int reset_counter = 3;

	dev_dbg(&dev->pci_dev->dev, "%s(): CAM_CTRLSTAT_READ_SET=0x%x\n",

Annotation

Implementation Notes