-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rework to accomodate changes in the linux subsystem by #49. Took the opportunity to go over the code once more and clean up the public methods of pin_controller and bmc_application.
- Loading branch information
1 parent
7b6e3a1
commit 005a1c7
Showing
8 changed files
with
351 additions
and
417 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,39 @@ | ||
//! This module contains pin numbers of the connected gpios. A next step would | ||
//! be to configure it in the dst as a new gpiochip | ||
|
||
#![allow(dead_code)] | ||
#![allow(clippy::identity_op)] | ||
|
||
pub const GPIO_PIN_PG: u32 = 192; | ||
pub const GPIO_PIN_PD: u32 = 96; | ||
|
||
pub const RTL_RESET: u32 = GPIO_PIN_PG + 13; | ||
pub const SYS_RESET: u32 = GPIO_PIN_PG + 11; | ||
pub const POWER_DETECT: u32 = GPIO_PIN_PG + 10; | ||
pub const POWER_BOARD: u32 = GPIO_PIN_PG + 15; | ||
|
||
pub const PORT1_EN: u32 = GPIO_PIN_PD + 11; | ||
pub const PORT2_EN: u32 = GPIO_PIN_PD + 10; | ||
pub const PORT3_EN: u32 = GPIO_PIN_PD + 9; | ||
pub const PORT4_EN: u32 = GPIO_PIN_PD + 8; | ||
|
||
pub const MODE1_EN: u32 = GPIO_PIN_PD + 7; | ||
pub const MODE2_EN: u32 = GPIO_PIN_PD + 6; | ||
pub const MODE3_EN: u32 = GPIO_PIN_PD + 5; | ||
pub const MODE4_EN: u32 = GPIO_PIN_PD + 4; | ||
pub const POWER_EN: u32 = GPIO_PIN_PD + 3; | ||
|
||
pub const PORT1_RST: u32 = GPIO_PIN_PD + 0; | ||
pub const PORT2_RST: u32 = GPIO_PIN_PD + 20; | ||
pub const PORT3_RST: u32 = GPIO_PIN_PD + 21; | ||
pub const PORT4_RST: u32 = GPIO_PIN_PD + 22; | ||
|
||
pub const PORT1_USB_VBUS: u32 = GPIO_PIN_PD + 19; | ||
pub const PORT2_USB_VBUS: u32 = GPIO_PIN_PD + 18; | ||
pub const PORT3_USB_VBUS: u32 = GPIO_PIN_PD + 17; | ||
pub const PORT4_USB_VBUS: u32 = GPIO_PIN_PD + 16; | ||
|
||
pub const PORT1_RPIBOOT: u32 = GPIO_PIN_PD + 15; | ||
pub const PORT2_RPIBOOT: u32 = GPIO_PIN_PD + 14; | ||
pub const PORT3_RPIBOOT: u32 = GPIO_PIN_PD + 12; | ||
pub const PORT4_RPIBOOT: u32 = GPIO_PIN_PD + 13; | ||
|
||
pub const USB_SEL1: u32 = GPIO_PIN_PG + 1; | ||
pub const USB_SEL2: u32 = GPIO_PIN_PG + 0; | ||
pub const USB_OE1: u32 = GPIO_PIN_PG + 2; | ||
pub const USB_OE2: u32 = GPIO_PIN_PG + 3; | ||
|
||
pub const USB_SWITCH: u32 = GPIO_PIN_PG + 5; | ||
pub const USB_PWEN: u32 = GPIO_PIN_PG + 4; | ||
|
||
// gpiochip0 aggregator | ||
pub const PORT1_USB_VBUS: u32 = 2; | ||
pub const PORT2_USB_VBUS: u32 = 6; | ||
pub const PORT3_USB_VBUS: u32 = 10; | ||
pub const PORT4_USB_VBUS: u32 = 14; | ||
|
||
pub const PORT1_EN: u32 = 0; | ||
pub const PORT2_EN: u32 = 4; | ||
pub const PORT3_EN: u32 = 8; | ||
pub const PORT4_EN: u32 = 12; | ||
|
||
pub const PORT1_RST: u32 = 1; | ||
pub const PORT2_RST: u32 = 5; | ||
pub const PORT3_RST: u32 = 9; | ||
pub const PORT4_RST: u32 = 13; | ||
|
||
pub const PORT1_RPIBOOT: u32 = 3; | ||
pub const PORT2_RPIBOOT: u32 = 7; | ||
pub const PORT3_RPIBOOT: u32 = 11; | ||
pub const PORT4_RPIBOOT: u32 = 15; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/// small helper macro which handles the code duplication of declaring gpio lines. | ||
#[macro_export] | ||
macro_rules! setup_output_array { | ||
// this macro has 2 match patterns, the differenciator is the 'arr' prefix. | ||
// which is used to switch from creating a output object with arr of values | ||
// to an array of output objects containing one value. | ||
($chip:ident, arr [$($pin:ident),+], $active: expr) => { | ||
[ | ||
$( | ||
setup_output_array!($chip, [$pin], $active) | ||
),* | ||
] | ||
}; | ||
|
||
($chip:ident, $output:expr, $active: expr) => { | ||
$chip | ||
.request_lines(gpiod::Options::output($output).active($active)) | ||
.context(concat!("error initializing pin ", stringify!($pin)))? | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.