blob: 417c7b675c406ba87fd0aa00b7c9beac6df42042 [file] [log] [blame]
wdenk012771d2002-03-08 21:31:05 +00001/* By Thomas.Lange@Corelatus.com 001025
2 $Revision: 1.6 $
3
4 Definitions for EEPROM/VOLT METER DS2438
5 Copyright (C) 2000-2001 Corelatus AB */
6
7#ifndef INCeedevh
8#define INCeedevh
9
10#define E_DEBUG(fmt,args...) if( Debug ) printk(KERN_DEBUG"EE: " fmt, ##args)
11
12#define PORT_B_PAR ((volatile immap_t *)CFG_IMMR)->im_cpm.cp_pbpar
13#define PORT_B_ODR ((volatile immap_t *)CFG_IMMR)->im_cpm.cp_pbodr
14#define PORT_B_DIR ((volatile immap_t *)CFG_IMMR)->im_cpm.cp_pbdir
15#define PORT_B_DAT ((volatile immap_t *)CFG_IMMR)->im_cpm.cp_pbdat
16
17#define SET_PORT_B_INPUT(Mask) PORT_B_DIR &= ~(Mask)
18#define SET_PORT_B_OUTPUT(Mask) PORT_B_DIR |= Mask
19
20#define WRITE_PORT_B(Mask,Value) { \
21 if (Value) PORT_B_DAT |= Mask; \
22 else PORT_B_DAT &= ~(Mask); \
23 }
24#define WRITE_PORT(Value) WRITE_PORT_B(PB_EEPROM,Value)
25
26#define READ_PORT (PORT_B_DAT&PB_EEPROM)
27
28/* 64 bytes chip */
29#define EE_CHIP_SIZE 64
30
31/* We use this resistor for measuring the current drain on 3.3V */
32#define CURRENT_RESISTOR 0.022
33
34/* microsecs
35 Pull line down at least this long for reset pulse */
36#define RESET_LOW_TIME 490
37
38/* Read presence pulse after we release reset pulse */
39#define PRESENCE_TIMEOUT 100
40#define PRESENCE_LOW_TIME 200
41
42#define WRITE_0_LOW 80
43#define WRITE_1_LOW 2
44#define TOTAL_WRITE_LOW 80
45
46#define READ_LOW 2
47#define READ_TIMEOUT 10
48#define TOTAL_READ_LOW 80
49
50/*** Rom function commands ***/
51#define READ_ROM 0x33
52#define MATCH_ROM 0x55
53#define SKIP_ROM 0xCC
54#define SEARCH_ROM 0xF0
55
56
57/*** Memory_command_function ***/
58#define WRITE_SCRATCHPAD 0x4E
59#define READ_SCRATCHPAD 0xBE
60#define COPY_SCRATCHPAD 0x48
61#define RECALL_MEMORY 0xB8
62#define CONVERT_TEMP 0x44
63#define CONVERT_VOLTAGE 0xB4
64
65/* Chip is divided in 8 pages, 8 bytes each */
66
67#define EE_PAGE_SIZE 8
68
69/* All chip data we want are in page 0 */
70
71/* Bytes in page 0 */
72#define EE_P0_STATUS 0
73#define EE_P0_TEMP_LSB 1
74#define EE_P0_TEMP_MSB 2
75#define EE_P0_VOLT_LSB 3
76#define EE_P0_VOLT_MSB 4
77#define EE_P0_CURRENT_LSB 5
78#define EE_P0_CURRENT_MSB 6
79
80
81/* 40 byte user data is located at page 3-7 */
82#define EE_USER_PAGE_0 3
83#define USER_PAGES 5
84
85#endif /* INCeedevh */