Dobrica Pavlinušić's random unstructured stuff
al3000a: Revision 2

al3000a i2c light sensor



alternative driver, different from one in 2.6 kernel, contains some registar names but not full description of values:

https://github.com/vhda/linux_kernel_TF101/blob/master/drivers/hwmon/al3000a.c

#define AL3000A_REG_CONFIGURATION 0x00
#define AL3000A_REG_TIMING_CONTROL 0x01
#define AL3000A_REG_ALS_CONTROL  0x02
#define AL3000A_REG_INTERRUPT_STATUS 0x03
#define AL3000A_REG_DATA 0x05
#define AL3000A_REG_ALS_WINDOW 0x08

#define AL3000A_MODE_POWER_UP 0
#define AL3000A_MODE_POWER_DOWN 2
#define AL3000A_MODE_RESET 3

#define AL3000A_OPERATION_ACTIVE 0
#define AL3000A_OPERATION_IDLE 3

i2c usage

# al_init


	//F/W Initial Flow
	//Power Down & Idle
	ret = i2c_smbus_write_byte_data(client, 0x00, 0x0B);

	// Integration Cycle = 4; Integration Time = 100ms;
	// Interrupt trigger when lux detection has changed 4 times
	// at 100ms intervals.
	ret = i2c_smbus_write_byte_data(client, 0x01, 0x11);

	//AL3000A ADC resolution = 64 levels; Low lux threshold = 0
	ret = i2c_smbus_write_byte_data(client, 0x02, 0xA0);

	//ALS Window Loss = 0
	//It isn't covered by shell so no window loss, need to modify at DVT
	ret = i2c_smbus_write_byte_data(client, 0x08, 0x00);


	//Read Data to clear INT Flag
	ret = i2c_smbus_read_i2c_block_data(client, 0x05, 1, &data);


# ls_enable

		//Read Data to clear INT Flag
		i2c_smbus_read_i2c_block_data(client, 0x05, 1, &data);
		//Power Up & Enable ALS
		i2c_smbus_write_byte_data(client, 0x00, 0x00);

# ls_disable

		//Power Down & Idle
		i2c_smbus_write_byte_data(client, 0x00, 0x0B);



re-create in shell

root@tegra20:/home/dpavlin# i2cget -y 0 0x1c 0x05 b
0x00
root@tegra20:/home/dpavlin# i2cset -y 0 0x1c 0x00 0 b
root@tegra20:/home/dpavlin# i2cget -y 0 0x1c 0x05 b
0x10
root@tegra20:/home/dpavlin# i2cget -y 0 0x1c 0x05 b
0x10
root@tegra20:/home/dpavlin# i2cget -y 0 0x1c 0x05 b
0x1f
root@tegra20:/home/dpavlin# i2cget -y 0 0x1c 0x05 b
0x1f
root@tegra20:/home/dpavlin# i2cget -y 0 0x1c 0x05 b
0x10
root@tegra20:/home/dpavlin# i2cget -y 0 0x1c 0x05 b
0x10
root@tegra20:/home/dpavlin# i2cdump -y 0 0x1c
No size specified (using byte-data access)
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f    0123456789abcdef
02: 00 11 a0 01 4a 01 00 00 00 ff ff ff ff ff ff ff    .???J?..........