Commit 83cfb429 authored by Andrey Filippov's avatar Andrey Filippov
Browse files

debuging Boson driver

parent 6405f029
Loading
Loading
Loading
Loading
+12 −8
Original line number Original line Diff line number Diff line
@@ -295,7 +295,7 @@ struct sensor_t boson640={
};
};


// Sysfs Interface for debugging the driver
// Sysfs Interface for debugging the driver
static int first_sensor_sa7 [SENSOR_PORTS] = {0,0,0,0};
//static int first_sensor_sa7 [SENSOR_PORTS] = {0,0,0,0};
/*
/*
static unsigned int debug_delays = 0x0; // 0x6464; // udelay() values for mrst (low 8 - mrst on), [15:8] - after mrst
static unsigned int debug_delays = 0x0; // 0x6464; // udelay() values for mrst (low 8 - mrst on), [15:8] - after mrst
static unsigned int debug_modes =  3;
static unsigned int debug_modes =  3;
@@ -835,7 +835,7 @@ int boson640_is_booted ( int sensor_port,
	cframe = getThisFrameNumber(sensor_port); // was cframe16?
	cframe = getThisFrameNumber(sensor_port); // was cframe16?
	if (cframe < BOSON640_BOOT_FRAME){
	if (cframe < BOSON640_BOOT_FRAME){
//        dev_warn(g_dev_ptr,"boson640_is_booted(): Not yet fully booted{%d}, frame %d < %d\n",sensor_port, cframe, BOSON640_BOOT_FRAME);
//        dev_warn(g_dev_ptr,"boson640_is_booted(): Not yet fully booted{%d}, frame %d < %d\n",sensor_port, cframe, BOSON640_BOOT_FRAME);
        dev_warn(g_dev_ptr,"boson640_is_booted(): Not yet fully booted{%d}, frame %d < %d, P_COLOR =%ld\n",sensor_port, cframe, BOSON640_BOOT_FRAME,thispars->pars[P_COLOR]);
        dev_dbg(g_dev_ptr,"boson640_is_booted(): Not yet fully booted{%d}, frame %d < %d, P_COLOR =%ld\n",sensor_port, cframe, BOSON640_BOOT_FRAME,thispars->pars[P_COLOR]);
		return 0; // too early
		return 0; // too early
	}
	}
    setFramePar(sensor_port, thispars, P_BOOTED,  1); // should initiate pgm_initsensor and others?
    setFramePar(sensor_port, thispars, P_BOOTED,  1); // should initiate pgm_initsensor and others?
@@ -965,6 +965,11 @@ int boson640_pgm_initsensor (int sensor_port, ///< sensor port
    i2c_stop_run_reset      (sensor_port, I2C_CMD_RUN);  // also programs status update
    i2c_stop_run_reset      (sensor_port, I2C_CMD_RUN);  // also programs status update
  #endif
  #endif


    // Enable extif (Boson UART CCI from the sequencer)
    uart_extif_en[sensor_port] = 1;
	set_sensor_uart_ctl_boson (sensor_port, uart_extif_en[sensor_port], -1, -1, 0, 0);
    dev_info(g_dev_ptr,"boson640_pgm_initsensor(): {%d}  frame16=%d frame=%ld: Enable EXTIF (Boson UART control from the sequencer)\n",sensor_port,frame16,getThisFrameNumber(sensor_port));

//    boson640_par2addr
//    boson640_par2addr


// read shadows from the sensor, ignore errors
// read shadows from the sensor, ignore errors
@@ -1854,11 +1859,10 @@ int boson640_init(struct platform_device *pdev)
//    int res;
//    int res;
    struct device *dev = &pdev->dev;
    struct device *dev = &pdev->dev;
//    const struct of_device_id *match;
//    const struct of_device_id *match;
    int sensor_port;
///    int sensor_port;

///    for (sensor_port = 0; sensor_port < SENSOR_PORTS; sensor_port++) {
    for (sensor_port = 0; sensor_port < SENSOR_PORTS; sensor_port++) {
///        first_sensor_sa7[sensor_port] = 0;
        first_sensor_sa7[sensor_port] = 0;
///    }
    }
    elphel393_boson640_sysfs_register(pdev);
    elphel393_boson640_sysfs_register(pdev);
    dev_info(dev, DEV393_NAME(DEV393_BOSON640)": registered sysfs\n");
    dev_info(dev, DEV393_NAME(DEV393_BOSON640)": registered sysfs\n");
    g_dev_ptr = dev;
    g_dev_ptr = dev;
+0 −163
Original line number Original line Diff line number Diff line
@@ -15,169 +15,6 @@
*  You should have received a copy of the GNU General Public License
*  You should have received a copy of the GNU General Public License
*  along with this program.  If not, see <http://www.gnu.org/licenses/>.
*  along with this program.  If not, see <http://www.gnu.org/licenses/>.
*******************************************************************************/
*******************************************************************************/
/*  $Log: pgm_functions.c,v $
*!  Revision 1.24  2012/03/14 00:05:41  elphel
*!  8.2.1 - GPS speed, x353.bit file tested on Eyesis
*!
*!  Revision 1.23  2012/01/16 01:48:00  elphel
*!  increased initial sensor clock frequency (20MHz->40MHz)
*!
*!  Revision 1.22  2011/12/22 05:40:05  elphel
*!  bug fix
*!
*!  Revision 1.21  2010/08/10 21:10:41  elphel
*!  portrait mode now includes all 4 rotations (2 bits)
*!
*!  Revision 1.20  2010/08/03 23:37:34  elphel
*!  rev 8.0.8.37, portrait mode support
*!
*!  Revision 1.19  2010/08/01 19:29:24  elphel
*!  files updated to support coring function for noise filtering
*!
*!  Revision 1.18  2010/06/06 04:24:10  elphel
*!  updated debug message
*!
*!  Revision 1.17  2010/06/05 07:11:48  elphel
*!  modified startup options
*!
*!  Revision 1.16  2010/06/02 16:31:04  elphel
*!  Added P_MULTI_SELECTED parameter
*!
*!  Revision 1.15  2010/06/01 08:30:36  elphel
*!  support for the FPGA code 03534022  with optional master time stamp over the inter-camera sync line(s)
*!
*!  Revision 1.14  2010/05/25 00:52:23  elphel
*!  8.0.8.20, working on multi-sensor
*!
*!  Revision 1.13  2010/05/21 06:12:16  elphel
*!  continue working on multi-sensor software
*!
*!  Revision 1.12  2010/05/13 03:39:31  elphel
*!  8.0.8.12 -  drivers modified for multi-sensor operation
*!
*!  Revision 1.11  2010/04/30 23:38:49  elphel
*!  fixed WOI_TOP in linescan mode
*!
*!  Revision 1.10  2010/04/30 00:29:54  elphel
*!  bug fixes related to linescan mode
*!
*!  Revision 1.9  2010/04/28 02:34:33  elphel
*!  8.0.6.6 - added support for linescan mode (also useful for high fps small images). 2.5K full line pairs/second with 5MPix sensor
*!
*!  Revision 1.8  2010/04/24 21:40:15  elphel
*!  8.0.8.4 (FPGA 03534016), most changes related to sensor signals phase adjustments
*!
*!  Revision 1.7  2010/01/27 22:51:52  elphel
*!  turned off ELPHEL_DEBUG, fixed errors caused by that.
*!
*!  Revision 1.6  2009/03/16 02:07:41  elphel
*!  Bug fix when calculating total width for focus processing - FPGA requires data 16 less than the actual WOI width
*!
*!  Revision 1.5  2008/12/08 21:55:02  elphel
*!  making 3MPix work, minor cleanup
*!
*!  Revision 1.4  2008/12/02 19:11:08  elphel
*!  bug fix in sensor detection, removed unneeded initialization for P_GAIN*
*!
*!  Revision 1.3  2008/12/02 00:29:04  elphel
*!  Added FIXME for the known problem
*!
*!  Revision 1.2  2008/11/30 05:01:03  elphel
*!  Changing gains/scales behavior
*!
*!  Revision 1.1.1.1  2008/11/27 20:04:00  elphel
*!
*!
*!  Revision 1.32  2008/11/27 09:27:31  elphel
*!  Support fro new parameters (vignetting correction related)
*!
*!  Revision 1.31  2008/11/14 01:01:40  elphel
*!  fixed new bug in pgm_gammaload
*!
*!  Revision 1.30  2008/11/13 05:40:45  elphel
*!  8.0.alpha16 - modified histogram storage, profiling
*!
*!  Revision 1.29  2008/11/03 18:43:18  elphel
*!  8.0.alpha12 with working apps/astreamer
*!
*!  Revision 1.28  2008/10/31 18:26:32  elphel
*!  Adding support for constants like SENSOR_REGS32 (defined constant plus 32 to simplify referencing sensor registers from PHP
*!
*!  Revision 1.27  2008/10/29 04:18:28  elphel
*!  v.8.0.alpha10 made a separate structure for global parameters (not related to particular frames in a frame queue)
*!
*!  Revision 1.26  2008/10/23 08:08:05  elphel
*!  corrected histogram window size setup (data written to FPGA is actual window size -2 for both width and height)
*!
*!  Revision 1.25  2008/10/22 05:29:03  elphel
*!  Rev. 8.0.alpha5 - working on external trigger mode - moved programming away from the sequencer that can only pass 24 data bits
*!
*!  Revision 1.24  2008/10/21 04:03:39  elphel
*!  bug fix (missing break in switch)
*!
*!  Revision 1.23  2008/10/20 18:45:07  elphel
*!  just more debug printk
*!
*!  Revision 1.22  2008/10/18 06:14:21  elphel
*!  8.0.alpha4 - removed some obsolete parameters, renumbered others, split P_FLIP into P_FLIPH and P_FLIPV (different latencies because of bad frames), pgm_window-> pgm_window, pgm_window_safe
*!
*!  Revision 1.21  2008/10/17 05:44:48  elphel
*!  fixing latencies
*!
*!  Revision 1.20  2008/10/12 06:13:10  elphel
*!  snapshot
*!
*!  Revision 1.19  2008/10/11 18:46:07  elphel
*!  snapshot
*!
*!  Revision 1.18  2008/10/08 21:26:25  elphel
*!  snapsot 7.2.0.pre4 - first images (actually - second)
*!
*!  Revision 1.17  2008/10/06 08:33:03  elphel
*!  snapshot, first images
*!
*!  Revision 1.15  2008/10/05 05:13:33  elphel
*!  snapshot003
*!
*!  Revision 1.14  2008/10/04 16:10:12  elphel
*!  snapshot
*!
*!  Revision 1.13  2008/09/28 00:31:57  elphel
*!  snapshot
*!
*!  Revision 1.12  2008/09/25 00:58:12  elphel
*!  snapshot
*!
*!  Revision 1.11  2008/09/22 22:55:49  elphel
*!  snapshot
*!
*!  Revision 1.10  2008/09/19 04:37:26  elphel
*!  snapshot
*!
*!  Revision 1.9  2008/09/16 00:49:32  elphel
*!  snapshot
*!
*!  Revision 1.8  2008/09/12 20:40:13  elphel
*!  snapshot
*!
*!  Revision 1.7  2008/09/12 00:23:59  elphel
*!  removed cc353.c, cc353.h
*!
*!  Revision 1.6  2008/09/05 23:21:32  elphel
*!  snapshot
*!
*!  Revision 1.4  2008/09/04 17:37:13  elphel
*!  documenting
*!
*!  Revision 1.3  2008/07/29 01:15:06  elphel
*!  another snapshot
*!
*!  Revision 1.2  2008/07/27 23:25:07  elphel
*!  next snapshot
*!
*!  Revision 1.1  2008/07/27 04:27:49  elphel
*!  next snapshot
*/


