2013-03-22 15:19:09 +01:00
|
|
|
/*
|
|
|
|
* \brief Exynos5-specific implementation of the Block::Driver interface
|
|
|
|
* \author Sebastian Sumpf
|
|
|
|
* \date 2013-03-22
|
|
|
|
*/
|
|
|
|
|
2013-03-22 15:31:16 +01:00
|
|
|
/*
|
2015-04-14 13:56:26 +02:00
|
|
|
* Copyright (C) 2015 Genode Labs GmbH
|
2013-03-22 15:31:16 +01:00
|
|
|
*
|
|
|
|
* This file is part of the Genode OS framework, which is distributed
|
|
|
|
* under the terms of the GNU General Public License version 2.
|
|
|
|
*/
|
|
|
|
|
2015-09-03 14:55:05 +02:00
|
|
|
#ifndef _DRIVERS__SD_CARD__SPEC__EXYNOS5__DRIVER_H_
|
|
|
|
#define _DRIVERS__SD_CARD__SPEC__EXYNOS5__DRIVER_H_
|
2013-03-22 15:19:09 +01:00
|
|
|
|
2016-12-16 13:11:08 +01:00
|
|
|
/* Genode includes */
|
2013-03-22 15:19:09 +01:00
|
|
|
#include <util/mmio.h>
|
|
|
|
#include <os/attached_io_mem_dataspace.h>
|
base: avoid use of deprecated base/printf.h
Besides adapting the components to the use of base/log.h, the patch
cleans up a few base headers, i.e., it removes unused includes from
root/component.h, specifically base/heap.h and
ram_session/ram_session.h. Hence, components that relied on the implicit
inclusion of those headers have to manually include those headers now.
While adjusting the log messages, I repeatedly stumbled over the problem
that printing char * arguments is ambiguous. It is unclear whether to
print the argument as pointer or null-terminated string. To overcome
this problem, the patch introduces a new type 'Cstring' that allows the
caller to express that the argument should be handled as null-terminated
string. As a nice side effect, with this type in place, the optional len
argument of the 'String' class could be removed. Instead of supplying a
pair of (char const *, size_t), the constructor accepts a 'Cstring'.
This, in turn, clears the way let the 'String' constructor use the new
output mechanism to assemble a string from multiple arguments (and
thereby getting rid of snprintf within Genode in the near future).
To enforce the explicit resolution of the char * ambiguity, the 'char *'
overload of the 'print' function is marked as deleted.
Issue #1987
2016-07-13 19:07:09 +02:00
|
|
|
#include <base/log.h>
|
2013-03-22 15:19:09 +01:00
|
|
|
#include <timer_session/connection.h>
|
2015-04-14 13:56:26 +02:00
|
|
|
#include <os/server.h>
|
2016-12-16 13:11:08 +01:00
|
|
|
#include <regulator_session/connection.h>
|
2013-03-22 15:19:09 +01:00
|
|
|
|
|
|
|
/* local includes */
|
|
|
|
#include <dwmmc.h>
|
|
|
|
|
|
|
|
namespace Block {
|
|
|
|
using namespace Genode;
|
2017-01-04 16:35:04 +01:00
|
|
|
class Sdhci_driver;
|
2013-03-22 15:19:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-12-23 14:53:30 +01:00
|
|
|
class Block::Sdhci_driver : public Block::Driver,
|
|
|
|
public Sd_ack_handler
|
2013-03-22 15:19:09 +01:00
|
|
|
{
|
|
|
|
private:
|
|
|
|
|
|
|
|
struct Timer_delayer : Timer::Connection, Mmio::Delayer
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Implementation of 'Delayer' interface
|
|
|
|
*/
|
|
|
|
void usleep(unsigned us)
|
|
|
|
{
|
|
|
|
/* polling */
|
|
|
|
if (us == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
Timer::Connection::usleep(us);
|
|
|
|
}
|
|
|
|
} _delayer;
|
|
|
|
|
|
|
|
enum {
|
|
|
|
MSH_BASE = 0x12200000, /* host controller base for eMMC */
|
|
|
|
MSH_SIZE = 0x10000,
|
|
|
|
};
|
|
|
|
|
2016-12-16 13:11:08 +01:00
|
|
|
struct Clock_regulator
|
|
|
|
{
|
|
|
|
Regulator::Connection regulator;
|
|
|
|
|
|
|
|
Clock_regulator(Env &env) : regulator(env, Regulator::CLK_MMC0) {
|
|
|
|
regulator.state(true); }
|
|
|
|
|
|
|
|
} _clock_regulator;
|
2013-03-22 15:19:09 +01:00
|
|
|
|
2015-04-14 13:56:26 +02:00
|
|
|
|
2013-03-22 15:19:09 +01:00
|
|
|
/* display sub system registers */
|
|
|
|
Attached_io_mem_dataspace _mmio;
|
|
|
|
|
|
|
|
/* mobile storage host controller instance */
|
|
|
|
Exynos5_msh_controller _controller;
|
|
|
|
|
|
|
|
bool const _use_dma;
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2016-12-16 13:11:08 +01:00
|
|
|
Sdhci_driver(Env &env)
|
2013-03-22 15:19:09 +01:00
|
|
|
:
|
2016-12-16 13:11:08 +01:00
|
|
|
_clock_regulator(env),
|
2013-03-22 15:19:09 +01:00
|
|
|
_mmio(MSH_BASE, MSH_SIZE),
|
2016-12-16 13:11:08 +01:00
|
|
|
_controller(env.ep(), (addr_t)_mmio.local_addr<void>(),
|
2016-12-23 14:53:30 +01:00
|
|
|
_delayer, *this, true),
|
2016-12-16 13:11:08 +01:00
|
|
|
_use_dma(true)
|
2013-03-22 15:19:09 +01:00
|
|
|
{
|
|
|
|
Sd_card::Card_info const card_info = _controller.card_info();
|
|
|
|
|
base: avoid use of deprecated base/printf.h
Besides adapting the components to the use of base/log.h, the patch
cleans up a few base headers, i.e., it removes unused includes from
root/component.h, specifically base/heap.h and
ram_session/ram_session.h. Hence, components that relied on the implicit
inclusion of those headers have to manually include those headers now.
While adjusting the log messages, I repeatedly stumbled over the problem
that printing char * arguments is ambiguous. It is unclear whether to
print the argument as pointer or null-terminated string. To overcome
this problem, the patch introduces a new type 'Cstring' that allows the
caller to express that the argument should be handled as null-terminated
string. As a nice side effect, with this type in place, the optional len
argument of the 'String' class could be removed. Instead of supplying a
pair of (char const *, size_t), the constructor accepts a 'Cstring'.
This, in turn, clears the way let the 'String' constructor use the new
output mechanism to assemble a string from multiple arguments (and
thereby getting rid of snprintf within Genode in the near future).
To enforce the explicit resolution of the char * ambiguity, the 'char *'
overload of the 'print' function is marked as deleted.
Issue #1987
2016-07-13 19:07:09 +02:00
|
|
|
Genode::log("SD/MMC card detected");
|
|
|
|
Genode::log("capacity: ", card_info.capacity_mb(), " MiB");
|
2013-03-22 15:19:09 +01:00
|
|
|
}
|
|
|
|
|
2016-12-23 14:53:30 +01:00
|
|
|
void handle_ack(Block::Packet_descriptor pkt, bool success) {
|
|
|
|
ack_packet(pkt, success); }
|
|
|
|
|
2013-03-22 15:19:09 +01:00
|
|
|
|
|
|
|
/*****************************
|
|
|
|
** Block::Driver interface **
|
|
|
|
*****************************/
|
|
|
|
|
|
|
|
Genode::size_t block_size() { return 512; }
|
|
|
|
|
2013-12-04 14:34:53 +01:00
|
|
|
virtual Block::sector_t block_count()
|
2013-03-22 15:19:09 +01:00
|
|
|
{
|
|
|
|
return _controller.card_info().capacity_mb() * 1024 * 2;
|
|
|
|
}
|
|
|
|
|
2013-11-23 00:24:44 +01:00
|
|
|
Block::Session::Operations ops()
|
|
|
|
{
|
|
|
|
Block::Session::Operations o;
|
|
|
|
o.set_operation(Block::Packet_descriptor::READ);
|
|
|
|
o.set_operation(Block::Packet_descriptor::WRITE);
|
|
|
|
return o;
|
|
|
|
}
|
|
|
|
|
2016-12-23 14:53:30 +01:00
|
|
|
void read_dma(Block::sector_t block_number,
|
|
|
|
Genode::size_t block_count,
|
|
|
|
Genode::addr_t phys,
|
2013-12-03 15:41:14 +01:00
|
|
|
Packet_descriptor &packet)
|
2013-03-22 15:19:09 +01:00
|
|
|
{
|
2016-12-23 14:53:30 +01:00
|
|
|
_controller.read_blocks_dma(block_number, block_count, phys, packet);
|
2013-03-22 15:19:09 +01:00
|
|
|
}
|
|
|
|
|
2013-12-04 14:34:53 +01:00
|
|
|
void write_dma(Block::sector_t block_number,
|
2013-12-03 15:41:14 +01:00
|
|
|
Genode::size_t block_count,
|
|
|
|
Genode::addr_t phys,
|
|
|
|
Packet_descriptor &packet)
|
2013-03-22 15:19:09 +01:00
|
|
|
{
|
2016-12-23 14:53:30 +01:00
|
|
|
_controller.write_blocks_dma(block_number, block_count, phys, packet);
|
2013-03-22 15:19:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
bool dma_enabled() { return _use_dma; }
|
|
|
|
};
|
|
|
|
|
2015-09-03 14:55:05 +02:00
|
|
|
#endif /* _DRIVERS__SD_CARD__SPEC__EXYNOS5__DRIVER_H_ */
|