* [PATCH 1/2] mmc: dw_mmc: Use device_property_read instead of of_property_read
@ 2017-05-17 22:17 David Woods
2017-05-17 22:17 ` [PATCH 2/2] mmc: core: " David Woods
0 siblings, 1 reply; 4+ messages in thread
From: David Woods @ 2017-05-17 22:17 UTC (permalink / raw)
To: ulf.hansson, jh80.chung, shawn.lin, hkallweit1, adrian.hunter,
cmetcalf, linux-mmc, linux-kernel
Cc: David Woods, stable
Using the device_property interfaces allows the dw_mmc driver to work
on platforms which run on either device tree or ACPI.
Signed-off-by: David Woods <dwoods@mellanox.com>
Reviewed-by: Chris Metcalf <cmetcalf@mellanox.com>
Cc: stable@vger.linux.org
---
drivers/mmc/host/dw_mmc.c | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
index e45129f..efde0f2 100644
--- a/drivers/mmc/host/dw_mmc.c
+++ b/drivers/mmc/host/dw_mmc.c
@@ -2707,8 +2707,8 @@ static int dw_mci_init_slot(struct dw_mci *host, unsigned int id)
host->slot[id] = slot;
mmc->ops = &dw_mci_ops;
- if (of_property_read_u32_array(host->dev->of_node,
- "clock-freq-min-max", freq, 2)) {
+ if (device_property_read_u32_array(host->dev, "clock-freq-min-max",
+ freq, 2)) {
mmc->f_min = DW_MCI_FREQ_MIN;
mmc->f_max = DW_MCI_FREQ_MAX;
} else {
@@ -2808,7 +2808,6 @@ static void dw_mci_init_dma(struct dw_mci *host)
{
int addr_config;
struct device *dev = host->dev;
- struct device_node *np = dev->of_node;
/*
* Check tansfer mode from HCON[17:16]
@@ -2869,8 +2868,9 @@ static void dw_mci_init_dma(struct dw_mci *host)
dev_info(host->dev, "Using internal DMA controller.\n");
} else {
/* TRANS_MODE_EDMAC: check dma bindings again */
- if ((of_property_count_strings(np, "dma-names") < 0) ||
- (!of_find_property(np, "dmas", NULL))) {
+ if ((device_property_read_string_array(dev, "dma-names",
+ NULL, 0) < 0) ||
+ !device_property_present(dev, "dmas")) {
goto no_dma;
}
host->dma_ops = &dw_mci_edmac_ops;
@@ -2937,7 +2937,6 @@ static struct dw_mci_board *dw_mci_parse_dt(struct dw_mci *host)
{
struct dw_mci_board *pdata;
struct device *dev = host->dev;
- struct device_node *np = dev->of_node;
const struct dw_mci_drv_data *drv_data = host->drv_data;
int ret;
u32 clock_frequency;
@@ -2954,20 +2953,21 @@ static struct dw_mci_board *dw_mci_parse_dt(struct dw_mci *host)
}
/* find out number of slots supported */
- of_property_read_u32(np, "num-slots", &pdata->num_slots);
+ device_property_read_u32(dev, "num-slots", &pdata->num_slots);
- if (of_property_read_u32(np, "fifo-depth", &pdata->fifo_depth))
+ if (device_property_read_u32(dev, "fifo-depth", &pdata->fifo_depth))
dev_info(dev,
"fifo-depth property not found, using value of FIFOTH register as default\n");
- of_property_read_u32(np, "card-detect-delay", &pdata->detect_delay_ms);
+ device_property_read_u32(dev, "card-detect-delay",
+ &pdata->detect_delay_ms);
- of_property_read_u32(np, "data-addr", &host->data_addr_override);
+ device_property_read_u32(dev, "data-addr", &host->data_addr_override);
- if (of_get_property(np, "fifo-watermark-aligned", NULL))
+ if (device_property_present(dev, "fifo-watermark-aligned"))
host->wm_aligned = true;
- if (!of_property_read_u32(np, "clock-frequency", &clock_frequency))
+ if (!device_property_read_u32(dev, "clock-frequency", &clock_frequency))
pdata->bus_hz = clock_frequency;
if (drv_data && drv_data->parse_dt) {
--
2.7.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] mmc: core: Use device_property_read instead of of_property_read
2017-05-17 22:17 [PATCH 1/2] mmc: dw_mmc: Use device_property_read instead of of_property_read David Woods
@ 2017-05-17 22:17 ` David Woods
2017-05-19 8:23 ` Ulf Hansson
0 siblings, 1 reply; 4+ messages in thread
From: David Woods @ 2017-05-17 22:17 UTC (permalink / raw)
To: ulf.hansson, jh80.chung, shawn.lin, hkallweit1, adrian.hunter,
cmetcalf, linux-mmc, linux-kernel
Cc: David Woods, stable
Using the device_property interfaces allows mmc drivers to work
on platforms which run on either device tree or ACPI.
Signed-off-by: David Woods <dwoods@mellanox.com>
Reviewed-by: Chris Metcalf <cmetcalf@mellanox.com>
Cc: stable@vger.linux.org
---
drivers/mmc/core/host.c | 72 ++++++++++++++++++++++++-------------------------
1 file changed, 35 insertions(+), 37 deletions(-)
diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c
index 3f8c85d..d2c059e 100644
--- a/drivers/mmc/core/host.c
+++ b/drivers/mmc/core/host.c
@@ -176,19 +176,17 @@ static void mmc_retune_timer(unsigned long data)
*/
int mmc_of_parse(struct mmc_host *host)
{
- struct device_node *np;
+ struct device *dev = host->parent;
u32 bus_width;
int ret;
bool cd_cap_invert, cd_gpio_invert = false;
bool ro_cap_invert, ro_gpio_invert = false;
- if (!host->parent || !host->parent->of_node)
+ if (!dev)
return 0;
- np = host->parent->of_node;
-
/* "bus-width" is translated to MMC_CAP_*_BIT_DATA flags */
- if (of_property_read_u32(np, "bus-width", &bus_width) < 0) {
+ if (device_property_read_u32(dev, "bus-width", &bus_width) < 0) {
dev_dbg(host->parent,
"\"bus-width\" property is missing, assuming 1 bit.\n");
bus_width = 1;
@@ -210,7 +208,7 @@ int mmc_of_parse(struct mmc_host *host)
}
/* f_max is obtained from the optional "max-frequency" property */
- of_property_read_u32(np, "max-frequency", &host->f_max);
+ device_property_read_u32(dev, "max-frequency", &host->f_max);
/*
* Configure CD and WP pins. They are both by default active low to
@@ -225,12 +223,12 @@ int mmc_of_parse(struct mmc_host *host)
*/
/* Parse Card Detection */
- if (of_property_read_bool(np, "non-removable")) {
+ if (device_property_read_bool(dev, "non-removable")) {
host->caps |= MMC_CAP_NONREMOVABLE;
} else {
- cd_cap_invert = of_property_read_bool(np, "cd-inverted");
+ cd_cap_invert = device_property_read_bool(dev, "cd-inverted");
- if (of_property_read_bool(np, "broken-cd"))
+ if (device_property_read_bool(dev, "broken-cd"))
host->caps |= MMC_CAP_NEEDS_POLL;
ret = mmc_gpiod_request_cd(host, "cd", 0, true,
@@ -256,7 +254,7 @@ int mmc_of_parse(struct mmc_host *host)
}
/* Parse Write Protection */
- ro_cap_invert = of_property_read_bool(np, "wp-inverted");
+ ro_cap_invert = device_property_read_bool(dev, "wp-inverted");
ret = mmc_gpiod_request_ro(host, "wp", 0, false, 0, &ro_gpio_invert);
if (!ret)
@@ -264,64 +262,64 @@ int mmc_of_parse(struct mmc_host *host)
else if (ret != -ENOENT && ret != -ENOSYS)
return ret;
- if (of_property_read_bool(np, "disable-wp"))
+ if (device_property_read_bool(dev, "disable-wp"))
host->caps2 |= MMC_CAP2_NO_WRITE_PROTECT;
/* See the comment on CD inversion above */
if (ro_cap_invert ^ ro_gpio_invert)
host->caps2 |= MMC_CAP2_RO_ACTIVE_HIGH;
- if (of_property_read_bool(np, "cap-sd-highspeed"))
+ if (device_property_read_bool(dev, "cap-sd-highspeed"))
host->caps |= MMC_CAP_SD_HIGHSPEED;
- if (of_property_read_bool(np, "cap-mmc-highspeed"))
+ if (device_property_read_bool(dev, "cap-mmc-highspeed"))
host->caps |= MMC_CAP_MMC_HIGHSPEED;
- if (of_property_read_bool(np, "sd-uhs-sdr12"))
+ if (device_property_read_bool(dev, "sd-uhs-sdr12"))
host->caps |= MMC_CAP_UHS_SDR12;
- if (of_property_read_bool(np, "sd-uhs-sdr25"))
+ if (device_property_read_bool(dev, "sd-uhs-sdr25"))
host->caps |= MMC_CAP_UHS_SDR25;
- if (of_property_read_bool(np, "sd-uhs-sdr50"))
+ if (device_property_read_bool(dev, "sd-uhs-sdr50"))
host->caps |= MMC_CAP_UHS_SDR50;
- if (of_property_read_bool(np, "sd-uhs-sdr104"))
+ if (device_property_read_bool(dev, "sd-uhs-sdr104"))
host->caps |= MMC_CAP_UHS_SDR104;
- if (of_property_read_bool(np, "sd-uhs-ddr50"))
+ if (device_property_read_bool(dev, "sd-uhs-ddr50"))
host->caps |= MMC_CAP_UHS_DDR50;
- if (of_property_read_bool(np, "cap-power-off-card"))
+ if (device_property_read_bool(dev, "cap-power-off-card"))
host->caps |= MMC_CAP_POWER_OFF_CARD;
- if (of_property_read_bool(np, "cap-mmc-hw-reset"))
+ if (device_property_read_bool(dev, "cap-mmc-hw-reset"))
host->caps |= MMC_CAP_HW_RESET;
- if (of_property_read_bool(np, "cap-sdio-irq"))
+ if (device_property_read_bool(dev, "cap-sdio-irq"))
host->caps |= MMC_CAP_SDIO_IRQ;
- if (of_property_read_bool(np, "full-pwr-cycle"))
+ if (device_property_read_bool(dev, "full-pwr-cycle"))
host->caps2 |= MMC_CAP2_FULL_PWR_CYCLE;
- if (of_property_read_bool(np, "keep-power-in-suspend"))
+ if (device_property_read_bool(dev, "keep-power-in-suspend"))
host->pm_caps |= MMC_PM_KEEP_POWER;
- if (of_property_read_bool(np, "wakeup-source") ||
- of_property_read_bool(np, "enable-sdio-wakeup")) /* legacy */
+ if (device_property_read_bool(dev, "wakeup-source") ||
+ device_property_read_bool(dev, "enable-sdio-wakeup")) /* legacy */
host->pm_caps |= MMC_PM_WAKE_SDIO_IRQ;
- if (of_property_read_bool(np, "mmc-ddr-3_3v"))
+ if (device_property_read_bool(dev, "mmc-ddr-3_3v"))
host->caps |= MMC_CAP_3_3V_DDR;
- if (of_property_read_bool(np, "mmc-ddr-1_8v"))
+ if (device_property_read_bool(dev, "mmc-ddr-1_8v"))
host->caps |= MMC_CAP_1_8V_DDR;
- if (of_property_read_bool(np, "mmc-ddr-1_2v"))
+ if (device_property_read_bool(dev, "mmc-ddr-1_2v"))
host->caps |= MMC_CAP_1_2V_DDR;
- if (of_property_read_bool(np, "mmc-hs200-1_8v"))
+ if (device_property_read_bool(dev, "mmc-hs200-1_8v"))
host->caps2 |= MMC_CAP2_HS200_1_8V_SDR;
- if (of_property_read_bool(np, "mmc-hs200-1_2v"))
+ if (device_property_read_bool(dev, "mmc-hs200-1_2v"))
host->caps2 |= MMC_CAP2_HS200_1_2V_SDR;
- if (of_property_read_bool(np, "mmc-hs400-1_8v"))
+ if (device_property_read_bool(dev, "mmc-hs400-1_8v"))
host->caps2 |= MMC_CAP2_HS400_1_8V | MMC_CAP2_HS200_1_8V_SDR;
- if (of_property_read_bool(np, "mmc-hs400-1_2v"))
+ if (device_property_read_bool(dev, "mmc-hs400-1_2v"))
host->caps2 |= MMC_CAP2_HS400_1_2V | MMC_CAP2_HS200_1_2V_SDR;
- if (of_property_read_bool(np, "mmc-hs400-enhanced-strobe"))
+ if (device_property_read_bool(dev, "mmc-hs400-enhanced-strobe"))
host->caps2 |= MMC_CAP2_HS400_ES;
- if (of_property_read_bool(np, "no-sdio"))
+ if (device_property_read_bool(dev, "no-sdio"))
host->caps2 |= MMC_CAP2_NO_SDIO;
- if (of_property_read_bool(np, "no-sd"))
+ if (device_property_read_bool(dev, "no-sd"))
host->caps2 |= MMC_CAP2_NO_SD;
- if (of_property_read_bool(np, "no-mmc"))
+ if (device_property_read_bool(dev, "no-mmc"))
host->caps2 |= MMC_CAP2_NO_MMC;
- host->dsr_req = !of_property_read_u32(np, "dsr", &host->dsr);
+ host->dsr_req = !device_property_read_u32(dev, "dsr", &host->dsr);
if (host->dsr_req && (host->dsr & ~0xffff)) {
dev_err(host->parent,
"device tree specified broken value for DSR: 0x%x, ignoring\n",
--
2.7.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] mmc: core: Use device_property_read instead of of_property_read
2017-05-17 22:17 ` [PATCH 2/2] mmc: core: " David Woods
@ 2017-05-19 8:23 ` Ulf Hansson
2017-05-23 19:30 ` David Woods
0 siblings, 1 reply; 4+ messages in thread
From: Ulf Hansson @ 2017-05-19 8:23 UTC (permalink / raw)
To: David Woods
Cc: Jaehoon Chung, Shawn Lin, Heiner Kallweit, Adrian Hunter,
cmetcalf, linux-mmc, linux-kernel, stable
On 18 May 2017 at 00:17, David Woods <dwoods@mellanox.com> wrote:
> Using the device_property interfaces allows mmc drivers to work
> on platforms which run on either device tree or ACPI.
>
> Signed-off-by: David Woods <dwoods@mellanox.com>
> Reviewed-by: Chris Metcalf <cmetcalf@mellanox.com>
> Cc: stable@vger.linux.org
> ---
> drivers/mmc/core/host.c | 72 ++++++++++++++++++++++++-------------------------
> 1 file changed, 35 insertions(+), 37 deletions(-)
>
> diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c
> index 3f8c85d..d2c059e 100644
> --- a/drivers/mmc/core/host.c
> +++ b/drivers/mmc/core/host.c
> @@ -176,19 +176,17 @@ static void mmc_retune_timer(unsigned long data)
> */
> int mmc_of_parse(struct mmc_host *host)
> {
> - struct device_node *np;
> + struct device *dev = host->parent;
> u32 bus_width;
> int ret;
> bool cd_cap_invert, cd_gpio_invert = false;
> bool ro_cap_invert, ro_gpio_invert = false;
>
> - if (!host->parent || !host->parent->of_node)
> + if (!dev)
> return 0;
>
So earlier we stopped executing the OF parsing at this point, unless
we had valid a of_node pointer. To be safe, I think we need to do
something similar here.
In other words, perhaps check the result from dev_fwnode(), before continue.
[...]
mmc_pwrseq_alloc() is called from mmc_of_parse() which currently only
supports OF parsing. I assume you would like to convert that as well?
Perhaps that should even be the first step?
Kind regards
Uffe
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] mmc: core: Use device_property_read instead of of_property_read
2017-05-19 8:23 ` Ulf Hansson
@ 2017-05-23 19:30 ` David Woods
0 siblings, 0 replies; 4+ messages in thread
From: David Woods @ 2017-05-23 19:30 UTC (permalink / raw)
To: Ulf Hansson
Cc: Jaehoon Chung, Shawn Lin, Heiner Kallweit, Adrian Hunter,
cmetcalf, linux-mmc, linux-kernel, stable
On 05/19/2017 04:23 AM, Ulf Hansson wrote:
> On 18 May 2017 at 00:17, David Woods <dwoods@mellanox.com> wrote:
>> Using the device_property interfaces allows mmc drivers to work
>> on platforms which run on either device tree or ACPI.
>>
>> Signed-off-by: David Woods <dwoods@mellanox.com>
>> Reviewed-by: Chris Metcalf <cmetcalf@mellanox.com>
>> Cc: stable@vger.linux.org
>> ---
>> drivers/mmc/core/host.c | 72 ++++++++++++++++++++++++-------------------------
>> 1 file changed, 35 insertions(+), 37 deletions(-)
>>
>> diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c
>> index 3f8c85d..d2c059e 100644
>> --- a/drivers/mmc/core/host.c
>> +++ b/drivers/mmc/core/host.c
>> @@ -176,19 +176,17 @@ static void mmc_retune_timer(unsigned long data)
>> */
>> int mmc_of_parse(struct mmc_host *host)
>> {
>> - struct device_node *np;
>> + struct device *dev = host->parent;
>> u32 bus_width;
>> int ret;
>> bool cd_cap_invert, cd_gpio_invert = false;
>> bool ro_cap_invert, ro_gpio_invert = false;
>>
>> - if (!host->parent || !host->parent->of_node)
>> + if (!dev)
>> return 0;
>>
> So earlier we stopped executing the OF parsing at this point, unless
> we had valid a of_node pointer. To be safe, I think we need to do
> something similar here.
>
> In other words, perhaps check the result from dev_fwnode(), before continue.
I will add that check.
> [...]
>
> mmc_pwrseq_alloc() is called from mmc_of_parse() which currently only
> supports OF parsing. I assume you would like to convert that as well?
> Perhaps that should even be the first step?
Our board does not have a power sequence device, so this is not
something I have the hardware available to test. It's not very clear to
me how a pwrseq reference would be represented in ACPI or how to access
it with the device_property API. As it is, of_parse_phandle just
returns NULL in the case where there is no parent->of_node.
-David Woods
>
> Kind regards
> Uffe
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-05-23 19:30 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-17 22:17 [PATCH 1/2] mmc: dw_mmc: Use device_property_read instead of of_property_read David Woods
2017-05-17 22:17 ` [PATCH 2/2] mmc: core: " David Woods
2017-05-19 8:23 ` Ulf Hansson
2017-05-23 19:30 ` David Woods
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).