// TODO:remove unneeded
// TODO:remove unneeded
//#define DEBUG // should be before linux/module.h - enables dev_dbg at boot in this file (needs "debug" in bootarg)
//#define DEBUG // should be before linux/module.h - enables dev_dbg at boot in this file (needs "debug" in bootarg)
+3 −1
Original line number Original line Diff line number Diff line
@@ -1209,7 +1209,8 @@ int fpga_register_i2c_pages(int port, int sub_chn, x393_i2c_device_t i2c_dev){


		haddr = (table[i]>>8)&0xff;
		haddr = (table[i]>>8)&0xff;


		dev_dbg(g_dev_ptr,"Registering page %d for haddr= 0x%02x, sa7= 0x%02x\n",line_num, haddr, i2c_dev.slave7);
//		dev_dbg(g_dev_ptr,"Registering page %d for haddr= 0x%02x, sa7= 0x%02x\n",line_num, haddr, i2c_dev.slave7);
//		dev_info(g_dev_ptr,"Registering page %d for haddr= 0x%02x, sa7= 0x%02x\n",line_num, haddr, i2c_dev.slave7);


		if ((table[i]==0xffff)||(i>255)){
		if ((table[i]==0xffff)||(i>255)){
			dev_dbg(g_dev_ptr,"haddr2rec (entries: %d)\n",i);
			dev_dbg(g_dev_ptr,"haddr2rec (entries: %d)\n",i);
@@ -1224,6 +1225,7 @@ int fpga_register_i2c_pages(int port, int sub_chn, x393_i2c_device_t i2c_dev){
				pr_err("{%d} Error registering page %d (haddr = 0x%02x)\n",port,line_num,haddr);
				pr_err("{%d} Error registering page %d (haddr = 0x%02x)\n",port,line_num,haddr);
				return line_num;
				return line_num;
			}
			}
			dev_dbg(g_dev_ptr,"Registering page %d for haddr= 0x%02x, sa7= 0x%02x\n",line_num, haddr, i2c_dev.slave7);


			//line_num = i2c_dev.slave7;
			//line_num = i2c_dev.slave7;
			//haddr = 0;
			//haddr = 0;
+8 −6
Original line number Original line Diff line number Diff line
@@ -388,17 +388,17 @@ void set_xi2c_wrc( x393_i2c_device_t * dc, ///< device class
    tb_data.d32 =      0;
    tb_data.d32 =      0;
    tb_data.rah =      rah;
    tb_data.rah =      rah;
    tb_data.rnw =      0;
    tb_data.rnw =      0;
    tb_data.sa =       dc -> slave7;
    tb_data.sa =       dc -> slave7; // verify 0x81 - no, 7 bits!
    tb_data.nbwr =     dc -> address_bytes + dc -> data_bytes;
    tb_data.nbwr =     dc -> address_bytes + dc -> data_bytes;
    tb_data.dly =      get_bit_delay(dc -> scl_khz);
    tb_data.dly =      get_bit_delay(dc -> scl_khz);
    tb_data.tbl_mode = 2;
    tb_data.tbl_mode = 2;
    tb_data.extif_mode = 0;
    tb_data.extif_mode = 0;
    if (tb_data.sa & 0x80){ // using external interface (currently Boson640 UART)
    if (dc -> slave7 & 0x80){ // using external interface (currently Boson640 UART)
    	tb_data.extif_mode = tb_data.sa & 3;
    	tb_data.extif_mode = tb_data.sa & 3;
    	tb_data.sa = (tb_data.rah >> 6) & 3; // number of bytes in uart command (later use (rah >> 8) after changing sensor_port_config_t.pages_ptr to 32 bits)
    	tb_data.sa = (tb_data.rah >> 6) & 3; // number of bytes in uart command (later use (rah >> 8) after changing sensor_port_config_t.pages_ptr to 32 bits)
    	tb_data.rah &= 0x3f; // later &= 0xff
    	tb_data.rah &= 0x3f; // later &= 0xff
    }
    }
    dev_dbg(sdev, "device name %s : port= %d, page = 0x%x, rah = 0x%x, sa = 0x%x, extif_mode=0x%x\n",dc->name, chn, page, tb_data.rah, tb_data.sa, tb_data.extif_mode);
    dev_dbg(sdev, "set_xi2c_wrc(): device name %s : port= %d, page = 0x%x, rah = 0x%x, sa = 0x%x, extif_mode=0x%x\n",dc->name, chn, page, tb_data.rah, tb_data.sa, tb_data.extif_mode);
    /* Table address and data should not interleave with others */
    /* Table address and data should not interleave with others */
#ifdef LOCK_BH_SENSORI2C
#ifdef LOCK_BH_SENSORI2C
    spin_lock_bh(sensori2c_locks[chn]);
    spin_lock_bh(sensori2c_locks[chn]);
@@ -414,7 +414,7 @@ void set_xi2c_wrc( x393_i2c_device_t * dc, ///< device class
#endif
#endif
//    i2c_pages_shadow[(chn << 8) + page] =tb_data.d32;
//    i2c_pages_shadow[(chn << 8) + page] =tb_data.d32;
    i2c_pages_shadow[chn][page] =tb_data.d32;
    i2c_pages_shadow[chn][page] =tb_data.d32;
    dev_dbg(sdev, "DONE: device name %s : port= %d, page = 0x%x, rah = 0x%x, sa = 0x%x, extif_mode=0x%x\n",dc->name, chn, page, tb_data.rah, tb_data.sa, tb_data.extif_mode);
    dev_dbg(sdev, "x393_sensi2c_ctrl() twice, device name %s : port= %d, page = 0x%x, tb_addr=0x%x, tb_data=0x%x\n",dc->name, chn, page, tb_addr.d32, tb_data.d32);
}
}
EXPORT_SYMBOL_GPL(set_xi2c_wrc);
EXPORT_SYMBOL_GPL(set_xi2c_wrc);
/** Set i2c table entry for read operation using known devices
/** Set i2c table entry for read operation using known devices
@@ -722,11 +722,12 @@ void read_xi2c (x393_i2c_device_t * dc, ///< device class
        int page,               ///< Table index (8 bits)
        int page,               ///< Table index (8 bits)
        int addr)               ///< 8/16 bit register address
        int addr)               ///< 8/16 bit register address
{
{
    u32 dw;
	if ((dc -> slave7) & 0x80){
	if ((dc -> slave7) & 0x80){
	    dev_warn(sdev, "Read not implemented for extif");
	    dev_warn(sdev, "Read not implemented for extif");
		return;
		return;
	}
	}
    u32 dw = ((page & 0xff) << 24)  | (dc -> slave7 << 17) | (addr & 0xffff);
    dw = ((page & 0xff) << 24)  | (dc -> slave7 << 17) | (addr & 0xffff);
    x393_sensi2c_rel (dw, chn, 0);
    x393_sensi2c_rel (dw, chn, 0);
    dev_dbg(sdev, "chn=%d, page = %d, addr = %d\n",chn,page, addr);
    dev_dbg(sdev, "chn=%d, page = %d, addr = %d\n",chn,page, addr);


@@ -742,11 +743,12 @@ void read_xi2c_sa7 (int chn, ///< sensor port
        int sa7,   ///< 7-bit i2c slave address
        int sa7,   ///< 7-bit i2c slave address
        int addr)  ///< 8/16 bit register address
        int addr)  ///< 8/16 bit register address
{
{
	u32 dw;
	if (sa7 & 0x80){
	if (sa7 & 0x80){
	    dev_warn(sdev, "Read not implemented for extif 2");
	    dev_warn(sdev, "Read not implemented for extif 2");
		return;
		return;
	}
	}
    u32 dw = ((page & 0xff) << 24)  | (sa7 << 17) | (addr & 0xffff);
    dw = ((page & 0xff) << 24)  | (sa7 << 17) | (addr & 0xffff);
    dev_dbg(sdev, "read_xi2c_sa7(%d,0x%x,0x%x,0x%x): 0x%08x\n",chn,page,sa7,addr,(int) dw);
    dev_dbg(sdev, "read_xi2c_sa7(%d,0x%x,0x%x,0x%x): 0x%08x\n",chn,page,sa7,addr,(int) dw);
    x393_sensi2c_rel (dw, chn, 0);
    x393_sensi2c_rel (dw, chn, 0);
}
}