summaryrefslogtreecommitdiffstats
path: root/board/gth/ee_dev.h
blob: 417c7b675c406ba87fd0aa00b7c9beac6df42042 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/* By Thomas.Lange@Corelatus.com 001025
   $Revision: 1.6 $

   Definitions for EEPROM/VOLT METER  DS2438
   Copyright (C) 2000-2001 Corelatus AB */

#ifndef INCeedevh
#define INCeedevh

#define E_DEBUG(fmt,args...) if( Debug ) printk(KERN_DEBUG"EE: " fmt, ##args)

#define PORT_B_PAR ((volatile immap_t *)CFG_IMMR)->im_cpm.cp_pbpar
#define PORT_B_ODR ((volatile immap_t *)CFG_IMMR)->im_cpm.cp_pbodr
#define PORT_B_DIR ((volatile immap_t *)CFG_IMMR)->im_cpm.cp_pbdir
#define PORT_B_DAT ((volatile immap_t *)CFG_IMMR)->im_cpm.cp_pbdat

#define SET_PORT_B_INPUT(Mask)  PORT_B_DIR &= ~(Mask)
#define SET_PORT_B_OUTPUT(Mask) PORT_B_DIR |= Mask

#define WRITE_PORT_B(Mask,Value) { \
			if (Value) PORT_B_DAT |= Mask; \
			else PORT_B_DAT &= ~(Mask); \
		}
#define WRITE_PORT(Value) WRITE_PORT_B(PB_EEPROM,Value)

#define READ_PORT (PORT_B_DAT&PB_EEPROM)

/* 64 bytes chip */
#define EE_CHIP_SIZE 64

/* We use this resistor for measuring the current drain on 3.3V */
#define CURRENT_RESISTOR 0.022

/* microsecs
   Pull line down at least this long for reset pulse */
#define RESET_LOW_TIME    490

/* Read presence pulse after we release reset pulse */
#define PRESENCE_TIMEOUT  100
#define PRESENCE_LOW_TIME 200

#define WRITE_0_LOW 80
#define WRITE_1_LOW 2
#define TOTAL_WRITE_LOW 80

#define READ_LOW        2
#define READ_TIMEOUT   10
#define TOTAL_READ_LOW 80

/*** Rom function commands ***/
#define READ_ROM   0x33
#define MATCH_ROM  0x55
#define SKIP_ROM   0xCC
#define SEARCH_ROM 0xF0


/*** Memory_command_function ***/
#define WRITE_SCRATCHPAD 0x4E
#define READ_SCRATCHPAD  0xBE
#define COPY_SCRATCHPAD  0x48
#define RECALL_MEMORY    0xB8
#define CONVERT_TEMP     0x44
#define CONVERT_VOLTAGE  0xB4

/* Chip is divided in 8 pages, 8 bytes each */

#define EE_PAGE_SIZE 8

/* All chip data we want are in page 0 */

/* Bytes in page 0 */
#define EE_P0_STATUS   0
#define EE_P0_TEMP_LSB 1
#define EE_P0_TEMP_MSB 2
#define EE_P0_VOLT_LSB 3
#define EE_P0_VOLT_MSB 4
#define EE_P0_CURRENT_LSB 5
#define EE_P0_CURRENT_MSB 6


/* 40 byte user data is located at page 3-7 */
#define EE_USER_PAGE_0 3
#define USER_PAGES 5

#endif /* INCeedevh */
OpenPOWER on IntegriCloud