-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[board] 100ask-ros support pmu and smhc
- Loading branch information
1 parent
fd54e52
commit 0916fce
Showing
7 changed files
with
119 additions
and
7 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -8,3 +8,5 @@ set(APP_COMMON_SOURCE | |
add_subdirectory(hello_world) | ||
|
||
add_subdirectory(init_dram) | ||
|
||
add_subdirectory(smhc_test) |
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
add_syterkit_app(smhc_test | ||
main.c | ||
) |
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,80 @@ | ||
/* SPDX-License-Identifier: Apache-2.0 */ | ||
|
||
#include <stdbool.h> | ||
#include <stddef.h> | ||
#include <stdint.h> | ||
#include <types.h> | ||
|
||
#include <log.h> | ||
|
||
#include <common.h> | ||
|
||
#include <mmu.h> | ||
|
||
#include <sys-dram.h> | ||
#include <sys-gpio.h> | ||
#include <sys-i2c.h> | ||
#include <sys-sid.h> | ||
#include <sys-sdcard.h> | ||
#include <sys-spi.h> | ||
#include <sys-uart.h> | ||
|
||
extern sunxi_serial_t uart_dbg; | ||
|
||
extern sunxi_i2c_t i2c_pmu; | ||
|
||
static void set_pmu_fin_voltage(char *power_name, uint32_t voltage) { | ||
int set_vol = voltage; | ||
int temp_vol, src_vol = pmu_axp2202_get_vol(&i2c_pmu, power_name); | ||
if (src_vol > voltage) { | ||
for (temp_vol = src_vol; temp_vol >= voltage; temp_vol -= 50) { | ||
pmu_axp2202_set_vol(&i2c_pmu, power_name, temp_vol, 1); | ||
} | ||
} else if (src_vol < voltage) { | ||
for (temp_vol = src_vol; temp_vol <= voltage; temp_vol += 50) { | ||
pmu_axp2202_set_vol(&i2c_pmu, power_name, temp_vol, 1); | ||
} | ||
} | ||
mdelay(30); /* Delay 300ms for pmu bootup */ | ||
} | ||
|
||
int main(void) { | ||
sunxi_serial_init(&uart_dbg); | ||
|
||
show_banner(); | ||
|
||
sunxi_clk_init(); | ||
|
||
sunxi_clk_dump(); | ||
|
||
sunxi_i2c_init(&i2c_pmu); | ||
|
||
pmu_axp2202_init(&i2c_pmu); | ||
|
||
set_pmu_fin_voltage("dcdc1", 1100); | ||
set_pmu_fin_voltage("dcdc3", 1100); | ||
|
||
pmu_axp2202_dump(&i2c_pmu); | ||
|
||
printk(LOG_LEVEL_INFO, "DRAM: DRAM Size = %dMB\n", sunxi_dram_init(NULL)); | ||
|
||
sunxi_clk_dump(); | ||
|
||
/* Initialize the SD host controller. */ | ||
if (sunxi_sdhci_init(&sdhci0) != 0) { | ||
printk(LOG_LEVEL_ERROR, "SMHC: %s controller init failed\n", sdhci0.name); | ||
} else { | ||
printk(LOG_LEVEL_INFO, "SMHC: %s controller initialized\n", sdhci0.name); | ||
} | ||
|
||
/* Initialize the SD card and check if initialization is successful. */ | ||
if (sdmmc_init(&card0, &sdhci0) != 0) { | ||
printk(LOG_LEVEL_WARNING, "SMHC: init failed\n"); | ||
} | ||
|
||
printk(LOG_LEVEL_DEBUG, "Card OK!\n"); | ||
|
||
abort(); | ||
|
||
return 0; | ||
} |
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