1/* 2 * Linux driver for digital TV devices equipped with B2C2 FlexcopII(b)/III 3 * flexcop-sram.c - functions for controlling the SRAM 4 * see flexcop.c for copyright information 5 */ 6#include "flexcop.h" 7 8static void flexcop_sram_set_chip(struct flexcop_device *fc, 9 flexcop_sram_type_t type) 10{ 11 flexcop_set_ibi_value(wan_ctrl_reg_71c, sram_chip, type); 12} 13 14int flexcop_sram_init(struct flexcop_device *fc) 15{ 16 switch (fc->rev) { 17 case FLEXCOP_II: 18 case FLEXCOP_IIB: 19 flexcop_sram_set_chip(fc, FC_SRAM_1_32KB); 20 break; 21 case FLEXCOP_III: 22 flexcop_sram_set_chip(fc, FC_SRAM_1_48KB); 23 break; 24 default: 25 return -EINVAL; 26 } 27 return 0; 28} 29 30int flexcop_sram_set_dest(struct flexcop_device *fc, flexcop_sram_dest_t dest, 31 flexcop_sram_dest_target_t target) 32{ 33 flexcop_ibi_value v; 34 v = fc->read_ibi_reg(fc, sram_dest_reg_714); 35 36 if (fc->rev != FLEXCOP_III && target == FC_SRAM_DEST_TARGET_FC3_CA) { 37 err("SRAM destination target to available on FlexCopII(b)\n"); 38 return -EINVAL; 39 } 40 deb_sram("sram dest: %x target: %x\n", dest, target); 41 42 if (dest & FC_SRAM_DEST_NET) 43 v.sram_dest_reg_714.NET_Dest = target; 44 if (dest & FC_SRAM_DEST_CAI) 45 v.sram_dest_reg_714.CAI_Dest = target; 46 if (dest & FC_SRAM_DEST_CAO) 47 v.sram_dest_reg_714.CAO_Dest = target; 48 if (dest & FC_SRAM_DEST_MEDIA) 49 v.sram_dest_reg_714.MEDIA_Dest = target; 50 51 fc->write_ibi_reg(fc,sram_dest_reg_714,v); 52 udelay(1000); /* TODO delay really necessary */ 53 54 return 0; 55} 56EXPORT_SYMBOL(flexcop_sram_set_dest); 57 58void flexcop_wan_set_speed(struct flexcop_device *fc, flexcop_wan_speed_t s) 59{ 60 flexcop_set_ibi_value(wan_ctrl_reg_71c,wan_speed_sig,s); 61} 62EXPORT_SYMBOL(flexcop_wan_set_speed); 63 64void flexcop_sram_ctrl(struct flexcop_device *fc, int usb_wan, int sramdma, int maximumfill) 65{ 66 flexcop_ibi_value v = fc->read_ibi_reg(fc,sram_dest_reg_714); 67 v.sram_dest_reg_714.ctrl_usb_wan = usb_wan; 68 v.sram_dest_reg_714.ctrl_sramdma = sramdma; 69 v.sram_dest_reg_714.ctrl_maximumfill = maximumfill; 70 fc->write_ibi_reg(fc,sram_dest_reg_714,v); 71} 72EXPORT_SYMBOL(flexcop_sram_ctrl); 73