1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/pkg/devices/lib/msc/include/msc-jz4780.h Sun Feb 11 00:39:56 2024 +0100
1.3 @@ -0,0 +1,89 @@
1.4 +/*
1.5 + * MSC (MMC/SD controller) peripheral support.
1.6 + *
1.7 + * Copyright (C) 2024 Paul Boddie <paul@boddie.org.uk>
1.8 + *
1.9 + * This program is free software; you can redistribute it and/or
1.10 + * modify it under the terms of the GNU General Public License as
1.11 + * published by the Free Software Foundation; either version 2 of
1.12 + * the License, or (at your option) any later version.
1.13 + *
1.14 + * This program is distributed in the hope that it will be useful,
1.15 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1.16 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1.17 + * GNU General Public License for more details.
1.18 + *
1.19 + * You should have received a copy of the GNU General Public License
1.20 + * along with this program; if not, write to the Free Software
1.21 + * Foundation, Inc., 51 Franklin Street, Fifth Floor,
1.22 + * Boston, MA 02110-1301, USA
1.23 + */
1.24 +
1.25 +#pragma once
1.26 +
1.27 +#include <l4/re/c/dma_space.h>
1.28 +#include <l4/sys/types.h>
1.29 +#include <stdint.h>
1.30 +
1.31 +
1.32 +
1.33 +#ifdef __cplusplus
1.34 +
1.35 +#include <l4/devices/dma-jz4780.h>
1.36 +#include <l4/devices/msc-common.h>
1.37 +
1.38 +// MMC/SD controller channel.
1.39 +
1.40 +class Msc_jz4780_channel : public Msc_channel
1.41 +{
1.42 +protected:
1.43 + Dma_jz4780_channel *_dma;
1.44 + enum Dma_jz4780_request_type _request_type_in, _request_type_out;
1.45 +
1.46 +public:
1.47 + explicit Msc_jz4780_channel(l4_addr_t msc_start, l4_addr_t addr,
1.48 + l4_cap_idx_t irq, Dma_jz4780_channel *dma,
1.49 + enum Dma_jz4780_request_type request_type_in,
1.50 + enum Dma_jz4780_request_type request_type_out);
1.51 +
1.52 + uint32_t transfer(l4re_dma_space_dma_addr_t from_paddr,
1.53 + l4re_dma_space_dma_addr_t to_paddr,
1.54 + bool recv, uint32_t count);
1.55 +};
1.56 +
1.57 +
1.58 +
1.59 +// MMC/SD controller device control.
1.60 +
1.61 +class Msc_jz4780_chip : public Msc_chip
1.62 +{
1.63 +protected:
1.64 + unsigned int num_channels()
1.65 + { return 3; }
1.66 +
1.67 +public:
1.68 + explicit Msc_jz4780_chip(l4_addr_t msc_start, l4_addr_t start, l4_addr_t end);
1.69 +
1.70 + Msc_channel *get_channel(uint8_t channel, l4_cap_idx_t irq,
1.71 + Dma_jz4780_channel *dma);
1.72 +};
1.73 +
1.74 +#endif /* __cplusplus */
1.75 +
1.76 +/* C language interface. */
1.77 +
1.78 +EXTERN_C_BEGIN
1.79 +
1.80 +void *jz4780_msc_init(l4_addr_t msc_start, l4_addr_t start, l4_addr_t end);
1.81 +
1.82 +void *jz4780_msc_get_channel(void *msc, uint8_t channel, l4_cap_idx_t irq,
1.83 + void *dma);
1.84 +
1.85 +uint32_t jz4780_msc_get_status(void *msc_channel);
1.86 +
1.87 +void jz4780_msc_enable(void *msc_channel);
1.88 +
1.89 +uint32_t jz4780_msc_read_block(void *msc_channel, uint8_t card,
1.90 + l4re_dma_space_dma_addr_t paddr);
1.91 +
1.92 +EXTERN_C_END