Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2)  * Linux driver for digital TV devices equipped with B2C2 FlexcopII(b)/III
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * flexcop.c - main module part
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  * Copyright (C) 2004-9 Patrick Boettcher <patrick.boettcher@posteo.de>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * based on skystar2-driver Copyright (C) 2003 Vadim Catana, skystar@moldova.cc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  * Acknowledgements:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  *   John Jurrius from BBTI, Inc. for extensive support
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  *                    with code examples and data books
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  *   Bjarne Steinsbo, bjarne at steinsbo.com (some ideas for rewriting)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12)  * Contributions to the skystar2-driver have been done by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13)  *   Vincenzo Di Massa, hawk.it at tiscalinet.it (several DiSEqC fixes)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14)  *   Roberto Ragusa, r.ragusa at libero.it (polishing, restyling the code)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15)  *   Uwe Bugla, uwe.bugla at gmx.de (doing tests, restyling code, writing docu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16)  *   Niklas Peinecke, peinecke at gdv.uni-hannover.de (hardware pid/mac
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17)  *               filtering)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19)  * This program is free software; you can redistribute it and/or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20)  * modify it under the terms of the GNU Lesser General Public License
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21)  * as published by the Free Software Foundation; either version 2.1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22)  * of the License, or (at your option) any later version.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24)  * This program is distributed in the hope that it will be useful,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25)  * but WITHOUT ANY WARRANTY; without even the implied warranty of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26)  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27)  * GNU General Public License for more details.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) #include "flexcop.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) #define DRIVER_NAME "B2C2 FlexcopII/II(b)/III digital TV receiver chip"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) #define DRIVER_AUTHOR "Patrick Boettcher <patrick.boettcher@posteo.de"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) #ifdef CONFIG_DVB_B2C2_FLEXCOP_DEBUG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) #define DEBSTATUS ""
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) #define DEBSTATUS " (debugging is not enabled)"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) int b2c2_flexcop_debug;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) EXPORT_SYMBOL_GPL(b2c2_flexcop_debug);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) module_param_named(debug, b2c2_flexcop_debug,  int, 0644);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) MODULE_PARM_DESC(debug,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 		"set debug level (1=info,2=tuner,4=i2c,8=ts,16=sram,32=reg,64=i2cdump (|-able))."
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 		DEBSTATUS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) #undef DEBSTATUS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) /* global zero for ibi values */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) flexcop_ibi_value ibi_zero;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) static int flexcop_dvb_start_feed(struct dvb_demux_feed *dvbdmxfeed)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	struct flexcop_device *fc = dvbdmxfeed->demux->priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	return flexcop_pid_feed_control(fc, dvbdmxfeed, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) static int flexcop_dvb_stop_feed(struct dvb_demux_feed *dvbdmxfeed)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	struct flexcop_device *fc = dvbdmxfeed->demux->priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	return flexcop_pid_feed_control(fc, dvbdmxfeed, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) static int flexcop_dvb_init(struct flexcop_device *fc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	int ret = dvb_register_adapter(&fc->dvb_adapter,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 			"FlexCop Digital TV device", fc->owner,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 			fc->dev, adapter_nr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	if (ret < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 		err("error registering DVB adapter");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	fc->dvb_adapter.priv = fc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	fc->demux.dmx.capabilities = (DMX_TS_FILTERING | DMX_SECTION_FILTERING
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 			| DMX_MEMORY_BASED_FILTERING);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	fc->demux.priv = fc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	fc->demux.filternum = fc->demux.feednum = FC_MAX_FEED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	fc->demux.start_feed = flexcop_dvb_start_feed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	fc->demux.stop_feed = flexcop_dvb_stop_feed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	fc->demux.write_to_decoder = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	ret = dvb_dmx_init(&fc->demux);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	if (ret < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 		err("dvb_dmx failed: error %d", ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 		goto err_dmx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	fc->hw_frontend.source = DMX_FRONTEND_0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	fc->dmxdev.filternum = fc->demux.feednum;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	fc->dmxdev.demux = &fc->demux.dmx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	fc->dmxdev.capabilities = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	ret = dvb_dmxdev_init(&fc->dmxdev, &fc->dvb_adapter);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	if (ret < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 		err("dvb_dmxdev_init failed: error %d", ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 		goto err_dmx_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	ret = fc->demux.dmx.add_frontend(&fc->demux.dmx, &fc->hw_frontend);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	if (ret < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 		err("adding hw_frontend to dmx failed: error %d", ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 		goto err_dmx_add_hw_frontend;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	fc->mem_frontend.source = DMX_MEMORY_FE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	ret = fc->demux.dmx.add_frontend(&fc->demux.dmx, &fc->mem_frontend);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	if (ret < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 		err("adding mem_frontend to dmx failed: error %d", ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 		goto err_dmx_add_mem_frontend;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	ret = fc->demux.dmx.connect_frontend(&fc->demux.dmx, &fc->hw_frontend);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	if (ret < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 		err("connect frontend failed: error %d", ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 		goto err_connect_frontend;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	ret = dvb_net_init(&fc->dvb_adapter, &fc->dvbnet, &fc->demux.dmx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	if (ret < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 		err("dvb_net_init failed: error %d", ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 		goto err_net;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 	fc->init_state |= FC_STATE_DVB_INIT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) err_net:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	fc->demux.dmx.disconnect_frontend(&fc->demux.dmx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) err_connect_frontend:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 	fc->demux.dmx.remove_frontend(&fc->demux.dmx, &fc->mem_frontend);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) err_dmx_add_mem_frontend:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 	fc->demux.dmx.remove_frontend(&fc->demux.dmx, &fc->hw_frontend);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) err_dmx_add_hw_frontend:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 	dvb_dmxdev_release(&fc->dmxdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) err_dmx_dev:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 	dvb_dmx_release(&fc->demux);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) err_dmx:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 	dvb_unregister_adapter(&fc->dvb_adapter);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) static void flexcop_dvb_exit(struct flexcop_device *fc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	if (fc->init_state & FC_STATE_DVB_INIT) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 		dvb_net_release(&fc->dvbnet);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 		fc->demux.dmx.close(&fc->demux.dmx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 		fc->demux.dmx.remove_frontend(&fc->demux.dmx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 			&fc->mem_frontend);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 		fc->demux.dmx.remove_frontend(&fc->demux.dmx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 			&fc->hw_frontend);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 		dvb_dmxdev_release(&fc->dmxdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 		dvb_dmx_release(&fc->demux);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 		dvb_unregister_adapter(&fc->dvb_adapter);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 		deb_info("deinitialized dvb stuff\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 	fc->init_state &= ~FC_STATE_DVB_INIT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) /* these methods are necessary to achieve the long-term-goal of hiding the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164)  * struct flexcop_device from the bus-parts */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) void flexcop_pass_dmx_data(struct flexcop_device *fc, u8 *buf, u32 len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 	dvb_dmx_swfilter(&fc->demux, buf, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) EXPORT_SYMBOL(flexcop_pass_dmx_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) void flexcop_pass_dmx_packets(struct flexcop_device *fc, u8 *buf, u32 no)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 	dvb_dmx_swfilter_packets(&fc->demux, buf, no);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) EXPORT_SYMBOL(flexcop_pass_dmx_packets);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) static void flexcop_reset(struct flexcop_device *fc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 	flexcop_ibi_value v210, v204;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 	/* reset the flexcop itself */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 	fc->write_ibi_reg(fc,ctrl_208,ibi_zero);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 	v210.raw = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 	v210.sw_reset_210.reset_block_000 = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 	v210.sw_reset_210.reset_block_100 = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 	v210.sw_reset_210.reset_block_200 = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 	v210.sw_reset_210.reset_block_300 = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 	v210.sw_reset_210.reset_block_400 = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 	v210.sw_reset_210.reset_block_500 = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 	v210.sw_reset_210.reset_block_600 = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 	v210.sw_reset_210.reset_block_700 = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 	v210.sw_reset_210.Block_reset_enable = 0xb2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 	v210.sw_reset_210.Special_controls = 0xc259;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 	fc->write_ibi_reg(fc,sw_reset_210,v210);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 	msleep(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 	/* reset the periphical devices */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 	v204 = fc->read_ibi_reg(fc,misc_204);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 	v204.misc_204.Per_reset_sig = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 	fc->write_ibi_reg(fc,misc_204,v204);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 	msleep(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 	v204.misc_204.Per_reset_sig = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 	fc->write_ibi_reg(fc,misc_204,v204);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) void flexcop_reset_block_300(struct flexcop_device *fc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 	flexcop_ibi_value v208_save = fc->read_ibi_reg(fc, ctrl_208),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 			  v210 = fc->read_ibi_reg(fc, sw_reset_210);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 	deb_rdump("208: %08x, 210: %08x\n", v208_save.raw, v210.raw);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 	fc->write_ibi_reg(fc,ctrl_208,ibi_zero);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 	v210.sw_reset_210.reset_block_300 = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 	v210.sw_reset_210.Block_reset_enable = 0xb2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 	fc->write_ibi_reg(fc,sw_reset_210,v210);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 	fc->write_ibi_reg(fc,ctrl_208,v208_save);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) struct flexcop_device *flexcop_device_kmalloc(size_t bus_specific_len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 	void *bus;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 	struct flexcop_device *fc = kzalloc(sizeof(struct flexcop_device),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 				GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 	if (!fc) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 		err("no memory");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 		return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 	bus = kzalloc(bus_specific_len, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 	if (!bus) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 		err("no memory");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 		kfree(fc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 		return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 	fc->bus_specific = bus;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 	return fc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) EXPORT_SYMBOL(flexcop_device_kmalloc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) void flexcop_device_kfree(struct flexcop_device *fc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 	kfree(fc->bus_specific);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 	kfree(fc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) EXPORT_SYMBOL(flexcop_device_kfree);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) int flexcop_device_initialize(struct flexcop_device *fc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 	ibi_zero.raw = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 	flexcop_reset(fc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 	flexcop_determine_revision(fc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 	flexcop_sram_init(fc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 	flexcop_hw_filter_init(fc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 	flexcop_smc_ctrl(fc, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 	ret = flexcop_dvb_init(fc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 	if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 		goto error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 	/* i2c has to be done before doing EEProm stuff -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 	 * because the EEProm is accessed via i2c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 	ret = flexcop_i2c_init(fc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 	if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 		goto error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 	/* do the MAC address reading after initializing the dvb_adapter */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 	if (fc->get_mac_addr(fc, 0) == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 		u8 *b = fc->dvb_adapter.proposed_mac;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 		info("MAC address = %pM", b);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 		flexcop_set_mac_filter(fc,b);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 		flexcop_mac_filter_ctrl(fc,1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 	} else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 		warn("reading of MAC address failed.\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 	ret = flexcop_frontend_init(fc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 	if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 		goto error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 	flexcop_device_name(fc,"initialization of","complete");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) error:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 	flexcop_device_exit(fc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) EXPORT_SYMBOL(flexcop_device_initialize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) void flexcop_device_exit(struct flexcop_device *fc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 	flexcop_frontend_exit(fc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 	flexcop_i2c_exit(fc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 	flexcop_dvb_exit(fc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) EXPORT_SYMBOL(flexcop_device_exit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) static int flexcop_module_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 	info(DRIVER_NAME " loaded successfully");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) static void flexcop_module_cleanup(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) 	info(DRIVER_NAME " unloaded successfully");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) module_init(flexcop_module_init);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) module_exit(flexcop_module_cleanup);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) MODULE_AUTHOR(DRIVER_AUTHOR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) MODULE_DESCRIPTION(DRIVER_NAME);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) MODULE_LICENSE("GPL");