-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Agilex SDMMC clock enable/disable API #808
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
// SPDX-License-Identifier: GPL-2.0+ | ||
/* | ||
* (C) Copyright 2013 Altera Corporation <www.altera.com> | ||
* (C) Copyright 2013-2025 Altera Corporation <www.altera.com> | ||
*/ | ||
|
||
#include <log.h> | ||
|
@@ -29,7 +29,9 @@ struct socfpga_dwmci_plat { | |
|
||
/* socfpga implmentation specific driver private data */ | ||
struct dwmci_socfpga_priv_data { | ||
struct udevice *dev; | ||
struct dwmci_host host; | ||
struct clk mmc_clk_ciu; | ||
unsigned int drvsel; | ||
unsigned int smplsel; | ||
}; | ||
|
@@ -51,28 +53,23 @@ static void socfpga_dwmci_reset(struct udevice *dev) | |
static int socfpga_dwmci_clksel(struct dwmci_host *host) | ||
{ | ||
struct dwmci_socfpga_priv_data *priv = host->priv; | ||
int ret; | ||
|
||
u32 sdmmc_mask = ((priv->smplsel & 0x7) << SYSMGR_SDMMC_SMPLSEL_SHIFT) | | ||
((priv->drvsel & 0x7) << SYSMGR_SDMMC_DRVSEL_SHIFT); | ||
|
||
/* Get clock manager base address */ | ||
struct udevice *clkmgr_dev; | ||
int ret = uclass_get_device_by_name(UCLASS_CLK, "clock-controller@ffd10000", &clkmgr_dev); | ||
|
||
ret = clk_get_by_name(priv->dev, "ciu", &priv->mmc_clk_ciu); | ||
if (ret) { | ||
printf("Failed to get clkmgr device: %d\n", ret); | ||
debug("%s: Failed to get SDMMC clock from dts\n", __func__); | ||
return ret; | ||
} | ||
|
||
fdt_addr_t clkmgr_base = dev_read_addr(clkmgr_dev); | ||
|
||
if (clkmgr_base == FDT_ADDR_T_NONE) { | ||
printf("Failed to read base address from clkmgr DT node\n"); | ||
return -EINVAL; | ||
} | ||
|
||
/* Disable SDMMC clock. */ | ||
clrbits_le32(clkmgr_base + CLKMGR_PERPLL_EN, | ||
CLKMGR_PERPLLGRP_EN_SDMMCCLK_MASK); | ||
ret = clk_disable(&priv->mmc_clk_ciu); | ||
if (ret) { | ||
printf("%s: Failed to disable SDMMC clock\n", __func__); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prefer dev_err(dev, ...) / dev_dbg(dev, ...) over bare printf() for driver-model devices. It keeps logs consistent and can be filtered per device. printf() Global: Always prints unconditionally to the console (UART or log). No context: Doesn’t automatically include which device/driver emitted the message. No log level: It’s treated like a raw string — you can’t filter or categorize it. Legacy: Older code uses printf(), but driver-model code is expected to use dev_*() helpers. dev_err(dev, ...) / dev_dbg(dev, ...) Device-aware logging: Log levels: dev_err(dev, ...) → error log, always shown. dev_warn(dev, ...) → warning. dev_info(dev, ...) → informational. dev_dbg(dev, ...) → debug, compiled in only if DEBUG or CONFIG_DEBUG_DEVRES (depending on subsystem) is enabled. This way you don’t flood normal builds with debug spam. Integration with log framework: Consistency: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i see some sections of the code not touched by this patch series still using printf, example - https://github.com/u-boot/u-boot/blame/dca578a9c9decb85271665de8086b8f41731d388/drivers/mmc/socfpga_dw_mmc.c#L84, and https://github.com/u-boot/u-boot/blame/dca578a9c9decb85271665de8086b8f41731d388/drivers/mmc/socfpga_dw_mmc.c#L120. do you want me to update these as well? |
||
return ret; | ||
} | ||
|
||
debug("%s: drvsel %d smplsel %d\n", __func__, | ||
priv->drvsel, priv->smplsel); | ||
|
@@ -92,8 +89,11 @@ static int socfpga_dwmci_clksel(struct dwmci_host *host) | |
#endif | ||
|
||
/* Enable SDMMC clock */ | ||
setbits_le32(clkmgr_base + CLKMGR_PERPLL_EN, | ||
CLKMGR_PERPLLGRP_EN_SDMMCCLK_MASK); | ||
ret = clk_enable(&priv->mmc_clk_ciu); | ||
if (ret) { | ||
printf("%s: Failed to enable SDMMC clock\n", __func__); | ||
return ret; | ||
} | ||
|
||
return 0; | ||
} | ||
|
@@ -169,6 +169,7 @@ static int socfpga_dwmmc_probe(struct udevice *dev) | |
struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev); | ||
struct dwmci_socfpga_priv_data *priv = dev_get_priv(dev); | ||
struct dwmci_host *host = &priv->host; | ||
priv->dev = dev; | ||
alifzakuan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
int ret; | ||
|
||
ret = socfpga_dwmmc_get_clk_rate(dev); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* SPDX-License-Identifier: GPL-2.0 */ | ||
/* | ||
* Copyright (C) 2019, Intel Corporation | ||
*/ | ||
|
||
#ifndef __AGILEX_CLOCK_H | ||
#define __AGILEX_CLOCK_H | ||
|
||
/* fixed rate clocks */ | ||
#define AGILEX_OSC1 0 | ||
#define AGILEX_CB_INTOSC_HS_DIV2_CLK 1 | ||
#define AGILEX_CB_INTOSC_LS_CLK 2 | ||
#define AGILEX_L4_SYS_FREE_CLK 3 | ||
#define AGILEX_F2S_FREE_CLK 4 | ||
|
||
/* PLL clocks */ | ||
#define AGILEX_MAIN_PLL_CLK 5 | ||
#define AGILEX_MAIN_PLL_C0_CLK 6 | ||
#define AGILEX_MAIN_PLL_C1_CLK 7 | ||
#define AGILEX_MAIN_PLL_C2_CLK 8 | ||
#define AGILEX_MAIN_PLL_C3_CLK 9 | ||
#define AGILEX_PERIPH_PLL_CLK 10 | ||
#define AGILEX_PERIPH_PLL_C0_CLK 11 | ||
#define AGILEX_PERIPH_PLL_C1_CLK 12 | ||
#define AGILEX_PERIPH_PLL_C2_CLK 13 | ||
#define AGILEX_PERIPH_PLL_C3_CLK 14 | ||
#define AGILEX_MPU_FREE_CLK 15 | ||
#define AGILEX_MPU_CCU_CLK 16 | ||
#define AGILEX_BOOT_CLK 17 | ||
|
||
/* fixed factor clocks */ | ||
#define AGILEX_L3_MAIN_FREE_CLK 18 | ||
#define AGILEX_NOC_FREE_CLK 19 | ||
#define AGILEX_S2F_USR0_CLK 20 | ||
#define AGILEX_NOC_CLK 21 | ||
#define AGILEX_EMAC_A_FREE_CLK 22 | ||
#define AGILEX_EMAC_B_FREE_CLK 23 | ||
#define AGILEX_EMAC_PTP_FREE_CLK 24 | ||
#define AGILEX_GPIO_DB_FREE_CLK 25 | ||
#define AGILEX_SDMMC_FREE_CLK 26 | ||
#define AGILEX_S2F_USER0_FREE_CLK 27 | ||
#define AGILEX_S2F_USER1_FREE_CLK 28 | ||
#define AGILEX_PSI_REF_FREE_CLK 29 | ||
|
||
/* Gate clocks */ | ||
#define AGILEX_MPU_CLK 30 | ||
#define AGILEX_MPU_PERIPH_CLK 31 | ||
#define AGILEX_L4_MAIN_CLK 32 | ||
#define AGILEX_L4_MP_CLK 33 | ||
#define AGILEX_L4_SP_CLK 34 | ||
#define AGILEX_CS_AT_CLK 35 | ||
#define AGILEX_CS_TRACE_CLK 36 | ||
#define AGILEX_CS_PDBG_CLK 37 | ||
#define AGILEX_CS_TIMER_CLK 38 | ||
#define AGILEX_S2F_USER0_CLK 39 | ||
#define AGILEX_EMAC0_CLK 40 | ||
#define AGILEX_EMAC1_CLK 41 | ||
#define AGILEX_EMAC2_CLK 42 | ||
#define AGILEX_EMAC_PTP_CLK 43 | ||
#define AGILEX_GPIO_DB_CLK 44 | ||
#define AGILEX_NAND_CLK 45 | ||
#define AGILEX_PSI_REF_CLK 46 | ||
#define AGILEX_S2F_USER1_CLK 47 | ||
#define AGILEX_SDMMC_CLK 48 | ||
#define AGILEX_SPI_M_CLK 49 | ||
#define AGILEX_USB_CLK 50 | ||
#define AGILEX_NAND_X_CLK 51 | ||
#define AGILEX_NAND_ECC_CLK 52 | ||
#define AGILEX_NUM_CLKS 53 | ||
|
||
#endif /* __AGILEX_CLOCK_H */ |
Uh oh!
There was an error while loading. Please reload this page.