Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Kestrel Collaboration
Kestrel Firmware
Bare Metal Firmware
Commits
1d87af65
Commit
1d87af65
authored
4 years ago
by
Evan Lojewski
Committed by
Raptor Engineering Development Team
4 years ago
Browse files
Options
Download
Email Patches
Plain Diff
i2c: Add a cpu-specific datastructure for use with i2c transactions
parent
ce097c90
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
58 deletions
+52
-58
main.c
main.c
+52
-58
No files found.
main.c
View file @
1d87af65
...
...
@@ -99,6 +99,18 @@ uint8_t post_code_low = 0;
static
uint8_t
allow_flash_write
=
0
;
static
uint8_t
enable_post_code_console_output
=
0
;
typedef
struct
{
int8_t
index
;
uint8_t
*
i2c_master
;
}
cpu_info_t
;
static
const
cpu_info_t
g_cpu_info
[]
=
{
{
.
index
=
0
,
.
i2c_master
=
(
uint8_t
*
)
I2CMASTER1_BASE
},
#ifdef I2CMASTER2_BASE
{
.
index
=
1
,
.
i2c_master
=
(
uint8_t
*
)
I2CMASTER2_BASE
},
#endif
};
void
primary_service_event_loop
(
void
);
static
char
*
readstr
(
void
)
...
...
@@ -1362,20 +1374,20 @@ static void run_post_shutdown_bmc_peripheral_teardown(void)
set_led_bank_display
(
0x00
);
}
static
int
apply_avsbus_workarounds_cpu
(
in
t
cpu
,
uint8_t
*
i2c_master
)
static
int
apply_avsbus_workarounds_cpu
(
cons
t
cpu
_info_t
*
cpu
)
{
printf
(
"
\t
VDD/VCS %d: Enabling AVSBus CLK/MDAT pullups and selecting "
"VIH/VIL 0x2 (0.65V/0.55V)
\n
"
,
cpu
);
if
(
i2c_write_register_byte
(
i2c_master
,
0x28
,
0x2e
,
0x23
))
cpu
->
index
);
if
(
i2c_write_register_byte
(
cpu
->
i2c_master
,
0x28
,
0x2e
,
0x23
))
{
return
-
1
;
}
printf
(
"
\t
VDN %d: Enabling AVSBus CLK/MDAT pullups and selecting VIH/VIL "
"0x2 (0.65V/0.55V)
\n
"
,
cpu
);
if
(
i2c_write_register_byte
(
i2c_master
,
0x2b
,
0x2e
,
0x23
))
cpu
->
index
);
if
(
i2c_write_register_byte
(
cpu
->
i2c_master
,
0x2b
,
0x2e
,
0x23
))
{
return
-
1
;
}
...
...
@@ -1383,57 +1395,51 @@ static int apply_avsbus_workarounds_cpu(int cpu, uint8_t *i2c_master)
return
0
;
}
static
int
apply_avsbus_workarounds
(
int
cpu_count
)
static
int
apply_avsbus_workarounds
(
const
cpu_info_t
*
cpu_info
,
int
cpu_count
)
{
printf
(
"Applying AVSBus workarounds...
\n
"
);
if
(
apply_avsbus_workarounds_cpu
(
0
,
(
uint8_t
*
)
I2CMASTER1_BASE
)
)
while
(
--
cpu_count
)
{
return
-
1
;
}
#ifdef I2CMASTER2_BASE
if
(
cpu_count
>
1
)
{
if
(
apply_avsbus_workarounds_cpu
(
1
,
(
uint8_t
*
)
I2CMASTER2_BASE
))
if
(
apply_avsbus_workarounds_cpu
(
&
cpu_info
[
0
]))
{
return
-
1
;
}
cpu_info
++
;
}
#endif
printf
(
"
\t
AVSBus workaround application complete!
\n
"
);
return
0
;
}
static
int
enable_avsbus_pmbus_cpu
(
in
t
cpu
,
uint8_t
*
i2c_master
)
static
int
enable_avsbus_pmbus_cpu
(
cons
t
cpu
_info_t
*
cpu
)
{
printf
(
"
\t
VDD %d: Placing device in AVSBus voltage command mode
\n
"
,
cpu
);
if
(
i2c_write_register_byte
(
i2c_master
,
0x70
,
0x00
,
0x00
))
printf
(
"
\t
VDD %d: Placing device in AVSBus voltage command mode
\n
"
,
cpu
->
index
);
if
(
i2c_write_register_byte
(
cpu
->
i2c_master
,
0x70
,
0x00
,
0x00
))
{
return
-
1
;
}
if
(
i2c_write_register_byte
(
i2c_master
,
0x70
,
0x01
,
0xb0
))
if
(
i2c_write_register_byte
(
cpu
->
i2c_master
,
0x70
,
0x01
,
0xb0
))
{
return
-
1
;
}
printf
(
"
\t
VCS %d: Placing device in AVSBus voltage command mode
\n
"
,
cpu
);
if
(
i2c_write_register_byte
(
i2c_master
,
0x70
,
0x00
,
0x01
))
printf
(
"
\t
VCS %d: Placing device in AVSBus voltage command mode
\n
"
,
cpu
->
index
);
if
(
i2c_write_register_byte
(
cpu
->
i2c_master
,
0x70
,
0x00
,
0x01
))
{
return
-
1
;
}
if
(
i2c_write_register_byte
(
i2c_master
,
0x70
,
0x01
,
0xb0
))
if
(
i2c_write_register_byte
(
cpu
->
i2c_master
,
0x70
,
0x01
,
0xb0
))
{
return
-
1
;
}
printf
(
"
\t
VDN %d: Placing device in AVSBus voltage command mode
\n
"
,
cpu
);
if
(
i2c_write_register_byte
(
i2c_master
,
0x73
,
0x00
,
0x00
))
printf
(
"
\t
VDN %d: Placing device in AVSBus voltage command mode
\n
"
,
cpu
->
index
);
if
(
i2c_write_register_byte
(
cpu
->
i2c_master
,
0x73
,
0x00
,
0x00
))
{
return
-
1
;
}
if
(
i2c_write_register_byte
(
i2c_master
,
0x73
,
0x01
,
0xb0
))
if
(
i2c_write_register_byte
(
cpu
->
i2c_master
,
0x73
,
0x01
,
0xb0
))
{
return
-
1
;
}
...
...
@@ -1441,81 +1447,69 @@ static int enable_avsbus_pmbus_cpu(int cpu, uint8_t *i2c_master)
return
0
;
}
static
int
enable_avsbus_pmbus
(
int
cpu_count
)
static
int
enable_avsbus_pmbus
(
const
cpu_info_t
*
cpu_info
,
int
cpu_count
)
{
printf
(
"Enabling AVSbus PMBUS functionality...
\n
"
);
if
(
enable_avsbus_pmbus_cpu
(
0
,
(
uint8_t
*
)
I2CMASTER1_BASE
))
{
return
-
1
;
}
#ifdef I2CMASTER2_BASE
if
(
cpu_count
>
1
)
while
(
--
cpu_count
)
{
if
(
enable_avsbus_pmbus_cpu
(
1
,
(
uint8_t
*
)
I2CMASTER2_BASE
))
if
(
enable_avsbus_pmbus_cpu
(
&
cpu_info
[
0
]
))
{
return
-
1
;
}
cpu_info
++
;
}
#endif
printf
(
"
\t
AVSBus PMBUS functionality enabled!
\n
"
);
return
0
;
}
static
int
disable_avsbus_pmbus_cpu
(
in
t
cpu
,
uint8_t
*
i2c_master
)
static
int
disable_avsbus_pmbus_cpu
(
cons
t
cpu
_info_t
*
cpu
)
{
printf
(
"
\t
VDD %d: Placing device in immediate off mode
\n
"
,
cpu
);
if
(
i2c_write_register_byte
(
i2c_master
,
0x70
,
0x00
,
0x00
))
printf
(
"
\t
VDD %d: Placing device in immediate off mode
\n
"
,
cpu
->
index
);
if
(
i2c_write_register_byte
(
cpu
->
i2c_master
,
0x70
,
0x00
,
0x00
))
{
return
-
1
;
}
if
(
i2c_write_register_byte
(
i2c_master
,
0x70
,
0x01
,
0xb0
))
if
(
i2c_write_register_byte
(
cpu
->
i2c_master
,
0x70
,
0x01
,
0xb0
))
{
return
-
1
;
}
printf
(
"
\t
VCS %d: Placing device in immediate off mode
\n
"
,
cpu
);
if
(
i2c_write_register_byte
(
i2c_master
,
0x70
,
0x00
,
0x01
))
printf
(
"
\t
VCS %d: Placing device in immediate off mode
\n
"
,
cpu
->
index
);
if
(
i2c_write_register_byte
(
cpu
->
i2c_master
,
0x70
,
0x00
,
0x01
))
{
return
-
1
;
}
if
(
i2c_write_register_byte
(
i2c_master
,
0x70
,
0x01
,
0xb0
))
if
(
i2c_write_register_byte
(
cpu
->
i2c_master
,
0x70
,
0x01
,
0xb0
))
{
return
-
1
;
}
printf
(
"
\t
VDN %d: Placing device in immediate off mode
\n
"
,
cpu
);
if
(
i2c_write_register_byte
(
i2c_master
,
0x73
,
0x00
,
0x00
))
printf
(
"
\t
VDN %d: Placing device in immediate off mode
\n
"
,
cpu
->
index
);
if
(
i2c_write_register_byte
(
cpu
->
i2c_master
,
0x73
,
0x00
,
0x00
))
{
return
-
1
;
}
if
(
i2c_write_register_byte
(
i2c_master
,
0x73
,
0x01
,
0xb0
))
if
(
i2c_write_register_byte
(
cpu
->
i2c_master
,
0x73
,
0x01
,
0xb0
))
{
return
-
1
;
}
return
0
;
}
static
int
disable_avsbus_pmbus
(
int
cpu_count
)
static
int
disable_avsbus_pmbus
(
const
cpu_info_t
*
cpu_info
,
int
cpu_count
)
{
printf
(
"Disabling AVSbus PMBUS functionality...
\n
"
);
if
(
disable_avsbus_pmbus_cpu
(
0
,
(
uint8_t
*
)
I2CMASTER1_BASE
)
)
while
(
--
cpu_count
)
{
return
-
1
;
}
#ifdef I2CMASTER2_BASE
if
(
cpu_count
>
1
)
{
if
(
disable_avsbus_pmbus_cpu
(
1
,
(
uint8_t
*
)
I2CMASTER2_BASE
))
if
(
disable_avsbus_pmbus_cpu
(
&
cpu_info
[
0
]))
{
return
-
1
;
}
cpu_info
++
;
}
#endif
printf
(
"
\t
AVSBus PMBUS functionality disabled!
\n
"
);
return
0
;
...
...
@@ -1524,7 +1518,7 @@ static int disable_avsbus_pmbus(int cpu_count)
static
void
power_off_chassis
(
void
)
{
// Disable PMBUS
if
(
disable_avsbus_pmbus
(
configured_cpu_count
))
if
(
disable_avsbus_pmbus
(
g_cpu_info
,
configured_cpu_count
))
{
printf
(
"PMBUS disable failed!
\n
"
);
}
...
...
@@ -1593,7 +1587,7 @@ static int power_on_chassis(void)
printf
(
"%d CPU(s) installed
\n
"
,
cpu_count
);
// Apply AVSBus workarounds
if
(
apply_avsbus_workarounds
(
cpu_count
))
if
(
apply_avsbus_workarounds
(
g_cpu_info
,
cpu_count
))
{
printf
(
"AVSBus setup failed!
\n
"
);
power_off_chassis
();
...
...
@@ -1601,7 +1595,7 @@ static int power_on_chassis(void)
}
// Enable PMBUS
if
(
enable_avsbus_pmbus
(
cpu_count
))
if
(
enable_avsbus_pmbus
(
g_cpu_info
,
cpu_count
))
{
printf
(
"PMBUS enable failed!
\n
"
);
power_off_chassis
();
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment