18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * GemTek radio card driver
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Copyright 1998 Jonas Munsin <jmunsin@iki.fi>
68c2ecf20Sopenharmony_ci *
78c2ecf20Sopenharmony_ci * GemTek hasn't released any specs on the card, so the protocol had to
88c2ecf20Sopenharmony_ci * be reverse engineered with dosemu.
98c2ecf20Sopenharmony_ci *
108c2ecf20Sopenharmony_ci * Besides the protocol changes, this is mostly a copy of:
118c2ecf20Sopenharmony_ci *
128c2ecf20Sopenharmony_ci *    RadioTrack II driver for Linux radio support (C) 1998 Ben Pfaff
138c2ecf20Sopenharmony_ci *
148c2ecf20Sopenharmony_ci *    Based on RadioTrack I/RadioReveal (C) 1997 M. Kirkwood
158c2ecf20Sopenharmony_ci *    Converted to new API by Alan Cox <alan@lxorguk.ukuu.org.uk>
168c2ecf20Sopenharmony_ci *    Various bugfixes and enhancements by Russell Kroll <rkroll@exploits.org>
178c2ecf20Sopenharmony_ci *
188c2ecf20Sopenharmony_ci * Converted to the radio-isa framework by Hans Verkuil <hans.verkuil@cisco.com>
198c2ecf20Sopenharmony_ci * Converted to V4L2 API by Mauro Carvalho Chehab <mchehab@kernel.org>
208c2ecf20Sopenharmony_ci *
218c2ecf20Sopenharmony_ci * Note: this card seems to swap the left and right audio channels!
228c2ecf20Sopenharmony_ci *
238c2ecf20Sopenharmony_ci * Fully tested with the Keene USB FM Transmitter and the v4l2-compliance tool.
248c2ecf20Sopenharmony_ci */
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ci#include <linux/module.h>	/* Modules			*/
278c2ecf20Sopenharmony_ci#include <linux/init.h>		/* Initdata			*/
288c2ecf20Sopenharmony_ci#include <linux/ioport.h>	/* request_region		*/
298c2ecf20Sopenharmony_ci#include <linux/delay.h>	/* udelay			*/
308c2ecf20Sopenharmony_ci#include <linux/videodev2.h>	/* kernel radio structs		*/
318c2ecf20Sopenharmony_ci#include <linux/mutex.h>
328c2ecf20Sopenharmony_ci#include <linux/io.h>		/* outb, outb_p			*/
338c2ecf20Sopenharmony_ci#include <linux/pnp.h>
348c2ecf20Sopenharmony_ci#include <linux/slab.h>
358c2ecf20Sopenharmony_ci#include <media/v4l2-ioctl.h>
368c2ecf20Sopenharmony_ci#include <media/v4l2-device.h>
378c2ecf20Sopenharmony_ci#include "radio-isa.h"
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_ci/*
408c2ecf20Sopenharmony_ci * Module info.
418c2ecf20Sopenharmony_ci */
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ciMODULE_AUTHOR("Jonas Munsin, Pekka Seppänen <pexu@kapsi.fi>");
448c2ecf20Sopenharmony_ciMODULE_DESCRIPTION("A driver for the GemTek Radio card.");
458c2ecf20Sopenharmony_ciMODULE_LICENSE("GPL");
468c2ecf20Sopenharmony_ciMODULE_VERSION("1.0.0");
478c2ecf20Sopenharmony_ci
488c2ecf20Sopenharmony_ci/*
498c2ecf20Sopenharmony_ci * Module params.
508c2ecf20Sopenharmony_ci */
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_ci#ifndef CONFIG_RADIO_GEMTEK_PORT
538c2ecf20Sopenharmony_ci#define CONFIG_RADIO_GEMTEK_PORT -1
548c2ecf20Sopenharmony_ci#endif
558c2ecf20Sopenharmony_ci#ifndef CONFIG_RADIO_GEMTEK_PROBE
568c2ecf20Sopenharmony_ci#define CONFIG_RADIO_GEMTEK_PROBE 1
578c2ecf20Sopenharmony_ci#endif
588c2ecf20Sopenharmony_ci
598c2ecf20Sopenharmony_ci#define GEMTEK_MAX 4
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_cistatic bool probe = CONFIG_RADIO_GEMTEK_PROBE;
628c2ecf20Sopenharmony_cistatic bool hardmute;
638c2ecf20Sopenharmony_cistatic int io[GEMTEK_MAX] = { [0] = CONFIG_RADIO_GEMTEK_PORT,
648c2ecf20Sopenharmony_ci			      [1 ... (GEMTEK_MAX - 1)] = -1 };
658c2ecf20Sopenharmony_cistatic int radio_nr[GEMTEK_MAX]	= { [0 ... (GEMTEK_MAX - 1)] = -1 };
668c2ecf20Sopenharmony_ci
678c2ecf20Sopenharmony_cimodule_param(probe, bool, 0444);
688c2ecf20Sopenharmony_ciMODULE_PARM_DESC(probe, "Enable automatic device probing.");
698c2ecf20Sopenharmony_ci
708c2ecf20Sopenharmony_cimodule_param(hardmute, bool, 0644);
718c2ecf20Sopenharmony_ciMODULE_PARM_DESC(hardmute, "Enable 'hard muting' by shutting down PLL, may reduce static noise.");
728c2ecf20Sopenharmony_ci
738c2ecf20Sopenharmony_cimodule_param_array(io, int, NULL, 0444);
748c2ecf20Sopenharmony_ciMODULE_PARM_DESC(io, "Force I/O ports for the GemTek Radio card if automatic probing is disabled or fails. The most common I/O ports are: 0x20c 0x30c, 0x24c or 0x34c (0x20c, 0x248 and 0x28c have been reported to work for the combined sound/radiocard).");
758c2ecf20Sopenharmony_ci
768c2ecf20Sopenharmony_cimodule_param_array(radio_nr, int, NULL, 0444);
778c2ecf20Sopenharmony_ciMODULE_PARM_DESC(radio_nr, "Radio device numbers");
788c2ecf20Sopenharmony_ci
798c2ecf20Sopenharmony_ci/*
808c2ecf20Sopenharmony_ci * Frequency calculation constants.  Intermediate frequency 10.52 MHz (nominal
818c2ecf20Sopenharmony_ci * value 10.7 MHz), reference divisor 6.39 kHz (nominal 6.25 kHz).
828c2ecf20Sopenharmony_ci */
838c2ecf20Sopenharmony_ci#define FSCALE		8
848c2ecf20Sopenharmony_ci#define IF_OFFSET	((unsigned int)(10.52 * 16000 * (1<<FSCALE)))
858c2ecf20Sopenharmony_ci#define REF_FREQ	((unsigned int)(6.39 * 16 * (1<<FSCALE)))
868c2ecf20Sopenharmony_ci
878c2ecf20Sopenharmony_ci#define GEMTEK_CK		0x01	/* Clock signal			*/
888c2ecf20Sopenharmony_ci#define GEMTEK_DA		0x02	/* Serial data			*/
898c2ecf20Sopenharmony_ci#define GEMTEK_CE		0x04	/* Chip enable			*/
908c2ecf20Sopenharmony_ci#define GEMTEK_NS		0x08	/* No signal			*/
918c2ecf20Sopenharmony_ci#define GEMTEK_MT		0x10	/* Line mute			*/
928c2ecf20Sopenharmony_ci#define GEMTEK_STDF_3_125_KHZ	0x01	/* Standard frequency 3.125 kHz	*/
938c2ecf20Sopenharmony_ci#define GEMTEK_PLL_OFF		0x07	/* PLL off			*/
948c2ecf20Sopenharmony_ci
958c2ecf20Sopenharmony_ci#define BU2614_BUS_SIZE	32	/* BU2614 / BU2614FS bus size		*/
968c2ecf20Sopenharmony_ci
978c2ecf20Sopenharmony_ci#define SHORT_DELAY 5		/* usec */
988c2ecf20Sopenharmony_ci#define LONG_DELAY 75		/* usec */
998c2ecf20Sopenharmony_ci
1008c2ecf20Sopenharmony_cistruct gemtek {
1018c2ecf20Sopenharmony_ci	struct radio_isa_card isa;
1028c2ecf20Sopenharmony_ci	bool muted;
1038c2ecf20Sopenharmony_ci	u32 bu2614data;
1048c2ecf20Sopenharmony_ci};
1058c2ecf20Sopenharmony_ci
1068c2ecf20Sopenharmony_ci#define BU2614_FREQ_BITS	16 /* D0..D15, Frequency data		*/
1078c2ecf20Sopenharmony_ci#define BU2614_PORT_BITS	3 /* P0..P2, Output port control data	*/
1088c2ecf20Sopenharmony_ci#define BU2614_VOID_BITS	4 /* unused				*/
1098c2ecf20Sopenharmony_ci#define BU2614_FMES_BITS	1 /* CT, Frequency measurement beginning data */
1108c2ecf20Sopenharmony_ci#define BU2614_STDF_BITS	3 /* R0..R2, Standard frequency data	*/
1118c2ecf20Sopenharmony_ci#define BU2614_SWIN_BITS	1 /* S, Switch between FMIN / AMIN	*/
1128c2ecf20Sopenharmony_ci#define BU2614_SWAL_BITS        1 /* PS, Swallow counter division (AMIN only)*/
1138c2ecf20Sopenharmony_ci#define BU2614_VOID2_BITS	1 /* unused				*/
1148c2ecf20Sopenharmony_ci#define BU2614_FMUN_BITS	1 /* GT, Frequency measurement time & unlock */
1158c2ecf20Sopenharmony_ci#define BU2614_TEST_BITS	1 /* TS, Test data is input		*/
1168c2ecf20Sopenharmony_ci
1178c2ecf20Sopenharmony_ci#define BU2614_FREQ_SHIFT	0
1188c2ecf20Sopenharmony_ci#define BU2614_PORT_SHIFT	(BU2614_FREQ_BITS + BU2614_FREQ_SHIFT)
1198c2ecf20Sopenharmony_ci#define BU2614_VOID_SHIFT	(BU2614_PORT_BITS + BU2614_PORT_SHIFT)
1208c2ecf20Sopenharmony_ci#define BU2614_FMES_SHIFT	(BU2614_VOID_BITS + BU2614_VOID_SHIFT)
1218c2ecf20Sopenharmony_ci#define BU2614_STDF_SHIFT	(BU2614_FMES_BITS + BU2614_FMES_SHIFT)
1228c2ecf20Sopenharmony_ci#define BU2614_SWIN_SHIFT	(BU2614_STDF_BITS + BU2614_STDF_SHIFT)
1238c2ecf20Sopenharmony_ci#define BU2614_SWAL_SHIFT	(BU2614_SWIN_BITS + BU2614_SWIN_SHIFT)
1248c2ecf20Sopenharmony_ci#define BU2614_VOID2_SHIFT	(BU2614_SWAL_BITS + BU2614_SWAL_SHIFT)
1258c2ecf20Sopenharmony_ci#define BU2614_FMUN_SHIFT	(BU2614_VOID2_BITS + BU2614_VOID2_SHIFT)
1268c2ecf20Sopenharmony_ci#define BU2614_TEST_SHIFT	(BU2614_FMUN_BITS + BU2614_FMUN_SHIFT)
1278c2ecf20Sopenharmony_ci
1288c2ecf20Sopenharmony_ci#define MKMASK(field)	(((1UL<<BU2614_##field##_BITS) - 1) << \
1298c2ecf20Sopenharmony_ci			BU2614_##field##_SHIFT)
1308c2ecf20Sopenharmony_ci#define BU2614_PORT_MASK	MKMASK(PORT)
1318c2ecf20Sopenharmony_ci#define BU2614_FREQ_MASK	MKMASK(FREQ)
1328c2ecf20Sopenharmony_ci#define BU2614_VOID_MASK	MKMASK(VOID)
1338c2ecf20Sopenharmony_ci#define BU2614_FMES_MASK	MKMASK(FMES)
1348c2ecf20Sopenharmony_ci#define BU2614_STDF_MASK	MKMASK(STDF)
1358c2ecf20Sopenharmony_ci#define BU2614_SWIN_MASK	MKMASK(SWIN)
1368c2ecf20Sopenharmony_ci#define BU2614_SWAL_MASK	MKMASK(SWAL)
1378c2ecf20Sopenharmony_ci#define BU2614_VOID2_MASK	MKMASK(VOID2)
1388c2ecf20Sopenharmony_ci#define BU2614_FMUN_MASK	MKMASK(FMUN)
1398c2ecf20Sopenharmony_ci#define BU2614_TEST_MASK	MKMASK(TEST)
1408c2ecf20Sopenharmony_ci
1418c2ecf20Sopenharmony_ci/*
1428c2ecf20Sopenharmony_ci * Set data which will be sent to BU2614FS.
1438c2ecf20Sopenharmony_ci */
1448c2ecf20Sopenharmony_ci#define gemtek_bu2614_set(dev, field, data) ((dev)->bu2614data = \
1458c2ecf20Sopenharmony_ci	((dev)->bu2614data & ~field##_MASK) | ((data) << field##_SHIFT))
1468c2ecf20Sopenharmony_ci
1478c2ecf20Sopenharmony_ci/*
1488c2ecf20Sopenharmony_ci * Transmit settings to BU2614FS over GemTek IC.
1498c2ecf20Sopenharmony_ci */
1508c2ecf20Sopenharmony_cistatic void gemtek_bu2614_transmit(struct gemtek *gt)
1518c2ecf20Sopenharmony_ci{
1528c2ecf20Sopenharmony_ci	struct radio_isa_card *isa = &gt->isa;
1538c2ecf20Sopenharmony_ci	int i, bit, q, mute;
1548c2ecf20Sopenharmony_ci
1558c2ecf20Sopenharmony_ci	mute = gt->muted ? GEMTEK_MT : 0x00;
1568c2ecf20Sopenharmony_ci
1578c2ecf20Sopenharmony_ci	outb_p(mute | GEMTEK_CE | GEMTEK_DA | GEMTEK_CK, isa->io);
1588c2ecf20Sopenharmony_ci	udelay(LONG_DELAY);
1598c2ecf20Sopenharmony_ci
1608c2ecf20Sopenharmony_ci	for (i = 0, q = gt->bu2614data; i < 32; i++, q >>= 1) {
1618c2ecf20Sopenharmony_ci		bit = (q & 1) ? GEMTEK_DA : 0;
1628c2ecf20Sopenharmony_ci		outb_p(mute | GEMTEK_CE | bit, isa->io);
1638c2ecf20Sopenharmony_ci		udelay(SHORT_DELAY);
1648c2ecf20Sopenharmony_ci		outb_p(mute | GEMTEK_CE | bit | GEMTEK_CK, isa->io);
1658c2ecf20Sopenharmony_ci		udelay(SHORT_DELAY);
1668c2ecf20Sopenharmony_ci	}
1678c2ecf20Sopenharmony_ci
1688c2ecf20Sopenharmony_ci	outb_p(mute | GEMTEK_DA | GEMTEK_CK, isa->io);
1698c2ecf20Sopenharmony_ci	udelay(SHORT_DELAY);
1708c2ecf20Sopenharmony_ci}
1718c2ecf20Sopenharmony_ci
1728c2ecf20Sopenharmony_ci/*
1738c2ecf20Sopenharmony_ci * Calculate divisor from FM-frequency for BU2614FS (3.125 KHz STDF expected).
1748c2ecf20Sopenharmony_ci */
1758c2ecf20Sopenharmony_cistatic unsigned long gemtek_convfreq(unsigned long freq)
1768c2ecf20Sopenharmony_ci{
1778c2ecf20Sopenharmony_ci	return ((freq << FSCALE) + IF_OFFSET + REF_FREQ / 2) / REF_FREQ;
1788c2ecf20Sopenharmony_ci}
1798c2ecf20Sopenharmony_ci
1808c2ecf20Sopenharmony_cistatic struct radio_isa_card *gemtek_alloc(void)
1818c2ecf20Sopenharmony_ci{
1828c2ecf20Sopenharmony_ci	struct gemtek *gt = kzalloc(sizeof(*gt), GFP_KERNEL);
1838c2ecf20Sopenharmony_ci
1848c2ecf20Sopenharmony_ci	if (gt)
1858c2ecf20Sopenharmony_ci		gt->muted = true;
1868c2ecf20Sopenharmony_ci	return gt ? &gt->isa : NULL;
1878c2ecf20Sopenharmony_ci}
1888c2ecf20Sopenharmony_ci
1898c2ecf20Sopenharmony_ci/*
1908c2ecf20Sopenharmony_ci * Set FM-frequency.
1918c2ecf20Sopenharmony_ci */
1928c2ecf20Sopenharmony_cistatic int gemtek_s_frequency(struct radio_isa_card *isa, u32 freq)
1938c2ecf20Sopenharmony_ci{
1948c2ecf20Sopenharmony_ci	struct gemtek *gt = container_of(isa, struct gemtek, isa);
1958c2ecf20Sopenharmony_ci
1968c2ecf20Sopenharmony_ci	if (hardmute && gt->muted)
1978c2ecf20Sopenharmony_ci		return 0;
1988c2ecf20Sopenharmony_ci
1998c2ecf20Sopenharmony_ci	gemtek_bu2614_set(gt, BU2614_PORT, 0);
2008c2ecf20Sopenharmony_ci	gemtek_bu2614_set(gt, BU2614_FMES, 0);
2018c2ecf20Sopenharmony_ci	gemtek_bu2614_set(gt, BU2614_SWIN, 0);	/* FM-mode	*/
2028c2ecf20Sopenharmony_ci	gemtek_bu2614_set(gt, BU2614_SWAL, 0);
2038c2ecf20Sopenharmony_ci	gemtek_bu2614_set(gt, BU2614_FMUN, 1);	/* GT bit set	*/
2048c2ecf20Sopenharmony_ci	gemtek_bu2614_set(gt, BU2614_TEST, 0);
2058c2ecf20Sopenharmony_ci	gemtek_bu2614_set(gt, BU2614_STDF, GEMTEK_STDF_3_125_KHZ);
2068c2ecf20Sopenharmony_ci	gemtek_bu2614_set(gt, BU2614_FREQ, gemtek_convfreq(freq));
2078c2ecf20Sopenharmony_ci	gemtek_bu2614_transmit(gt);
2088c2ecf20Sopenharmony_ci	return 0;
2098c2ecf20Sopenharmony_ci}
2108c2ecf20Sopenharmony_ci
2118c2ecf20Sopenharmony_ci/*
2128c2ecf20Sopenharmony_ci * Set mute flag.
2138c2ecf20Sopenharmony_ci */
2148c2ecf20Sopenharmony_cistatic int gemtek_s_mute_volume(struct radio_isa_card *isa, bool mute, int vol)
2158c2ecf20Sopenharmony_ci{
2168c2ecf20Sopenharmony_ci	struct gemtek *gt = container_of(isa, struct gemtek, isa);
2178c2ecf20Sopenharmony_ci	int i;
2188c2ecf20Sopenharmony_ci
2198c2ecf20Sopenharmony_ci	gt->muted = mute;
2208c2ecf20Sopenharmony_ci	if (hardmute) {
2218c2ecf20Sopenharmony_ci		if (!mute)
2228c2ecf20Sopenharmony_ci			return gemtek_s_frequency(isa, isa->freq);
2238c2ecf20Sopenharmony_ci
2248c2ecf20Sopenharmony_ci		/* Turn off PLL, disable data output */
2258c2ecf20Sopenharmony_ci		gemtek_bu2614_set(gt, BU2614_PORT, 0);
2268c2ecf20Sopenharmony_ci		gemtek_bu2614_set(gt, BU2614_FMES, 0);	/* CT bit off	*/
2278c2ecf20Sopenharmony_ci		gemtek_bu2614_set(gt, BU2614_SWIN, 0);	/* FM-mode	*/
2288c2ecf20Sopenharmony_ci		gemtek_bu2614_set(gt, BU2614_SWAL, 0);
2298c2ecf20Sopenharmony_ci		gemtek_bu2614_set(gt, BU2614_FMUN, 0);	/* GT bit off	*/
2308c2ecf20Sopenharmony_ci		gemtek_bu2614_set(gt, BU2614_TEST, 0);
2318c2ecf20Sopenharmony_ci		gemtek_bu2614_set(gt, BU2614_STDF, GEMTEK_PLL_OFF);
2328c2ecf20Sopenharmony_ci		gemtek_bu2614_set(gt, BU2614_FREQ, 0);
2338c2ecf20Sopenharmony_ci		gemtek_bu2614_transmit(gt);
2348c2ecf20Sopenharmony_ci		return 0;
2358c2ecf20Sopenharmony_ci	}
2368c2ecf20Sopenharmony_ci
2378c2ecf20Sopenharmony_ci	/* Read bus contents (CE, CK and DA). */
2388c2ecf20Sopenharmony_ci	i = inb_p(isa->io);
2398c2ecf20Sopenharmony_ci	/* Write it back with mute flag set. */
2408c2ecf20Sopenharmony_ci	outb_p((i >> 5) | (mute ? GEMTEK_MT : 0), isa->io);
2418c2ecf20Sopenharmony_ci	udelay(SHORT_DELAY);
2428c2ecf20Sopenharmony_ci	return 0;
2438c2ecf20Sopenharmony_ci}
2448c2ecf20Sopenharmony_ci
2458c2ecf20Sopenharmony_cistatic u32 gemtek_g_rxsubchans(struct radio_isa_card *isa)
2468c2ecf20Sopenharmony_ci{
2478c2ecf20Sopenharmony_ci	if (inb_p(isa->io) & GEMTEK_NS)
2488c2ecf20Sopenharmony_ci		return V4L2_TUNER_SUB_MONO;
2498c2ecf20Sopenharmony_ci	return V4L2_TUNER_SUB_STEREO;
2508c2ecf20Sopenharmony_ci}
2518c2ecf20Sopenharmony_ci
2528c2ecf20Sopenharmony_ci/*
2538c2ecf20Sopenharmony_ci * Check if requested card acts like GemTek Radio card.
2548c2ecf20Sopenharmony_ci */
2558c2ecf20Sopenharmony_cistatic bool gemtek_probe(struct radio_isa_card *isa, int io)
2568c2ecf20Sopenharmony_ci{
2578c2ecf20Sopenharmony_ci	int i, q;
2588c2ecf20Sopenharmony_ci
2598c2ecf20Sopenharmony_ci	q = inb_p(io);	/* Read bus contents before probing. */
2608c2ecf20Sopenharmony_ci	/* Try to turn on CE, CK and DA respectively and check if card responds
2618c2ecf20Sopenharmony_ci	   properly. */
2628c2ecf20Sopenharmony_ci	for (i = 0; i < 3; ++i) {
2638c2ecf20Sopenharmony_ci		outb_p(1 << i, io);
2648c2ecf20Sopenharmony_ci		udelay(SHORT_DELAY);
2658c2ecf20Sopenharmony_ci
2668c2ecf20Sopenharmony_ci		if ((inb_p(io) & ~GEMTEK_NS) != (0x17 | (1 << (i + 5))))
2678c2ecf20Sopenharmony_ci			return false;
2688c2ecf20Sopenharmony_ci	}
2698c2ecf20Sopenharmony_ci	outb_p(q >> 5, io);	/* Write bus contents back. */
2708c2ecf20Sopenharmony_ci	udelay(SHORT_DELAY);
2718c2ecf20Sopenharmony_ci	return true;
2728c2ecf20Sopenharmony_ci}
2738c2ecf20Sopenharmony_ci
2748c2ecf20Sopenharmony_cistatic const struct radio_isa_ops gemtek_ops = {
2758c2ecf20Sopenharmony_ci	.alloc = gemtek_alloc,
2768c2ecf20Sopenharmony_ci	.probe = gemtek_probe,
2778c2ecf20Sopenharmony_ci	.s_mute_volume = gemtek_s_mute_volume,
2788c2ecf20Sopenharmony_ci	.s_frequency = gemtek_s_frequency,
2798c2ecf20Sopenharmony_ci	.g_rxsubchans = gemtek_g_rxsubchans,
2808c2ecf20Sopenharmony_ci};
2818c2ecf20Sopenharmony_ci
2828c2ecf20Sopenharmony_cistatic const int gemtek_ioports[] = { 0x20c, 0x30c, 0x24c, 0x34c, 0x248, 0x28c };
2838c2ecf20Sopenharmony_ci
2848c2ecf20Sopenharmony_ci#ifdef CONFIG_PNP
2858c2ecf20Sopenharmony_cistatic const struct pnp_device_id gemtek_pnp_devices[] = {
2868c2ecf20Sopenharmony_ci	/* AOpen FX-3D/Pro Radio */
2878c2ecf20Sopenharmony_ci	{.id = "ADS7183", .driver_data = 0},
2888c2ecf20Sopenharmony_ci	{.id = ""}
2898c2ecf20Sopenharmony_ci};
2908c2ecf20Sopenharmony_ci
2918c2ecf20Sopenharmony_ciMODULE_DEVICE_TABLE(pnp, gemtek_pnp_devices);
2928c2ecf20Sopenharmony_ci#endif
2938c2ecf20Sopenharmony_ci
2948c2ecf20Sopenharmony_cistatic struct radio_isa_driver gemtek_driver = {
2958c2ecf20Sopenharmony_ci	.driver = {
2968c2ecf20Sopenharmony_ci		.match		= radio_isa_match,
2978c2ecf20Sopenharmony_ci		.probe		= radio_isa_probe,
2988c2ecf20Sopenharmony_ci		.remove		= radio_isa_remove,
2998c2ecf20Sopenharmony_ci		.driver		= {
3008c2ecf20Sopenharmony_ci			.name	= "radio-gemtek",
3018c2ecf20Sopenharmony_ci		},
3028c2ecf20Sopenharmony_ci	},
3038c2ecf20Sopenharmony_ci#ifdef CONFIG_PNP
3048c2ecf20Sopenharmony_ci	.pnp_driver = {
3058c2ecf20Sopenharmony_ci		.name		= "radio-gemtek",
3068c2ecf20Sopenharmony_ci		.id_table	= gemtek_pnp_devices,
3078c2ecf20Sopenharmony_ci		.probe		= radio_isa_pnp_probe,
3088c2ecf20Sopenharmony_ci		.remove		= radio_isa_pnp_remove,
3098c2ecf20Sopenharmony_ci	},
3108c2ecf20Sopenharmony_ci#endif
3118c2ecf20Sopenharmony_ci	.io_params = io,
3128c2ecf20Sopenharmony_ci	.radio_nr_params = radio_nr,
3138c2ecf20Sopenharmony_ci	.io_ports = gemtek_ioports,
3148c2ecf20Sopenharmony_ci	.num_of_io_ports = ARRAY_SIZE(gemtek_ioports),
3158c2ecf20Sopenharmony_ci	.region_size = 1,
3168c2ecf20Sopenharmony_ci	.card = "GemTek Radio",
3178c2ecf20Sopenharmony_ci	.ops = &gemtek_ops,
3188c2ecf20Sopenharmony_ci	.has_stereo = true,
3198c2ecf20Sopenharmony_ci};
3208c2ecf20Sopenharmony_ci
3218c2ecf20Sopenharmony_cistatic int __init gemtek_init(void)
3228c2ecf20Sopenharmony_ci{
3238c2ecf20Sopenharmony_ci	gemtek_driver.probe = probe;
3248c2ecf20Sopenharmony_ci#ifdef CONFIG_PNP
3258c2ecf20Sopenharmony_ci	pnp_register_driver(&gemtek_driver.pnp_driver);
3268c2ecf20Sopenharmony_ci#endif
3278c2ecf20Sopenharmony_ci	return isa_register_driver(&gemtek_driver.driver, GEMTEK_MAX);
3288c2ecf20Sopenharmony_ci}
3298c2ecf20Sopenharmony_ci
3308c2ecf20Sopenharmony_cistatic void __exit gemtek_exit(void)
3318c2ecf20Sopenharmony_ci{
3328c2ecf20Sopenharmony_ci	hardmute = true;	/* Turn off PLL */
3338c2ecf20Sopenharmony_ci#ifdef CONFIG_PNP
3348c2ecf20Sopenharmony_ci	pnp_unregister_driver(&gemtek_driver.pnp_driver);
3358c2ecf20Sopenharmony_ci#endif
3368c2ecf20Sopenharmony_ci	isa_unregister_driver(&gemtek_driver.driver);
3378c2ecf20Sopenharmony_ci}
3388c2ecf20Sopenharmony_ci
3398c2ecf20Sopenharmony_cimodule_init(gemtek_init);
3408c2ecf20Sopenharmony_cimodule_exit(gemtek_exit);
341