mmc: Add LiteSDCard mmc driver
Subsystems (3)
v9 cover mmc: Add LiteSDCard mmc driver
Add support for the LiteX SD-Card device, LiteSDCard.
LiteSDCard is a simple SD-Card interface available as part of the LiteX environment, used with various RISC-V and other FPGA based SoCs.
New in v9:
drivers/mmc/host/Kconfig:
- fix OF dependencydrivers/mmc/host/litex_mmc.c:
- remove linux/of.h include, no longer needed since dropping
`of_match_ptr()`
- add linux/mod_devicetable.h include
- use devm_action_or_reset() to devm-ify mmc_alloc_host(), and obviate the need to call mmc_free_host() explicitly during either probe() error path or during remove()
Quoted 131 lines
New in v8:
commit blurbs:
- cosmetic editing of descriptions
- removedCc:linesdrivers/mmc/host/litex_mmc.c:
- fix file header comment (for real, this time)
- add explicitbits.hinclude
- removeof_match_ptr()wrapper from around .of_match_table argument
- fix devm ordering issues: usedevm_request_irq(), which precludes the need to callfree_irq()onprobe()error path or fromremove()Quoted 120 lines
New in v7:
drivers/mmc/host/Kconfig:
- added module name in LiteSDCardKconfigentry
drivers/mmc/host/litex_mmc.c:
- fixed comment formatting, ordering, and capitalization throughout the entire file
- sorted header #include statements
- removed redundant parantheses inreadx_poll_timeout()condition
- explicit handling ofreadx_poll_timeout()timeout scenarios
-dev_err()used inlitex_mmc_sdcard_wait_done()
- usememcpy_fromio()to grab command response
- no need to apply0xffffmask to a 32-bit value right-shifted by 16 (host->resp[3])
- useclamp()instead of min(max(...)...)
- reworkedplatform_get_irq_optional()error handling logic
- no need to explicitly zerohost->irq,kzalloc()does that already
- added missingfree_irq()inlitex_mmc_probe()error path
- reordered calls insidelitex_mmc_remove()(callingmmc_free_host()beforefree_irq()Quoted 98 lines
New in v6:
drivers/mmc/host/litex_mmc.c:
- fix handling of deferred probe vs.platform_get_irq_optional()
- don't #ifdefdma_set_mask_and_coherent(), since it automatically does the right thing on both 32- and 64-bit DMA capable arches
- removeMMC_CAP2_FULL_PWR_CYCLE, addMMC_CAP2_NO_MMCto list of hardcoded capabilities duringlitex_mmc_probe()
- hardcodemmc->ocr_availto the full 2.7-3.6V range allowed by the SDCard spec (the LiteSDCard device doesn't accept software configuration)Quoted 86 lines
New in v5:
MAINTAINERS:- picked up a/b Mateusz
Doc/dt/bindings/mmc/litex,mmc.yaml:- picked up r/b Rob, Joel
drivers/mmc/host/litex_mmc.c:- shorten #define constant names (cosmetic, make them less unwieldy)
- picked up r/b JoelQuoted 71 lines
New in v4:
Doc/dt/bindings/mmc/litex,mmc.yaml:- fixed
dt_binding_checkerrors uncovered by Rob's script
drivers/mmc/host/litex_mmc.c:- struct
litex_mmc_hostfields re-ordered so thatpaholereports no holes in either 32- or 64-bit builds
-litex_mmc_set_bus_width()now encapsulates check forhost->is_bus_width_set
-litex_mmc_request()- factor out dma data setup into separate helper function:litex_mmc_do_dma()Quoted 56 lines
New in v3:
MAINTAINERS:- picked up acked-by Joel
- added listing for liteeth driver
- added Joel as additional co-maintainer (thanks!)
Doc/dt/bindings/mmc/litex,mmc.yaml:- picked up r/b Geert Uytterhoeven <[email protected]> in DT bindings document (please let me know if that was premature, and happy to take further review if needed :)
- add dedicated DT property for source clock frequency
drivers/mmc/host/litex_mmc.c:- fixed function signature (no line split), and naming (litex_mmc_*)
- more informativeMODULE_AUTHOR()entries
- also added matching "Copyright" entries in file header
- fixed description inKconfig
- fixed DT documentation
- removed magic constants
- removedlitex_map_status(), havesdcard_wait_done()return *real* error codes directly instead.
- streamlinedlitex_mmc_reponse_len()
- calllitex_mmc_set_bus_width()only once, and ensure it returns correct error code(s)
- usereadx_poll_timeout()-- more concise -- instead ofread_poll_timeout()
- usedev_err()inlitex_mmc_send_cmd()(instead ofpr_err())
-litex_mmc_setclk()will updatehost->clockbefore returning
- separate irq initialization into its own function,litex_mmc_irq_init()
- document rationale forf_min,f_max
- usedmam_alloc_coherent(), which simplifies cleanup significantly
- largeif (data) { ... }block inlitex_mmc_request()left as-is, there are too many variables shared with the rest of the parent function body to easily separate (e.g.,len,transfer,direct). If this is indeed a blocker, I can take another shot at refactoring it in a future revision!
- bumpdma_set_mask_and_coherent()to 64-bits on suitable architectures
- clock source picked up from dedicated DT clock reference property
- remove gpio card-detect logic (needs testing and a dt binding example before being eligible for upstream inclusion)Quoted 9 lines
New in v2:
- reword info message inlitex_set_clk()
- streamline code inlitex_map_status()
- fix typos inKconfig(thanks Randy Dunlap <[email protected]>)
- improvements suggested by Stafford Horne <[email protected]>
- allowCOMPILE_TESTinKconfig
- useread_poll_timeout()when waiting for cmd/data/DMA xfer completion
- includeinterrupt.h(thanks kernel test robot <[email protected]>)
Gabriel Somlo (3):
MAINTAINERS: co-maintain LiteX platform
dt-bindings: mmc: Add bindings for LiteSDCard
mmc: Add driver for LiteX's LiteSDCard interface
.../devicetree/bindings/mmc/litex,mmc.yaml | 72 ++ MAINTAINERS | 9 +- drivers/mmc/host/Kconfig | 9 + drivers/mmc/host/Makefile | 1 + drivers/mmc/host/litex_mmc.c | 654 ++++++++++++++++++ 5 files changed, 743 insertions(+), 2 deletions(-) create mode 100644 Documentation/devicetree/bindings/mmc/litex,mmc.yaml create mode 100644 drivers/mmc/host/litex_mmc.c
Signature · 1 line
2.31.1
PATCH v9 1/3 MAINTAINERS: co-maintain LiteX platform
Add the litex_mmc (LiteSDCard) and LiteETH drivers to the list of files maintained under LiteX.
Add Gabriel Somlo and Joel Stanley as maintainers; Joel authored the LiteETH driver, and Gabriel is currently curating the LiteX out-of-tree device drivers as they are tested and prepared for upstream submission, having also co-authored a number of them.
--- MAINTAINERS | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
MAINTAINERS +7 -2
@@ -11012,12 +11012,17 @@ F: lib/list-test.c LITEX PLATFORM M: Karol Gugala <[email protected]> M: Mateusz Holenko <[email protected]> +M: Gabriel Somlo <[email protected]> +M: Joel Stanley <[email protected]> S: Maintained F: Documentation/devicetree/bindings/*/litex,*.yaml F: arch/openrisc/boot/dts/or1klitex.dts -F: drivers/soc/litex/litex_soc_ctrl.c -F: drivers/tty/serial/liteuart.c F: include/linux/litex.h +F: drivers/tty/serial/liteuart.c +F: drivers/soc/litex/* +F: drivers/net/ethernet/litex/* +F: drivers/mmc/host/litex_mmc.c +N: litex LIVE PATCHING M: Josh Poimboeuf <[email protected]>
Signature · 1 line
2.31.1
PATCH v9 2/3 dt-bindings: mmc: Add bindings for LiteSDCard
In reply to Gabriel SomloLiteSDCard is a small footprint, configurable SDCard core for FPGA based SoCs.
--- .../devicetree/bindings/mmc/litex,mmc.yaml | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 Documentation/devicetree/bindings/mmc/litex,mmc.yaml
Documentation/devicetree/bindings/mmc/litex,mmc.yaml new file +72 -0
@@ -0,0 +1,72 @@ +# SPDX-License-Identifier: GPL-2.0-or-later OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/mmc/litex,mmc.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: LiteX LiteSDCard device + +maintainers: + - Gabriel Somlo <[email protected]> + +description: | + LiteSDCard is a small footprint, configurable SDCard core for FPGA based + system on chips. + + The hardware source is Open Source and can be found on at + https://github.com/enjoy-digital/litesdcard/. + +allOf: + - $ref: mmc-controller.yaml# + +properties: + compatible: + const: litex,mmc + + reg: + items: + - description: PHY registers + - description: CORE registers + - description: DMA Reader buffer + - description: DMA Writer buffer + - description: IRQ registers + minItems: 4 + + reg-names: + items: + - const: phy + - const: core + - const: reader + - const: writer + - const: irq + minItems: 4 + + clocks: + maxItems: 1 + description: + Handle to reference clock. + + interrupts: + maxItems: 1 + +required: + - compatible + - reg + - reg-names + - clocks + +additionalProperties: false + +examples: + - | + mmc: mmc@12005000 { + compatible = "litex,mmc"; + reg = <0x12005000 0x100>, + <0x12003800 0x100>, + <0x12003000 0x100>, + <0x12004800 0x100>, + <0x12004000 0x100>; + reg-names = "phy", "core", "reader", "writer", "irq"; + clocks = <&reference_clk>; + interrupts = <4>; + };
Signature · 1 line
2.31.1
PATCH v9 3/3 mmc: Add driver for LiteX's LiteSDCard interface
In reply to Gabriel SomloLiteX (https://github.com/enjoy-digital/litex) is a SoC framework that targets FPGAs. LiteSDCard is a small footprint, configurable SDCard core commonly used in LiteX designs.
The driver was first written in May 2020 and has been maintained cooperatively by the LiteX community. Thanks to all contributors!
---
New in v9:
drivers/mmc/host/Kconfig:
- fix OF dependencydrivers/mmc/host/litex_mmc.c:
- remove linux/of.h include, no longer needed since dropping
`of_match_ptr()`
- add linux/mod_devicetable.h include
- use devm_action_or_reset() to devm-ify mmc_alloc_host(), and obviate the need to call mmc_free_host() explicitly during either probe() error path or during remove()
Quoted 80 lines
New in v8:
- removeCc:lines from commit blurbdrivers/mmc/host/litex_mmc.c:
- fix file header comment (for real, this time)
- add explicitbits.hinclude
- removeof_match_ptr()wrapper from around .of_match_table argument
- fix devm ordering issues: usedevm_request_irq(), which precludes the need to callfree_irq()onprobe()error path or fromremove()Quoted 71 lines
New in v7:
drivers/mmc/host/Kconfig:
- added module name in LiteSDCardKconfigentrydrivers/mmc/host/litex_mmc.c:
- fixed comment formatting, ordering, and capitalization throughout the entire file
- sorted header #include statements
- removed redundant parantheses inreadx_poll_timeout()condition
- explicit handling ofreadx_poll_timeout()timeout scenarios
-dev_err()used inlitex_mmc_sdcard_wait_done()
- usememcpy_fromio()to grab command response
- no need to apply0xffffmask to a 32-bit value right-shifted by 16 (host->resp[3])
- useclamp()instead of min(max(...)...)
- reworkedplatform_get_irq_optional()error handling logic
- no need to explicitly zerohost->irq,kzalloc()does that already
- added missingfree_irq()inlitex_mmc_probe()error path
- reordered calls insidelitex_mmc_remove()(callingmmc_free_host()beforefree_irq()Quoted 51 lines
New in v6:
- fix handling of deferred probe vs.platform_get_irq_optional()
- don't #ifdefdma_set_mask_and_coherent(), since it automatically does the right thing on both 32- and 64-bit DMA capable arches
- removeMMC_CAP2_FULL_PWR_CYCLE, addMMC_CAP2_NO_MMCto list of hardcoded capabilities duringlitex_mmc_probe()
- hardcodemmc->ocr_availto the full 2.7-3.6V range allowed by the SDCard spec (the LiteSDCard device doesn't accept software configuration)Quoted 41 lines
New in v5:
- shorter #define constant names (cosmetic, make them less unwieldy)
- picked up reviewed-by JoelQuoted 37 lines
New in v4:
- structlitex_mmc_hostfields re-ordered so thatpaholereports no holes on either 32- or 64-bit builds
-litex_mmc_set_bus_width()now encapsulates check forhost->is_bus_width_set
-litex_mmc_request()- factor out dma data setup into separate helper function:litex_mmc_do_dma()Quoted 29 lines
New in v3:
- fixed function signature (no line split), and naming (litex_mmc_*)
- more informativeMODULE_AUTHOR()entries
- also added matching "Copyright" entries in file header
- fixed description and dependencies inKconfig
- removed magic constants
- removedlitex_map_status(), havesdcard_wait_done()return *real* error codes directly instead.
- streamlinedlitex_mmc_reponse_len()
- calllitex_mmc_set_bus_width()only once, and ensure it returns correct error code(s)
- usereadx_poll_timeout()-- more concise -- instead ofread_poll_timeout()
- usedev_err()inlitex_mmc_send_cmd()(instead ofpr_err())
-litex_mmc_setclk()will updatehost->clockbefore returning
- separate irq initialization into its own function,litex_mmc_irq_init()
- document rationale forf_min,f_max
- usedmam_alloc_coherent(), which simplifies cleanup significantly
- bumpdma_set_mask_and_coherent()to 64-bits on suitable architectures
- clock source picked up from dedicated DT clock reference property
- remove gpio card-detect logic (needs testing and a dt binding example before being eligible for upstream inclusion)
- largeif (data) { ... }block inlitex_mmc_request()left as-is, there are too many variables shared with the rest of the parent function body to easily separate (e.g.,len,transfer,direct). If this is indeed a blocker, I can take another shot at refactoring it in a future revision!
drivers/mmc/host/Kconfig | 9 + drivers/mmc/host/Makefile | 1 + drivers/mmc/host/litex_mmc.c | 654 +++++++++++++++++++++++++++++++++++ 3 files changed, 664 insertions(+) create mode 100644 drivers/mmc/host/litex_mmc.c
drivers/mmc/host/Kconfig +9 -0
@@ -1093,3 +1093,12 @@ config MMC_OWL config MMC_SDHCI_EXTERNAL_DMA bool + +config MMC_LITEX + tristate "LiteX MMC Host Controller support" + depends on ((PPC_MICROWATT || LITEX) && OF) || COMPILE_TEST + help + This selects support for the MMC Host Controller found in LiteX SoCs. + + To compile this driver as a module, choose M here: the + module will be called litex_mmc.
drivers/mmc/host/Makefile +1 -0
@@ -101,6 +101,7 @@ obj-$(CONFIG_MMC_CQHCI) += cqhci.o cqhci-y += cqhci-core.o cqhci-$(CONFIG_MMC_CRYPTO) += cqhci-crypto.o obj-$(CONFIG_MMC_HSQ) += mmc_hsq.o +obj-$(CONFIG_MMC_LITEX) += litex_mmc.o ifeq ($(CONFIG_CB710_DEBUG),y) CFLAGS-cb710-mmc += -DDEBUG
drivers/mmc/host/litex_mmc.c new file +654 -0
654 lines not on this page · raw message
Signature · 1 line
2.31.1
Re: [PATCH v9 3/3] mmc: Add driver for LiteX's LiteSDCard interface
Quoted 7 lines · Gabriel Somlo
LiteX (https://github.com/enjoy-digital/litex) is a SoC framework that targets FPGAs. LiteSDCard is a small footprint, configurable SDCard core commonly used in LiteX designs.
The driver was first written in May 2020 and has been maintained cooperatively by the LiteX community. Thanks to all contributors!
Thanks for an update, my comments below.
...
drivers/mmc/host/litex_mmc.c line 23
Quoted 13 lines
drivers/mmc/host/litex_mmc.c new file +12
-0+#include <linux/bits.h> +#include <linux/clk.h> +#include <linux/delay.h> +#include <linux/dma-mapping.h> +#include <linux/interrupt.h> +#include <linux/iopoll.h> +#include <linux/litex.h> +#include <linux/mod_devicetable.h> +#include <linux/module.h> +#include <linux/mmc/host.h> +#include <linux/mmc/mmc.h> +#include <linux/mmc/sd.h>
I would move this group of headers...
Review
Quoted 2 lines
(quoted diff) +2
-0+#include <linux/platform_device.h> +
...somewhere here to show that this driver belongs to the MMC subsystem.
...
drivers/mmc/host/litex_mmc.c line 77
Quoted 3 lines
drivers/mmc/host/litex_mmc.c new file +3
-0+#define LITEX_MMC_OCR (MMC_VDD_27_28 | MMC_VDD_28_29 | MMC_VDD_29_30 | \ + MMC_VDD_30_31 | MMC_VDD_31_32 | MMC_VDD_32_33 | \ + MMC_VDD_33_34 | MMC_VDD_34_35 | MMC_VDD_35_36)
Seems to me this is identical to
https://elixir.bootlin.com/linux/latest/source/drivers/mmc/host/au1xmmc.c#L72
And may be reused in
https://elixir.bootlin.com/linux/latest/source/drivers/mmc/host/vub300.c#L2168.
Perhaps it makes sense to have
#define MMC_VDD_27_36 ...
in mmc.h?
In any case, it can be postponed, just a side note for the future improvements.
...
drivers/mmc/host/litex_mmc.c line 253
Quoted 5 lines
drivers/mmc/host/litex_mmc.c new file +5
-0+/* Ensure bus width will be set (again) upon card (re)insertion */ +if (ret ==0 ) + host->is_bus_width_set = false; + +return ret;
Please, switch to standard pattern, i.e.
if (ret)
return ret;
...
return 0;
...
drivers/mmc/host/litex_mmc.c line 441
Quoted 6 lines
drivers/mmc/host/litex_mmc.c new file +5
-0+u32 div; + + div = freq ? host->ref_clk / freq :256U ; + div =roundup_pow_of_two (div); + div =clamp (div,2U ,256U );
Not sure why it becomes two lines again.
...
drivers/mmc/host/litex_mmc.c line 526
Quoted 2 lines
drivers/mmc/host/litex_mmc.c new file +2
-0+ ret =devm_add_action_or_reset (dev, + (void (*)(void *))mmc_free_host, mmc);
One line?
An actually preferable way is to define a separate wrapper function and use it here without any casting.
drivers/mmc/host/litex_mmc.c line 529
Quoted 4 lines
drivers/mmc/host/litex_mmc.c new file +3
-0+if (ret) { +dev_err (dev,"Failed to register mmc_free_host action\n" ); +return ret;
return dev_err_probe(...);
Quoted 1 line
+ }
...
drivers/mmc/host/litex_mmc.c line 540
Quoted 5 lines
drivers/mmc/host/litex_mmc.c new file +4
-0+ clk =devm_clk_get (dev,NULL ); +if (IS_ERR (clk)) { + ret =dev_err_probe (dev,PTR_ERR (clk),"can't get clock\n" ); +return ret;
return dev_err_probe(...);
Quoted 1 line
+ }
...
drivers/mmc/host/litex_mmc.c line 621
Quoted 3 lines
drivers/mmc/host/litex_mmc.c new file +3
-0+ ret =mmc_add_host (mmc); + +return ret;
It's now
return mmc_add_host(...);
Quoted 1 line
+}
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v9 3/3] mmc: Add driver for LiteX's LiteSDCard interface
Quoted 29 lines · Andy Shevchenko
Quoted 7 lines · Gabriel Somlo
LiteX (https://github.com/enjoy-digital/litex) is a SoC framework that targets FPGAs. LiteSDCard is a small footprint, configurable SDCard core commonly used in LiteX designs.
The driver was first written in May 2020 and has been maintained cooperatively by the LiteX community. Thanks to all contributors!
Thanks for an update, my comments below.
...
drivers/mmc/host/litex_mmc.c line 23
Quoted 13 lines
drivers/mmc/host/litex_mmc.c new file +12
-0+#include <linux/bits.h> +#include <linux/clk.h> +#include <linux/delay.h> +#include <linux/dma-mapping.h> +#include <linux/interrupt.h> +#include <linux/iopoll.h> +#include <linux/litex.h> +#include <linux/mod_devicetable.h> +#include <linux/module.h> +#include <linux/mmc/host.h> +#include <linux/mmc/mmc.h> +#include <linux/mmc/sd.h> I would move this group of headers...
Quoted 4 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+#include <linux/platform_device.h> +...somewhere here to show that this driver belongs to the MMC subsystem.
OK, lined up for v10
Quoted 12 lines
...
drivers/mmc/host/litex_mmc.c line 77
Quoted 3 lines
drivers/mmc/host/litex_mmc.c new file +3
-0+#define LITEX_MMC_OCR (MMC_VDD_27_28 | MMC_VDD_28_29 | MMC_VDD_29_30 | \ + MMC_VDD_30_31 | MMC_VDD_31_32 | MMC_VDD_32_33 | \ + MMC_VDD_33_34 | MMC_VDD_34_35 | MMC_VDD_35_36)Seems to me this is identical to
https://elixir.bootlin.com/linux/latest/source/drivers/mmc/host/au1xmmc.c#L72And may be reused in
https://elixir.bootlin.com/linux/latest/source/drivers/mmc/host/vub300.c#L2168.
Quoted 7 lines
Perhaps it makes sense to have
#define
MMC_VDD_27_36...in
mmc.h?In any case, it can be postponed, just a side note for the future improvements.
I'm awaiting follow-up advice from Ulf Hansson, who originally suggested this should be dynamically configured through a dummy voltage regulator in DTS. Since LiteSDCard doesn't a (current or planned) option to adaptively configure voltages via software, I think hard-coding the valid range in the driver (in the exact way as au1xmmc.c) might be cleaner, and if we end up agreeing on that, there might be opportunity for factoring it out in the way you describe.
Quoted 9 lines
...
drivers/mmc/host/litex_mmc.c line 253
Quoted 5 lines
drivers/mmc/host/litex_mmc.c new file +5
-0+/* Ensure bus width will be set (again) upon card (re)insertion */ +if (ret ==0 ) + host->is_bus_width_set = false; + +return ret;
Quoted 6 lines
Please, switch to standard pattern, i.e.
if (ret)
return ret;...
return 0;
OK, lined up for v10
Quoted 10 lines
...
drivers/mmc/host/litex_mmc.c line 441
Quoted 6 lines
drivers/mmc/host/litex_mmc.c new file +5
-0+u32 div; + + div = freq ? host->ref_clk / freq :256U ; + div =roundup_pow_of_two (div); + div =clamp (div,2U ,256U );Not sure why it becomes two lines again.
Per my previous email, I have:
div = clamp((u32)roundup_pow_of_two(div), 2U, 256U);
... lined up for v10 (pending also Geert's OK on the (u32) cast to shut up compiler warnings) :)
Quoted 8 lines
...
drivers/mmc/host/litex_mmc.c line 526
Quoted 2 lines
drivers/mmc/host/litex_mmc.c new file +2
-0+ ret =devm_add_action_or_reset (dev, + (void (*)(void *))mmc_free_host, mmc);One line?
An actually preferable way is to define a separate wrapper function and use it here without any casting.
Done and lined up for v10:
/* wrapper for use with devm_add_action_or_reset(), below */
static void litex_mmc_free_host_wrapper(void *ptr)
{
mmc_free_host((struct mmc_host *)ptr);
}
static int litex_mmc_probe(struct platform_device *pdev)
{
...
ret = devm_add_action_or_reset(dev, litex_mmc_free_host_wrapper, mmc);
...
}Quoted 6 lines
drivers/mmc/host/litex_mmc.c line 529
Quoted 4 lines
drivers/mmc/host/litex_mmc.c new file +3
-0+if (ret) { +dev_err (dev,"Failed to register mmc_free_host action\n" ); +return ret;return
dev_err_probe(...);
OK.
Quoted 11 lines
Quoted 1 line
+ }
...
drivers/mmc/host/litex_mmc.c line 540
Quoted 5 lines
drivers/mmc/host/litex_mmc.c new file +4
-0+ clk =devm_clk_get (dev,NULL ); +if (IS_ERR (clk)) { + ret =dev_err_probe (dev,PTR_ERR (clk),"can't get clock\n" ); +return ret;return dev_err_probe(...);
OK.
Quoted 11 lines
Quoted 1 line
+ }
...
drivers/mmc/host/litex_mmc.c line 621
Quoted 3 lines
drivers/mmc/host/litex_mmc.c new file +3
-0+ ret =mmc_add_host (mmc); + +return ret;It's now
return mmc_add_host(...);
OK.
I'll wait till sometime tomorrow for additional feedback on clamp() casting and voltage range hard-coding vs. regulators, before I send out v10 so we can continue from there.
Thanks, as always,
--Gabriel
Re: [PATCH v9 3/3] mmc: Add driver for LiteX's LiteSDCard interface
Quoted 2 lines · Gabriel L. Somlo
Quoted 1 line · Andy Shevchenko
On Sat, Jan 8, 2022 at 6:11 PM Gabriel Somlo <[email protected]> wrote:
...
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
drivers/mmc/host/litex_mmc.c new file +5
-0+u32 div; + + div = freq ? host->ref_clk / freq :256U ; + div =roundup_pow_of_two (div); + div =clamp (div,2U ,256U );
Quoted 8 lines
Quoted 1 line
Not sure why it becomes two lines again.
Per my previous email, I have:
div = clamp((u32)roundup_pow_of_two(div), 2U, 256U);... lined up for v10 (pending also Geert's OK on the (u32) cast to shut up compiler warnings) :)
Yeah, I have read that and I think we may survive without comment and being in two lines.
That roundup_pow_of_two may return int, unsigned long, and who knows what depending on the per arch implementations.
What a mess...
...
Quoted 1 line
/* wrapper for use with devm_add_action_or_reset(), below */
No need for this comment.
Quoted 4 lines
static void litex_mmc_free_host_wrapper(void *ptr)
{
mmc_free_host((struct mmc_host *)ptr);Casting is not needed, just name the variable as mmc
mmc_free_host(mmc);
Quoted 1 line
}
...
Quoted 3 lines
I'll wait till sometime tomorrow for additional feedback on
clamp()casting and voltage range hard-coding vs. regulators, before I send out v10 so we can continue from there.
Thanks!
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v9 3/3] mmc: Add driver for LiteX's LiteSDCard interface
In reply to Gabriel L. SomloHi Gabriel,
Quoted 9 lines · Gabriel L. Somlo
Quoted 8 lines · Andy Shevchenko
Quoted 6 lines · Gabriel Somlo
drivers/mmc/host/litex_mmc.c new file +5
-0+u32 div; + + div = freq ? host->ref_clk / freq :256U ; + div =roundup_pow_of_two (div); + div =clamp (div,2U ,256U );
Quoted 8 lines
Quoted 1 line
Not sure why it becomes two lines again.
Per my previous email, I have:
div = clamp((u32)roundup_pow_of_two(div), 2U, 256U);... lined up for v10 (pending also Geert's OK on the (u32) cast to shut up compiler warnings) :)
JFY (as you decided to keep the two separate lines), this is exactly why clamp_t()exists: to avoid the explicit cast.
i.e.
div = clamp_t(u32, roundup_pow_of_two(div), 2U, 256U);
or
div = clamp_t(u32, roundup_pow_of_two(div), 2, 256);
(the implicit cast is applied to all parameters).
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH v9 3/3] mmc: Add driver for LiteX's LiteSDCard interface
Quoted 12 lines · Hillf Danton
Review
Quoted 9 lines · On Sat, 8 Jan 2022 11:11:34 -0500 Gabriel Somlo wrote:
(quoted diff) +9
-0+ + /* LiteSDCard can support 64-bit DMA addressing */ + ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(64)); + if (ret) + return ret; + + host->buf_size = mmc->max_req_size * 2; + host->buffer = dmam_alloc_coherent(dev, host->buf_size, + &host->dma, GFP_DMA);
GFP_DMAcan not make much sence given the above comment.
I'll change it to GFP_KERNEL in v10. Thanks for catching that, --Gabriel