From 9da422696bfa77f25a0f1f1c46b7a5f5ea9f4d22 Mon Sep 17 00:00:00 2001 From: Martin Stein Date: Thu, 22 Oct 2015 17:50:56 +0200 Subject: [PATCH] sd_card & imx53: set ADMA entry size more clean Less heuristics. Ref #1497 --- .../src/drivers/sd_card/spec/imx53/esdhcv2.h | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/repos/os/src/drivers/sd_card/spec/imx53/esdhcv2.h b/repos/os/src/drivers/sd_card/spec/imx53/esdhcv2.h index dec19f2f9..177de1ed1 100644 --- a/repos/os/src/drivers/sd_card/spec/imx53/esdhcv2.h +++ b/repos/os/src/drivers/sd_card/spec/imx53/esdhcv2.h @@ -32,14 +32,24 @@ namespace Adma2 */ struct Desc : Register<64> { - static size_t constexpr max_size = 64 * 1024 - 4; - struct Valid : Bitfield<0, 1> { }; struct End : Bitfield<1, 1> { }; struct Int : Bitfield<2, 1> { }; struct Act1 : Bitfield<4, 1> { }; struct Act2 : Bitfield<5, 1> { }; - struct Length : Bitfield<16, 16> { }; + struct Length : Bitfield<16, 16> + { + /* + * According to the 'SD Specifications, Part A2, SD Host + * Controller, Simplified Specification, Version 2.00, February 8, + * 2007, Table 1-10', a maximum length of 65536 bytes is achieved + * by value 0. However, if we do so, the completion host-signal + * times out now and then. Thus, we use the next lower possible + * value. + */ + static constexpr addr_t align_log2 = 2; + static constexpr size_t max = (1 << WIDTH) - (1 << align_log2); + }; struct Address : Bitfield<32, 32> { }; }; @@ -84,7 +94,7 @@ namespace Adma2 * the driver partition large requests into ones that are * supported. */ - static size_t constexpr max_size = _max_desc * Desc::max_size; + static size_t constexpr max_size = _max_desc * Desc::Length::max; if (size > max_size) { PERR("Block request too large"); return false; @@ -95,7 +105,7 @@ namespace Adma2 /* clamp current request to maximum request size */ size_t const remaining = size - consumed; - size_t const curr = min(Desc::max_size, remaining); + size_t const curr = min(Desc::Length::max, remaining); /* assemble new descriptor */ Desc::access_t desc = 0;